DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.54k stars 224 forks source link

BallAndSocketJoint goes invalid if the bodies are too heavy #329

Closed lodgegao closed 1 year ago

lodgegao commented 1 year ago

企业微信20230423-184938 Hello, I tried creating two rigid bodies and one BallAndSocketJoint connecting them. One body is static, while the other is dynamic. I didn't change any other properties of the static body, I modified the mass of the dynamic body only.

And I found that when I set the mass to 500, everything works well; but when the mass is set to a value higher than 1000, the joint would lose effect.

I tried to figure out the reason, and I found that, as is shown by the figure, the check between inverse(sum(mass1, mass2)) and MACHINE_EPSILON failed. I compiled the project with float precision. I don't known whether it is a feature or not. But I believe that 1000 kilograms is not a very big mass...

DanielChappuis commented 1 year ago

Hello,

Thanks a lot for your feedback. It's a known issue in general physics engine development known as "High Mass Ratio Problem". When the masses of two bodies that interact with each other (collision, joint, ...) are very different it can affect the convergence rate of the iteration algorithm used to solve the constraints.

I think that is the issue you are experiencing. You should try to use more similar masses for your bodies to avoid this effect.

lodgegao commented 1 year ago

Thank you Daniel ! I had wrongly thought it to be the problem of large mass, now I know it is the diversity of mass that matters. I would avoid using bodies whose mass differs a lot !