Change the testCollision() methods to return void instead of bool
This commit is contained in:
parent
32d9c0e1b8
commit
5c8320583d
|
@ -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) {
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user