dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.77k stars 235 forks source link

Dynamic -> Ground impulse joint limits are (not) flipped #549

Closed funmaker closed 2 months ago

funmaker commented 7 months ago

Joint constraint solver has separate functions for dealing with Dynamic <-> Fixed/Kinematic bodies. In them, it assumes that the body1 of the joint is the static one, and if that's not the case, it flips the bodies around https://github.com/dimforge/rapier/blob/e9ea2ca10b3058a6ac2d7f4b79d351ef18ad3c06/src/dynamics/solver/joint_constraint/joint_constraint.rs#L271-L276 However it does not flip the limits so if two bodies have asymmetric limits(eg, 45deg to 0), they can jump around when one of them becomes Fixed. I can provide reproduction but I think the problem should be evident from the lines of code mentioned above. I will include a video.

https://github.com/dimforge/rapier/assets/3338680/aa904259-2c03-4544-a1da-8e3bb6d29e29

I am not sure if simply flipping sign of limits would be enough to fix that(are angular limits symmetric like that?) and whenever this also affects multibody joints.