Class LSCollider
Common runtime type for the closed set of Gravitas-owned 3D collider shapes. Use CreateCollider() when constructing from engine-adapter shape data.
public abstract class LSCollider : IRecordable
- Inheritance
-
LSCollider
- Implements
-
IRecordable
- Derived
- Inherited Members
Fields
_bounds
Stores the committed world-space axis-aligned bounds.
protected FixedBoundBox _bounds
Field Value
- FixedBoundBox
_debug
Controls collider debug diagnostics.
protected bool _debug
Field Value
_drawShape
Controls collider shape debug drawing.
protected bool _drawShape
Field Value
_offset
Center of collider in local space, used for calculating bounds and offsets. Should be set in the Setup method of each collider type.
protected Vector3d _offset
Field Value
- Vector3d
_radius
Stores the unscaled radius for radius-based collider shapes.
protected Fixed64 _radius
Field Value
- Fixed64
_size
Stores the unscaled local collider size.
protected Vector3d _size
Field Value
- Vector3d
Properties
Area
Gets the committed shape-specific measure used as the frontal-area fallback.
public virtual Fixed64 Area { get; protected set; }
Property Value
- Fixed64
Body
Gets the owning 3D body, or null for a bodyless collider.
public SolidBody? Body { get; }
Property Value
Bounds
Gets the committed world-space axis-aligned bounds.
public FixedBoundBox Bounds { get; }
Property Value
- FixedBoundBox
BoundsMax
Gets the maximum corner of Bounds.
public Vector3d BoundsMax { get; }
Property Value
- Vector3d
BoundsMin
Gets the minimum corner of Bounds.
public Vector3d BoundsMin { get; }
Property Value
- Vector3d
Center
Bodies position in world space + collider offset (center) value
public Vector3d Center { get; }
Property Value
- Vector3d
Context
Gets the world context to which this collider is bound.
public GravitasWorldContext Context { get; }
Property Value
HasCommittedShape
Gets whether this collider has committed runtime shape state.
protected bool HasCommittedShape { get; }
Property Value
Id
Gets the context-local runtime collider identifier.
public int Id { get; }
Property Value
IgnoredCollisionLayers
Gets or sets physical layers this collider ignores for collider-to-collider interactions. Public queries continue to use the caller's query mask.
public PhysicsLayerMask IgnoredCollisionLayers { get; set; }
Property Value
IsActive
Gets or sets whether this collider participates in runtime physics.
public bool IsActive { get; set; }
Property Value
IsChild
Gets whether this collider has a hierarchy parent.
public bool IsChild { get; }
Property Value
IsParent
Gets whether this collider is configured as or currently owns a hierarchy parent.
public bool IsParent { get; }
Property Value
IsPartitioned
Gets whether this collider currently has 3D broad-phase partition membership.
public bool IsPartitioned { get; }
Property Value
IsStatic
Gets whether this collider is bodyless or belongs to an explicit static body role.
public bool IsStatic { get; }
Property Value
IsTrigger
Gets or sets whether this bodyless collider is a trigger volume. Trigger volumes raise trigger enter/stay/exit callbacks for valid overlap pairs and never apply physical response.
public bool IsTrigger { get; set; }
Property Value
Layer
Gets or sets the single physics layer used for collision and query filtering.
public PhysicsLayer Layer { get; set; }
Property Value
LocalOffset
Gets or sets the unscaled local center offset used by bounds and shape-derived state.
public Vector3d LocalOffset { get; set; }
Property Value
- Vector3d
LocalScale
Gets the combined owner and compound-part scale.
public virtual Vector3d LocalScale { get; }
Property Value
- Vector3d
Material
Gets or sets the deterministic surface material used by collision response for this collider.
public PhysicsMaterial Material { get; set; }
Property Value
Parent2D
Gets the 2D parent collider, when the parent belongs to the 2D runtime.
public LSCollider2D? Parent2D { get; }
Property Value
Parent3D
Gets the 3D parent collider, when the parent belongs to the 3D runtime.
public LSCollider? Parent3D { get; }
Property Value
ParentId
Gets the context-local identifier of the parent collider, or -1 when unparented.
public int ParentId { get; }
Property Value
PartitionChanged
Used for preventing culling for the first frame this object is added to a new partition node.
public bool PartitionChanged { get; set; }
Property Value
Position
Gets the runtime world position, or sets it for a bodyless collider.
public Vector3d Position { get; set; }
Property Value
- Vector3d
Priority
Gets the deterministic narrow-phase ordering priority.
public abstract int Priority { get; }
Property Value
Radius
Gets or sets the unscaled shape radius used by radius-based colliders.
public Fixed64 Radius { get; set; }
Property Value
- Fixed64
Rotation
Gets the committed world rotation, or sets it for a bodyless collider.
public FixedQuaternion Rotation { get; set; }
Property Value
- FixedQuaternion
ScaledOffset
Gets the component-scaled local offset.
public Vector3d ScaledOffset { get; }
Property Value
- Vector3d
Exceptions
- InvalidOperationException
The scaled offset itself is outside the Fixed64 coordinate domain. The collider may still have a representable world center through exact transform cancellation.
ScaledRadius
Gets the bounding circle radius. For boxes, this is half of the diagonal length of the cube
public virtual Fixed64 ScaledRadius { get; }
Property Value
- Fixed64
The radius.
ScaledRadiusSqr
Gets the squared scaled bounding radius.
public Fixed64 ScaledRadiusSqr { get; }
Property Value
- Fixed64
Shape
Gets the runtime 3D shape family.
public abstract ColliderType Shape { get; }
Property Value
Size
Gets or sets the unscaled local size used when rebuilding collider bounds.
public Vector3d Size { get; set; }
Property Value
- Vector3d
Transform
Gets the transform that supplies this collider's runtime pose.
public FixedTransform Transform { get; }
Property Value
- FixedTransform
Velocity
Gets the owning body's linear velocity, or zero for a bodyless collider.
public Vector3d Velocity { get; }
Property Value
- Vector3d
World
Gets the GridForge world owned by this collider's context.
public GridWorld World { get; }
Property Value
- GridWorld
Methods
CalculateInertiaTensor(Fixed64, Vector3d)
Calculates inertia for a mass about a body-local reference point.
public virtual Fixed3x3 CalculateInertiaTensor(Fixed64 mass, Vector3d localCenterOfMassOffset)
Parameters
massFixed64localCenterOfMassOffsetVector3d
Returns
- Fixed3x3
CalculateLocalCenterOfMassOffset()
Calculates the body-local center of mass offset implied by this collider's current shape state.
public virtual Vector3d CalculateLocalCenterOfMassOffset()
Returns
- Vector3d
ClearParent()
Removes this collider from its current hierarchy parent.
public void ClearParent()
ClosestPointOnSurface(Vector3d)
Gets the point on this collider's surface nearest to a world-space point.
public abstract Vector3d ClosestPointOnSurface(Vector3d other)
Parameters
otherVector3d
Returns
- Vector3d
ColliderOverlapsRay(RaycastSegmentWorker, ref SwiftList<Vector3d>)
Checks if this object overlaps the line formed by p1 and p2
public abstract bool ColliderOverlapsRay(RaycastSegmentWorker worker, ref SwiftList<Vector3d> outputIntersectionPoints)
Parameters
workerRaycastSegmentWorkerThe prepared ray-axis worker for the owning query service.
outputIntersectionPointsSwiftList<Vector3d>
Returns
Deactivate()
Unregisters this collider, or deactivates its owning body.
public void Deactivate()
GetFrontalArea(Vector3d)
Gets the frontal-area estimate for a world-space direction; the base implementation returns Area.
public virtual Fixed64 GetFrontalArea(Vector3d direction)
Parameters
directionVector3d
Returns
- Fixed64
GetNormalAtPoint(Vector3d)
The direction pointing outward from the surface of the collider at the point
public abstract Vector3d GetNormalAtPoint(Vector3d point)
Parameters
pointVector3d
Returns
- Vector3d
InitializeWithNoBody(IMatterAgent)
Binds and registers this collider as a bodyless runtime collider.
public void InitializeWithNoBody(IMatterAgent agent)
Parameters
agentIMatterAgent
IsPositionInBounds(Fixed64, Vector3d)
Checks if position is in the padded bounds of the collider, used for broad phase collision detection
public bool IsPositionInBounds(Fixed64 cellPadding, Vector3d position)
Parameters
cellPaddingFixed64The topology cell edge used to conservatively pad the bounds.
positionVector3dThe position to check
Returns
- bool
True if position within bounds
IsSibling(LSCollider)
Gets whether hierarchy rules exclude collision with another 3D collider.
public bool IsSibling(LSCollider other)
Parameters
otherLSCollider
Returns
MarkShapeDirty()
Marks derived runtime shape state for deterministic rebuilding.
protected void MarkShapeDirty()
NormalizeSize(Vector3d)
Normalizes an authored size for the derived shape.
protected virtual Vector3d NormalizeSize(Vector3d value)
Parameters
valueVector3d
Returns
- Vector3d
OnBeforeInitialize(IMatterAgent)
Validates or prepares derived shape state before runtime registration.
protected virtual void OnBeforeInitialize(IMatterAgent agent)
Parameters
agentIMatterAgent
OnInitialize()
Runs derived initialization after runtime registration.
protected virtual void OnInitialize()
OnMaterialChanged()
Updates derived material state after Material changes.
protected virtual void OnMaterialChanged()
OnRadiusChanged()
Updates derived authored dimensions after Radius changes.
protected virtual void OnRadiusChanged()
RecordData(IChronicler)
Records the current instance state to the provided chronicler.
public void RecordData(IChronicler chronicler)
Parameters
chroniclerIChroniclerThe active chronicler pass.
SetParent(LSCollider)
Assigns a 3D hierarchy parent used for collision exclusion.
public void SetParent(LSCollider parent)
Parameters
parentLSCollider
SetParent(LSCollider2D)
Assigns a 2D hierarchy parent used for mixed collision exclusion.
public void SetParent(LSCollider2D parent)
Parameters
parentLSCollider2D
SetPreparedBounds(FixedBoundBox)
Sets the bounds for the shape transaction being prepared.
protected void SetPreparedBounds(FixedBoundBox bounds)
Parameters
boundsFixedBoundBox
SetPreviousGridBounds()
Records the current bounds and partition role for broad-phase refresh checks.
public void SetPreviousGridBounds()
Simulate()
Refreshes bodyless collider shape and broad-phase state for one simulation step.
public void Simulate()
TryGetLocalScale(out Vector3d)
Attempts to materialize the combined owner and compound-part scale. Shape preparation retains those factors separately and does not require their product to be representable.
public bool TryGetLocalScale(out Vector3d scale)
Parameters
scaleVector3d
Returns
TryGetScaledOffset(out Vector3d)
Attempts to materialize the component-scaled local offset independently from the collider's complete world transform.
public bool TryGetScaledOffset(out Vector3d scaledOffset)
Parameters
scaledOffsetVector3d
Returns
Events
OnContact
Raised while this collider is touching another collider that owns a 3D body.
public event LSCollider.BodyCollisionFunc? OnContact
Event Type
OnContactEnter
Raised on the first simulation frame this collider touches another 3D body.
public event LSCollider.BodyCollisionFunc? OnContactEnter
Event Type
OnContactExit
Raised when this collider stops touching another 3D body.
public event LSCollider.BodyCollisionFunc? OnContactExit
Event Type
OnMixedContact
Raised while this collider has a physical mixed contact with a 2D collider.
public event LSCollider.MixedCollisionFunc? OnMixedContact
Event Type
OnMixedContactEnter
Raised when this collider begins a physical mixed contact with a 2D collider.
public event LSCollider.MixedCollisionFunc? OnMixedContactEnter
Event Type
OnMixedContactExit
Raised when this collider ends a physical mixed contact with a 2D collider.
public event LSCollider.MixedCollisionFunc? OnMixedContactExit
Event Type
OnMixedTriggerEnter
Raised on the first mixed 3D/2D simulation frame this collider participates in a valid trigger pair.
public event LSCollider.MixedCollisionFunc? OnMixedTriggerEnter
Event Type
OnMixedTriggerExit
Raised when this collider stops participating in a valid mixed 3D/2D trigger pair.
public event LSCollider.MixedCollisionFunc? OnMixedTriggerExit
Event Type
OnMixedTriggerStay
Raised each mixed 3D/2D simulation frame this collider participates in an overlapped valid trigger pair.
public event LSCollider.MixedCollisionFunc? OnMixedTriggerStay
Event Type
OnTriggerEnter
Raised on the first simulation frame this collider participates in a valid trigger pair.
public event LSCollider.TriggerCollisionFunc? OnTriggerEnter
Event Type
OnTriggerExit
Raised when this collider stops participating in a valid trigger pair.
public event LSCollider.TriggerCollisionFunc? OnTriggerExit
Event Type
OnTriggerStay
Raised each simulation frame this collider participates in an overlapped valid trigger pair.
public event LSCollider.TriggerCollisionFunc? OnTriggerStay