castRay method
void
castRay(
- Vector2 origin,
- Vector2 translation,
- double callback(
- RayHit hit
- QueryFilter? filter,
Casts a ray from origin along translation, invoking callback for
every candidate hit in an arbitrary order.
The callback controls the rest of the cast with its return value: -1 to ignore the hit, 0 to stop, the hit's fraction to clip the ray to the hit, or 1 to continue looking without clipping.
Implementation
void castRay(
Vector2 origin,
Vector2 translation,
double Function(RayHit hit) callback, {
QueryFilter? filter,
}) {
final queryFilter = filter ?? QueryFilter();
rawBox2D.worldCastRay(
id,
origin.x,
origin.y,
translation.x,
translation.y,
queryFilter.categoryBits,
queryFilter.maskBits,
(hit) => callback(_rayHit(hit)),
);
}