From 60132edd97bb5a253fc8443027187f65d3787ab5 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Wed, 8 Jul 2009 16:35:57 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@173 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- .../collision/BroadPhaseAlgorithm.h | 2 +- .../collision/CollisionDetection.cpp | 12 ++++++----- .../collision/CollisionDetection.h | 20 +++++++++++++++---- .../collision/SeparatingAxisOBB.cpp | 9 +++++---- .../collision/SeparatingAxisOBB.h | 11 +++++----- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/sources/reactphysics3d/collision/BroadPhaseAlgorithm.h b/sources/reactphysics3d/collision/BroadPhaseAlgorithm.h index d13b8c94..909fd5be 100644 --- a/sources/reactphysics3d/collision/BroadPhaseAlgorithm.h +++ b/sources/reactphysics3d/collision/BroadPhaseAlgorithm.h @@ -46,7 +46,7 @@ class BroadPhaseAlgorithm { BroadPhaseAlgorithm(); // Constructor virtual ~BroadPhaseAlgorithm(); // Destructor - virtual bool testCollisionPair(const BoundingVolume& boundingVolume1, const BoundingVolume& boundingVolume2)=0; // Return true is the two bounding volume can collide + virtual bool testCollisionPair(const BoundingVolume& boundingVolume1, const BoundingVolume& boundingVolume2)=0; // Return true if the two bounding volume can collide }; } // End of reactphysics3d namespace diff --git a/sources/reactphysics3d/collision/CollisionDetection.cpp b/sources/reactphysics3d/collision/CollisionDetection.cpp index 53981aaf..866ab0c6 100644 --- a/sources/reactphysics3d/collision/CollisionDetection.cpp +++ b/sources/reactphysics3d/collision/CollisionDetection.cpp @@ -19,6 +19,8 @@ // Libraries #include "CollisionDetection.h" +#include "SeparatingAxisAABB.h" +#include "SeparatingAxisOBB.h" // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; @@ -26,15 +28,15 @@ using namespace reactphysics3d; // Constructor CollisionDetection::CollisionDetection() { - // Construct the broad-phase algorithm that will be used - broadPhaseAlgorithm = + // Construct the broad-phase algorithm that will be used (Separating axis with AABB) + broadPhaseAlgorithm = new SeparatingAxisAABB(); - // Construct the narrow-phase algorithm that will be used - narrowPhaseAlgorithm = new SeparatingAxis(); + // Construct the narrow-phase algorithm that will be used (Separating axis with OBB) + narrowPhaseAlgorithm = new SeparatingAxisOBB(); } // Destructor -~CollisionDetection() { +CollisionDetection::~CollisionDetection() { } diff --git a/sources/reactphysics3d/collision/CollisionDetection.h b/sources/reactphysics3d/collision/CollisionDetection.h index 4b516585..eaa44625 100644 --- a/sources/reactphysics3d/collision/CollisionDetection.h +++ b/sources/reactphysics3d/collision/CollisionDetection.h @@ -26,7 +26,6 @@ #include "../body/Body.h" #include "../engine/CollisionWorld.h" #include -#include // ReactPhysics3D namespace namespace reactphysics3d { @@ -41,12 +40,14 @@ namespace reactphysics3d { */ class CollisionDetection { private : - std::vector<(std::pair)> possibleCollisionPairList; // List that contains the possible collision pairs of bodies + std::vector< std::pair > possibleCollisionPairList; // List that contains the possible collision pairs of bodies BroadPhaseAlgorithm* broadPhaseAlgorithm; // Broad-phase algorithm NarrowPhaseAlgorithm* narrowPhaseAlgorithm; // Narrow-phase algorithm - void computePossibleCollisionPairs(); // Compute all the possible collisions pairs of bodies (broad-phase) - void computeCollisionContacts(); // Compute all collision contacts between bodies (narrow-phase) + void computePossibleCollisionPairs(); // Compute all the possible collisions pairs of bodies (broad-phase) + void computeCollisionContacts(); // Compute all collision contacts between bodies (narrow-phase) + void addPossibleCollisionPair(Body* body1, Body* body2); // Add a possible collision pair of bodies in the possibleCollisionPairList + void initPossibleCollisionPairList(); // Initialize the possibleCollisionPairList public : CollisionDetection(); // Constructor @@ -55,6 +56,17 @@ class CollisionDetection { void computeCollisionDetection(CollisionWorld& collisionWorld); // Compute the collision detection }; +// Add a possible collision pair of bodies in the possibleCollisionPairList +inline void CollisionDetection::addPossibleCollisionPair(Body* body1, Body* body2) { + // TODO : Implement this method +} + +// Initialize the possibleCollisionPairList +inline void CollisionDetection::initPossibleCollisionPairList() { + // TODO : Implement this method +} + + } // End of the ReactPhysics3D namespace #endif diff --git a/sources/reactphysics3d/collision/SeparatingAxisOBB.cpp b/sources/reactphysics3d/collision/SeparatingAxisOBB.cpp index 4bb528b2..6a9970d8 100644 --- a/sources/reactphysics3d/collision/SeparatingAxisOBB.cpp +++ b/sources/reactphysics3d/collision/SeparatingAxisOBB.cpp @@ -18,23 +18,24 @@ ***************************************************************************/ // Libraries -#include "SeparatingAxis.h" +#include "SeparatingAxisOBB.h" +#include "../body/OBB.h" // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; // Constructor -SeparatingAxis::SeparatingAxis() { +SeparatingAxisOBB::SeparatingAxisOBB() { } // Destructor -SeparatingAxis::~SeparatingAxis() { +SeparatingAxisOBB::~SeparatingAxisOBB() { } // Return true and compute a collision contact if the two bounding volume collide. // The method returns false if there is no collision between the two bounding volumes. -bool SeparatingAxis::testCollision(const BoundingVolume& boundingVolume1, const BoundingVolume& boundingVolume2, Contact* const contact) { +bool SeparatingAxisOBB::testCollision(const BoundingVolume& boundingVolume1, const BoundingVolume& boundingVolume2, Contact* const contact) { // TODO : Implement this method } diff --git a/sources/reactphysics3d/collision/SeparatingAxisOBB.h b/sources/reactphysics3d/collision/SeparatingAxisOBB.h index d843d781..af6ab52a 100644 --- a/sources/reactphysics3d/collision/SeparatingAxisOBB.h +++ b/sources/reactphysics3d/collision/SeparatingAxisOBB.h @@ -17,23 +17,22 @@ * along with ReactPhysics3D. If not, see . * ***************************************************************************/ -#ifndef SEPARATINGAXIS_H -#define SEPARATINGAXIS_H +#ifndef SEPARATINGAXISOBB_H +#define SEPARATINGAXISOBB_H // Libraries #include "NarrowPhaseAlgorithm.h" #include "../constraint/Contact.h" -#include "../body/OBB.h" // ReactPhysics3D namespace namespace reactphysics3d { -class SeparatingAxis : public NarrowPhaseAlgorithm { +class SeparatingAxisOBB : public NarrowPhaseAlgorithm { private : public : - SeparatingAxis(); // Constructor - ~SeparatingAxis(); // Destructor + SeparatingAxisOBB(); // Constructor + ~SeparatingAxisOBB(); // Destructor virtual bool testCollision(const BoundingVolume& boundingVolume1, const BoundingVolume& boundingVolume2, Contact* const contact); // Return true and compute a collision contact if the two bounding volume collide