Open hpmv opened 2 months ago
actually i luckily figured this out... prismatic joint's "local axis" approach is not sound, as it arbitrarily derives the other two axes based on that one axis vector. If the resulting frames end up being unaligned then the solver goes nuts. If I use a GenericJointBuilder and specify sane frames, then this is all fine.
The docs mention that there's the ability to specify a local tangent axis but that is nowhere to be found in the code. If that were implemented (or automatically calculated correctly like the document says), then we should be good.
Setup: Two rigidbody cubes, one at (0, 0, 0) and one at (1, 0, 0), with a prismatic joint between them with local anchors (0, 0, 0) and the global common axis of (1, 0, 0). Both objects are exempt from gravity, so there's no force other than the joint itself, and with the way the positions are set up, the joint is already satisfied.
However, if the second rigidbody already has a rotation transform, even though the local axis for the second rigidbody is specified so that the global axis is still (1, 0, 0), for some rotations, the simulation explodes even in one step.
This selects 8 different angles to specify the same global axis, but some simulations are stable, but some are not: