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.74k stars 452 forks source link

Introduce the DEBUG_RENDERER setting #894

Closed AndreaCatania closed 9 months ago

AndreaCatania commented 9 months ago

Introduces the possibility to enable the debug renderer even when compiling Jolt in distribution.

jrouwe commented 9 months ago

Hello,

Can I ask what the use case for this is? There is quite a bit of code inside the physics engine (besides the official draw calls like PhysicsSystem::DrawBodies) that draws stuff, so I would not recommend enabling the debug renderer in a distribution build as it introduces overhead even if you're not calling draw functions yourself.

What the sample app does in distribution mode is to use Shape::GetTrianglesStart to display the state of the world. See:

https://github.com/jrouwe/JoltPhysics/blob/cc49e07d7c4eb854a60cb21ea0abdfcc93511410/Samples/SamplesApp.cpp#L2258-L2380

Also, shouldn't there be an option(DEBUG_RENDERER OFF) in CMakeLists.txt then?

AndreaCatania commented 9 months ago

We are building a game-engine-like App that allows the users to implement their games. For them is good to be able to visualize the physics engine colliders, and the DebugRenderer is the perfect tool for doing that (considering all the built-in functionalities it provides, like the LOD, that we should re-implement if we would use Shape::GetTrianglesStart). The extra overhead is a price we are willing to pay right now, considering that the physics engine is not a bottleneck at the moment.

Also, shouldn't there be an option(DEBUG_RENDERER OFF) in CMakeLists.txt then?

I'm not a CMake expert, can you please guide me on what to do exactly? Should I add option(DEBUG_RENDERER OFF) in:

jrouwe commented 9 months ago

I'll patch it up for you.

AndreaCatania commented 9 months ago

@jrouwe Thanks!