raytrace abstract method

Iterable<RaycastResult<T>> raytrace(
  1. Ray2 ray, {
  2. int maxDepth = 10,
  3. bool hitboxFilter(
    1. T candidate
    )?,
  4. List<T>? ignoreHitboxes,
  5. List<RaycastResult<T>>? out,
})

Follows the ray and its reflections until maxDepth is reached and then returns all hitboxes, intersection points, normals and reflection rays (bundled in a list of RaycastResults) from where the ray hits.

maxDepth is how many times the ray should collide before returning a result, defaults to 10.

You can provide a hitboxFilter callback to define which hitboxes to consider and which to ignore. This callback will be called with every prospective hitbox, and only if the callback returns true will the hitbox be considered. Otherwise, the ray will go straight through it. One common use case is ignoring the component that is shooting the ray.

If you have a list of hitboxes to ignore in advance, you can provide them via the ignoreHitboxes argument.

If out is provided the RaycastResults in that list be modified and returned with the result. If there are less objects in out than the result requires, the missing RaycastResult objects will be created.

Implementation

Iterable<RaycastResult<T>> raytrace(
  Ray2 ray, {
  int maxDepth = 10,
  bool Function(T candidate)? hitboxFilter,
  List<T>? ignoreHitboxes,
  List<RaycastResult<T>>? out,
});