feature: Selective debug rendering

This commit is contained in:
Norman Breau 2022-04-04 23:58:26 -03:00
parent d7cf8bcf17
commit 5956c67ee3
3 changed files with 26 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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++) {