Attach-constrained element attachment

Đang mở
#4,847 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp, lua
Lĩnh vực
api, game-dev

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
C++
Star
1.9k
Fork
588
Merge trung bình
4 ngày 9 phút
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của multitheftauto/mtasa-blue

Tất cả issue của multitheftauto/mtasa-blue

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.