Переглянути джерело

Added new error code that triggers when hull building failed due to precision problems.

Jorrit Rouwe 3 роки тому
батько
коміт
46d123f7ff

+ 7 - 0
Jolt/Geometry/ConvexHullBuilder.cpp

@@ -606,6 +606,13 @@ ConvexHullBuilder::EResult ConvexHullBuilder::Initialize(int inMaxVertices, floa
 #endif
 	}
 
+	// Check if we are left with a hull. It is possible that hull building fails if the points are nearly coplanar.
+	if (mFaces.size() < 2)
+	{
+		outError = "Too few faces in hull";
+		return EResult::TooFewFaces;
+	}
+
 	return EResult::Success;
 }
 

+ 1 - 0
Jolt/Geometry/ConvexHullBuilder.h

@@ -97,6 +97,7 @@ public:
 		Success,											///< Hull building finished successfully
 		MaxVerticesReached,									///< Hull building finished successfully, but the desired accuracy was not reached because the max vertices limit was reached
 		TooFewPoints,										///< Too few points to create a hull
+		TooFewFaces,										///< Too few faces in the created hull (signifies precision errors during building)
 		Degenerate,											///< Degenerate hull detected
 	};