Table of Contents

Class LSCollider2D

Namespace
Gravitas.Colliders
Assembly
Gravitas.dll

Common runtime type for the closed set of Gravitas-owned pure 2D collider shapes. Use CreateCollider() when constructing from engine-adapter shape data.

public abstract class LSCollider2D : IRecordable
Inheritance
LSCollider2D
Implements
IRecordable
Derived
Inherited Members

Properties

Agent

Gets the host agent to which this collider is bound.

public IMatterAgent Agent { get; }

Property Value

IMatterAgent

Body

Gets the owning 2D body, or null for a bodyless collider.

public SolidBody2D? Body { get; }

Property Value

SolidBody2D

Bounds

Gets the committed pure 2D world-space bounds.

public FixedBoundArea Bounds { get; }

Property Value

FixedBoundArea

Center

Gets the collider center in planar world coordinates.

public Vector2d Center { get; }

Property Value

Vector2d

Context

Gets the world context to which this collider is bound.

public GravitasWorldContext Context { get; }

Property Value

GravitasWorldContext

HasCommittedShape

Gets whether this collider has committed runtime shape state.

protected bool HasCommittedShape { get; }

Property Value

bool

Id

Gets the context-local runtime collider identifier.

public int Id { get; }

Property Value

int

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

PhysicsLayerMask

IsActive

Gets or sets whether this collider participates in runtime physics.

public bool IsActive { get; set; }

Property Value

bool

IsChild

Gets whether this collider has a hierarchy parent.

public bool IsChild { get; }

Property Value

bool

IsParent

Gets whether this collider is configured as or currently owns a hierarchy parent.

public bool IsParent { get; }

Property Value

bool

IsStatic

Gets whether this collider is bodyless or belongs to an explicit static body role.

public bool IsStatic { get; }

Property Value

bool

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

bool

Layer

Gets or sets the single physics layer used by 2D collision matrix and query-mask filtering.

public PhysicsLayer Layer { get; set; }

Property Value

PhysicsLayer

LocalOffset

Gets or sets the unscaled local center offset.

public Vector2d LocalOffset { get; set; }

Property Value

Vector2d

LocalScale

Gets the combined planar owner and compound-part scale.

public virtual Vector2d LocalScale { get; }

Property Value

Vector2d

Material

Gets or sets the deterministic surface material used by pure 2D and mixed collision response for this collider.

public PhysicsMaterial Material { get; set; }

Property Value

PhysicsMaterial

MaxX

Gets the maximum world X coordinate of Bounds.

public Fixed64 MaxX { get; }

Property Value

Fixed64

MaxY

Gets the maximum planar Y coordinate of Bounds.

public Fixed64 MaxY { get; }

Property Value

Fixed64

MinX

Gets the minimum world X coordinate of Bounds.

public Fixed64 MinX { get; }

Property Value

Fixed64

MinY

Gets the minimum planar Y coordinate of Bounds.

public Fixed64 MinY { get; }

Property Value

Fixed64

MixedHalfThicknessOverride

Gets or sets the optional half-thickness used when this 2D collider is embedded into mixed 2D/3D contacts.

public Fixed64? MixedHalfThicknessOverride { get; set; }

Property Value

Fixed64?

Parent2D

Gets the 2D parent collider, when the parent belongs to the 2D runtime.

public LSCollider2D? Parent2D { get; }

Property Value

LSCollider2D

Parent3D

Gets the 3D parent collider, when the parent belongs to the 3D runtime.

public LSCollider? Parent3D { get; }

Property Value

LSCollider

ParentId

Gets the context-local identifier of the parent collider, or -1 when unparented.

public int ParentId { get; }

Property Value

int

Position

Gets the planar runtime position.

public Vector2d Position { get; }

Property Value

Vector2d

Priority

Gets the deterministic pure 2D narrow-phase ordering priority.

public virtual int Priority { get; }

Property Value

int

Rotation

Gets the committed planar rotation in radians.

public Fixed64 Rotation { get; }

Property Value

Fixed64

ScaledLocalOffset

Gets the component-scaled local offset.

public Vector2d ScaledLocalOffset { get; }

Property Value

Vector2d

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.

Shape

Gets the runtime pure 2D shape family.

public abstract ColliderType2D Shape { get; }

Property Value

ColliderType2D

Methods

CalculateLocalCenterOfMassOffset()

Calculates the body-local center of mass implied by this 2D collider's current shape state.

public virtual Vector2d CalculateLocalCenterOfMassOffset()

Returns

Vector2d

CalculateMomentOfInertia(Fixed64, Vector2d)

Calculates the scalar moment of inertia about a requested body-local reference point.

public virtual Fixed64 CalculateMomentOfInertia(Fixed64 mass, Vector2d localReferencePoint)

Parameters

mass Fixed64
localReferencePoint Vector2d

Returns

Fixed64

ClampNearZero(Vector2d)

Replaces vector components within fixed-point epsilon of zero.

protected static Vector2d ClampNearZero(Vector2d value)

Parameters

value Vector2d

Returns

Vector2d

ClearParent()

Removes this collider from its current hierarchy parent.

public void ClearParent()

ContainsPoint(Vector2d)

Gets whether a planar world-space point lies inside this collider.

public abstract bool ContainsPoint(Vector2d point)

Parameters

point Vector2d

Returns

bool

Deactivate()

Unregisters this collider, or deactivates its owning body.

public void Deactivate()

GetClosestPoint(Vector2d)

Gets the closest representable point on this collider to a planar world-space point.

public abstract Vector2d GetClosestPoint(Vector2d point)

Parameters

point Vector2d

Returns

Vector2d

GetCurrentScaleFactors(out Vector2d, out Vector2d)

Gets the current owner and compound-part scale factors separately.

protected void GetCurrentScaleFactors(out Vector2d ownerScale, out Vector2d partScale)

Parameters

ownerScale Vector2d
partScale Vector2d

GetSupportPoint(Vector2d)

Gets the farthest representable point along a planar world-space direction.

public abstract Vector2d GetSupportPoint(Vector2d direction)

Parameters

direction Vector2d

Returns

Vector2d

InitializeWithNoBody(IMatterAgent)

Binds and registers this collider as a bodyless pure 2D collider.

public void InitializeWithNoBody(IMatterAgent agent)

Parameters

agent IMatterAgent

IsSibling(LSCollider2D)

Gets whether hierarchy rules exclude collision with another 2D collider.

public bool IsSibling(LSCollider2D other)

Parameters

other LSCollider2D

Returns

bool

MarkShapeDirty()

Marks derived runtime shape state for deterministic rebuilding.

protected void MarkShapeDirty()

OnBeforeInitialize(IMatterAgent)

Validates or prepares derived shape state before runtime registration.

protected virtual void OnBeforeInitialize(IMatterAgent agent)

Parameters

agent IMatterAgent

OnMaterialChanged()

Updates derived material state after Material changes.

protected virtual void OnMaterialChanged()

RecordData(IChronicler)

Records the current instance state to the provided chronicler.

public void RecordData(IChronicler chronicler)

Parameters

chronicler IChronicler

The active chronicler pass.

RecordShapeData(IChronicler)

Records derived authored shape data.

protected virtual void RecordShapeData(IChronicler chronicler)

Parameters

chronicler IChronicler

Rotate(Vector2d, Fixed64)

Rotates a planar vector and removes fixed-point epsilon residue.

protected static Vector2d Rotate(Vector2d value, Fixed64 radians)

Parameters

value Vector2d
radians Fixed64

Returns

Vector2d

SetParent(LSCollider)

Assigns a 3D hierarchy parent used for mixed collision exclusion.

public void SetParent(LSCollider parent)

Parameters

parent LSCollider

SetParent(LSCollider2D)

Assigns a 2D hierarchy parent used for collision exclusion.

public void SetParent(LSCollider2D parent)

Parameters

parent LSCollider2D

SetPreparedBounds(FixedBoundArea)

Sets the bounds for the shape transaction being prepared.

protected void SetPreparedBounds(FixedBoundArea bounds)

Parameters

bounds FixedBoundArea

Simulate()

Refreshes bodyless collider shape and broad-phase state for one simulation step.

public void Simulate()

TryGetLocalScale(out Vector2d)

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 Vector2d scale)

Parameters

scale Vector2d

Returns

bool

TryGetScaledLocalOffset(out Vector2d)

Attempts to materialize the component-scaled local offset independently from the collider's complete world transform.

public bool TryGetScaledLocalOffset(out Vector2d scaledLocalOffset)

Parameters

scaledLocalOffset Vector2d

Returns

bool

Events

OnContact

Raised while this collider is touching another collider that owns a 2D body.

public event LSCollider2D.Body2DCollisionFunc? OnContact

Event Type

LSCollider2D.Body2DCollisionFunc

OnContactEnter

Raised on the first simulation frame this non-trigger collider touches another 2D body.

public event LSCollider2D.Body2DCollisionFunc? OnContactEnter

Event Type

LSCollider2D.Body2DCollisionFunc

OnContactExit

Raised when this collider stops touching another 2D body.

public event LSCollider2D.Body2DCollisionFunc? OnContactExit

Event Type

LSCollider2D.Body2DCollisionFunc

OnMixedContact

Raised while this collider has a physical mixed contact with a 3D collider.

public event LSCollider2D.Mixed2DCollisionFunc? OnMixedContact

Event Type

LSCollider2D.Mixed2DCollisionFunc

OnMixedContactEnter

Raised when this collider begins a physical mixed contact with a 3D collider.

public event LSCollider2D.Mixed2DCollisionFunc? OnMixedContactEnter

Event Type

LSCollider2D.Mixed2DCollisionFunc

OnMixedContactExit

Raised when this collider ends a physical mixed contact with a 3D collider.

public event LSCollider2D.Mixed2DCollisionFunc? OnMixedContactExit

Event Type

LSCollider2D.Mixed2DCollisionFunc

OnMixedTriggerEnter

Raised on the first mixed 2D/3D simulation frame this collider participates in a valid trigger pair.

public event LSCollider2D.Mixed2DCollisionFunc? OnMixedTriggerEnter

Event Type

LSCollider2D.Mixed2DCollisionFunc

OnMixedTriggerExit

Raised when this collider stops participating in a valid mixed 2D/3D trigger pair.

public event LSCollider2D.Mixed2DCollisionFunc? OnMixedTriggerExit

Event Type

LSCollider2D.Mixed2DCollisionFunc

OnMixedTriggerStay

Raised each mixed 2D/3D simulation frame this collider participates in an overlapped valid trigger pair.

public event LSCollider2D.Mixed2DCollisionFunc? OnMixedTriggerStay

Event Type

LSCollider2D.Mixed2DCollisionFunc

OnTriggerEnter

Raised on the first simulation frame this collider participates in a valid trigger pair.

public event LSCollider2D.Trigger2DCollisionFunc? OnTriggerEnter

Event Type

LSCollider2D.Trigger2DCollisionFunc

OnTriggerExit

Raised when this collider stops participating in a valid trigger pair.

public event LSCollider2D.Trigger2DCollisionFunc? OnTriggerExit

Event Type

LSCollider2D.Trigger2DCollisionFunc

OnTriggerStay

Raised each simulation frame this collider participates in an overlapped valid trigger pair.

public event LSCollider2D.Trigger2DCollisionFunc? OnTriggerStay

Event Type

LSCollider2D.Trigger2DCollisionFunc