Add profiling code
This commit is contained in:
parent
bcb4febb16
commit
87614b7dad
src
collision
engine
|
@ -204,6 +204,8 @@ void CollisionDetection::computeMiddlePhase() {
|
||||||
void CollisionDetection::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair, MemoryAllocator& allocator,
|
void CollisionDetection::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair, MemoryAllocator& allocator,
|
||||||
NarrowPhaseInfo** firstNarrowPhaseInfo) {
|
NarrowPhaseInfo** firstNarrowPhaseInfo) {
|
||||||
|
|
||||||
|
RP3D_PROFILE("CollisionDetection::computeConvexVsConcaveMiddlePhase()", mProfiler);
|
||||||
|
|
||||||
ProxyShape* shape1 = pair->getShape1();
|
ProxyShape* shape1 = pair->getShape1();
|
||||||
ProxyShape* shape2 = pair->getShape2();
|
ProxyShape* shape2 = pair->getShape2();
|
||||||
|
|
||||||
|
@ -311,6 +313,8 @@ void CollisionDetection::computeNarrowPhase() {
|
||||||
/// This method is called by the broad-phase collision detection algorithm
|
/// This method is called by the broad-phase collision detection algorithm
|
||||||
void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* shape1, ProxyShape* shape2) {
|
void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* shape1, ProxyShape* shape2) {
|
||||||
|
|
||||||
|
RP3D_PROFILE("CollisionDetection::broadPhaseNotifyOverlappingPair()", mProfiler);
|
||||||
|
|
||||||
assert(shape1->getBroadPhaseId() != -1);
|
assert(shape1->getBroadPhaseId() != -1);
|
||||||
assert(shape2->getBroadPhaseId() != -1);
|
assert(shape2->getBroadPhaseId() != -1);
|
||||||
assert(shape1->getBroadPhaseId() != shape2->getBroadPhaseId());
|
assert(shape1->getBroadPhaseId() != shape2->getBroadPhaseId());
|
||||||
|
@ -331,6 +335,7 @@ void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* shape1, Pro
|
||||||
mMemoryManager.getSingleFrameAllocator(), mWorld->mConfig);
|
mMemoryManager.getSingleFrameAllocator(), mWorld->mConfig);
|
||||||
assert(newPair != nullptr);
|
assert(newPair != nullptr);
|
||||||
|
|
||||||
|
newPair->setProfiler(mProfiler);
|
||||||
mOverlappingPairs.add(Pair<Pair<uint, uint>, OverlappingPair*>(pairID, newPair));
|
mOverlappingPairs.add(Pair<Pair<uint, uint>, OverlappingPair*>(pairID, newPair));
|
||||||
|
|
||||||
// Wake up the two bodies
|
// Wake up the two bodies
|
||||||
|
|
|
@ -52,6 +52,8 @@ BroadPhaseAlgorithm::BroadPhaseAlgorithm(CollisionDetection& collisionDetection)
|
||||||
bool BroadPhaseAlgorithm::testOverlappingShapes(const ProxyShape* shape1,
|
bool BroadPhaseAlgorithm::testOverlappingShapes(const ProxyShape* shape1,
|
||||||
const ProxyShape* shape2) const {
|
const ProxyShape* shape2) const {
|
||||||
|
|
||||||
|
RP3D_PROFILE("BroadPhaseAlgorithm::testOverlappingShapes()", mProfiler);
|
||||||
|
|
||||||
if (shape1->getBroadPhaseId() == -1 || shape2->getBroadPhaseId() == -1) return false;
|
if (shape1->getBroadPhaseId() == -1 || shape2->getBroadPhaseId() == -1) return false;
|
||||||
|
|
||||||
// Get the two AABBs of the collision shapes
|
// Get the two AABBs of the collision shapes
|
||||||
|
@ -139,6 +141,8 @@ void BroadPhaseAlgorithm::reportAllShapesOverlappingWithAABB(const AABB& aabb,
|
||||||
// Compute all the overlapping pairs of collision shapes
|
// Compute all the overlapping pairs of collision shapes
|
||||||
void BroadPhaseAlgorithm::computeOverlappingPairs(MemoryManager& memoryManager) {
|
void BroadPhaseAlgorithm::computeOverlappingPairs(MemoryManager& memoryManager) {
|
||||||
|
|
||||||
|
RP3D_PROFILE("BroadPhaseAlgorithm::computeOverlappingPairs()", mProfiler);
|
||||||
|
|
||||||
// TODO : Try to see if we can allocate potential pairs in single frame allocator
|
// TODO : Try to see if we can allocate potential pairs in single frame allocator
|
||||||
|
|
||||||
// Reset the potential overlapping pairs
|
// Reset the potential overlapping pairs
|
||||||
|
@ -218,6 +222,8 @@ void BroadPhaseAlgorithm::computeOverlappingPairs(MemoryManager& memoryManager)
|
||||||
// Notify the broad-phase about a potential overlapping pair in the dynamic AABB tree
|
// Notify the broad-phase about a potential overlapping pair in the dynamic AABB tree
|
||||||
void BroadPhaseAlgorithm::addOverlappingNodes(int referenceNodeId, const LinkedList<int>& overlappingNodes) {
|
void BroadPhaseAlgorithm::addOverlappingNodes(int referenceNodeId, const LinkedList<int>& overlappingNodes) {
|
||||||
|
|
||||||
|
RP3D_PROFILE("BroadPhaseAlgorithm::addOverlappingNodes()", mProfiler);
|
||||||
|
|
||||||
// For each overlapping node in the linked list
|
// For each overlapping node in the linked list
|
||||||
LinkedList<int>::ListElement* elem = overlappingNodes.getListHead();
|
LinkedList<int>::ListElement* elem = overlappingNodes.getListHead();
|
||||||
while (elem != nullptr) {
|
while (elem != nullptr) {
|
||||||
|
|
|
@ -597,6 +597,8 @@ int DynamicAABBTree::balanceSubTreeAtNode(int nodeID) {
|
||||||
void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb,
|
void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& aabb,
|
||||||
DynamicAABBTreeOverlapCallback& callback) const {
|
DynamicAABBTreeOverlapCallback& callback) const {
|
||||||
|
|
||||||
|
RP3D_PROFILE("DynamicAABBTree::reportAllShapesOverlappingWithAABB()", mProfiler);
|
||||||
|
|
||||||
// Create a stack with the nodes to visit
|
// Create a stack with the nodes to visit
|
||||||
Stack<int, 64> stack(mAllocator);
|
Stack<int, 64> stack(mAllocator);
|
||||||
stack.push(mRootNodeID);
|
stack.push(mRootNodeID);
|
||||||
|
|
|
@ -41,6 +41,12 @@ OverlappingPair::OverlappingPair(ProxyShape* shape1, ProxyShape* shape2,
|
||||||
mPersistentAllocator(persistentMemoryAllocator), mTempMemoryAllocator(temporaryMemoryAllocator),
|
mPersistentAllocator(persistentMemoryAllocator), mTempMemoryAllocator(temporaryMemoryAllocator),
|
||||||
mLastFrameCollisionInfos(mPersistentAllocator), mWorldSettings(worldSettings) {
|
mLastFrameCollisionInfos(mPersistentAllocator), mWorldSettings(worldSettings) {
|
||||||
|
|
||||||
|
#ifdef IS_PROFILING_ACTIVE
|
||||||
|
|
||||||
|
mProfiler = nullptr;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -128,6 +128,13 @@ class OverlappingPair {
|
||||||
/// World settings
|
/// World settings
|
||||||
const WorldSettings& mWorldSettings;
|
const WorldSettings& mWorldSettings;
|
||||||
|
|
||||||
|
#ifdef IS_PROFILING_ACTIVE
|
||||||
|
|
||||||
|
/// Pointer to the profiler
|
||||||
|
Profiler* mProfiler;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// -------------------- Methods -------------------- //
|
// -------------------- Methods -------------------- //
|
||||||
|
@ -208,6 +215,13 @@ class OverlappingPair {
|
||||||
/// Return the pair of bodies index of the pair
|
/// Return the pair of bodies index of the pair
|
||||||
static bodyindexpair computeBodiesIndexPair(CollisionBody* body1, CollisionBody* body2);
|
static bodyindexpair computeBodiesIndexPair(CollisionBody* body1, CollisionBody* body2);
|
||||||
|
|
||||||
|
#ifdef IS_PROFILING_ACTIVE
|
||||||
|
|
||||||
|
/// Set the profiler
|
||||||
|
void setProfiler(Profiler* profiler);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// -------------------- Friendship -------------------- //
|
// -------------------- Friendship -------------------- //
|
||||||
|
|
||||||
friend class DynamicsWorld;
|
friend class DynamicsWorld;
|
||||||
|
@ -309,6 +323,15 @@ inline LastFrameCollisionInfo* OverlappingPair::getLastFrameCollisionInfo(uint s
|
||||||
return mLastFrameCollisionInfos[ShapeIdPair(shapeId1, shapeId2)];
|
return mLastFrameCollisionInfos[ShapeIdPair(shapeId1, shapeId2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IS_PROFILING_ACTIVE
|
||||||
|
|
||||||
|
// Set the profiler
|
||||||
|
inline void OverlappingPair::setProfiler(Profiler* profiler) {
|
||||||
|
mProfiler = profiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user