intersectBody method
Shoot a ray at a body, get back information about the hit. @deprecated @param result set the result property of the Ray instead.
Implementation
void intersectBody(Body body, [RaycastResult? result]) {
if (result != null) {
this.result = result;
_updateDirection();
}
final checkCollisionResponse = this.checkCollisionResponse;
if (checkCollisionResponse && !body.collisionResponse) {
return;
}
if (
(collisionFilterGroup & body.collisionFilterMask) == 0 ||
(body.collisionFilterGroup & collisionFilterMask) == 0
) {
return;
}
final xi = _intersectBodyXi;
final qi = _intersectBodyQi;
for (int i = 0; i < body.shapes.length; i++) {
final shape = body.shapes[i];
if (checkCollisionResponse && !shape.collisionResponse) {
continue; // Skip
}
body.quaternion.mult(body.shapeOrientations[i], qi);
body.quaternion.vmult(body.shapeOffsets[i], xi);
xi.vadd(body.position, xi);
_intersectShape(shape, qi, xi, body);
if (this.result.shouldStop) {
break;
}
}
}