Table of Contents

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 CollidableReference

Candidate 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 CollidableReference

Parent of the candidate.

childIndex int

Index 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 RayData

Information about the ray associated with this hit.

maximumT float

Maximum 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 float

Distance along the ray to the impact in units of ray direction length. In other words, hitLocation = ray.Origin + ray.Direction * t.

normal Vector3

Surface normal at the hit location.

collidable CollidableReference

Collidable hit by the ray.

childIndex int

Index 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.