Interface IRayHitHandler
- Namespace
- BepuPhysics
- Assembly
- BepuPhysics.dll
Defines a type capable of filtering ray test candidates and handling ray hit results.
public interface IRayHitHandler
Methods
AllowTest(CollidableReference)
Checks whether a collidable identified by the acceleration structure should be tested against a ray.
bool AllowTest(CollidableReference collidable)
Parameters
collidable
CollidableReferenceCandidate collidable for ray testing.
Returns
- bool
True if the collidable should be tested by the ray, false otherwise.
AllowTest(CollidableReference, int)
Checks whether the child of a collidable should be tested against a ray. Only called by shape types that can have more than one child.
bool AllowTest(CollidableReference collidable, int childIndex)
Parameters
collidable
CollidableReferenceParent of the candidate.
childIndex
intIndex of the candidate child in its parent collidable.
For compounds, this is the index of the child in the child array. For meshes, this is the triangle index. For convex shapes or other types that don't have multiple children, this is always zero.
Returns
- bool
True if the child should be tested by the ray, false otherwise.
OnRayHit(in RayData, ref float, float, Vector3, CollidableReference, int)
Called when a ray impact has been found.
void OnRayHit(in RayData ray, ref float maximumT, float t, Vector3 normal, CollidableReference collidable, int childIndex)
Parameters
ray
RayDataInformation about the ray associated with this hit.
maximumT
floatMaximum distance along the ray that the traversal is allowed to go in units of ray direction length. Can be set to limit future tests.
t
floatDistance along the ray to the impact in units of ray direction length. In other words, hitLocation = ray.Origin + ray.Direction * t.
normal
Vector3Surface normal at the hit location.
collidable
CollidableReferenceCollidable hit by the ray.
childIndex
intIndex of the hit child in its parent collidable.
For compounds, this is the index of the child in the child array. For meshes, this is the triangle index. For convex shapes or other types that don't have multiple children, this is always zero.