feature: Selective debug rendering
This commit is contained in:
parent
d7cf8bcf17
commit
5956c67ee3
|
@ -62,6 +62,9 @@ class CollisionBody {
|
||||||
/// Reference to the world the body belongs to
|
/// Reference to the world the body belongs to
|
||||||
PhysicsWorld& mWorld;
|
PhysicsWorld& mWorld;
|
||||||
|
|
||||||
|
/// Determines if debug information is computed for this body
|
||||||
|
bool mDebugEnabled;
|
||||||
|
|
||||||
#ifdef IS_RP3D_PROFILING_ENABLED
|
#ifdef IS_RP3D_PROFILING_ENABLED
|
||||||
|
|
||||||
/// Pointer to the profiler
|
/// 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
|
/// Return the body local-space coordinates of a vector given in the world-space coordinates
|
||||||
Vector3 getLocalVector(const Vector3& worldVector) const;
|
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
|
#ifdef IS_RP3D_PROFILING_ENABLED
|
||||||
|
|
||||||
/// Set the profiler
|
/// Set the profiler
|
||||||
|
|
|
@ -465,3 +465,19 @@ Vector3 CollisionBody::getLocalPoint(const Vector3& worldPoint) const {
|
||||||
Vector3 CollisionBody::getLocalVector(const Vector3& worldVector) const {
|
Vector3 CollisionBody::getLocalVector(const Vector3& worldVector) const {
|
||||||
return mWorld.mTransformComponents.getTransform(mEntity).getOrientation().getInverse() * worldVector;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -410,7 +410,7 @@ void DebugRenderer::computeDebugRenderingPrimitives(const PhysicsWorld& world) {
|
||||||
// Get a body
|
// Get a body
|
||||||
const CollisionBody* body = b < nbCollisionBodies ? world.getCollisionBody(b) : world.getRigidBody(b - nbCollisionBodies);
|
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 each collider of the body
|
||||||
for (uint32 c = 0; c < body->getNbColliders(); c++) {
|
for (uint32 c = 0; c < body->getNbColliders(); c++) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user