Skip to content

PhysicsWorld.ShapeCastAll Method

Definition

Namespace: Brine2D.Physics

Overloads
ShapeCastAll(Vector2, float, float, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(Vector2, float, float, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, float, float, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(Vector2, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, Vector2, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(Vector2, Vector2, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, Vector2, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(ReadOnlySpan<Vector2>, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(ReadOnlySpan<Vector2>, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins). Vertices are in world space at the start of the sweep.
ShapeCastAll(ReadOnlySpan<Vector2>, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins). Vertices are in world space at the start of the sweep.

PhysicsWorld.ShapeCastAll(Vector2, float, float, float, Vector2, float, List\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps an oriented box along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.

public void ShapeCastAll(System.Numerics.Vector2 origin, float halfWidth, float halfHeight, float angle, System.Numerics.Vector2 direction, float maxDistance, System.Collections.Generic.List<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

origin System.Numerics.Vector2

halfWidth System.Single

halfHeight System.Single

angle System.Single

direction System.Numerics.Vector2

maxDistance System.Single

results System.Collections.Generic.List<ShapeCastHit>

filter System.Nullable<PhysicsQueryFilter>

PhysicsWorld.ShapeCastAll(Vector2, float, float, float, Vector2, float, Span\<ShapeCastHit>, bool, Nullable\<PhysicsQueryFilter>) Method

Sweeps an oriented box along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).

public int ShapeCastAll(System.Numerics.Vector2 origin, float halfWidth, float halfHeight, float angle, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, out bool wasTruncated, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

origin System.Numerics.Vector2

Center of the box at the start of the sweep in pixel coordinates.

halfWidth System.Single

Half-width of the box in pixels.

halfHeight System.Single

Half-height of the box in pixels.

angle System.Single

Rotation of the box in radians.

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, sorted nearest-first.

wasTruncated System.Boolean

Set to true when the internal 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.

PhysicsWorld.ShapeCastAll(Vector2, float, float, float, Vector2, float, Span\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps an oriented box along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).

public int ShapeCastAll(System.Numerics.Vector2 origin, float halfWidth, float halfHeight, float angle, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

origin System.Numerics.Vector2

Center of the box at the start of the sweep in pixel coordinates.

halfWidth System.Single

Half-width of the box in pixels.

halfHeight System.Single

Half-height of the box in pixels.

angle System.Single

Rotation of the box in radians.

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, 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.

PhysicsWorld.ShapeCastAll(Vector2, float, Vector2, float, List\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps a circle along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.

public void ShapeCastAll(System.Numerics.Vector2 origin, float radius, System.Numerics.Vector2 direction, float maxDistance, System.Collections.Generic.List<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

origin System.Numerics.Vector2

radius System.Single

direction System.Numerics.Vector2

maxDistance System.Single

results System.Collections.Generic.List<ShapeCastHit>

filter System.Nullable<PhysicsQueryFilter>

PhysicsWorld.ShapeCastAll(Vector2, float, Vector2, float, Span\<ShapeCastHit>, bool, Nullable\<PhysicsQueryFilter>) Method

Sweeps a circle along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).

public int ShapeCastAll(System.Numerics.Vector2 origin, float radius, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, out bool wasTruncated, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

origin System.Numerics.Vector2

Center of the circle at the start of the sweep in pixel coordinates.

radius System.Single

Circle radius in pixels.

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, sorted nearest-first.

wasTruncated System.Boolean

Set to true when the internal 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 are hit, collection stops early and wasTruncated is set to true. Provide a larger buffer to increase capacity.

PhysicsWorld.ShapeCastAll(Vector2, float, Vector2, float, Span\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps a circle along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).

public int ShapeCastAll(System.Numerics.Vector2 origin, float radius, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

origin System.Numerics.Vector2

Center of the circle at the start of the sweep in pixel coordinates.

radius System.Single

Circle radius in pixels.

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, 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 are hit, collection stops early and wasTruncated is set to true. Provide a larger buffer to increase capacity.

PhysicsWorld.ShapeCastAll(Vector2, Vector2, float, Vector2, float, List\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps a capsule along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.

public void ShapeCastAll(System.Numerics.Vector2 center1, System.Numerics.Vector2 center2, float radius, System.Numerics.Vector2 direction, float maxDistance, System.Collections.Generic.List<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

center1 System.Numerics.Vector2

center2 System.Numerics.Vector2

radius System.Single

direction System.Numerics.Vector2

maxDistance System.Single

results System.Collections.Generic.List<ShapeCastHit>

filter System.Nullable<PhysicsQueryFilter>

PhysicsWorld.ShapeCastAll(Vector2, Vector2, float, Vector2, float, Span\<ShapeCastHit>, bool, Nullable\<PhysicsQueryFilter>) Method

Sweeps a capsule along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).

public int ShapeCastAll(System.Numerics.Vector2 center1, System.Numerics.Vector2 center2, float radius, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, out bool wasTruncated, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

center1 System.Numerics.Vector2

First capsule center point at the start of the sweep in pixel coordinates.

center2 System.Numerics.Vector2

Second capsule center point at the start of the sweep in pixel coordinates.

radius System.Single

Capsule radius in pixels.

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, sorted nearest-first.

wasTruncated System.Boolean

Set to true when the internal 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.

PhysicsWorld.ShapeCastAll(Vector2, Vector2, float, Vector2, float, Span\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps a capsule along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).

public int ShapeCastAll(System.Numerics.Vector2 center1, System.Numerics.Vector2 center2, float radius, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

center1 System.Numerics.Vector2

First capsule center point at the start of the sweep in pixel coordinates.

center2 System.Numerics.Vector2

Second capsule center point at the start of the sweep in pixel coordinates.

radius System.Single

Capsule radius in pixels.

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, 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.

PhysicsWorld.ShapeCastAll(ReadOnlySpan\<Vector2>, Vector2, float, List\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps a convex polygon along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.

public void ShapeCastAll(System.ReadOnlySpan<System.Numerics.Vector2> vertices, System.Numerics.Vector2 direction, float maxDistance, System.Collections.Generic.List<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

vertices System.ReadOnlySpan<System.Numerics.Vector2>

direction System.Numerics.Vector2

maxDistance System.Single

results System.Collections.Generic.List<ShapeCastHit>

filter System.Nullable<PhysicsQueryFilter>

PhysicsWorld.ShapeCastAll(ReadOnlySpan\<Vector2>, Vector2, float, Span\<ShapeCastHit>, bool, Nullable\<PhysicsQueryFilter>) Method

Sweeps a convex polygon along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins). Vertices are in world space at the start of the sweep.

public int ShapeCastAll(System.ReadOnlySpan<System.Numerics.Vector2> vertices, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, out bool wasTruncated, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

vertices System.ReadOnlySpan<System.Numerics.Vector2>

Convex polygon vertices in world space (3–8 vertices).

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, sorted nearest-first.

wasTruncated System.Boolean

Set to true when the internal 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.

PhysicsWorld.ShapeCastAll(ReadOnlySpan\<Vector2>, Vector2, float, Span\<ShapeCastHit>, Nullable\<PhysicsQueryFilter>) Method

Sweeps a convex polygon along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins). Vertices are in world space at the start of the sweep.

public int ShapeCastAll(System.ReadOnlySpan<System.Numerics.Vector2> vertices, System.Numerics.Vector2 direction, float maxDistance, System.Span<Brine2D.Physics.ShapeCastHit> results, System.Nullable<Brine2D.Physics.PhysicsQueryFilter> filter=null);

Parameters

vertices System.ReadOnlySpan<System.Numerics.Vector2>

Convex polygon vertices in world space (3–8 vertices).

direction System.Numerics.Vector2

Sweep direction (does not need to be normalized). Must be non-zero.

maxDistance System.Single

Maximum sweep distance in pixels.

results System.Span<ShapeCastHit>

Buffer to receive hits, 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.