Attach-constrained element attachment

Abierto
#4,847 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
cpp, lua
Área
api, game-dev

Línea de trabajo

Start by reading the existing attachElements function and how it is exposed to Lua. Work out how attachment state is represented before assessing how the six inheritance flags could be applied. Done means an already-attached child can selectively inherit position and rotation axes, with each flag defaulting to true.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement
Is your feature request related to a problem? Please describe.

The current attachElements function attaches one element to another so that whenever the parent changes its position or rotation, the child follows along. However, there is no way to restrict which axes the child should inherit from the parent — it always follows all transformations completely.

Describe the solution you'd like

A new function attachWithConstraints that works on an already-attached element — since the parent is already known after attachElements is called, there is no need to pass it again. The function receives only the child element and boolean flags controlling which axes should be inherited (all defaulting to true).

Suggested syntax:

bool attachWithConstraints ( element theElement,
    [ bool x = true, bool y = true, bool z = true,
      bool rx = true, bool ry = true, bool rz = true ] )

Example — child only rotates on the Y axis:

-- Attach normally first
attachElements(childElement, parentElement)

-- Then define the constraints (position free, only Y rotation)
attachWithConstraints(childElement, false, true, false, false, true, false)
Describe alternatives you've considered

The current workaround involves multiple objects and manual matrix calculations:

  • The main object is attached to the vehicle, with rotations managed manually
    via setElementAttachedOffsets each frame.
  • A base object must follow only the position of the main object (no rotation inheritance).
  • A secondary object must follow the position and only the Z rotation of the main object.

To achieve this, it is necessary to retrieve the matrix of the main object every frame
and perform the axis calculations manually in Lua — which at scale becomes expensive on the CPU.

The proposed attachWithConstraints function would handle this natively, eliminating
the per-frame matrix reads and manual calculations, significantly reducing CPU overhead.

Additional context

Here is a video demonstrating the problem and the motivation for this feature:

https://github.com/user-attachments/assets/0e5d969d-7db2-4dbd-8c39-f613567d997a

Security Policy
  • I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
Lenguaje dominante
C++
Estrellas
1.9k
Forks
588
Merge medio
4 d 9 min
PR fusionados (30 d)
11

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de multitheftauto/mtasa-blue

Todos los issues de multitheftauto/mtasa-blue

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.