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
SimulationPhysics simulation.
raySegment
RaySegmentRay.
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
SimulationPhysics simulation.
raySegment
RaySegmentRay.
collisionFilterGroups
CollisionFilterGroupsThe collision group of this shape sweep
collisionFilterGroupFlags
CollisionFilterGroupFlagsThe 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
SimulationThe Simulation instance in which the raycast is performed.
entityPosition
EntityThe Entity from which the ray starts. The ray is cast from the entity's current world position.
direction
Vector3The direction in which the ray is cast.
length
floatThe length of the ray, which determines how far it should extend from the entity. Defaults to 1.
collisionFlags
CollisionFilterGroupFlagsSpecifies which collision groups to include in the raycast. Defaults to AllFilter.
eFlags
EFlagsAdditional 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
SimulationThe Simulation instance in which the raycast is performed.
entityPosition
EntityThe Entity from which the ray starts. The ray is cast from the entity's current world position and direction.
length
floatThe length of the ray, which determines how far it should extend from the entity. Defaults to 1.
collisionFlags
CollisionFilterGroupFlagsSpecifies which collision groups to include in the raycast. Defaults to AllFilter.
eFlags
EFlagsAdditional 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
SimulationPhysics simulation.
raySegment
RaySegmentRay.
Returns
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
SimulationPhysics simulation.
raySegment
RaySegmentRay.
collisionFilterGroups
CollisionFilterGroupsThe collision group of this shape sweep
collisionFilterGroupFlags
CollisionFilterGroupFlagsThe collision group that this shape sweep can collide with
Returns
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
SimulationPhysics simulation.
raySegment
RaySegmentRay.
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
SimulationPhysics simulation.
raySegment
RaySegmentRay.
resultsOutput
IList<HitResult>The list to fill with results.
collisionFilterGroups
CollisionFilterGroupsThe collision group of this shape sweep
collisionFilterGroupFlags
CollisionFilterGroupFlagsThe collision group that this shape sweep can collide with
Exceptions
- ArgumentNullException
If the simulation argument is null.