Class CollidableComponent
- Namespace
- Stride.BepuPhysics
- Assembly
- Stride.BepuPhysics.dll
[CategoryOrder(5, "Collider")]
[CategoryOrder(10, "Forces", Expand = ExpandRule.Once)]
[CategoryOrder(15, "Contacts", Expand = ExpandRule.Once)]
[CategoryOrder(20, "Activity", Expand = ExpandRule.Once)]
[DataContract(Inherited = true)]
[DefaultEntityComponentProcessor(typeof(CollidableProcessor), ExecutionMode = ExecutionMode.Runtime)]
public abstract class CollidableComponent : EntityComponent, IIdentifiable
- Inheritance
-
objectCollidableComponent
- Implements
- Derived
- Inherited Members
Constructors
CollidableComponent()
public CollidableComponent()
Fields
CategoryActivity
public const string CategoryActivity = "Activity"
Field Value
CategoryCollider
public const string CategoryCollider = "Collider"
Field Value
CategoryContacts
public const string CategoryContacts = "Contacts"
Field Value
CategoryForces
public const string CategoryForces = "Forces"
Field Value
Properties
CenterOfMass
The center of mass of this object in local space
public Vector3 CenterOfMass { get; }
Property Value
Remarks
This property will always return Zero if this object is not part of a simulation yet.
CollidableReference
protected abstract CollidableReference? CollidableReference { get; }
Property Value
- CollidableReference?
Collider
The collider definition used by this object.
[Display(null, "Collider", Expand = ExpandRule.Always)]
public required ICollider Collider { get; set; }
Property Value
Remarks
Changing this value will reset some of the internal physics state of this body
CollisionGroup
This value follows up CollisionLayer when filtering out collisions. It prevents collisions between objects sharing the same Id, when the absolute difference between their IndexA, IndexB, and IndexC is less than two.
[DataAlias("FilterByDistance")]
[Display(null, "Contacts")]
public CollisionGroup CollisionGroup { get; set; }
Property Value
Remarks
Example A: You have multiple characters (A, B, C, D) all with the same CollisionLayer, they are split in two teams {A, B} and {C, D}, but you don't want members of the same team to collide between each other, you can set {A, B}'s Id to 1 and {C, D}'s Id to 2.
Example B: You have a chain of three colliders attached to each other {A, B, C}, you don't want A and C to collide with B, but A and C should collide together. Set A, B and C's Ids to 1 to start filtering, leave A's IndexA at 0, B's to 1 and C to 2. A and C will collide since the difference between their IndexA is equal to two, but neither of them will collide with B since they are both only one away from B's index.CollisionLayer
Controls how this object interacts with other objects, allow or prevent collisions between it and other groups based on how CollisionMatrix is set up.
[DataAlias("CollisionMask")]
[Display(null, "Contacts")]
public CollisionLayer CollisionLayer { get; set; }
Property Value
ContactEventHandler
Provides the ability to collect and mutate contact data when this object collides with other objects.
[Display(null, "Contacts")]
public IContactEventHandler? ContactEventHandler { get; set; }
Property Value
FrictionCoefficient
[Display(null, "Forces")]
public float FrictionCoefficient { get; set; }
Property Value
MaterialProperties
protected abstract ref MaterialProperties MaterialProperties { get; }
Property Value
MaximumRecoveryVelocity
The maximum speed this object will exit out of the collision when overlapping another collidable
[Display(null, "Forces")]
public float MaximumRecoveryVelocity { get; set; }
Property Value
Pose
protected abstract RigidPose? Pose { get; }
Property Value
- RigidPose?
ShapeIndex
protected TypedIndex ShapeIndex { get; }
Property Value
- TypedIndex
Simulation
The simulation this object belongs to, null when it is not part of a simulation.
public BepuSimulation? Simulation { get; }
Property Value
SimulationSelector
Which simulation this object is assigned to
[DefaultValueIsSceneBased]
[Display(null, "Contacts")]
public ISimulationSelector SimulationSelector { get; set; }
Property Value
SpringDampingRatio
The amount of energy/velocity lost when this collidable bounces off
[Display(null, "Forces")]
public float SpringDampingRatio { get; set; }
Property Value
SpringFrequency
The bounce frequency in hz
[Display(null, "Forces")]
public float SpringFrequency { get; set; }
Property Value
Remarks
Must be low enough that the simulation can actually represent it. If the contact is trying to make a bounce happen at 240hz, but the integrator timestep is only 60hz, the unrepresentable motion will get damped out and the body won't bounce as much.
Methods
AttachInner(RigidPose, BodyInertia, TypedIndex)
Called every time this is added to a simulation
protected abstract void AttachInner(RigidPose pose, BodyInertia shapeInertia, TypedIndex shapeIndex)
Parameters
pose
RigidPoseshapeInertia
BodyInertiashapeIndex
TypedIndex
Remarks
May occur when certain larger changes are made to the object, Simulation is the one this object is being added to
DetachInner()
Called every time this is removed from the simulation
protected abstract void DetachInner()
Remarks
May occur right before AttachInner(RigidPose, BodyInertia, TypedIndex) when certain larger changes are made to the object, Simulation is the one this object was on prior to detaching
GetHandleValue()
protected abstract int GetHandleValue()
Returns
IsContactHandlerRegistered()
protected bool IsContactHandlerRegistered()
Returns
RayCast(in Vector3, in Vector3, float, out HitInfo)
Finds the closest intersection between the ray provided and this shape.
public bool RayCast(in Vector3 origin, in Vector3 dir, float maxDistance, out HitInfo result)
Parameters
origin
Vector3The start position for this ray
dir
Vector3The normalized direction the ray is facing
maxDistance
floatThe maximum distance from the origin that hits will be collected
result
HitInfoAn intersection in the world when this method returns true, an undefined value when this method returns false
Returns
- bool
True when the given ray intersects with this shape, false otherwise
RayCastPenetrating(in Vector3, in Vector3, float, ICollection<HitInfo>)
Collect intersections between the given ray and this shape. Hits are NOT sorted.
public void RayCastPenetrating(in Vector3 origin, in Vector3 dir, float maxDistance, ICollection<HitInfo> collection)
Parameters
origin
Vector3The start position for this ray
dir
Vector3The normalized direction the ray is facing
maxDistance
floatThe maximum distance from the origin that hits will be collected
collection
ICollection<HitInfo>The collection used to store hits into, the collection is not cleared before usage, hits are appended to it
Remarks
There are no guarantees as to the order hits are returned in.
RayCastPenetrating(in Vector3, in Vector3, float, Span<HitInfoStack>)
Collect intersections between the ray provided and this shape in this simulation.
public ConversionEnum<ManagedConverter, HitInfoStack, HitInfo> RayCastPenetrating(in Vector3 origin, in Vector3 dir, float maxDistance, Span<HitInfoStack> buffer)
Parameters
origin
Vector3The start position for this ray
dir
Vector3The normalized direction the ray is facing
maxDistance
floatThe maximum distance from the origin that hits will be collected
buffer
Span<HitInfoStack>A temporary buffer which is used as a backing array to write to, its length defines the maximum amount of info you want to read. It is used by the returned enumerator as its backing array from which you read
Returns
Remarks
When there are more hits than buffer
can accomodate, returns only the closest hits.
There are no guarantees as to the order hits are returned in.
RegisterContactHandler()
protected void RegisterContactHandler()
TryUpdateMaterialProperties()
protected void TryUpdateMaterialProperties()
UnregisterContactHandler()
protected void UnregisterContactHandler()