Fixed a false positive in sphere vs polyhedron

This commit is contained in:
Diren D Bharwani 2023-01-12 15:58:01 +08:00
parent ec945693aa
commit 6663156405
1 changed files with 8 additions and 1 deletions

View File

@ -325,8 +325,15 @@ namespace SHADE
// Check Region C
// Face to vertex is in the opposite direction of any tangent.
const float PROJECTION = SHVec3::Dot(FACE_TO_CENTER, tangent1);
if (PROJECTION < 0)
if (PROJECTION < 0.0f)
{
const float DISTANCE_SQUARED = SHVec3::DistanceSquared(faceVertex, CENTER);
if (DISTANCE_SQUARED > RADIUS * RADIUS)
return 0;
return 3;
}
// Belongs in region D by default
return 4;