diff --git a/src/collision/BroadPhaseAlgorithm.h b/src/collision/BroadPhaseAlgorithm.h index b592f221..ebc213f8 100644 --- a/src/collision/BroadPhaseAlgorithm.h +++ b/src/collision/BroadPhaseAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef BROADPHASEALGORITHM_H -#define BROADPHASEALGORITHM_H +#ifndef BROAD_PHASE_ALGORITHM_H +#define BROAD_PHASE_ALGORITHM_H // Libraries #include "../body/BoundingVolume.h" diff --git a/src/collision/CollisionDetection.h b/src/collision/CollisionDetection.h index 20c50311..f965ac61 100644 --- a/src/collision/CollisionDetection.h +++ b/src/collision/CollisionDetection.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef COLLISIONDETECTION_H -#define COLLISIONDETECTION_H +#ifndef COLLISION_DETECTION_H +#define COLLISION_DETECTION_H // Libraries #include "BroadPhaseAlgorithm.h" diff --git a/src/collision/ContactInfo.h b/src/collision/ContactInfo.h index 3df5c885..1b93f79e 100644 --- a/src/collision/ContactInfo.h +++ b/src/collision/ContactInfo.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef CONTACTINFO_H -#define CONTACTINFO_H +#ifndef CONTACT_INFO_H +#define CONTACT_INFO_H // Libraries #include "../body/OBB.h" diff --git a/src/collision/EPA/EPAAlgorithm.cpp b/src/collision/EPA/EPAAlgorithm.cpp index f0cf7887..e44d9482 100644 --- a/src/collision/EPA/EPAAlgorithm.cpp +++ b/src/collision/EPA/EPAAlgorithm.cpp @@ -323,7 +323,7 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(Simplex simplex, cons // Compute the support point of the Minkowski difference (A-B) in the closest point direction suppPointsA[nbVertices] = boundingVolume1->getSupportPoint(triangle->getClosestPoint(), OBJECT_MARGIN); - suppPointsB[nbVertices] = boundingVolume2->getSupportPoint(triangle->getClosestPoint().getOpposite()); + suppPointsB[nbVertices] = boundingVolume2->getSupportPoint(triangle->getClosestPoint().getOpposite(), OBJECT_MARGIN); points[nbVertices] = suppPointsA[nbVertices] - suppPointsB[nbVertices]; int indexNewVertex = nbVertices; @@ -360,7 +360,6 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(Simplex simplex, cons // polytope is always convex while(i != triangleStore.getNbTriangles()) { TriangleEPA* newTriangle = &triangleStore[i]; - addFaceCandidate(newTriangle, triangleHeap, nbTriangles, upperBoundSquarePenDepth); i++; } diff --git a/src/collision/EPA/EPAAlgorithm.h b/src/collision/EPA/EPAAlgorithm.h index 28e90eed..fc3e5662 100644 --- a/src/collision/EPA/EPAAlgorithm.h +++ b/src/collision/EPA/EPAAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef EPAAlgorithm_H -#define EPAAlgorithm_H +#ifndef EPA_ALGORITHM_H +#define EPA_ALGORITHM_H // Libraries #include "../GJK/Simplex.h" diff --git a/src/collision/EPA/EdgeEPA.cpp b/src/collision/EPA/EdgeEPA.cpp index ee8904a7..b420c308 100644 --- a/src/collision/EPA/EdgeEPA.cpp +++ b/src/collision/EPA/EdgeEPA.cpp @@ -82,7 +82,7 @@ void EdgeEPA::halfLink(EdgeEPA edge) { } // Compute the silhouette -bool EdgeEPA::computeSilhouette(const Vector3D* vertices, uint index, TrianglesStore triangleStore) { +bool EdgeEPA::computeSilhouette(const Vector3D* vertices, uint index, TrianglesStore& triangleStore) { // If the edge has not already been visited if (!ownerTriangle->getIsObsolete()) { // If the triangle of this edge is not visible from the given point @@ -104,7 +104,7 @@ bool EdgeEPA::computeSilhouette(const Vector3D* vertices, uint index, TrianglesS int backup = triangleStore.getNbTriangles(); - if(!ownerTriangle->getAdjacentEdge(indexOfNextCounterClockwiseEdge(index)).computeSilhouette(vertices, index, triangleStore)) { + if(!ownerTriangle->getAdjacentEdge(indexOfNextCounterClockwiseEdge(this->index)).computeSilhouette(vertices, index, triangleStore)) { ownerTriangle->setIsObsolete(false); TriangleEPA* triangle = triangleStore.newTriangle(vertices, index, getTarget(), getSource()); @@ -117,7 +117,7 @@ bool EdgeEPA::computeSilhouette(const Vector3D* vertices, uint index, TrianglesS return false; } - else if (!ownerTriangle->getAdjacentEdge(indexOfPreviousCounterClockwiseEdge(index)).computeSilhouette(vertices, index, triangleStore)) { + else if (!ownerTriangle->getAdjacentEdge(indexOfPreviousCounterClockwiseEdge(this->index)).computeSilhouette(vertices, index, triangleStore)) { ownerTriangle->setIsObsolete(false); triangleStore.setNbTriangles(backup); diff --git a/src/collision/EPA/EdgeEPA.h b/src/collision/EPA/EdgeEPA.h index e2f3540d..250f9a52 100644 --- a/src/collision/EPA/EdgeEPA.h +++ b/src/collision/EPA/EdgeEPA.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef EDGEEPA_H -#define EDGEEPA_H +#ifndef EDGE_EPA_H +#define EDGE_EPA_H // Libraries @@ -49,9 +49,9 @@ class EdgeEPA { // The edge with index i connect triangle vertices i and (i+1 % 3) public: - EdgeEPA(); // Constructor - EdgeEPA(TriangleEPA* ownerTriangle, int index); // Constructor - ~EdgeEPA(); // Destructor + EdgeEPA(); // Constructor + EdgeEPA(TriangleEPA* ownerTriangle, int index); // Constructor + ~EdgeEPA(); // Destructor TriangleEPA* getOwnerTriangle() const; // Return the pointer to the owner triangle int getIndex() const; // Return the index of the edge in the triangle uint getSource() const; // Return index of the source vertex of the edge @@ -59,7 +59,7 @@ class EdgeEPA { bool link(EdgeEPA edge); // Link the edge with another one void halfLink(EdgeEPA edge); // Half link the edge with another one bool computeSilhouette(const Vector3D* vertices, uint index, - TrianglesStore triangleStore); // Compute the recursive silhouette algorithm + TrianglesStore& triangleStore); // Compute the recursive silhouette algorithm }; diff --git a/src/collision/EPA/TriangleEPA.h b/src/collision/EPA/TriangleEPA.h index 49c227ad..029347f8 100644 --- a/src/collision/EPA/TriangleEPA.h +++ b/src/collision/EPA/TriangleEPA.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef TRIANGLEEPA_H -#define TRIANGLEEPA_H +#ifndef TRIANGLE_EPA_H +#define TRIANGLE_EPA_H // Libraries #include "../../mathematics/mathematics.h" diff --git a/src/collision/EPA/TrianglesStore.h b/src/collision/EPA/TrianglesStore.h index 5b3b2966..cf89eff4 100644 --- a/src/collision/EPA/TrianglesStore.h +++ b/src/collision/EPA/TrianglesStore.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef TRIANGLESSTORE_H -#define TRIANGLESSTORE_H +#ifndef TRIANGLES_STORE_H +#define TRIANGLES_STORE_H #include "TriangleEPA.h" diff --git a/src/collision/GJK/GJKAlgorithm.h b/src/collision/GJK/GJKAlgorithm.h index 92f9ec06..6315b7de 100644 --- a/src/collision/GJK/GJKAlgorithm.h +++ b/src/collision/GJK/GJKAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef GJKALGORITHM_H -#define GJKALGORITHM_H +#ifndef GJK_ALGORITHM_H +#define GJK_ALGORITHM_H // Libraries #include "../NarrowPhaseAlgorithm.h" diff --git a/src/collision/NarrowPhaseAlgorithm.h b/src/collision/NarrowPhaseAlgorithm.h index 7588ec27..f71727ca 100644 --- a/src/collision/NarrowPhaseAlgorithm.h +++ b/src/collision/NarrowPhaseAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef NARROWPHASEALGORITHM_H -#define NARROWPHASEALGORITHM_H +#ifndef NARROW_PHASE_ALGORITHM_H +#define NARROW_PHASE_ALGORITHM_H // Libraries #include "../body/BoundingVolume.h" diff --git a/src/collision/NoBroadPhaseAlgorithm.h b/src/collision/NoBroadPhaseAlgorithm.h index fc047547..c0857e43 100644 --- a/src/collision/NoBroadPhaseAlgorithm.h +++ b/src/collision/NoBroadPhaseAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef NOBROADPHASEALGORITHM_H -#define NOBROADPHASEALGORITHM_H +#ifndef NO_BROAD_PHASE_ALGORITHM_H +#define NO_BROAD_PHASE_ALGORITHM_H // Libraries #include "BroadPhaseAlgorithm.h" diff --git a/src/collision/SAPAlgorithm.h b/src/collision/SAPAlgorithm.h index 39c9a34a..bb86f33e 100644 --- a/src/collision/SAPAlgorithm.h +++ b/src/collision/SAPAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef SAPALGORITHM_H -#define SAPALGORITHM_H +#ifndef SAP_ALGORITHM_H +#define SAP_ALGORITHM_H // Libraries #include "BroadPhaseAlgorithm.h" diff --git a/src/collision/SATAlgorithm.h b/src/collision/SATAlgorithm.h index 875d1313..72614371 100644 --- a/src/collision/SATAlgorithm.h +++ b/src/collision/SATAlgorithm.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef SATALGORITHM_H -#define SATALGORITHM_H +#ifndef SAT_ALGORITHM_H +#define SAT_ALGORITHM_H // Libraries #include "NarrowPhaseAlgorithm.h" diff --git a/src/engine/ConstraintSolver.h b/src/engine/ConstraintSolver.h index f141c99a..4867f961 100644 --- a/src/engine/ConstraintSolver.h +++ b/src/engine/ConstraintSolver.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef CONSTRAINTSOLVER_H -#define CONSTRAINTSOLVER_H +#ifndef CONSTRAINT_SOLVER_H +#define CONSTRAINT_SOLVER_H // Libraries #include "../constants.h" diff --git a/src/engine/ContactCache.h b/src/engine/ContactCache.h index 95511d58..1c4cfc15 100644 --- a/src/engine/ContactCache.h +++ b/src/engine/ContactCache.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef CONTACTCACHE_H -#define CONTACTCACHE_H +#ifndef CONTACT_CACHE_H +#define CONTACT_CACHE_H // Libraries #include diff --git a/src/engine/ContactCachingInfo.h b/src/engine/ContactCachingInfo.h index 5340bae7..07b75bcc 100644 --- a/src/engine/ContactCachingInfo.h +++ b/src/engine/ContactCachingInfo.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef CONTACTCACHINGINFO_H -#define CONTACTCACHINGINFO_H +#ifndef CONTACT_CACHING_INFO_H +#define CONTACT_CACHING_INFO_H // Libraries #include "../body/OBB.h" diff --git a/src/engine/PhysicsEngine.h b/src/engine/PhysicsEngine.h index 5ddd40ee..5335134d 100644 --- a/src/engine/PhysicsEngine.h +++ b/src/engine/PhysicsEngine.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef PHYSICSENGINE_H -#define PHYSICSENGINE_H +#ifndef PHYSICS_ENGINE_H +#define PHYSICS_ENGINE_H // Libraries #include "PhysicsWorld.h" diff --git a/src/engine/PhysicsWorld.h b/src/engine/PhysicsWorld.h index a281987a..b46de269 100644 --- a/src/engine/PhysicsWorld.h +++ b/src/engine/PhysicsWorld.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef PHYSICSWORLD_H -#define PHYSICSWORLD_H +#ifndef PHYSICS_WORLD_H +#define PHYSICS_WORLD_H // Libraries #include diff --git a/src/mathematics/Quaternion.cpp b/src/mathematics/Quaternion.cpp index 4ba3d8ea..fa4b532a 100755 --- a/src/mathematics/Quaternion.cpp +++ b/src/mathematics/Quaternion.cpp @@ -207,7 +207,7 @@ Quaternion Quaternion::slerp(const Quaternion& quaternion1, const Quaternion& qu // Because of precision, if cos(theta) is nearly 1, therefore theta is nearly 0 and we can write // sin((1-t)*theta) as (1-t) and sin(t*theta) as t - if(1-cosineTheta < EPSILON) { + if(1-cosineTheta < EPSILON_TEST) { return quaternion1 * (1.0-t) + quaternion2 * (t * invert); } diff --git a/src/mathematics/Vector3D.h b/src/mathematics/Vector3D.h index 546a626f..35253ac5 100644 --- a/src/mathematics/Vector3D.h +++ b/src/mathematics/Vector3D.h @@ -70,6 +70,9 @@ class Vector3D { Vector3D getOneOrthogonalVector() const; // Return one unit orthogonal vectors of the current vector double dot(const Vector3D& vector) const; // Dot product of two vectors Vector3D cross(const Vector3D& vector) const; // Cross product of two vectors + Vector3D getAbsoluteVector() const; // Return the corresponding absolute value vector + int getMinAxis() const; // Return the axis with the minimal value + int getMaxAxis() const; // Return the axis with the maximal value bool isParallelWith(const Vector3D& vector) const; // Return true if two vectors are parallel // --- Overloaded operators --- // @@ -162,12 +165,27 @@ inline Vector3D Vector3D::cross(const Vector3D& vector) const { return Vector3D(y * vector.z - z * vector.y, z * vector.x - x * vector.z , x * vector.y - y * vector.x); } +// Return the corresponding absolute value vector +inline Vector3D Vector3D::getAbsoluteVector() const { + return Vector3D(std::abs(x), std::abs(y), std::abs(z)); +} + // Return true if two vectors are parallel inline bool Vector3D::isParallelWith(const Vector3D& vector) const { double scalarProd = this->dot(vector); return approxEqual(std::abs(scalarProd), length() * vector.length()); } +// Return the axis with the minimal value +inline int Vector3D::getMinAxis() const { + return (x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2)); +} + +// Return the axis with the maximal value +inline int Vector3D::getMaxAxis() const { + return (x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0)); +} + // Return true if the vector is unit and false otherwise inline bool Vector3D::isUnit() const { return approxEqual(x*x+y*y+z*z, 1.0); diff --git a/src/mathematics/lcp/LCPProjectedGaussSeidel.h b/src/mathematics/lcp/LCPProjectedGaussSeidel.h index 8a0269dc..a46157ed 100644 --- a/src/mathematics/lcp/LCPProjectedGaussSeidel.h +++ b/src/mathematics/lcp/LCPProjectedGaussSeidel.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef LCPPROJECTEDGAUSSSEIDEL_H -#define LCPPROJECTEDGAUSSSEIDEL_H +#ifndef LCP_PROJECTED_GAUSS_SEIDEL_H +#define LCP_PROJECTED_GAUSS_SEIDEL_H // Libraries #include "LCPSolver.h" diff --git a/src/mathematics/lcp/LCPSolver.h b/src/mathematics/lcp/LCPSolver.h index 64c90d4c..7e3986c4 100644 --- a/src/mathematics/lcp/LCPSolver.h +++ b/src/mathematics/lcp/LCPSolver.h @@ -22,8 +22,8 @@ * THE SOFTWARE. * ********************************************************************************/ -#ifndef LCPSOLVER_H -#define LCPSOLVER_H +#ifndef LCP_SOLVER_H +#define LCP_SOLVER_H // Libraries #include diff --git a/src/mathematics/mathematics.h b/src/mathematics/mathematics.h index e6a40f02..5e16ebd0 100644 --- a/src/mathematics/mathematics.h +++ b/src/mathematics/mathematics.h @@ -148,7 +148,7 @@ inline reactphysics3d::Vector3D computeNonParallelSegmentsIntersection(const rea // If the two closest point aren't very close, there is no intersection between the segments reactphysics3d::Vector3D d = point2 - point1; - assert(d.length() <= EPSILON); + assert(d.length() <= EPSILON_TEST); // They are very close so we return the intersection point (halfway between "point1" and "point2" return 0.5 * (point1 + point2); diff --git a/src/mathematics/mathematics_functions.h b/src/mathematics/mathematics_functions.h index 7b8d77f5..3b71abfd 100644 --- a/src/mathematics/mathematics_functions.h +++ b/src/mathematics/mathematics_functions.h @@ -37,7 +37,7 @@ namespace reactphysics3d { // We test if two numbers a and b are such that (a-b) are in [-EPSILON; EPSILON] inline bool approxEqual(double a, double b) { double difference = a - b; - return (difference < EPSILON && difference > -EPSILON); + return (difference < EPSILON_TEST && difference > -EPSILON_TEST); } } // End of ReactPhysics3D namespace