Browse Source

Tautology in GetPenetrationDepthStepEPA (#760)

* The function ConvexHullBuilder::AddPoint calls ConvexHullBuilder::FindEdge, which sets inFacingFace->mRemoved = true. Thus, the condition if (t->mRemoved) in GetPenetrationDepthStepEPA is always true.
* Fixed a "misleading" comment in TriangleQueue::PopClosest: Given sTriangleSorter, the function pop_heap moves the closest point to the end, not the largest one.
Felix Büttner 1 year ago
parent
commit
affe4fcc83
2 changed files with 4 additions and 4 deletions
  1. 1 1
      Jolt/Geometry/EPAConvexHullBuilder.h
  2. 3 3
      Jolt/Geometry/EPAPenetrationDepth.h

+ 1 - 1
Jolt/Geometry/EPAConvexHullBuilder.h

@@ -209,7 +209,7 @@ public:
 		/// Get next closest triangle
 		/// Get next closest triangle
 		Triangle *		PopClosest()
 		Triangle *		PopClosest()
 		{
 		{
-			// Move largest to end
+			// Move closest to end
 			std::pop_heap(begin(), end(), sTriangleSorter);
 			std::pop_heap(begin(), end(), sTriangleSorter);
 
 
 			// Remove last triangle
 			// Remove last triangle

+ 3 - 3
Jolt/Geometry/EPAPenetrationDepth.h

@@ -284,9 +284,9 @@ public:
 			if (!t->IsFacing(w) || !hull.AddPoint(t, new_index, FLT_MAX, new_triangles))
 			if (!t->IsFacing(w) || !hull.AddPoint(t, new_index, FLT_MAX, new_triangles))
 				return false;
 				return false;
 
 
-			// If the triangle was removed we can free it now
-			if (t->mRemoved)
-				hull.FreeTriangle(t);
+			// The triangle is facing the support point "w" and can now be safely removed
+			JPH_ASSERT(t->mRemoved);
+			hull.FreeTriangle(t);
 
 
 			// If we run out of triangles or points, we couldn't include the origin in the hull so there must be very little penetration and we report no collision.
 			// If we run out of triangles or points, we couldn't include the origin in the hull so there must be very little penetration and we report no collision.
 			if (!hull.HasNextTriangle() || support_points.mY.size() >= cMaxPointsToIncludeOriginInHull)
 			if (!hull.HasNextTriangle() || support_points.mY.size() >= cMaxPointsToIncludeOriginInHull)