When working on the 6DOF joint, I was unable to find suitable functionality in Rapier lib to implement the same swing twist joint that Jolt does. The swing twist joint with a pyramid cone constraint is necessary in order to implement limits that make sense to the user when they have more than one angular degree of freedom at a time.
There may be other joint limit and motor compositions that can work there. I don't know. I do know that independent axes in the Rapier Generic Joint will do strange things from the user perspective.
The generic joint with independent angular axes will work fine for any case that has no more than 1 angular DOF for now.
If the user needs rag doll shoulder, then the cone twist joint will serve them better, but this joint cannot serve for the 6DOF because the user can set all the angular limits independently, whereas the cone constraint ties two angular axes into one.
The user can also construct compound joints to achieve the DOF that they need. I left a sample of a compound joint in the code base, but to do this well they need to be cognisant of both the engineering issues and how the iterative impulse solver will struggle to pass forces through highly different masses. I don't think we can automatically create a compound joint ourselves in Godot-Rapier-Physics code without varying the mass and behaviour of the user's joint, so I don't think we should pursue that.
Hidden colliders is another user workaround for enforcing sane limits.
I think the correct fix is additional functionality within Rapier Lib itself.
I left this comment in the code:
// NOTE: 6DOF Angle limits may not behave as expected or be
// unstable when there is more than one angular DOF.
//
// Jolt seems to use a swing twist constraint for it's 6DOF which
// improves the situation by eliminating path dependence problems.
// If Rapier could add a pyramid like constraint to it's coupled angular
// axes then we could match what Jolt is doing.
// As of Rapier 0.32.0, I don't believe we can match jolt's limit behavior.
//
// For now, if a user needs high angular DOF's with limits, they
// can construct a compound joint out of multiple low DOF joints
// with dummy rigid bodies between them.
//
// They could also use hidden colliders as a constraint, instead of joint limits
//
When working on the 6DOF joint, I was unable to find suitable functionality in Rapier lib to implement the same swing twist joint that Jolt does. The swing twist joint with a pyramid cone constraint is necessary in order to implement limits that make sense to the user when they have more than one angular degree of freedom at a time.
There may be other joint limit and motor compositions that can work there. I don't know. I do know that independent axes in the Rapier Generic Joint will do strange things from the user perspective.
The generic joint with independent angular axes will work fine for any case that has no more than 1 angular DOF for now.
If the user needs rag doll shoulder, then the cone twist joint will serve them better, but this joint cannot serve for the 6DOF because the user can set all the angular limits independently, whereas the cone constraint ties two angular axes into one.
The user can also construct compound joints to achieve the DOF that they need. I left a sample of a compound joint in the code base, but to do this well they need to be cognisant of both the engineering issues and how the iterative impulse solver will struggle to pass forces through highly different masses. I don't think we can automatically create a compound joint ourselves in Godot-Rapier-Physics code without varying the mass and behaviour of the user's joint, so I don't think we should pursue that.
Hidden colliders is another user workaround for enforcing sane limits.
I think the correct fix is additional functionality within Rapier Lib itself.
I left this comment in the code: