diff --git a/src/collision/broadphase/BroadPhaseAlgorithm.cpp b/src/collision/broadphase/BroadPhaseAlgorithm.cpp index 41649de1..4491c068 100644 --- a/src/collision/broadphase/BroadPhaseAlgorithm.cpp +++ b/src/collision/broadphase/BroadPhaseAlgorithm.cpp @@ -26,6 +26,7 @@ // Libraries #include "BroadPhaseAlgorithm.h" #include "../CollisionDetection.h" +#include "../../engine/Profiler.h" // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; diff --git a/src/collision/broadphase/DynamicAABBTree.cpp b/src/collision/broadphase/DynamicAABBTree.cpp index 89c2705d..6d1c57cd 100644 --- a/src/collision/broadphase/DynamicAABBTree.cpp +++ b/src/collision/broadphase/DynamicAABBTree.cpp @@ -27,6 +27,7 @@ #include "DynamicAABBTree.h" #include "BroadPhaseAlgorithm.h" #include "../../memory/Stack.h" +#include "../../engine/Profiler.h" using namespace reactphysics3d; @@ -159,6 +160,8 @@ void DynamicAABBTree::removeObject(int nodeID) { /// frames. bool DynamicAABBTree::updateObject(int nodeID, const AABB& newAABB, const Vector3& displacement) { + PROFILE("DynamicAABBTree::updateObject()"); + assert(nodeID >= 0 && nodeID < mNbAllocatedNodes); assert(mNodes[nodeID].isLeaf()); assert(mNodes[nodeID].height >= 0); @@ -333,9 +336,6 @@ void DynamicAABBTree::insertLeafNode(int nodeID) { } assert(mNodes[nodeID].isLeaf()); - - // Check the structure of the tree - check(); } // Remove a leaf node from the tree @@ -403,9 +403,6 @@ void DynamicAABBTree::removeLeafNode(int nodeID) { mNodes[siblingNodeID].parentID = TreeNode::NULL_TREE_NODE; releaseNode(parentNodeID); } - - // Check the structure of the tree - check(); } // Balance the sub-tree of a given node using left or right rotations. @@ -608,6 +605,8 @@ void DynamicAABBTree::reportAllShapesOverlappingWith(int nodeID, const AABB& aab } } +#ifndef NDEBUG + // Check if the tree structure is valid (for debugging purpose) void DynamicAABBTree::check() const { @@ -678,3 +677,5 @@ void DynamicAABBTree::checkNode(int nodeID) const { checkNode(rightChild); } } + +#endif diff --git a/src/collision/broadphase/DynamicAABBTree.h b/src/collision/broadphase/DynamicAABBTree.h index ef6686f9..874c5a60 100644 --- a/src/collision/broadphase/DynamicAABBTree.h +++ b/src/collision/broadphase/DynamicAABBTree.h @@ -123,12 +123,16 @@ class DynamicAABBTree { /// Balance the sub-tree of a given node using left or right rotations. int balanceSubTreeAtNode(int nodeID); +#ifndef NDEBUG + /// Check if the tree structure is valid (for debugging purpose) void check() const; /// Check if the node structure is valid (for debugging purpose) void checkNode(int nodeID) const; +#endif + public: // -------------------- Methods -------------------- //