jrouwe / JoltPhysics

A multi core friendly rigid body physics and collision detection library. Written in C++. Suitable for games and VR applications. Used by Horizon Forbidden West.
MIT License
6.76k stars 452 forks source link

Missing documentation on how to destroy a physics object. #1170

Closed vblanco20-1 closed 4 months ago

vblanco20-1 commented 4 months ago

On a project we have that added Jolt, we ran into an issue with the system crashing when calling BodyInterface::DestroyBody and then running a simulation step. It took us hours to debug, but we didnt see in the documentation anything about it other than you use that to delete a Body. Through the help of a friend, we found out that one needs to call RemoveBody before calling DestroyBody, and this is not mentioned anywhere and not seen in most of the samples either other than the hello world one. The code also doesnt have it mentioned on the comments within the BodyInterface, so its really easy to miss.

Adding a mention to this somewhere in the documentation and in the header comments will be a big help as im sure this is something most users will run into.

jrouwe commented 4 months ago

I added some extra information here: https://github.com/jrouwe/JoltPhysics/commit/e371cbf5e7acb37d47400342f26d9088d54df152

Did you run Jolt in debug mode? Because if you did, you should have triggered asserts to indicate what's going wrong.

vblanco20-1 commented 4 months ago

Debug mode is so slow we cant use it. We force-enabled the jolt asserts, but then the assert being hit still wasnt clear on what was the issue. Your new addition to the document is great, it fixes it completely. Thanks a lot.