git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@173 92aac97c-a6ce-11dd-a772-7fcde58d38e6

This commit is contained in:
chappuis.daniel 2009-07-08 16:35:57 +00:00
parent 817c8a17a1
commit 60132edd97
5 changed files with 34 additions and 20 deletions

View File

@ -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

View File

@ -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() {
}

View File

@ -26,7 +26,6 @@
#include "../body/Body.h"
#include "../engine/CollisionWorld.h"
#include <vector>
#include <utility>
// ReactPhysics3D namespace
namespace reactphysics3d {
@ -41,12 +40,14 @@ namespace reactphysics3d {
*/
class CollisionDetection {
private :
std::vector<(std::pair<Body*, Body*>)> possibleCollisionPairList; // List that contains the possible collision pairs of bodies
std::vector< std::pair<Body*, Body*> > 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

View File

@ -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
}

View File

@ -17,23 +17,22 @@
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#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