diff --git a/neo/cm/CollisionModel_translate.cpp b/neo/cm/CollisionModel_translate.cpp index 1c6982ba..7a55dfd1 100644 --- a/neo/cm/CollisionModel_translate.cpp +++ b/neo/cm/CollisionModel_translate.cpp @@ -319,7 +319,10 @@ void idCollisionModelManagerLocal::TranslateTrmEdgeThroughPolygon( cm_traceWork_ dist = normal * trmEdge->start; d1 = normal * start - dist; d2 = normal * end - dist; - f1 = d1 / ( d1 - d2 ); + float d1d2diff = d1 - d2; + // DG: d1 - d2 was 0 in some weird case, which caused f1 to be INF, + // which caused NaN mayhem all over the place + f1 = ( fabsf(d1d2diff) > idMath::FLT_EPSILON ) ? d1 / d1d2diff : 0.0f; //assert( f1 >= 0.0f && f1 <= 1.0f ); tw->trace.c.point = start + f1 * ( end - start ); // if retrieving contacts