소스 검색

Avoiding potential div by zero

Jorrit Rouwe 3 년 전
부모
커밋
faba3abbba
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      Jolt/Geometry/ClipPoly.h

+ 4 - 1
Jolt/Geometry/ClipPoly.h

@@ -34,7 +34,10 @@ void ClipPolyVsPlane(const VERTEX_ARRAY &inPolygonToClip, Vec3Arg inPlaneOrigin,
 			// Solve: (X - inPlaneOrigin) . inPlaneNormal = 0 and X = e1 + t * (e2 - e1) for X
 			Vec3 e12 = e2 - e1;
 			float denom = e12.Dot(inPlaneNormal);
-			outClippedPolygon.push_back(e1 + (prev_num / denom) * e12);
+			if (denom != 0.0f)
+				outClippedPolygon.push_back(e1 + (prev_num / denom) * e12);
+			else
+				cur_inside = prev_inside; // Edge is parallel to plane, treat point as if it were on the same side as the last point
 		}
 
 		// Point inside, add it