From df04be0e6db749d57776ef29bd47364aa61ebdd5 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Fri, 9 Aug 2019 07:13:15 +0200 Subject: [PATCH] Rename CollisionDetection class to CollisionDetectionSystem --- CMakeLists.txt | 4 +- src/body/CollisionBody.h | 2 +- src/collision/CollisionCallback.h | 2 +- src/collision/ContactManifold.h | 2 +- src/collision/OverlapCallback.h | 2 +- src/collision/ProxyShape.h | 2 +- .../narrowphase/NarrowPhaseAlgorithm.h | 2 +- src/constraint/ContactPoint.h | 2 +- src/engine/CollisionWorld.h | 6 +- src/engine/DynamicsWorld.h | 2 +- src/systems/BroadPhaseSystem.cpp | 4 +- src/systems/BroadPhaseSystem.h | 6 +- .../CollisionDetectionSystem.cpp} | 74 +++++++++---------- .../CollisionDetectionSystem.h} | 36 ++++----- 14 files changed, 73 insertions(+), 73 deletions(-) rename src/{collision/CollisionDetection.cpp => systems/CollisionDetectionSystem.cpp} (95%) rename src/{collision/CollisionDetection.h => systems/CollisionDetectionSystem.h} (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00011295..7c912f67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,6 @@ SET (REACTPHYSICS3D_HEADERS "src/collision/TriangleMesh.h" "src/collision/PolyhedronMesh.h" "src/collision/HalfEdgeStructure.h" - "src/collision/CollisionDetection.h" "src/collision/ContactManifold.h" "src/constraint/BallAndSocketJoint.h" "src/constraint/ContactPoint.h" @@ -132,6 +131,7 @@ SET (REACTPHYSICS3D_HEADERS "src/systems/ConstraintSolverSystem.h" "src/systems/ContactSolverSystem.h" "src/systems/DynamicsSystem.h" + "src/systems/CollisionDetectionSystem.h" "src/engine/DynamicsWorld.h" "src/engine/EventListener.h" "src/engine/Island.h" @@ -211,7 +211,6 @@ SET (REACTPHYSICS3D_SOURCES "src/collision/TriangleMesh.cpp" "src/collision/PolyhedronMesh.cpp" "src/collision/HalfEdgeStructure.cpp" - "src/collision/CollisionDetection.cpp" "src/collision/ContactManifold.cpp" "src/constraint/BallAndSocketJoint.cpp" "src/constraint/ContactPoint.cpp" @@ -223,6 +222,7 @@ SET (REACTPHYSICS3D_SOURCES "src/systems/ConstraintSolverSystem.cpp" "src/systems/ContactSolverSystem.cpp" "src/systems/DynamicsSystem.cpp" + "src/systems/CollisionDetectionSystem.cpp" "src/engine/DynamicsWorld.cpp" "src/engine/Island.cpp" "src/engine/Material.cpp" diff --git a/src/body/CollisionBody.h b/src/body/CollisionBody.h index 7101181f..4764a331 100644 --- a/src/body/CollisionBody.h +++ b/src/body/CollisionBody.h @@ -181,7 +181,7 @@ class CollisionBody { friend class CollisionWorld; friend class DynamicsWorld; - friend class CollisionDetection; + friend class CollisionDetectionSystem; friend class BroadPhaseAlgorithm; friend class ConvexMeshShape; friend class ProxyShape; diff --git a/src/collision/CollisionCallback.h b/src/collision/CollisionCallback.h index 87e416ff..4d2169cf 100644 --- a/src/collision/CollisionCallback.h +++ b/src/collision/CollisionCallback.h @@ -211,7 +211,7 @@ class CollisionCallback { // -------------------- Friendship -------------------- // - friend class CollisionDetection; + friend class CollisionDetectionSystem; }; /// Destructor diff --git a/src/collision/ContactManifold.h b/src/collision/ContactManifold.h index abc5fed8..b54644ca 100644 --- a/src/collision/ContactManifold.h +++ b/src/collision/ContactManifold.h @@ -125,7 +125,7 @@ class ContactManifold { friend class CollisionBody; friend class ContactManifoldSet; friend class ContactSolverSystem; - friend class CollisionDetection; + friend class CollisionDetectionSystem; }; } diff --git a/src/collision/OverlapCallback.h b/src/collision/OverlapCallback.h index c9e83250..34e16b40 100644 --- a/src/collision/OverlapCallback.h +++ b/src/collision/OverlapCallback.h @@ -133,7 +133,7 @@ class OverlapCallback { // -------------------- Friendship -------------------- // - friend class CollisionDetection; + friend class CollisionDetectionSystem; }; /// Destructor diff --git a/src/collision/ProxyShape.h b/src/collision/ProxyShape.h index 743ed443..201d493a 100644 --- a/src/collision/ProxyShape.h +++ b/src/collision/ProxyShape.h @@ -199,7 +199,7 @@ class ProxyShape { friend class RigidBody; friend class BroadPhaseAlgorithm; friend class DynamicAABBTree; - friend class CollisionDetection; + friend class CollisionDetectionSystem; friend class CollisionWorld; friend class DynamicsWorld; friend class GJKAlgorithm; diff --git a/src/collision/narrowphase/NarrowPhaseAlgorithm.h b/src/collision/narrowphase/NarrowPhaseAlgorithm.h index 6cae33fa..14d9a8b4 100644 --- a/src/collision/narrowphase/NarrowPhaseAlgorithm.h +++ b/src/collision/narrowphase/NarrowPhaseAlgorithm.h @@ -32,7 +32,7 @@ /// Namespace ReactPhysics3D namespace reactphysics3d { -class CollisionDetection; +class CollisionDetectionSystem; class ContactManifoldInfo; class PoolAllocator; class OverlappingPair; diff --git a/src/constraint/ContactPoint.h b/src/constraint/ContactPoint.h index a6adb8bb..d71add9f 100644 --- a/src/constraint/ContactPoint.h +++ b/src/constraint/ContactPoint.h @@ -137,7 +137,7 @@ class ContactPoint { friend class ContactManifold; friend class ContactManifoldSet; friend class ContactSolverSystem; - friend class CollisionDetection; + friend class CollisionDetectionSystem; }; // Return the normal vector of the contact diff --git a/src/engine/CollisionWorld.h b/src/engine/CollisionWorld.h index c109ae5d..0541a4cd 100644 --- a/src/engine/CollisionWorld.h +++ b/src/engine/CollisionWorld.h @@ -29,7 +29,7 @@ // Libraries #include "mathematics/mathematics.h" #include "containers/List.h" -#include "collision/CollisionDetection.h" +#include "systems/CollisionDetectionSystem.h" #include "constraint/Joint.h" #include "memory/MemoryManager.h" #include "engine/EntityManager.h" @@ -89,7 +89,7 @@ class CollisionWorld { ProxyShapeComponents mProxyShapesComponents; /// Reference to the collision detection - CollisionDetection mCollisionDetection; + CollisionDetectionSystem mCollisionDetection; /// All the bodies (rigid and soft) of the world List mBodies; @@ -195,7 +195,7 @@ class CollisionWorld { // -------------------- Friendship -------------------- // - friend class CollisionDetection; + friend class CollisionDetectionSystem; friend class CollisionBody; friend class RigidBody; friend class ProxyShape; diff --git a/src/engine/DynamicsWorld.h b/src/engine/DynamicsWorld.h index 3606db4b..edbd63ef 100644 --- a/src/engine/DynamicsWorld.h +++ b/src/engine/DynamicsWorld.h @@ -39,7 +39,7 @@ namespace reactphysics3d { // Declarations -class CollisionDetection; +class CollisionDetectionSystem; class Island; class RigidBody; diff --git a/src/systems/BroadPhaseSystem.cpp b/src/systems/BroadPhaseSystem.cpp index 0b837744..52e48375 100644 --- a/src/systems/BroadPhaseSystem.cpp +++ b/src/systems/BroadPhaseSystem.cpp @@ -25,7 +25,7 @@ // Libraries #include "BroadPhaseSystem.h" -#include "collision/CollisionDetection.h" +#include "systems/CollisionDetectionSystem.h" #include "utils/Profiler.h" #include "collision/RaycastInfo.h" #include "memory/MemoryManager.h" @@ -35,7 +35,7 @@ using namespace reactphysics3d; // Constructor -BroadPhaseSystem::BroadPhaseSystem(CollisionDetection& collisionDetection, ProxyShapeComponents& proxyShapesComponents, +BroadPhaseSystem::BroadPhaseSystem(CollisionDetectionSystem& collisionDetection, ProxyShapeComponents& proxyShapesComponents, TransformComponents& transformComponents, RigidBodyComponents &rigidBodyComponents) :mDynamicAABBTree(collisionDetection.getMemoryManager().getPoolAllocator(), DYNAMIC_TREE_AABB_GAP), mProxyShapesComponents(proxyShapesComponents), mTransformsComponents(transformComponents), diff --git a/src/systems/BroadPhaseSystem.h b/src/systems/BroadPhaseSystem.h index a5bef448..934ea9b6 100644 --- a/src/systems/BroadPhaseSystem.h +++ b/src/systems/BroadPhaseSystem.h @@ -39,7 +39,7 @@ namespace reactphysics3d { // Declarations -class CollisionDetection; +class CollisionDetectionSystem; class BroadPhaseSystem; class CollisionBody; class ProxyShape; @@ -129,7 +129,7 @@ class BroadPhaseSystem { Set mMovedShapes; /// Reference to the collision detection object - CollisionDetection& mCollisionDetection; + CollisionDetectionSystem& mCollisionDetection; #ifdef IS_PROFILING_ACTIVE @@ -150,7 +150,7 @@ class BroadPhaseSystem { // -------------------- Methods -------------------- // /// Constructor - BroadPhaseSystem(CollisionDetection& collisionDetection, ProxyShapeComponents& proxyShapesComponents, + BroadPhaseSystem(CollisionDetectionSystem& collisionDetection, ProxyShapeComponents& proxyShapesComponents, TransformComponents& transformComponents, RigidBodyComponents& rigidBodyComponents); /// Destructor diff --git a/src/collision/CollisionDetection.cpp b/src/systems/CollisionDetectionSystem.cpp similarity index 95% rename from src/collision/CollisionDetection.cpp rename to src/systems/CollisionDetectionSystem.cpp index a74010c4..6349cfc4 100644 --- a/src/collision/CollisionDetection.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -24,7 +24,7 @@ ********************************************************************************/ // Libraries -#include "CollisionDetection.h" +#include "systems/CollisionDetectionSystem.h" #include "engine/CollisionWorld.h" #include "collision/OverlapCallback.h" #include "collision/shapes/BoxShape.h" @@ -51,7 +51,7 @@ using namespace std; // Constructor -CollisionDetection::CollisionDetection(CollisionWorld* world, ProxyShapeComponents& proxyShapesComponents, TransformComponents& transformComponents, +CollisionDetectionSystem::CollisionDetectionSystem(CollisionWorld* world, ProxyShapeComponents& proxyShapesComponents, TransformComponents& transformComponents, RigidBodyComponents& rigidBodyComponents, MemoryManager& memoryManager) : mMemoryManager(memoryManager), mProxyShapesComponents(proxyShapesComponents), mCollisionDispatch(mMemoryManager.getPoolAllocator()), mWorld(world), @@ -81,7 +81,7 @@ CollisionDetection::CollisionDetection(CollisionWorld* world, ProxyShapeComponen } // Compute the collision detection -void CollisionDetection::computeCollisionDetection() { +void CollisionDetectionSystem::computeCollisionDetection() { RP3D_PROFILE("CollisionDetection::computeCollisionDetection()", mProfiler); @@ -96,7 +96,7 @@ void CollisionDetection::computeCollisionDetection() { } // Compute the broad-phase collision detection -void CollisionDetection::computeBroadPhase() { +void CollisionDetectionSystem::computeBroadPhase() { RP3D_PROFILE("CollisionDetection::computeBroadPhase()", mProfiler); @@ -114,7 +114,7 @@ void CollisionDetection::computeBroadPhase() { } // Remove pairs that are not overlapping anymore -void CollisionDetection::removeNonOverlappingPairs() { +void CollisionDetectionSystem::removeNonOverlappingPairs() { // For each possible collision pair of bodies for (auto it = mOverlappingPairs.begin(); it != mOverlappingPairs.end(); ) { @@ -141,7 +141,7 @@ void CollisionDetection::removeNonOverlappingPairs() { } // Take a list of overlapping nodes in the broad-phase and create new overlapping pairs if necessary -void CollisionDetection::updateOverlappingPairs(const List>& overlappingNodes) { +void CollisionDetectionSystem::updateOverlappingPairs(const List>& overlappingNodes) { // For each overlapping pair of nodes for (uint i=0; i < overlappingNodes.size(); i++) { @@ -201,7 +201,7 @@ void CollisionDetection::updateOverlappingPairs(const List>& over } // Compute the middle-phase collision detection -void CollisionDetection::computeMiddlePhase(OverlappingPairMap& overlappingPairs, NarrowPhaseInput& narrowPhaseInput) { +void CollisionDetectionSystem::computeMiddlePhase(OverlappingPairMap& overlappingPairs, NarrowPhaseInput& narrowPhaseInput) { RP3D_PROFILE("CollisionDetection::computeMiddlePhase()", mProfiler); @@ -285,7 +285,7 @@ void CollisionDetection::computeMiddlePhase(OverlappingPairMap& overlappingPairs } // Compute the concave vs convex middle-phase algorithm for a given pair of bodies -void CollisionDetection::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair, MemoryAllocator& allocator, +void CollisionDetectionSystem::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair, MemoryAllocator& allocator, NarrowPhaseInput& narrowPhaseInput) { RP3D_PROFILE("CollisionDetection::computeConvexVsConcaveMiddlePhase()", mProfiler); @@ -363,7 +363,7 @@ void CollisionDetection::computeConvexVsConcaveMiddlePhase(OverlappingPair* pair } // Execute the narrow-phase collision detection algorithm on batches -bool CollisionDetection::testNarrowPhaseCollision(NarrowPhaseInput& narrowPhaseInput, bool reportContacts, +bool CollisionDetectionSystem::testNarrowPhaseCollision(NarrowPhaseInput& narrowPhaseInput, bool reportContacts, bool clipWithPreviousAxisIfStillColliding, MemoryAllocator& allocator) { bool contactFound = false; @@ -408,7 +408,7 @@ bool CollisionDetection::testNarrowPhaseCollision(NarrowPhaseInput& narrowPhaseI } // Process the potential contacts after narrow-phase collision detection -void CollisionDetection::processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, +void CollisionDetectionSystem::processAllPotentialContacts(NarrowPhaseInput& narrowPhaseInput, bool updateLastFrameInfo, List& potentialContactPoints, Map* mapPairIdToContactPairIndex, List& potentialContactManifolds, @@ -442,7 +442,7 @@ void CollisionDetection::processAllPotentialContacts(NarrowPhaseInput& narrowPha } // Compute the narrow-phase collision detection -void CollisionDetection::computeNarrowPhase() { +void CollisionDetectionSystem::computeNarrowPhase() { RP3D_PROFILE("CollisionDetection::computeNarrowPhase()", mProfiler); @@ -471,7 +471,7 @@ void CollisionDetection::computeNarrowPhase() { // Compute the narrow-phase collision detection for the testOverlap() methods. /// This method returns true if contacts are found. -bool CollisionDetection::computeNarrowPhaseOverlapSnapshot(NarrowPhaseInput& narrowPhaseInput, OverlapCallback* callback) { +bool CollisionDetectionSystem::computeNarrowPhaseOverlapSnapshot(NarrowPhaseInput& narrowPhaseInput, OverlapCallback* callback) { RP3D_PROFILE("CollisionDetection::computeNarrowPhaseOverlapSnapshot()", mProfiler); @@ -494,7 +494,7 @@ bool CollisionDetection::computeNarrowPhaseOverlapSnapshot(NarrowPhaseInput& nar } // Process the potential overlapping bodies for the testOverlap() methods -void CollisionDetection::computeSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, List>& overlapPairs) const { +void CollisionDetectionSystem::computeSnapshotContactPairs(NarrowPhaseInput& narrowPhaseInput, List>& overlapPairs) const { // get the narrow-phase batches to test for collision NarrowPhaseInfoBatch& sphereVsSphereBatch = narrowPhaseInput.getSphereVsSphereBatch(); @@ -514,7 +514,7 @@ void CollisionDetection::computeSnapshotContactPairs(NarrowPhaseInput& narrowPha } // Convert the potential overlapping bodies for the testOverlap() methods -void CollisionDetection::computeSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, List>& overlapPairs) const { +void CollisionDetectionSystem::computeSnapshotContactPairs(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, List>& overlapPairs) const { RP3D_PROFILE("CollisionDetection::computeSnapshotContactPairs()", mProfiler); @@ -535,7 +535,7 @@ void CollisionDetection::computeSnapshotContactPairs(NarrowPhaseInfoBatch& narro // Compute the narrow-phase collision detection for the testCollision() methods. // This method returns true if contacts are found. -bool CollisionDetection::computeNarrowPhaseCollisionSnapshot(NarrowPhaseInput& narrowPhaseInput, CollisionCallback& callback) { +bool CollisionDetectionSystem::computeNarrowPhaseCollisionSnapshot(NarrowPhaseInput& narrowPhaseInput, CollisionCallback& callback) { RP3D_PROFILE("CollisionDetection::computeNarrowPhaseCollisionSnapshot()", mProfiler); @@ -574,7 +574,7 @@ bool CollisionDetection::computeNarrowPhaseCollisionSnapshot(NarrowPhaseInput& n } // Swap the previous and current contacts lists -void CollisionDetection::swapPreviousAndCurrentContacts() { +void CollisionDetectionSystem::swapPreviousAndCurrentContacts() { if (mPreviousContactPairs == &mContactPairs1) { @@ -603,7 +603,7 @@ void CollisionDetection::swapPreviousAndCurrentContacts() { } // Create the actual contact manifolds and contacts points -void CollisionDetection::createContacts() { +void CollisionDetectionSystem::createContacts() { RP3D_PROFILE("CollisionDetection::createContacts()", mProfiler); @@ -670,7 +670,7 @@ void CollisionDetection::createContacts() { } // Create the actual contact manifolds and contacts points for testCollision() methods -void CollisionDetection::createSnapshotContacts(List& contactPairs, +void CollisionDetectionSystem::createSnapshotContacts(List& contactPairs, List& contactManifolds, List& contactPoints, List& potentialContactManifolds, @@ -726,7 +726,7 @@ void CollisionDetection::createSnapshotContacts(List& contactPairs, } // Initialize the current contacts with the contacts from the previous frame (for warmstarting) -void CollisionDetection::initContactsWithPreviousOnes() { +void CollisionDetectionSystem::initContactsWithPreviousOnes() { // For each contact pair of the current frame for (uint i=0; i < mCurrentContactPairs->size(); i++) { @@ -821,7 +821,7 @@ void CollisionDetection::initContactsWithPreviousOnes() { } // Remove a body from the collision detection -void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) { +void CollisionDetectionSystem::removeProxyCollisionShape(ProxyShape* proxyShape) { assert(proxyShape->getBroadPhaseId() != -1); assert(mMapBroadPhaseIdToProxyShapeEntity.containsKey(proxyShape->getBroadPhaseId())); @@ -853,7 +853,7 @@ void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) { } // Ray casting method -void CollisionDetection::raycast(RaycastCallback* raycastCallback, +void CollisionDetectionSystem::raycast(RaycastCallback* raycastCallback, const Ray& ray, unsigned short raycastWithCategoryMaskBits) const { @@ -867,7 +867,7 @@ void CollisionDetection::raycast(RaycastCallback* raycastCallback, } // Convert the potential contact into actual contacts -void CollisionDetection::processPotentialContacts(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, bool updateLastFrameInfo, +void CollisionDetectionSystem::processPotentialContacts(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, bool updateLastFrameInfo, List& potentialContactPoints, Map* mapPairIdToContactPairIndex, List& potentialContactManifolds, @@ -1007,7 +1007,7 @@ void CollisionDetection::processPotentialContacts(NarrowPhaseInfoBatch& narrowPh } // Clear the obsolete manifolds and contact points and reduce the number of contacts points of the remaining manifolds -void CollisionDetection::reducePotentialContactManifolds(List* contactPairs, +void CollisionDetectionSystem::reducePotentialContactManifolds(List* contactPairs, List& potentialContactManifolds, const List& potentialContactPoints) const { @@ -1070,7 +1070,7 @@ void CollisionDetection::reducePotentialContactManifolds(List* cont } // Return the largest depth of all the contact points of a potential manifold -decimal CollisionDetection::computePotentialManifoldLargestContactDepth(const ContactManifoldInfo& manifold, +decimal CollisionDetectionSystem::computePotentialManifoldLargestContactDepth(const ContactManifoldInfo& manifold, const List& potentialContactPoints) const { decimal largestDepth = 0.0f; @@ -1092,7 +1092,7 @@ decimal CollisionDetection::computePotentialManifoldLargestContactDepth(const Co // This is based on the technique described by Dirk Gregorius in his // "Contacts Creation" GDC presentation. This method will reduce the number of // contact points to a maximum of 4 points (but it can be less). -void CollisionDetection::reduceContactPoints(ContactManifoldInfo& manifold, const Transform& shape1ToWorldTransform, +void CollisionDetectionSystem::reduceContactPoints(ContactManifoldInfo& manifold, const Transform& shape1ToWorldTransform, const List& potentialContactPoints) const { assert(manifold.potentialContactPointsIndices.size() > MAX_CONTACT_POINTS_IN_MANIFOLD); @@ -1269,7 +1269,7 @@ void CollisionDetection::reduceContactPoints(ContactManifoldInfo& manifold, cons } // Report contacts -void CollisionDetection::reportContacts() { +void CollisionDetectionSystem::reportContacts() { if (mWorld->mEventListener != nullptr) { reportContacts(*(mWorld->mEventListener), mCurrentContactPairs, mCurrentContactManifolds, @@ -1278,7 +1278,7 @@ void CollisionDetection::reportContacts() { } // Report all contacts -void CollisionDetection::reportContacts(CollisionCallback& callback, List* contactPairs, +void CollisionDetectionSystem::reportContacts(CollisionCallback& callback, List* contactPairs, List* manifolds, List* contactPoints) { RP3D_PROFILE("CollisionDetection::reportContacts()", mProfiler); @@ -1294,7 +1294,7 @@ void CollisionDetection::reportContacts(CollisionCallback& callback, ListmEventListener; } // Return the world-space AABB of a given proxy shape -const AABB CollisionDetection::getWorldAABB(const ProxyShape* proxyShape) const { +const AABB CollisionDetectionSystem::getWorldAABB(const ProxyShape* proxyShape) const { assert(proxyShape->getBroadPhaseId() > -1); return mBroadPhaseSystem.getFatAABB(proxyShape->getBroadPhaseId()); } diff --git a/src/collision/CollisionDetection.h b/src/systems/CollisionDetectionSystem.h similarity index 93% rename from src/collision/CollisionDetection.h rename to src/systems/CollisionDetectionSystem.h index a9e9a2c6..15e85b0c 100644 --- a/src/collision/CollisionDetection.h +++ b/src/systems/CollisionDetectionSystem.h @@ -23,8 +23,8 @@ * * ********************************************************************************/ -#ifndef REACTPHYSICS3D_COLLISION_DETECTION_H -#define REACTPHYSICS3D_COLLISION_DETECTION_H +#ifndef REACTPHYSICS3D_COLLISION_DETECTION_SYSTEM_H +#define REACTPHYSICS3D_COLLISION_DETECTION_SYSTEM_H // Libraries #include "body/CollisionBody.h" @@ -56,14 +56,14 @@ class MemoryManager; class EventListener; class CollisionDispatch; -// Class CollisionDetection +// Class CollisionDetectionSystem /** * This class computes the collision detection algorithms. We first * perform a broad-phase algorithm to know which pairs of bodies can * collide and then we run a narrow-phase algorithm to compute the * collision contacts between bodies. */ -class CollisionDetection { +class CollisionDetectionSystem { private : @@ -269,18 +269,18 @@ class CollisionDetection { // -------------------- Methods -------------------- // /// Constructor - CollisionDetection(CollisionWorld* world, ProxyShapeComponents& proxyShapesComponents, + CollisionDetectionSystem(CollisionWorld* world, ProxyShapeComponents& proxyShapesComponents, TransformComponents& transformComponents, RigidBodyComponents& rigidBodyComponents, MemoryManager& memoryManager); /// Destructor - ~CollisionDetection() = default; + ~CollisionDetectionSystem() = default; /// Deleted copy-constructor - CollisionDetection(const CollisionDetection& collisionDetection) = delete; + CollisionDetectionSystem(const CollisionDetectionSystem& collisionDetection) = delete; /// Deleted assignment operator - CollisionDetection& operator=(const CollisionDetection& collisionDetection) = delete; + CollisionDetectionSystem& operator=(const CollisionDetectionSystem& collisionDetection) = delete; /// Set the collision dispatch configuration CollisionDispatch& getCollisionDispatch(); @@ -360,12 +360,12 @@ class CollisionDetection { }; // Return a reference to the collision dispatch configuration -inline CollisionDispatch& CollisionDetection::getCollisionDispatch() { +inline CollisionDispatch& CollisionDetectionSystem::getCollisionDispatch() { return mCollisionDispatch; } // Add a body to the collision detection -inline void CollisionDetection::addProxyCollisionShape(ProxyShape* proxyShape, const AABB& aabb) { +inline void CollisionDetectionSystem::addProxyCollisionShape(ProxyShape* proxyShape, const AABB& aabb) { // Add the body to the broad-phase mBroadPhaseSystem.addProxyCollisionShape(proxyShape, aabb); @@ -379,13 +379,13 @@ inline void CollisionDetection::addProxyCollisionShape(ProxyShape* proxyShape, c } // Add a pair of bodies that cannot collide with each other -inline void CollisionDetection::addNoCollisionPair(CollisionBody* body1, +inline void CollisionDetectionSystem::addNoCollisionPair(CollisionBody* body1, CollisionBody* body2) { mNoCollisionPairs.add(OverlappingPair::computeBodiesIndexPair(body1, body2)); } // Remove a pair of bodies that cannot collide with each other -inline void CollisionDetection::removeNoCollisionPair(CollisionBody* body1, +inline void CollisionDetectionSystem::removeNoCollisionPair(CollisionBody* body1, CollisionBody* body2) { mNoCollisionPairs.remove(OverlappingPair::computeBodiesIndexPair(body1, body2)); } @@ -393,7 +393,7 @@ inline void CollisionDetection::removeNoCollisionPair(CollisionBody* body1, // Ask for a collision shape to be tested again during broad-phase. /// We simply put the shape in the list of collision shape that have moved in the /// previous frame so that it is tested for collision again in the broad-phase. -inline void CollisionDetection::askForBroadPhaseCollisionCheck(ProxyShape* shape) { +inline void CollisionDetectionSystem::askForBroadPhaseCollisionCheck(ProxyShape* shape) { if (shape->getBroadPhaseId() != -1) { mBroadPhaseSystem.addMovedCollisionShape(shape->getBroadPhaseId()); @@ -401,31 +401,31 @@ inline void CollisionDetection::askForBroadPhaseCollisionCheck(ProxyShape* shape } // Return a pointer to the world -inline CollisionWorld* CollisionDetection::getWorld() { +inline CollisionWorld* CollisionDetectionSystem::getWorld() { return mWorld; } // Return a reference to the memory manager -inline MemoryManager& CollisionDetection::getMemoryManager() const { +inline MemoryManager& CollisionDetectionSystem::getMemoryManager() const { return mMemoryManager; } // Update a proxy collision shape (that has moved for instance) -inline void CollisionDetection::updateProxyShape(Entity proxyShapeEntity, decimal timeStep) { +inline void CollisionDetectionSystem::updateProxyShape(Entity proxyShapeEntity, decimal timeStep) { // Update the proxy-shape component mBroadPhaseSystem.updateProxyShape(proxyShapeEntity, timeStep); } // Update all the enabled proxy-shapes -inline void CollisionDetection::updateProxyShapes(decimal timeStep) { +inline void CollisionDetectionSystem::updateProxyShapes(decimal timeStep) { mBroadPhaseSystem.updateProxyShapes(timeStep); } #ifdef IS_PROFILING_ACTIVE // Set the profiler -inline void CollisionDetection::setProfiler(Profiler* profiler) { +inline void CollisionDetectionSystem::setProfiler(Profiler* profiler) { mProfiler = profiler; mBroadPhaseSystem.setProfiler(profiler); mCollisionDispatch.setProfiler(profiler);