diff --git a/src/collision/narrowphase/ConcaveVsConvexAlgorithm.cpp b/src/collision/narrowphase/ConcaveVsConvexAlgorithm.cpp index f7efa16e..27c66daa 100644 --- a/src/collision/narrowphase/ConcaveVsConvexAlgorithm.cpp +++ b/src/collision/narrowphase/ConcaveVsConvexAlgorithm.cpp @@ -43,7 +43,7 @@ ConcaveVsConvexAlgorithm::~ConcaveVsConvexAlgorithm() { } // Return true and compute a contact info if the two bounding volumes collide -bool ConcaveVsConvexAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, +void ConcaveVsConvexAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback) { diff --git a/src/collision/narrowphase/ConcaveVsConvexAlgorithm.h b/src/collision/narrowphase/ConcaveVsConvexAlgorithm.h index fbbd41c0..68dceb2f 100644 --- a/src/collision/narrowphase/ConcaveVsConvexAlgorithm.h +++ b/src/collision/narrowphase/ConcaveVsConvexAlgorithm.h @@ -129,8 +129,8 @@ class ConcaveVsConvexAlgorithm : public NarrowPhaseAlgorithm { /// Destructor virtual ~ConcaveVsConvexAlgorithm(); - /// Return true and compute a contact info if the two bounding volume collide - virtual bool testCollision(const CollisionShapeInfo& shape1Info, + /// Compute a contact info if the two bounding volume collide + virtual void testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback); }; diff --git a/src/collision/narrowphase/EPA/EPAAlgorithm.cpp b/src/collision/narrowphase/EPA/EPAAlgorithm.cpp index 213169d8..be05ac95 100644 --- a/src/collision/narrowphase/EPA/EPAAlgorithm.cpp +++ b/src/collision/narrowphase/EPA/EPAAlgorithm.cpp @@ -81,7 +81,7 @@ int EPAAlgorithm::isOriginInTetrahedron(const Vector3& p1, const Vector3& p2, /// intersect. An initial simplex that contains origin has been computed with /// GJK algorithm. The EPA Algorithm will extend this simplex polytope to find /// the correct penetration depth -bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simplex, +void EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simplex, CollisionShapeInfo shape1Info, const Transform& transform1, CollisionShapeInfo shape2Info, @@ -134,7 +134,7 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple // Only one point in the simplex (which should be the origin). // We have a touching contact with zero penetration depth. // We drop that kind of contact. Therefore, we return false - return false; + return; case 2: { // The simplex returned by GJK is a line segment d containing the origin. @@ -201,7 +201,7 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple } else { // The origin is not in the initial polytope - return false; + return; } // The polytope contains now 4 vertices @@ -231,7 +231,7 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple if (!((face0 != NULL) && (face1 != NULL) && (face2 != NULL) && (face3 != NULL) && face0->getDistSquare() > 0.0 && face1->getDistSquare() > 0.0 && face2->getDistSquare() > 0.0 && face3->getDistSquare() > 0.0)) { - return false; + return; } // Associate the edges of neighbouring triangle faces @@ -316,14 +316,14 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple face3 = triangleStore.newTriangle(points, 1, 4, 2); } else { - return false; + return; } // If the constructed tetrahedron is not correct if (!((face0 != NULL) && (face1 != NULL) && (face2 != NULL) && (face3 != NULL) && face0->getDistSquare() > 0.0 && face1->getDistSquare() > 0.0 && face2->getDistSquare() > 0.0 && face3->getDistSquare() > 0.0)) { - return false; + return; } // Associate the edges of neighbouring triangle faces @@ -350,7 +350,7 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple // can run the EPA algorithm. if (nbTriangles == 0) { - return false; + return; } TriangleEPA* triangle = 0; @@ -432,5 +432,5 @@ bool EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple narrowPhaseCallback->notifyContact(shape1Info.overlappingPair, contactInfo); - return true; + return; } diff --git a/src/collision/narrowphase/EPA/EPAAlgorithm.h b/src/collision/narrowphase/EPA/EPAAlgorithm.h index d0b8dfa4..a98e0a67 100644 --- a/src/collision/narrowphase/EPA/EPAAlgorithm.h +++ b/src/collision/narrowphase/EPA/EPAAlgorithm.h @@ -123,7 +123,7 @@ class EPAAlgorithm { void init(MemoryAllocator* memoryAllocator); /// Compute the penetration depth with EPA algorithm. - bool computePenetrationDepthAndContactPoints(const Simplex& simplex, + void computePenetrationDepthAndContactPoints(const Simplex& simplex, CollisionShapeInfo shape1Info, const Transform& transform1, CollisionShapeInfo shape2Info, diff --git a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp index caa574a4..35587c93 100644 --- a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp +++ b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp @@ -46,17 +46,16 @@ GJKAlgorithm::~GJKAlgorithm() { } -// Return true and compute a contact info if the two collision shapes collide. +// Compute a contact info if the two collision shapes collide. /// This method implements the Hybrid Technique for computing the penetration depth by -/// running the GJK algorithm on original objects (without margin). -/// If the objects don't intersect, this method returns false. If they intersect +/// running the GJK algorithm on original objects (without margin). If the shapes intersect /// only in the margins, the method compute the penetration depth and contact points /// (of enlarged objects). If the original objects (without margin) intersect, we /// call the computePenetrationDepthForEnlargedObjects() method that run the GJK /// algorithm on the enlarged object to obtain a simplex polytope that contains the /// origin, they we give that simplex polytope to the EPA algorithm which will compute /// the correct penetration depth and contact points between the enlarged objects. -bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, +void GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback) { @@ -122,8 +121,8 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, // Cache the current separating axis for frame coherence mCurrentOverlappingPair->setCachedSeparatingAxis(v); - // No intersection, we return false - return false; + // No intersection, we return + return; } // If the objects intersect only in the margins @@ -144,7 +143,7 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, decimal penetrationDepth = margin - dist; // Reject the contact if the penetration depth is negative (due too numerical errors) - if (penetrationDepth <= 0.0) return false; + if (penetrationDepth <= 0.0) return; // Create the contact info object ContactPointInfo contactInfo(shape1Info.proxyShape, shape2Info.proxyShape, @@ -152,8 +151,8 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, narrowPhaseCallback->notifyContact(shape1Info.overlappingPair, contactInfo); - // There is an intersection, therefore we return true - return true; + // There is an intersection, therefore we return + return; } // Add the new support point to the simplex @@ -177,7 +176,7 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, decimal penetrationDepth = margin - dist; // Reject the contact if the penetration depth is negative (due too numerical errors) - if (penetrationDepth <= 0.0) return false; + if (penetrationDepth <= 0.0) return; // Create the contact info object ContactPointInfo contactInfo(shape1Info.proxyShape, shape2Info.proxyShape, @@ -185,8 +184,8 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, narrowPhaseCallback->notifyContact(shape1Info.overlappingPair, contactInfo); - // There is an intersection, therefore we return true - return true; + // There is an intersection, therefore we return + return; } // Compute the point of the simplex closest to the origin @@ -208,7 +207,7 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, decimal penetrationDepth = margin - dist; // Reject the contact if the penetration depth is negative (due too numerical errors) - if (penetrationDepth <= 0.0) return false; + if (penetrationDepth <= 0.0) return; // Create the contact info object ContactPointInfo contactInfo(shape1Info.proxyShape, shape2Info.proxyShape, @@ -216,8 +215,8 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, narrowPhaseCallback->notifyContact(shape1Info.overlappingPair, contactInfo); - // There is an intersection, therefore we return true - return true; + // There is an intersection, therefore we return + return; } // Store and update the squared distance of the closest point @@ -246,7 +245,7 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, decimal penetrationDepth = margin - dist; // Reject the contact if the penetration depth is negative (due too numerical errors) - if (penetrationDepth <= 0.0) return false; + if (penetrationDepth <= 0.0) return; // Create the contact info object ContactPointInfo contactInfo(shape1Info.proxyShape, shape2Info.proxyShape, @@ -254,8 +253,8 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, narrowPhaseCallback->notifyContact(shape1Info.overlappingPair, contactInfo); - // There is an intersection, therefore we return true - return true; + // There is an intersection, therefore we return + return; } } while(!simplex.isFull() && distSquare > MACHINE_EPSILON * simplex.getMaxLengthSquareOfAPoint()); @@ -273,7 +272,7 @@ bool GJKAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, /// assumed to intersect in the original objects (without margin). Therefore such /// a polytope must exist. Then, we give that polytope to the EPA algorithm to /// compute the correct penetration depth and contact points of the enlarged objects. -bool GJKAlgorithm::computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info, +void GJKAlgorithm::computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info, const Transform& transform1, const CollisionShapeInfo& shape2Info, const Transform& transform2, @@ -317,19 +316,19 @@ bool GJKAlgorithm::computePenetrationDepthForEnlargedObjects(const CollisionShap // If the enlarge objects do not intersect if (vDotw > 0.0) { - // No intersection, we return false - return false; + // No intersection, we return + return; } // Add the new support point to the simplex simplex.addPoint(w, suppA, suppB); if (simplex.isAffinelyDependent()) { - return false; + return; } if (!simplex.computeClosestPoint(v)) { - return false; + return; } // Store and update the square distance @@ -337,7 +336,7 @@ bool GJKAlgorithm::computePenetrationDepthForEnlargedObjects(const CollisionShap distSquare = v.lengthSquare(); if (prevDistSquare - distSquare <= MACHINE_EPSILON * prevDistSquare) { - return false; + return; } } while(!simplex.isFull() && distSquare > MACHINE_EPSILON * diff --git a/src/collision/narrowphase/GJK/GJKAlgorithm.h b/src/collision/narrowphase/GJK/GJKAlgorithm.h index 2c3c5641..2161a4dd 100644 --- a/src/collision/narrowphase/GJK/GJKAlgorithm.h +++ b/src/collision/narrowphase/GJK/GJKAlgorithm.h @@ -75,7 +75,7 @@ class GJKAlgorithm : public NarrowPhaseAlgorithm { GJKAlgorithm& operator=(const GJKAlgorithm& algorithm); /// Compute the penetration depth for enlarged objects. - bool computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info, + void computePenetrationDepthForEnlargedObjects(const CollisionShapeInfo& shape1Info, const Transform& transform1, const CollisionShapeInfo& shape2Info, const Transform& transform2, @@ -96,8 +96,8 @@ class GJKAlgorithm : public NarrowPhaseAlgorithm { virtual void init(CollisionDetection* collisionDetection, MemoryAllocator* memoryAllocator); - /// Return true and compute a contact info if the two bounding volumes collide. - virtual bool testCollision(const CollisionShapeInfo& shape1Info, + /// Compute a contact info if the two bounding volumes collide. + virtual void testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback); diff --git a/src/collision/narrowphase/NarrowPhaseAlgorithm.h b/src/collision/narrowphase/NarrowPhaseAlgorithm.h index 41ecc00c..5bc19086 100644 --- a/src/collision/narrowphase/NarrowPhaseAlgorithm.h +++ b/src/collision/narrowphase/NarrowPhaseAlgorithm.h @@ -98,8 +98,8 @@ class NarrowPhaseAlgorithm { /// Set the current overlapping pair of bodies void setCurrentOverlappingPair(OverlappingPair* overlappingPair); - /// Return true and compute a contact info if the two bounding volume collide - virtual bool testCollision(const CollisionShapeInfo& shape1Info, + /// Compute a contact info if the two bounding volume collide + virtual void testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback)=0; }; diff --git a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp index c58048b0..5ed530a8 100644 --- a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp @@ -40,7 +40,7 @@ SphereVsSphereAlgorithm::~SphereVsSphereAlgorithm() { } -bool SphereVsSphereAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, +void SphereVsSphereAlgorithm::testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback) { @@ -76,9 +76,7 @@ bool SphereVsSphereAlgorithm::testCollision(const CollisionShapeInfo& shape1Info // Notify about the new contact narrowPhaseCallback->notifyContact(shape1Info.overlappingPair, contactInfo); - - return true; } - return false; + return; } diff --git a/src/collision/narrowphase/SphereVsSphereAlgorithm.h b/src/collision/narrowphase/SphereVsSphereAlgorithm.h index f0bf69a2..9e986706 100644 --- a/src/collision/narrowphase/SphereVsSphereAlgorithm.h +++ b/src/collision/narrowphase/SphereVsSphereAlgorithm.h @@ -62,8 +62,8 @@ class SphereVsSphereAlgorithm : public NarrowPhaseAlgorithm { /// Destructor virtual ~SphereVsSphereAlgorithm(); - /// Return true and compute a contact info if the two bounding volume collide - virtual bool testCollision(const CollisionShapeInfo& shape1Info, + /// Compute a contact info if the two bounding volume collide + virtual void testCollision(const CollisionShapeInfo& shape1Info, const CollisionShapeInfo& shape2Info, NarrowPhaseCallback* narrowPhaseCallback); };