FlaxEngine / FlaxEngine/FlaxEngine
Joint api functions use incorrect coordinate system for anchors
- Dominant language
- C++
- Stars
- 7k
- Forks
- 713
- Avg merge
- 7d 11h
- Merged PRs (30d)
- 19
Description
Joints in flax seem to ignore `Target` scale in their anchor calculations, and this is generally good because it simplifies the coordinate space —only needing to account for orientation and location. However, the documentation does not mention this fact, and even some api functions don't seem to account for this.
If any transform in the hierarchy has non-identity scale this code will produce an invalid anchor. This can be fixed easily by setting the `Scale` component of the transform to one before calculating the local position.
https://github.com/FlaxEngine/FlaxEngine/blob/a672f6aa6bc529c468b53edf5125c12871cfbfb2/Source/Engine/Physics/Joints/Joint.cpp#L89
https://github.com/FlaxEngine/FlaxEngine/blob/a672f6aa6bc529c468b53edf5125c12871cfbfb2/Source/Engine/Physics/Joints/Joint.cpp#L93
Additionally, the related api functions should probably mention in their documentation that `TargetAnchor` values are calculated in a space that doesn't account for scale
https://github.com/FlaxEngine/FlaxEngine/blob/a672f6aa6bc529c468b53edf5125c12871cfbfb2/Source/Engine/Physics/Joints/Joint.h#L109
Contributor guide
Research direction
Start in Source/Engine/Physics/Joints/Joint.cpp at the linked anchor calculations, then review the related API documentation in Source/Engine/Physics/Joints/Joint.h around TargetAnchor. Verify behavior with non-identity scale in the transform hierarchy, ensure the anchor calculation handles scale as described, and update the API documentation to state that TargetAnchor ignores scale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100