Skip to content

PhysicsWorld.ShapeCastClosest Method

Definition

Namespace: Brine2D.Physics

Overloads
ShapeCastClosest(Vector2, float, float, float, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns the closest hit.
ShapeCastClosest(Vector2, float, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns the closest hit.
ShapeCastClosest(Vector2, Vector2, float, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns the closest hit.
ShapeCastClosest(ReadOnlySpan<Vector2>, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns the closest hit. Vertices are in world space at the start of the sweep.

PhysicsWorld.ShapeCastClosest(Vector2, float, float, float, Vector2, float, Nullable\<PhysicsQueryFilter>) Method

Sweeps an oriented box along a direction and returns the closest hit.

public System.Nullable<Brine2D.Physics.ShapeCastHit> ShapeCastClosest(System.Numerics.Vector2 origin, float halfWidth, float halfHeight, float angle, System.Numerics.Vector2 direction, float maxDistance, 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.

filter System.Nullable<PhysicsQueryFilter>

Optional query filter.

Returns

System.Nullable<ShapeCastHit>

Exceptions

System.ArgumentException
Thrown when direction is zero.

Remarks

When ExcludeSensors is true, this method collects all hits via callback and returns the nearest non-sensor, which is more expensive than the default single-closest path. Prefer leaving ExcludeSensors unset and filtering results manually in performance-critical code.

PhysicsWorld.ShapeCastClosest(Vector2, float, Vector2, float, Nullable\<PhysicsQueryFilter>) Method

Sweeps a circle along a direction and returns the closest hit.

public System.Nullable<Brine2D.Physics.ShapeCastHit> ShapeCastClosest(System.Numerics.Vector2 origin, float radius, System.Numerics.Vector2 direction, float maxDistance, 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.

filter System.Nullable<PhysicsQueryFilter>

Optional query filter.

Returns

System.Nullable<ShapeCastHit>

Exceptions

System.ArgumentException
Thrown when direction is zero.

PhysicsWorld.ShapeCastClosest(Vector2, Vector2, float, Vector2, float, Nullable\<PhysicsQueryFilter>) Method

Sweeps a capsule along a direction and returns the closest hit.

public System.Nullable<Brine2D.Physics.ShapeCastHit> ShapeCastClosest(System.Numerics.Vector2 center1, System.Numerics.Vector2 center2, float radius, System.Numerics.Vector2 direction, float maxDistance, 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. Must be greater than zero.

direction System.Numerics.Vector2

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

maxDistance System.Single

Maximum sweep distance in pixels.

filter System.Nullable<PhysicsQueryFilter>

Optional query filter.

Returns

System.Nullable<ShapeCastHit>

Exceptions

System.ArgumentException
Thrown when direction is zero.

Remarks

When ExcludeSensors is true, this method collects all hits via callback and returns the nearest non-sensor, which is more expensive than the default single-closest path. Prefer leaving ExcludeSensors unset and filtering results manually in performance-critical code.

PhysicsWorld.ShapeCastClosest(ReadOnlySpan\<Vector2>, Vector2, float, Nullable\<PhysicsQueryFilter>) Method

Sweeps a convex polygon along a direction and returns the closest hit. Vertices are in world space at the start of the sweep.

public System.Nullable<Brine2D.Physics.ShapeCastHit> ShapeCastClosest(System.ReadOnlySpan<System.Numerics.Vector2> vertices, System.Numerics.Vector2 direction, float maxDistance, 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.

filter System.Nullable<PhysicsQueryFilter>

Optional query filter.

Returns

System.Nullable<ShapeCastHit>

Exceptions

System.ArgumentException
Thrown when direction is zero.

Remarks

When ExcludeSensors is true, this method collects all hits via callback and returns the nearest non-sensor, which is more expensive than the default single-closest path. Prefer leaving ExcludeSensors unset and filtering results manually in performance-critical code.