PhysicsWorld.RaycastAll Method
Definition¶
Namespace: Brine2D.Physics
| Overloads | |
|---|---|
| RaycastAll(Vector2, Vector2, float, List<RaycastHit>, Nullable<PhysicsQueryFilter>) | Casts a ray and returns all hits (deduplicated by body, sorted nearest-first) into results. Unlike the System.Span<> overloads, this variant retries with a larger internal buffer if needed and is guaranteed to return every hit. Clears results before writing. |
| RaycastAll(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) | Casts a ray and returns all hits sorted by distance, deduplicated by body (one entry per body), written into the caller-provided buffer. Use RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) when you need per-shape granularity on compound bodies. |
| RaycastAll(Vector2, Vector2, float, Span<RaycastHit>, Nullable<PhysicsQueryFilter>) | Casts a ray and returns all hits sorted by distance, deduplicated by body (one entry per body), written into the caller-provided buffer. Use RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) when you need per-shape granularity on compound bodies. |
PhysicsWorld.RaycastAll(Vector2, Vector2, float, List\<RaycastHit>, Nullable\<PhysicsQueryFilter>) Method¶
Casts a ray and returns all hits (deduplicated by body, sorted nearest-first) into results. Unlike the System.Span<> overloads, this variant retries with a larger internal buffer if needed and is guaranteed to return every hit. Clears results before writing.
public void RaycastAll(System.Numerics.Vector2 origin, System.Numerics.Vector2 direction, float maxDistance, System.Collections.Generic.List<Brine2D.Physics.RaycastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);
Parameters¶
origin System.Numerics.Vector2
direction System.Numerics.Vector2
maxDistance System.Single
results System.Collections.Generic.List<RaycastHit>
filter System.Nullable<PhysicsQueryFilter>
PhysicsWorld.RaycastAll(Vector2, Vector2, float, Span\<RaycastHit>, bool, Nullable\<PhysicsQueryFilter>) Method¶
Casts a ray and returns all hits sorted by distance, deduplicated by body (one entry per body), written into the caller-provided buffer. Use RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) when you need per-shape granularity on compound bodies.
public int RaycastAll(System.Numerics.Vector2 origin, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.RaycastHit> results, out bool wasTruncated, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);
Parameters¶
origin System.Numerics.Vector2
Ray start in pixel coordinates.
direction System.Numerics.Vector2
Ray direction (does not need to be normalized). Must be non-zero.
maxDistance System.Single
Maximum ray length in pixels.
results System.Span<RaycastHit>
Buffer to receive hits. One entry per body, sorted nearest-first.
wasTruncated System.Boolean
Set to true when the internal collection buffer was too small.
filter System.Nullable<PhysicsQueryFilter>
Optional query filter.
Returns¶
System.Int32
Number of hits written to results.
Exceptions¶
System.ArgumentException
Thrown when direction is zero.
Remarks¶
The internal collection buffer is sized to results.Length * 8. If more shapes than
that overlap the ray, collection stops early and wasTruncated is set to
true. Provide a larger buffer to increase capacity.
PhysicsWorld.RaycastAll(Vector2, Vector2, float, Span\<RaycastHit>, Nullable\<PhysicsQueryFilter>) Method¶
Casts a ray and returns all hits sorted by distance, deduplicated by body (one entry per body), written into the caller-provided buffer. Use RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) when you need per-shape granularity on compound bodies.
public int RaycastAll(System.Numerics.Vector2 origin, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.RaycastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);
Parameters¶
origin System.Numerics.Vector2
Ray start in pixel coordinates.
direction System.Numerics.Vector2
Ray direction (does not need to be normalized). Must be non-zero.
maxDistance System.Single
Maximum ray length in pixels.
results System.Span<RaycastHit>
Buffer to receive hits. One entry per body, sorted nearest-first.
filter System.Nullable<PhysicsQueryFilter>
Optional query filter.
Returns¶
System.Int32
Number of hits written to results.
Exceptions¶
System.ArgumentException
Thrown when direction is zero.
Remarks¶
The internal collection buffer is sized to results.Length * 8. If more shapes than
that overlap the ray, collection stops early and wasTruncated is set to
true. Provide a larger buffer to increase capacity.