Table of Contents

Class SimulationExtensions

Namespace
Stride.CommunityToolkit.Bullet
Assembly
Stride.CommunityToolkit.Bullet.dll

Provides extension methods for the Simulation class to perform raycasting operations in a game simulation fro the Bullet physics.

public static class SimulationExtensions
Inheritance
SimulationExtensions

Methods

Raycast(Simulation, RaySegment)

Raycasts and stops at the first hit.

public static HitResult Raycast(this Simulation simulation, RaySegment raySegment)

Parameters

simulation Simulation

Physics simulation.

raySegment RaySegment

Ray.

Returns

HitResult

The hit results.

Exceptions

ArgumentNullException

If the simulation argument is null.

Raycast(Simulation, RaySegment, CollisionFilterGroups, CollisionFilterGroupFlags)

Raycasts and stops at the first hit.

public static HitResult Raycast(this Simulation simulation, RaySegment raySegment, CollisionFilterGroups collisionFilterGroups, CollisionFilterGroupFlags collisionFilterGroupFlags)

Parameters

simulation Simulation

Physics simulation.

raySegment RaySegment

Ray.

collisionFilterGroups CollisionFilterGroups

The collision group of this shape sweep

collisionFilterGroupFlags CollisionFilterGroupFlags

The collision group that this shape sweep can collide with

Returns

HitResult

The hit results.

Exceptions

ArgumentNullException

If the simulation argument is null.

Raycast(Simulation, Entity, Vector3, float, CollisionFilterGroupFlags, EFlags)

Performs a raycast from the given entity's position in the specified direction, with the specified length.

public static HitResult Raycast(this Simulation simulation, Entity entityPosition, Vector3 direction, float length = 1, CollisionFilterGroupFlags collisionFlags = CollisionFilterGroupFlags.AllFilter, EFlags eFlags = EFlags.None)

Parameters

simulation Simulation

The Simulation instance in which the raycast is performed.

entityPosition Entity

The Entity from which the ray starts. The ray is cast from the entity's current world position.

direction Vector3

The direction in which the ray is cast.

length float

The length of the ray, which determines how far it should extend from the entity. Defaults to 1.

collisionFlags CollisionFilterGroupFlags

Specifies which collision groups to include in the raycast. Defaults to AllFilter.

eFlags EFlags

Additional raycasting flags for fine-tuning the behavior. Defaults to None.

Returns

HitResult

A HitResult that contains information about the first object hit by the ray, or an empty result if nothing is hit.

Raycast(Simulation, Entity, float, CollisionFilterGroupFlags, EFlags)

Performs a raycast from the given entity's position in the direction the entity is facing, with the specified length.

public static HitResult Raycast(this Simulation simulation, Entity entityPosition, float length = 1, CollisionFilterGroupFlags collisionFlags = CollisionFilterGroupFlags.AllFilter, EFlags eFlags = EFlags.None)

Parameters

simulation Simulation

The Simulation instance in which the raycast is performed.

entityPosition Entity

The Entity from which the ray starts. The ray is cast from the entity's current world position and direction.

length float

The length of the ray, which determines how far it should extend from the entity. Defaults to 1.

collisionFlags CollisionFilterGroupFlags

Specifies which collision groups to include in the raycast. Defaults to AllFilter.

eFlags EFlags

Additional raycasting flags for fine-tuning the behavior. Defaults to None.

Returns

HitResult

A HitResult that contains information about the first object hit by the ray, or an empty result if nothing is hit.

Remarks

Ensure that you are using the actual rotating entity, as debugging with the wrong entity can lead to unexpected results.

RaycastPenetrating(Simulation, RaySegment)

Raycasts penetrating any shape the ray encounters.

public static List<HitResult> RaycastPenetrating(this Simulation simulation, RaySegment raySegment)

Parameters

simulation Simulation

Physics simulation.

raySegment RaySegment

Ray.

Returns

List<HitResult>

The list with hit results.

Exceptions

ArgumentNullException

If the simulation argument is null.

RaycastPenetrating(Simulation, RaySegment, CollisionFilterGroups, CollisionFilterGroupFlags)

Raycasts penetrating any shape the ray encounters.

public static List<HitResult> RaycastPenetrating(this Simulation simulation, RaySegment raySegment, CollisionFilterGroups collisionFilterGroups, CollisionFilterGroupFlags collisionFilterGroupFlags)

Parameters

simulation Simulation

Physics simulation.

raySegment RaySegment

Ray.

collisionFilterGroups CollisionFilterGroups

The collision group of this shape sweep

collisionFilterGroupFlags CollisionFilterGroupFlags

The collision group that this shape sweep can collide with

Returns

List<HitResult>

The list with hit results.

Exceptions

ArgumentNullException

If the simulation argument is null.

RaycastPenetrating(Simulation, RaySegment, IList<HitResult>)

Raycasts penetrating any shape the ray encounters.

public static void RaycastPenetrating(this Simulation simulation, RaySegment raySegment, IList<HitResult> resultsOutput)

Parameters

simulation Simulation

Physics simulation.

raySegment RaySegment

Ray.

resultsOutput IList<HitResult>

The list to fill with results.

Exceptions

ArgumentNullException

If the simulation argument is null.

RaycastPenetrating(Simulation, RaySegment, IList<HitResult>, CollisionFilterGroups, CollisionFilterGroupFlags)

Raycasts penetrating any shape the ray encounters. Filtering by CollisionGroup

public static void RaycastPenetrating(this Simulation simulation, RaySegment raySegment, IList<HitResult> resultsOutput, CollisionFilterGroups collisionFilterGroups, CollisionFilterGroupFlags collisionFilterGroupFlags)

Parameters

simulation Simulation

Physics simulation.

raySegment RaySegment

Ray.

resultsOutput IList<HitResult>

The list to fill with results.

collisionFilterGroups CollisionFilterGroups

The collision group of this shape sweep

collisionFilterGroupFlags CollisionFilterGroupFlags

The collision group that this shape sweep can collide with

Exceptions

ArgumentNullException

If the simulation argument is null.