Skip to content

Commit

Permalink
Fixed a special case hole that allowed negative values to be reported…
Browse files Browse the repository at this point in the history
… for hits on cylinders.
  • Loading branch information
RossNordby committed Nov 16, 2024
1 parent f1103bb commit f4b086c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion BepuPhysics/Collidables/Cylinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public readonly bool RayTest(in RigidPose pose, Vector3 origin, Vector3 directio
else
{
//The ray is parallel to the axis; the impact is on a disc or nothing.
discY = d.Y > 0 ? -HalfLength : HalfLength;
//If the ray is inside the cylinder, we want t = 0, so just set the discY to match the ray's origin in that case and it'll shake out like we want.
discY = float.MinMagnitude(d.Y > 0 ? -HalfLength : HalfLength, o.Y);
}

//Intersect the ray with the plane anchored at discY with normal equal to (0,1,0).
Expand Down

0 comments on commit f4b086c

Please sign in to comment.