diff --git a/sources/reactphysics3d/collision/CollisionDetection.cpp b/sources/reactphysics3d/collision/CollisionDetection.cpp index 4f50af9e..c753dd94 100644 --- a/sources/reactphysics3d/collision/CollisionDetection.cpp +++ b/sources/reactphysics3d/collision/CollisionDetection.cpp @@ -20,7 +20,7 @@ // Libraries #include "CollisionDetection.h" #include "NoBroadPhaseAlgorithm.h" -#include "NarrowPhaseSATAlgorithm.h" +#include "SATAlgorithm.h" #include "../body/OBB.h" #include "../body/RigidBody.h" #include @@ -35,7 +35,7 @@ CollisionDetection::CollisionDetection() { broadPhaseAlgorithm = new NoBroadPhaseAlgorithm(); // Construct the narrow-phase algorithm that will be used (Separating axis with OBB) - narrowPhaseAlgorithm = new NarrowPhaseSATAlgorithm(); + narrowPhaseAlgorithm = new SATAlgorithm(); } // Destructor diff --git a/sources/reactphysics3d/collision/SATAlgorithm.cpp b/sources/reactphysics3d/collision/SATAlgorithm.cpp index 6103364f..84f8ca02 100644 --- a/sources/reactphysics3d/collision/SATAlgorithm.cpp +++ b/sources/reactphysics3d/collision/SATAlgorithm.cpp @@ -18,13 +18,12 @@ ***************************************************************************/ // Libraries -#include "NarrowPhaseSATAlgorithm.h" +#include "SATAlgorithm.h" #include "../body/OBB.h" #include "../body/RigidBody.h" #include "../constraint/Contact.h" #include #include -#include // TODO : Delete this #include // We want to use the ReactPhysics3D namespace @@ -36,18 +35,18 @@ using namespace reactphysics3d; //  everything have to do with the new SAT algorithm // Constructor -NarrowPhaseSATAlgorithm::NarrowPhaseSATAlgorithm() { +SATAlgorithm::SATAlgorithm() { } // Destructor -NarrowPhaseSATAlgorithm::~NarrowPhaseSATAlgorithm() { +SATAlgorithm::~SATAlgorithm() { } // 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 NarrowPhaseSATAlgorithm::testCollision(const BoundingVolume* const boundingVolume1, const BoundingVolume* const boundingVolume2, Contact** contact) { +bool SATAlgorithm::testCollision(const BoundingVolume* const boundingVolume1, const BoundingVolume* const boundingVolume2, Contact** contact) { assert(boundingVolume1 != boundingVolume2); assert(*contact == 0); @@ -74,7 +73,7 @@ bool NarrowPhaseSATAlgorithm::testCollision(const BoundingVolume* const bounding // OBB are the six face normals (3 for each OBB) and the nine vectors V = Ai x Bj where Ai is the ith face normal // vector of OBB 1 and Bj is the jth face normal vector of OBB 2. We will use the notation Ai for the ith face // normal of OBB 1 and Bj for the jth face normal of OBB 2. -bool NarrowPhaseSATAlgorithm::computeCollisionTest(const OBB* const obb1, const OBB* const obb2, Contact** contact) const { +bool SATAlgorithm::computeCollisionTest(const OBB* const obb1, const OBB* const obb2, Contact** contact) const { double center; // Center of a projection interval double radius1; // Radius of projection interval [min1, max1] @@ -456,7 +455,7 @@ bool NarrowPhaseSATAlgorithm::computeCollisionTest(const OBB* const obb1, const // penetration depth (note that it could return a negative penetration depth if the intervals are separated. This // method also find which interval is at the left of the other in order to know which extreme of interval 1 collides with // which extreme of interval 2 if a collision occur. -double NarrowPhaseSATAlgorithm::computePenetrationDepth(double min1, double max1, double min2, double max2, bool& side) const { +double SATAlgorithm::computePenetrationDepth(double min1, double max1, double min2, double max2, bool& side) const { // Compute the length of both intervals double lengthInterval1 = max1 - min1; @@ -485,8 +484,8 @@ double NarrowPhaseSATAlgorithm::computePenetrationDepth(double min1, double max1 } // Compute a new collision contact between two OBBs -void NarrowPhaseSATAlgorithm::computeContact(const OBB* const obb1, const OBB* const obb2, const Vector3D normal, double penetrationDepth, - const std::vector& obb1ExtremePoints, const std::vector& obb2ExtremePoints, Contact** contact) const { +void SATAlgorithm::computeContact(const OBB* const obb1, const OBB* const obb2, const Vector3D normal, double penetrationDepth, + const std::vector& obb1ExtremePoints, const std::vector& obb2ExtremePoints, Contact** contact) const { unsigned int nbVerticesExtremeOBB1 = obb1ExtremePoints.size(); unsigned int nbVerticesExtremeOBB2 = obb2ExtremePoints.size(); diff --git a/sources/reactphysics3d/collision/SATAlgorithm.h b/sources/reactphysics3d/collision/SATAlgorithm.h index 02afea69..fcf7842e 100644 --- a/sources/reactphysics3d/collision/SATAlgorithm.h +++ b/sources/reactphysics3d/collision/SATAlgorithm.h @@ -17,8 +17,8 @@ * along with ReactPhysics3D. If not, see . * ***************************************************************************/ -#ifndef NARROWPHASESATALGORITHM_H -#define NARROWPHASESATALGORITHM_H +#ifndef SATALGORITHM_H +#define SATALGORITHM_H // Libraries #include "NarrowPhaseAlgorithm.h" @@ -29,7 +29,7 @@ namespace reactphysics3d { /* ------------------------------------------------------------------- - Class NarrowPhaseSATAlgorithm : + Class SATAlgorithm : This class implements a narrow-phase algorithm. This algorithm uses a separating axis theorem (SAT) to check if two bounding volumes collide or not. If the @@ -42,7 +42,7 @@ namespace reactphysics3d { intersect. ------------------------------------------------------------------- */ -class NarrowPhaseSATAlgorithm : public NarrowPhaseAlgorithm { +class SATAlgorithm : public NarrowPhaseAlgorithm { private : bool computeCollisionTest(const OBB* const obb1, const OBB* const obb2, Contact** contact) const; // Return true and compute a collision contact if the two OBB collide double computePenetrationDepth(double min1, double max1, double min2, double max2, bool& side) const; // Compute the penetration depth of two projection intervals @@ -51,8 +51,8 @@ class NarrowPhaseSATAlgorithm : public NarrowPhaseAlgorithm { Vector3D computeContactNormal(const Vector3D& axis, const Vector3D& distanceOfOBBs) const; // Compute a contact normal public : - NarrowPhaseSATAlgorithm(); // Constructor - ~NarrowPhaseSATAlgorithm(); // Destructor + SATAlgorithm(); // Constructor + ~SATAlgorithm(); // Destructor virtual bool testCollision(const BoundingVolume* const boundingVolume1, const BoundingVolume* const boundingVolume2, Contact** contact); // Return true and compute a collision contact if the two bounding volume collide }; @@ -61,7 +61,7 @@ class NarrowPhaseSATAlgorithm : public NarrowPhaseAlgorithm { // Return the contact normal with the correct sign (from obb1 toward obb2). "axis" is the axis vector direction where the // collision occur and "distanceOfOBBs" is the vector (obb2.center - obb1.center). -inline Vector3D NarrowPhaseSATAlgorithm::computeContactNormal(const Vector3D& axis, const Vector3D& distanceOfOBBs) const { +inline Vector3D SATAlgorithm::computeContactNormal(const Vector3D& axis, const Vector3D& distanceOfOBBs) const { if (distanceOfOBBs.scalarProduct(axis) >= 0.0) { return axis; }