git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@173 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
817c8a17a1
commit
60132edd97
|
@ -46,7 +46,7 @@ class BroadPhaseAlgorithm {
|
||||||
BroadPhaseAlgorithm(); // Constructor
|
BroadPhaseAlgorithm(); // Constructor
|
||||||
virtual ~BroadPhaseAlgorithm(); // Destructor
|
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
|
} // End of reactphysics3d namespace
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "CollisionDetection.h"
|
#include "CollisionDetection.h"
|
||||||
|
#include "SeparatingAxisAABB.h"
|
||||||
|
#include "SeparatingAxisOBB.h"
|
||||||
|
|
||||||
// We want to use the ReactPhysics3D namespace
|
// We want to use the ReactPhysics3D namespace
|
||||||
using namespace reactphysics3d;
|
using namespace reactphysics3d;
|
||||||
|
@ -26,15 +28,15 @@ using namespace reactphysics3d;
|
||||||
// Constructor
|
// Constructor
|
||||||
CollisionDetection::CollisionDetection() {
|
CollisionDetection::CollisionDetection() {
|
||||||
|
|
||||||
// Construct the broad-phase algorithm that will be used
|
// Construct the broad-phase algorithm that will be used (Separating axis with AABB)
|
||||||
broadPhaseAlgorithm =
|
broadPhaseAlgorithm = new SeparatingAxisAABB();
|
||||||
|
|
||||||
// Construct the narrow-phase algorithm that will be used
|
// Construct the narrow-phase algorithm that will be used (Separating axis with OBB)
|
||||||
narrowPhaseAlgorithm = new SeparatingAxis();
|
narrowPhaseAlgorithm = new SeparatingAxisOBB();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~CollisionDetection() {
|
CollisionDetection::~CollisionDetection() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "../body/Body.h"
|
#include "../body/Body.h"
|
||||||
#include "../engine/CollisionWorld.h"
|
#include "../engine/CollisionWorld.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
// ReactPhysics3D namespace
|
// ReactPhysics3D namespace
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
@ -41,12 +40,14 @@ namespace reactphysics3d {
|
||||||
*/
|
*/
|
||||||
class CollisionDetection {
|
class CollisionDetection {
|
||||||
private :
|
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
|
BroadPhaseAlgorithm* broadPhaseAlgorithm; // Broad-phase algorithm
|
||||||
NarrowPhaseAlgorithm* narrowPhaseAlgorithm; // Narrow-phase algorithm
|
NarrowPhaseAlgorithm* narrowPhaseAlgorithm; // Narrow-phase algorithm
|
||||||
|
|
||||||
void computePossibleCollisionPairs(); // Compute all the possible collisions pairs of bodies (broad-phase)
|
void computePossibleCollisionPairs(); // Compute all the possible collisions pairs of bodies (broad-phase)
|
||||||
void computeCollisionContacts(); // Compute all collision contacts between bodies (narrow-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 :
|
public :
|
||||||
CollisionDetection(); // Constructor
|
CollisionDetection(); // Constructor
|
||||||
|
@ -55,6 +56,17 @@ class CollisionDetection {
|
||||||
void computeCollisionDetection(CollisionWorld& collisionWorld); // Compute the collision detection
|
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
|
} // End of the ReactPhysics3D namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,23 +18,24 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "SeparatingAxis.h"
|
#include "SeparatingAxisOBB.h"
|
||||||
|
#include "../body/OBB.h"
|
||||||
|
|
||||||
// We want to use the ReactPhysics3D namespace
|
// We want to use the ReactPhysics3D namespace
|
||||||
using namespace reactphysics3d;
|
using namespace reactphysics3d;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
SeparatingAxis::SeparatingAxis() {
|
SeparatingAxisOBB::SeparatingAxisOBB() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
SeparatingAxis::~SeparatingAxis() {
|
SeparatingAxisOBB::~SeparatingAxisOBB() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true and compute a collision contact if the two bounding volume collide.
|
// 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.
|
// 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
|
// TODO : Implement this method
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,23 +17,22 @@
|
||||||
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef SEPARATINGAXIS_H
|
#ifndef SEPARATINGAXISOBB_H
|
||||||
#define SEPARATINGAXIS_H
|
#define SEPARATINGAXISOBB_H
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "NarrowPhaseAlgorithm.h"
|
#include "NarrowPhaseAlgorithm.h"
|
||||||
#include "../constraint/Contact.h"
|
#include "../constraint/Contact.h"
|
||||||
#include "../body/OBB.h"
|
|
||||||
|
|
||||||
// ReactPhysics3D namespace
|
// ReactPhysics3D namespace
|
||||||
namespace reactphysics3d {
|
namespace reactphysics3d {
|
||||||
|
|
||||||
class SeparatingAxis : public NarrowPhaseAlgorithm {
|
class SeparatingAxisOBB : public NarrowPhaseAlgorithm {
|
||||||
private :
|
private :
|
||||||
|
|
||||||
public :
|
public :
|
||||||
SeparatingAxis(); // Constructor
|
SeparatingAxisOBB(); // Constructor
|
||||||
~SeparatingAxis(); // Destructor
|
~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
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user