diff --git a/include/reactphysics3d/body/CollisionBody.h b/include/reactphysics3d/body/CollisionBody.h index 5dd6a879..3b072c8b 100644 --- a/include/reactphysics3d/body/CollisionBody.h +++ b/include/reactphysics3d/body/CollisionBody.h @@ -62,6 +62,9 @@ class CollisionBody { /// Reference to the world the body belongs to PhysicsWorld& mWorld; + /// Determines if debug information is computed for this body + bool mDebugEnabled; + #ifdef IS_RP3D_PROFILING_ENABLED /// Pointer to the profiler @@ -157,6 +160,12 @@ class CollisionBody { /// Return the body local-space coordinates of a vector given in the world-space coordinates Vector3 getLocalVector(const Vector3& worldVector) const; + /// Set whether or not debug lines are computed for this body + void setDebugEnabled(bool enabled); + + /// Return true if debug lines should be computed for this body + bool isDebugEnabled() const; + #ifdef IS_RP3D_PROFILING_ENABLED /// Set the profiler diff --git a/src/body/CollisionBody.cpp b/src/body/CollisionBody.cpp index 95f0afc0..c5dd2565 100644 --- a/src/body/CollisionBody.cpp +++ b/src/body/CollisionBody.cpp @@ -465,3 +465,19 @@ Vector3 CollisionBody::getLocalPoint(const Vector3& worldPoint) const { Vector3 CollisionBody::getLocalVector(const Vector3& worldVector) const { return mWorld.mTransformComponents.getTransform(mEntity).getOrientation().getInverse() * worldVector; } + +// Set whether to compute debug lines on this body +/** + * @param enabled Set to true if this body should have it's debug information computed + */ +void CollisionBody::setDebugEnabled(bool enabled) { + mDebugEnabled = enabled; +} + +// Returns true if this collision body is computing debug information +/** + * @return Returns true if this body is computing debug information + */ +bool CollisionBody::isDebugEnabled() const { + return mDebugEnabled; +} diff --git a/src/utils/DebugRenderer.cpp b/src/utils/DebugRenderer.cpp index 4e8e8667..7b00c693 100644 --- a/src/utils/DebugRenderer.cpp +++ b/src/utils/DebugRenderer.cpp @@ -410,7 +410,7 @@ void DebugRenderer::computeDebugRenderingPrimitives(const PhysicsWorld& world) { // Get a body const CollisionBody* body = b < nbCollisionBodies ? world.getCollisionBody(b) : world.getRigidBody(b - nbCollisionBodies); - if (body->isActive()) { + if (body->isActive() && body->isDebugEnabled()) { // For each collider of the body for (uint32 c = 0; c < body->getNbColliders(); c++) {