< Summary

Line coverage
100%
Covered lines: 1231
Uncovered lines: 0
Coverable lines: 1231
Total lines: 2443
Line coverage: 100%
Branch coverage
100%
Covered branches: 508
Total branches: 508
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: PrepareDetachedBodyReconfigurationCandidate(...)100%11100%
File 1: MatchesCommittedReconfigurationCandidate(...)100%88100%
File 1: PublishBodyReconfigurationCandidate(...)100%22100%
File 1: CreateReconfigurationSnapshot(...)100%11100%
File 2: .ctor()100%11100%
File 2: get_Id()100%11100%
File 2: get_ReplayOrdinal()100%11100%
File 2: get_LifetimeVersion()100%11100%
File 2: get_CompoundOwner()100%11100%
File 2: get_ServiceRefreshIndex()100%11100%
File 2: get_IsPartitioned()100%11100%
File 2: get_PartitionCoordinates()100%11100%
File 2: get_PartitionKind()100%11100%
File 2: get_IsMixedPartitioned()100%11100%
File 2: get_MixedPartitionCoordinates()100%11100%
File 2: get_MixedPartitionKind()100%11100%
File 2: get_BroadPhaseVersion()100%11100%
File 2: get_RuntimeShapeVersion()100%11100%
File 2: get_HasHostBinding()100%11100%
File 2: get_CollisionPairCount()100%11100%
File 2: get_CollisionPairHolderCount()100%11100%
File 2: get_CollisionPairs()100%11100%
File 2: get_CollisionPairHolders()100%11100%
File 2: get_Body()100%11100%
File 2: get_IsStatic()100%22100%
File 2: get_RequiresServiceSideRefresh()100%22100%
File 2: get_Agent()100%11100%
File 2: get_AgentOrNull()100%11100%
File 2: get_Context()100%11100%
File 2: get_IsActive()100%11100%
File 2: set_IsActive(...)100%1414100%
File 2: get_IsTrigger()100%11100%
File 2: set_IsTrigger(...)100%11100%
File 2: get_Layer()100%11100%
File 2: set_Layer(...)100%44100%
File 2: get_IgnoredCollisionLayers()100%11100%
File 2: set_IgnoredCollisionLayers(...)100%44100%
File 2: get_Material()100%11100%
File 2: set_Material(...)100%44100%
File 2: get_Priority()100%11100%
File 2: get_RaycastVersion()100%11100%
File 2: set_RaycastVersion(...)100%11100%
File 2: get_CircleQueryVersion()100%11100%
File 2: set_CircleQueryVersion(...)100%11100%
File 2: get_IsChild()100%11100%
File 2: get_IsParent()100%11100%
File 2: get_ParentId()100%11100%
File 2: get_Parent2D()100%11100%
File 2: get_Parent3D()100%11100%
File 2: get_TopParent2D()100%11100%
File 2: get_TopParent3D()100%11100%
File 2: get_HierarchyChildCount()100%11100%
File 2: get_HierarchyKey()100%22100%
File 2: get_ParentKey()100%11100%
File 2: get_TopParentKey()100%11100%
File 2: get_HierarchyState()100%11100%
File 2: Gravitas.Colliders.IColliderHierarchyNode.get_HierarchyKey()100%11100%
File 2: Gravitas.Colliders.IColliderHierarchyNode.get_HierarchyParent()100%11100%
File 2: get_LocalOffset()100%11100%
File 2: set_LocalOffset(...)100%22100%
File 2: get_Bounds()100%11100%
File 2: get_MixedBounds3D()100%11100%
File 2: get_MixedHalfThickness()100%11100%
File 2: get_MixedSlabCenterY()100%11100%
File 2: get_MixedHalfThicknessOverride()100%11100%
File 2: set_MixedHalfThicknessOverride(...)100%1212100%
File 2: get_MinX()100%11100%
File 2: get_MaxX()100%11100%
File 2: get_MinY()100%11100%
File 2: get_MaxY()100%11100%
File 2: Initialize(...)100%11100%
File 2: InitializeWithNoBody(...)100%44100%
File 2: PreflightBodyInitialization(...)100%11100%
File 2: PreflightInitialization(...)100%11100%
File 2: InitCore(...)100%11100%
File 2: OnBeforeInitialize(...)100%11100%
File 2: SetPhysicsState(...)100%11100%
File 2: SetServiceIndex(...)100%11100%
File 2: SetReplayOrdinal(...)100%11100%
File 2: SetServiceRefreshIndex(...)100%11100%
File 2: ClearServiceRefreshIndex()100%11100%
File 2: ClearPhysicsState()100%11100%
File 2: Gravitas.Colliders.IPhysicsColliderRegistryItem.SetRegistryState(...)100%11100%
File 2: Gravitas.Colliders.IPhysicsColliderRegistryItem.get_ServiceIndex()100%11100%
File 2: Gravitas.Colliders.IPhysicsColliderRegistryItem.get_ReplayOrder()100%11100%
File 2: Gravitas.Colliders.IPhysicsColliderRegistryItem.SetRegistryServiceIndex(...)100%11100%
File 2: Gravitas.Colliders.IPhysicsColliderRegistryItem.SetRegistryReplayOrdinal(...)100%11100%
File 2: Gravitas.Colliders.IPhysicsColliderRegistryItem.ClearRegistryState()100%11100%
File 2: ClearBindingState()100%11100%
File 2: Deactivate()100%44100%
File 2: Simulate()100%22100%
File 2: Rebuild(...)100%44100%
File 2: RebuildRuntimeShapeOnly(...)100%11100%
File 2: ValidateCurrentRuntimeTransform()100%11100%
File 2: SetParent(...)100%44100%
File 2: SetParent(...)100%44100%
File 2: ClearParent()100%44100%
File 2: IsSibling(...)100%11100%
File 2: ExcludesMixedCollisionWith(...)100%11100%
File 2: GetOrCreatePartitionCoordinates()100%22100%
File 2: GetOrCreateMixedPartitionCoordinates()100%22100%
File 2: MatchesPartitionGridBounds(...)100%11100%
File 2: MatchesMixedPartitionGridBounds(...)100%66100%
File 2: MarkPartitioned(...)100%11100%
File 2: MarkMixedPartitioned(...)100%11100%
File 2: MarkUnpartitioned()100%11100%
File 2: MarkMixedUnpartitioned()100%11100%
File 2: ClearPartitionCoordinates()100%11100%
File 2: ClearMixedPartitionCoordinates()100%11100%
File 2: IsPositionInPlanarBounds(...)100%66100%
File 2: IsPositionInMixedBounds(...)100%1010100%
File 2: TryGetCollisionPair(...)100%11100%
File 2: TryAddCollisionPair(...)100%11100%
File 2: TryRemoveCollisionPair(...)100%11100%
File 2: TryAddCollisionPairHolder(...)100%11100%
File 2: TryRemoveCollisionPairHolder(...)100%11100%
File 2: ClearCollisionPairState()100%11100%
File 2: ClearRuntimeRelationships()100%11100%
File 2: ResolveAgentRotation()100%22100%
File 2: BindContext(...)100%22100%
File 2: ReserveCompoundPart(...)100%22100%
File 2: ThrowIfCompoundPartLifecycle(...)100%11100%
File 2: TransformRelativeMassPropertyPointExact(...)100%22100%
File 2: get_CompoundLocalRotation()100%11100%
File 2: Rotate(...)100%22100%
File 2: ClampNearZero(...)100%44100%
File 2: SetTrigger(...)100%66100%
File 2: MarkContactDependencyChanged(...)100%66100%
File 2: ThrowIfCannotEnableTrigger(...)100%11100%
File 2: ThrowIfTriggerWouldAttachToBody(...)100%11100%
File 2: ThrowIfLoadedTriggerHasBody(...)100%22100%
File 2: RecordData(...)100%44100%
File 2: RecordShapeData(...)100%11100%
File 2: IgnoresCollisionLayer(...)100%11100%
File 2: ApplyLoadedState()100%1212100%
File 3: get_Position()100%22100%
File 3: get_Rotation()100%44100%
File 3: get_LocalScale()100%11100%
File 3: TryGetLocalScale(...)100%22100%
File 3: get_ScaledLocalOffset()100%11100%
File 3: TryGetScaledLocalOffset(...)100%11100%
File 3: get_Center()100%22100%
File 3: get_VertexCount()100%22100%
File 3: get_ConvexRotation()100%11100%
File 3: GetScaledLocalVertexUnchecked(...)100%11100%
File 3: GetConvexSupportAnchor(...)100%11100%
File 3: TryGetClosestBoundaryAnchor(...)100%1010100%
File 3: TryGetClosestBoundaryAnchor(...)100%44100%
File 3: TryGetVertex(...)100%11100%
File 3: GetRoundBoundaryAnchor(...)100%22100%
File 3: TryGetAABoxBoundaryAnchor(...)100%11100%
File 3: TryGetConvexBoundaryAnchor(...)100%11100%
File 3: TryGetCompoundBoundaryAnchor(...)100%22100%
File 3: TryGetCompoundBoundaryAnchor(...)100%1010100%
File 3: TryGetAnchorDistance(...)100%44100%
File 3: CalculateLocalCenterOfMassOffset()100%11100%
File 3: CalculateLocalMassPoint()100%11100%
File 3: CalculatePreparedLocalMassPoint()100%11100%
File 3: CalculateMomentOfInertia(...)100%66100%
File 3: OnMaterialChanged()100%11100%
File 3: TransformPreparedPartMassPropertyPointExact(...)100%11100%
File 3: MarkShapeDirty()100%44100%
File 3: RebuildRuntimeShapeState(...)100%2626100%
File 3: ResolveStandalonePosition()100%44100%
File 3: ResolveStandaloneRotation()100%22100%
File 4: ValidateGeometryMutation(...)100%2828100%
File 4: ValidateMixedGeometry(...)100%11100%
File 4: GetCandidateGeometryReach(...)100%1616100%
File 5: ClearChildParentReferences()100%88100%
File 5: Gravitas.Colliders.IColliderHierarchyNode.AddChild(...)100%11100%
File 5: Gravitas.Colliders.IColliderHierarchyNode.RemoveChild(...)100%11100%
File 5: Gravitas.Colliders.IColliderHierarchyNode.ClearParentReference()100%44100%
File 5: Gravitas.Colliders.IColliderHierarchyNode.TryGetHierarchyColliderByKey(...)100%1212100%
File 6: NotifyContact(...)100%22100%
File 6: NotifyContact(...)100%5050100%
File 6: NotifyMixedContact(...)100%11100%
File 6: NotifyMixedContact(...)100%4646100%
File 7: ContributeReplayHash(...)100%44100%
File 7: ContributeShapeReplayHash(...)100%1212100%
File 7: WriteReplayHierarchyKey(...)100%22100%
File 7: TryResolveReplayHierarchyOrdinal(...)100%66100%
File 7: ContributeCompoundPartReplayHash(...)100%22100%
File 7: ContributeShapeDefinitionReplayHash(...)100%44100%
File 7: WriteMaterial(...)100%11100%
File 8: .ctor()100%11100%
File 8: get_HasCommittedShape()100%11100%
File 8: get_PreparedGeometryReach()100%11100%
File 8: get_PreparedAttachmentReach()100%11100%
File 8: ValidateCommittedMixedGeometry()100%11100%
File 8: get_PreparedContext()100%11100%
File 8: get_PreparedShapeBounds()100%11100%
File 8: TryPrepareRecoveryPose(...)100%66100%
File 8: get_CanonicalCenteredProxyRadius()100%11100%
File 8: get_CanonicalPivotProxyRadius()100%11100%
File 8: get_CanonicalGroundProbeRadius()100%11100%
File 8: get_CanonicalCenter()100%11100%
File 8: TryGetCommittedOwnerScale(...)100%22100%
File 8: GetCurrentOwnerScale()100%66100%
File 8: GetCurrentScaleFactors(...)100%44100%
File 8: TryGetCurrentScaledOffset(...)100%22100%
File 8: GetCurrentScaledOffset()100%11100%
File 8: GetUncommittedCenter()100%22100%
File 8: CreateStandaloneSnapshot(...)100%44100%
File 8: CaptureShapeSnapshot()100%88100%
File 8: CreateCompoundPartSnapshot(...)100%11100%
File 8: PrepareRuntimeShape(...)100%1010100%
File 8: PublishPreparedShape(...)100%1414100%
File 8: TryPrepareBodyPose(...)100%22100%
File 8: CreateDetachedBodySnapshot(...)100%11100%
File 8: PublishPreparedBodyPose()100%11100%
File 8: PublishPreparedExplicitBodyPose(...)100%1212100%
File 8: PrepareStandaloneInitialization(...)100%11100%
File 8: PrepareCompoundPart(...)100%22100%
File 8: PublishCompoundPart(...)100%11100%
File 8: SetPreparedGeometryReach(...)100%11100%
File 8: SetPreparedBounds(...)100%11100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.ColliderReconfiguration.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.ColliderReconfiguration.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using FixedMathSharp;
 9
 10namespace Gravitas.Colliders;
 11
 12/// <content>Stages and publishes native primitive reconfiguration without changing runtime identity.</content>
 13public abstract partial class LSCollider2D
 14{
 15    internal void PrepareDetachedBodyReconfigurationCandidate(
 16        SolidBody2D body, Vector2d localOffset, Vector2d position)
 17    {
 8418        _body = body;
 8419        _agent = body.Agent;
 8420        _context = body.Context;
 8421        _localOffset = localOffset;
 8422        _mixedHalfThicknessOverride = body.Collider._mixedHalfThicknessOverride;
 8423        PrepareStandaloneInitialization(body.Agent, useRequestedPose: true, position, body.Rotation);
 8324        PublishPreparedShape();
 8325    }
 26
 27    internal bool MatchesCommittedReconfigurationCandidate(LSCollider2D candidate)
 28    {
 6629        bool sameDimensions = this is LSCircleCollider2D circle
 6630            ? circle.Radius == ((LSCircleCollider2D)candidate).Radius
 6631            : ((LSCapsuleCollider2D)this).Radius == ((LSCapsuleCollider2D)candidate).Radius
 6632                && ((LSCapsuleCollider2D)this).Height == ((LSCapsuleCollider2D)candidate).Height;
 6633        return sameDimensions && _localOffset == candidate._localOffset
 6634            && !_runtimeShapeState.ShouldRebuild(CreateReconfigurationSnapshot(candidate, _shapeVersion));
 35    }
 36
 37    internal void PublishBodyReconfigurationCandidate(LSCollider2D candidate)
 38    {
 5739        if (this is LSCircleCollider2D circle)
 3540            circle.CopyPreparedReconfiguration((LSCircleCollider2D)candidate);
 41        else
 2242            ((LSCapsuleCollider2D)this).CopyPreparedReconfiguration((LSCapsuleCollider2D)candidate);
 43
 5744        _localOffset = candidate._localOffset;
 5745        _shapeVersion++;
 5746        _preparedSnapshot = CreateReconfigurationSnapshot(candidate, _shapeVersion);
 5747        _preparedGeometryReach = candidate._preparedGeometryReach;
 5748        _preparedAttachmentReach = candidate._preparedAttachmentReach;
 5749        _preparedBounds = candidate._preparedBounds;
 5750        _preparedMixedBounds = candidate._preparedMixedBounds;
 5751        PublishPreparedShape();
 5752    }
 53
 54    private static ColliderShapeSnapshot2D CreateReconfigurationSnapshot(LSCollider2D candidate, uint shapeVersion)
 55    {
 5956        ColliderShapeSnapshot2D snapshot = candidate._preparedSnapshot;
 5957        return new ColliderShapeSnapshot2D(snapshot.Center, snapshot.Rotation,
 5958            snapshot.OwnerScale, snapshot.PartScale, snapshot.LocalOffset, shapeVersion,
 5959            snapshot.MixedSlabCenterY, snapshot.MixedHalfThickness);
 60    }
 61}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System.Runtime.CompilerServices;
 9using Chronicler;
 10using FixedMathSharp;
 11using FixedMathSharp.Geometry;
 12using Gravitas.Materials;
 13using Gravitas.Support;
 14using GridForge.Spatial;
 15using SwiftCollections;
 16
 17namespace Gravitas.Colliders;
 18
 19
 20
 21/// <summary>
 22/// Common runtime type for the closed set of Gravitas-owned pure 2D collider
 23/// shapes. Use <see cref="ColliderShapeDefinition2D.CreateCollider"/> when
 24/// constructing from engine-adapter shape data.
 25/// </summary>
 26/// <content>Owns planar collider state, registration, authored mutations and recording.</content>
 27public abstract partial class LSCollider2D : IRecordable, IColliderHierarchyNode, IPhysicsColliderRegistryItem
 28{
 2034829    internal LSCollider2D() { }
 30
 31    private SolidBody2D? _body;
 32    private IMatterAgent? _agent;
 33    private GravitasWorldContext? _context;
 34    private LSCompoundCollider2D? _compoundOwner;
 35    private Fixed64 _compoundLocalRotation;
 1017436    private Vector2d _compoundLocalScale = Vector2d.One;
 1017437    private int _id = -1;
 1017438    private int _serviceIndex = -1;
 1017439    private int _replayOrder = -1;
 1017440    private int _replayOrdinal = -1;
 41    private long _lifetimeVersion;
 1017442    private int _serviceRefreshIndex = -1;
 1017443    private bool _isActive = true;
 44    private bool _isTrigger;
 45    private PhysicsLayer _layer = new();
 1017446    private PhysicsLayerMask _ignoredCollisionLayers = PhysicsLayerMask.None;
 1017447    private PhysicsMaterial _material = PhysicsMaterial.Default;
 48    private Vector2d _localOffset;
 49    private FixedBoundArea _bounds;
 50    private FixedBoundBox _mixedBounds3D;
 51    private Fixed64? _mixedHalfThicknessOverride;
 52    private Fixed64 _mixedHalfThickness;
 53    private Fixed64 _mixedSlabCenterY;
 54    private uint _shapeVersion;
 1017455    private readonly ColliderRuntimeShapeState<ColliderShapeSnapshot2D> _runtimeShapeState = new();
 56    private ColliderPartitionState2D _partitionState;
 57    private ColliderPartitionState _mixedPartitionState;
 58    private ColliderQueryState _queryState;
 59    private ColliderPairState<CollisionPair2D> _pairState;
 60    private ColliderHierarchyState _hierarchyState;
 61
 62
 63
 64
 65
 66    /// <summary>
 67    /// Raised while this collider is touching another collider that owns a 2D body.
 68    /// </summary>
 69    public event Body2DCollisionFunc? OnContact;
 70
 71    /// <summary>
 72    /// Raised on the first simulation frame this non-trigger collider touches another 2D body.
 73    /// </summary>
 74    public event Body2DCollisionFunc? OnContactEnter;
 75
 76    /// <summary>
 77    /// Raised when this collider stops touching another 2D body.
 78    /// </summary>
 79    public event Body2DCollisionFunc? OnContactExit;
 80
 81    /// <summary>
 82    /// Raised on the first simulation frame this collider participates in a valid trigger pair.
 83    /// </summary>
 84    public event Trigger2DCollisionFunc? OnTriggerEnter;
 85
 86    /// <summary>
 87    /// Raised each simulation frame this collider participates in an overlapped valid trigger pair.
 88    /// </summary>
 89    public event Trigger2DCollisionFunc? OnTriggerStay;
 90
 91    /// <summary>
 92    /// Raised when this collider stops participating in a valid trigger pair.
 93    /// </summary>
 94    public event Trigger2DCollisionFunc? OnTriggerExit;
 95
 96    /// <summary>Raised while this collider has a physical mixed contact with a 3D collider.</summary>
 97    public event Mixed2DCollisionFunc? OnMixedContact;
 98    /// <summary>Raised when this collider begins a physical mixed contact with a 3D collider.</summary>
 99    public event Mixed2DCollisionFunc? OnMixedContactEnter;
 100    /// <summary>Raised when this collider ends a physical mixed contact with a 3D collider.</summary>
 101    public event Mixed2DCollisionFunc? OnMixedContactExit;
 102
 103    /// <summary>
 104    /// Raised on the first mixed 2D/3D simulation frame this collider participates in a valid trigger pair.
 105    /// </summary>
 106    public event Mixed2DCollisionFunc? OnMixedTriggerEnter;
 107
 108    /// <summary>
 109    /// Raised each mixed 2D/3D simulation frame this collider participates in an overlapped valid trigger pair.
 110    /// </summary>
 111    public event Mixed2DCollisionFunc? OnMixedTriggerStay;
 112
 113    /// <summary>
 114    /// Raised when this collider stops participating in a valid mixed 2D/3D trigger pair.
 115    /// </summary>
 116    public event Mixed2DCollisionFunc? OnMixedTriggerExit;
 117
 118    /// <summary>Gets the context-local runtime collider identifier.</summary>
 2290294119    public int Id => _id;
 120
 9173121    internal int ReplayOrdinal => _replayOrdinal;
 122
 272528123    internal long LifetimeVersion => _lifetimeVersion;
 124
 125    internal StaticSurface2D? StaticSurface { get; set; }
 126
 127    internal bool IsDeactivationInProgress { get; set; }
 128
 12702129    internal LSCompoundCollider2D? CompoundOwner => _compoundOwner;
 130
 5361131    internal int ServiceRefreshIndex => _serviceRefreshIndex;
 132
 14851133    internal bool IsPartitioned => _partitionState.IsPartitioned;
 134
 37256135    internal SwiftList<WorldVoxelIndex>? PartitionCoordinates => _partitionState.Coordinates;
 136
 26410137    internal int PartitionKind => _partitionState.LastPartitionKind;
 138
 31692139    internal bool IsMixedPartitioned => _mixedPartitionState.IsPartitioned;
 140
 27421141    internal SwiftList<WorldVoxelIndex>? MixedPartitionCoordinates => _mixedPartitionState.Coordinates;
 142
 10923143    internal int MixedPartitionKind => _mixedPartitionState.LastPartitionKind;
 144
 56917145    internal uint BroadPhaseVersion => _partitionState.BroadPhaseVersion;
 146
 147    internal uint ContactDependencyVersion { get; private set; }
 148
 5286149    internal uint RuntimeShapeVersion => _runtimeShapeState.RuntimeVersion;
 150
 10001151    internal bool HasHostBinding => _agent != null;
 152
 2207153    internal int CollisionPairCount => _pairState.CollisionPairCount;
 154
 2219155    internal int CollisionPairHolderCount => _pairState.CollisionPairHolderCount;
 156
 12855157    internal SwiftDictionary<int, CollisionPair2D>? CollisionPairs => _pairState.CollisionPairs;
 158
 12855159    internal SwiftHashSet<int>? CollisionPairHolders => _pairState.CollisionPairHolders;
 160
 161    /// <summary>Gets the owning 2D body, or <see langword="null"/> for a bodyless collider.</summary>
 1229215162    public SolidBody2D? Body => _body;
 163
 164    /// <summary>
 165    /// Gets whether this collider is bodyless or belongs to an explicit static
 166    /// body role.
 167    /// </summary>
 108942168    public bool IsStatic => _body == null || _body.IsStatic;
 169
 9539170    internal bool RequiresServiceSideRefresh => _body == null || _body.DynamicId < 0;
 171
 172    /// <summary>Gets the host agent to which this collider is bound.</summary>
 173    public IMatterAgent Agent
 174    {
 175        get
 176        {
 30177            ChronicleGuard.ThrowIfTrue(
 30178                _agent == null,
 30179                nameof(LSCollider2D),
 30180                "2D collider is not bound to an IMatterAgent.");
 29181            return _agent!;
 182        }
 183    }
 184
 428520185    internal IMatterAgent? AgentOrNull => _agent;
 186
 187    /// <summary>Gets the world context to which this collider is bound.</summary>
 188    public GravitasWorldContext Context
 189    {
 190        get
 191        {
 99857192            ChronicleGuard.ThrowIfTrue(
 99857193                _context == null,
 99857194                nameof(LSCollider2D),
 99857195                "2D collider is not bound to a GravitasWorldContext.");
 99856196            return _context!;
 197        }
 198    }
 199
 200    /// <summary>Gets or sets whether this collider participates in runtime physics.</summary>
 201    public bool IsActive
 202    {
 203        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1076103204        get => _isActive;
 205        set
 206        {
 232207            ThrowIfCompoundPartLifecycle(nameof(IsActive));
 208
 232209            if (_isActive == value)
 4210                return;
 211
 228212            if (_context == null || _id < 0)
 213            {
 208214                _isActive = value;
 208215                return;
 216            }
 217
 20218            if (value)
 219            {
 3220                RebuildRuntimeShapeState();
 3221                _isActive = true;
 3222                _context.Collisions2D.RefreshColliderPartition(this);
 3223                if (_context.Settings.RuntimeMode.RunsMixedContacts())
 1224                    _context.MixedCollisions.Refresh2DColliderPartition(this);
 225            }
 226            else
 227            {
 17228                StaticSurface?.Remove(this);
 17229                _isActive = false;
 17230                _context.Collisions2D.ClearPartitionedCollider(this, force: true);
 17231                if (IsMixedPartitioned)
 2232                    _context.MixedCollisions.ClearPartitioned2DCollider(this, force: true);
 233            }
 19234        }
 235    }
 236
 237    /// <summary>
 238    /// Gets or sets whether this bodyless collider is a trigger volume.
 239    /// Trigger volumes raise trigger enter/stay/exit callbacks for valid overlap
 240    /// pairs and never apply physical response.
 241    /// </summary>
 242    public bool IsTrigger
 243    {
 244        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 316752245        get => _isTrigger;
 156246        set => SetTrigger(value);
 247    }
 248
 249    /// <summary>
 250    /// Gets or sets the single physics layer used by 2D collision matrix and query-mask filtering.
 251    /// </summary>
 252    public PhysicsLayer Layer
 253    {
 254        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 977804255        get => _layer;
 256        set
 257        {
 1724258            if (_layer == value) return;
 84259            _layer = value;
 84260            MarkContactDependencyChanged();
 84261            _body?.Wake();
 12262        }
 263    }
 264
 265    /// <summary>
 266    /// Gets or sets physical layers this collider ignores for collider-to-collider
 267    /// interactions. Public queries continue to use the caller's query mask.
 268    /// </summary>
 269    public PhysicsLayerMask IgnoredCollisionLayers
 270    {
 271        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 14272        get => _ignoredCollisionLayers;
 273        set
 274        {
 74275            if (_ignoredCollisionLayers == value)
 13276                return;
 277
 61278            _ignoredCollisionLayers = value;
 61279            MarkContactDependencyChanged();
 61280            _body?.Wake();
 32281        }
 282    }
 283
 284    /// <summary>
 285    /// Gets or sets the deterministic surface material used by pure 2D and
 286    /// mixed collision response for this collider.
 287    /// </summary>
 288    public PhysicsMaterial Material
 289    {
 290        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 48377291        get => _material;
 292        set
 293        {
 3450294            if (_material == value)
 1042295                return;
 296
 2408297            _material = value;
 2408298            MarkContactDependencyChanged(surfaceNeighborsChanged: false);
 2408299            OnMaterialChanged();
 2408300            _body?.Wake();
 247301        }
 302    }
 303
 304    /// <summary>Gets the runtime pure 2D shape family.</summary>
 305    public abstract ColliderType2D Shape { get; }
 306
 307    /// <summary>Gets the deterministic pure 2D narrow-phase ordering priority.</summary>
 9231308    public virtual int Priority => ColliderSettings2D.GetPriority(Shape);
 309
 310    internal uint RaycastVersion
 311    {
 312        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 175199313        get => _queryState.RaycastVersion;
 314        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 41376315        set => _queryState.RaycastVersion = value;
 316    }
 317
 318    internal uint CircleQueryVersion
 319    {
 320        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 232965321        get => _queryState.CircleQueryVersion;
 322        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 30495323        set => _queryState.CircleQueryVersion = value;
 324    }
 325
 326    /// <summary>Gets whether this collider has a hierarchy parent.</summary>
 2327    public bool IsChild => _hierarchyState.IsChild;
 328
 329    /// <summary>Gets whether this collider is configured as or currently owns a hierarchy parent.</summary>
 2330    public bool IsParent => _hierarchyState.IsParent;
 331
 332    /// <summary>Gets the context-local identifier of the parent collider, or -1 when unparented.</summary>
 5333    public int ParentId => ParentKey.Id;
 334
 335    /// <summary>Gets the 2D parent collider, when the parent belongs to the 2D runtime.</summary>
 8336    public LSCollider2D? Parent2D => _hierarchyState.Parent as LSCollider2D;
 337
 338    /// <summary>Gets the 3D parent collider, when the parent belongs to the 3D runtime.</summary>
 5339    public LSCollider? Parent3D => _hierarchyState.Parent as LSCollider;
 340
 25960341    internal LSCollider2D? TopParent2D => _hierarchyState.TopParent as LSCollider2D;
 342
 2343    internal LSCollider? TopParent3D => _hierarchyState.TopParent as LSCollider;
 344
 5686345    internal int HierarchyChildCount => _hierarchyState.ChildCount;
 346
 430703347    internal ColliderHierarchyKey HierarchyKey => Id >= 0 ? ColliderHierarchyKey.Create2D(Id) : ColliderHierarchyKey.Non
 348
 5690349    internal ColliderHierarchyKey ParentKey => _hierarchyState.ParentKey;
 350
 5682351    internal ColliderHierarchyKey TopParentKey => _hierarchyState.TopParentKey;
 352
 361510353    internal ColliderHierarchyState HierarchyState => _hierarchyState;
 354
 129355    ColliderHierarchyKey IColliderHierarchyNode.HierarchyKey => HierarchyKey;
 356
 37357    IColliderHierarchyNode? IColliderHierarchyNode.HierarchyParent => _hierarchyState.Parent;
 358
 359    /// <summary>Gets or sets the unscaled local center offset.</summary>
 360    public Vector2d LocalOffset
 361    {
 362        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 95153363        get => _localOffset;
 364        set
 365        {
 653366            if (_localOffset == value)
 182367                return;
 368
 471369            ValidateGeometryMutation(offset: value);
 465370            _localOffset = value;
 465371            MarkShapeDirty();
 465372        }
 373    }
 374
 375    /// <summary>Gets the committed pure 2D world-space bounds.</summary>
 24515376    public FixedBoundArea Bounds => _bounds;
 377
 525771378    internal FixedBoundBox MixedBounds3D => _mixedBounds3D;
 379
 104448380    internal Fixed64 MixedHalfThickness => _mixedHalfThickness;
 381
 211396382    internal Fixed64 MixedSlabCenterY => _mixedSlabCenterY;
 383
 384    /// <summary>
 385    /// Gets or sets the optional half-thickness used when this 2D collider is embedded into mixed 2D/3D contacts.
 386    /// </summary>
 387    public Fixed64? MixedHalfThicknessOverride
 388    {
 389        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 10390        get => _mixedHalfThicknessOverride;
 391        set
 392        {
 1756393            if (value.HasValue)
 394            {
 1751395                ChronicleGuard.ThrowIfArgument(
 1751396                    value.Value <= Fixed64.Zero,
 1751397                    nameof(value),
 1751398                    "2D mixed half-thickness override must be greater than zero.");
 399            }
 400
 1754401            if (_mixedHalfThicknessOverride == value)
 2402                return;
 403
 1752404            ValidateGeometryMutation(halfThickness: value ?? _context?.Settings.Mixed2DHalfThickness
 1752405                ?? PhysicsSettings.DefaultMixed2DHalfThickness);
 1752406            _mixedHalfThicknessOverride = value;
 1752407            MarkShapeDirty();
 1752408        }
 409    }
 410
 411    /// <summary>Gets the minimum world X coordinate of <see cref="Bounds"/>.</summary>
 502865412    public Fixed64 MinX => _bounds.Min.X;
 413
 414    /// <summary>Gets the maximum world X coordinate of <see cref="Bounds"/>.</summary>
 481172415    public Fixed64 MaxX => _bounds.Max.X;
 416
 417    /// <summary>Gets the minimum planar Y coordinate of <see cref="Bounds"/>.</summary>
 427677418    public Fixed64 MinY => _bounds.Min.Y;
 419
 420    /// <summary>Gets the maximum planar Y coordinate of <see cref="Bounds"/>.</summary>
 414913421    public Fixed64 MaxY => _bounds.Max.Y;
 422
 423    internal void Initialize(SolidBody2D body)
 424    {
 6460425        InitCore(body.Agent, body);
 6460426    }
 427
 428    /// <summary>Binds and registers this collider as a bodyless pure 2D collider.</summary>
 429    public void InitializeWithNoBody(IMatterAgent agent)
 430    {
 3021431        ThrowIfCompoundPartLifecycle(nameof(InitializeWithNoBody));
 3021432        ChronicleGuard.ThrowIfNull(agent, nameof(agent));
 3021433        ChronicleGuard.ThrowIfArgument(
 3021434            Id >= 0 || (HasHostBinding && !ReferenceEquals(_agent, agent)),
 3021435            nameof(agent),
 3021436            "2D collider is already registered or bound to another host agent.");
 3019437        PreflightInitialization(agent);
 2996438        InitCore(agent, null);
 2996439        Context.Physics2D.AssimilateCollider(this);
 2996440    }
 441
 442    internal void PreflightBodyInitialization(
 443        SolidBody2D body,
 444        Vector2d requestedPosition,
 445        Fixed64 requestedRotation)
 446    {
 6474447        ThrowIfCompoundPartLifecycle(nameof(Initialize));
 6474448        ChronicleGuard.ThrowIfNull(body, nameof(body));
 6474449        ThrowIfTriggerWouldAttachToBody(nameof(Initialize));
 6473450        PreflightInitialization(
 6473451            body.Agent,
 6473452            useRequestedPose: true,
 6473453            requestedPosition,
 6473454            requestedRotation);
 6459455    }
 456
 457    private void PreflightInitialization(
 458        IMatterAgent agent,
 459        bool useRequestedPose = false,
 460        Vector2d requestedPosition = default,
 461        Fixed64 requestedRotation = default)
 462    {
 9492463        ChronicleGuard.ThrowIfNull(agent, nameof(agent));
 9492464        OnBeforeInitialize(agent);
 9492465        PrepareStandaloneInitialization(
 9492466            agent,
 9492467            useRequestedPose,
 9492468            requestedPosition,
 9492469            requestedRotation);
 9455470    }
 471
 472    private void InitCore(IMatterAgent agent, SolidBody2D? body)
 473    {
 9456474        _lifetimeVersion++;
 9456475        _body = body;
 9456476        _agent = agent;
 9456477        _context = agent.Context;
 9456478        _isActive = true;
 9456479        _queryState.Reset();
 9456480        _hierarchyState.Initialize(agent.IsParent);
 9456481        ContactDependencyVersion = 0;
 9456482        PublishPreparedShape();
 9456483    }
 484
 485    /// <summary>Validates or prepares derived shape state before runtime registration.</summary>
 9492486    protected virtual void OnBeforeInitialize(IMatterAgent agent) { }
 487
 488    internal void SetPhysicsState(int id, int serviceIndex, int replayOrder)
 489    {
 9455490        ChronicleGuard.ThrowIfNegative(id, nameof(id));
 9455491        ChronicleGuard.ThrowIfNegative(serviceIndex, nameof(serviceIndex));
 9455492        ChronicleGuard.ThrowIfNegative(replayOrder, nameof(replayOrder));
 9455493        _id = id;
 9455494        _serviceIndex = serviceIndex;
 9455495        _replayOrder = replayOrder;
 9455496        _replayOrdinal = -1;
 9455497    }
 498
 499    internal void SetServiceIndex(int serviceIndex)
 500    {
 152501        ChronicleGuard.ThrowIfNegative(serviceIndex, nameof(serviceIndex));
 152502        _serviceIndex = serviceIndex;
 152503    }
 504
 505    internal void SetReplayOrdinal(int replayOrdinal)
 506    {
 12063507        ChronicleGuard.ThrowIfNegative(replayOrdinal, nameof(replayOrdinal));
 12063508        _replayOrdinal = replayOrdinal;
 12063509    }
 510
 511    internal void SetServiceRefreshIndex(int serviceRefreshIndex)
 512    {
 4751513        ChronicleGuard.ThrowIfNegative(serviceRefreshIndex, nameof(serviceRefreshIndex));
 4751514        _serviceRefreshIndex = serviceRefreshIndex;
 4751515    }
 516
 517    internal void ClearServiceRefreshIndex()
 518    {
 5361519        _serviceRefreshIndex = -1;
 5361520    }
 521
 522    internal void ClearPhysicsState()
 523    {
 822524        _partitionState.MarkUnpartitioned();
 822525        _partitionState.ClearCoordinates();
 822526        _mixedPartitionState.MarkUnpartitioned();
 822527        _mixedPartitionState.ClearCoordinates();
 822528        _pairState.ClearCollisionPairs();
 822529        _pairState.ClearCollisionPairHolders();
 822530        _id = -1;
 822531        _serviceIndex = -1;
 822532        _replayOrder = -1;
 822533        _replayOrdinal = -1;
 822534        _serviceRefreshIndex = -1;
 822535    }
 536
 537    void IPhysicsColliderRegistryItem.SetRegistryState(int id, int serviceIndex, int replayOrder) =>
 9455538        SetPhysicsState(id, serviceIndex, replayOrder);
 539
 503540    int IPhysicsColliderRegistryItem.ServiceIndex => _serviceIndex;
 541
 54589542    int IPhysicsColliderRegistryItem.ReplayOrder => _replayOrder;
 543
 544    void IPhysicsColliderRegistryItem.SetRegistryServiceIndex(int serviceIndex) =>
 152545        SetServiceIndex(serviceIndex);
 546
 547    void IPhysicsColliderRegistryItem.SetRegistryReplayOrdinal(int replayOrdinal) =>
 12063548        SetReplayOrdinal(replayOrdinal);
 549
 614550    void IPhysicsColliderRegistryItem.ClearRegistryState() => ClearPhysicsState();
 551
 552    internal void ClearBindingState()
 553    {
 508554        _body = null;
 508555        _agent = null;
 508556        _context = null;
 508557        _preparedContext = null;
 508558    }
 559
 560    /// <summary>Unregisters this collider, or deactivates its owning body.</summary>
 561    public void Deactivate()
 562    {
 354563        ThrowIfCompoundPartLifecycle(nameof(Deactivate));
 564
 354565        if (_body != null)
 566        {
 54567            _body.Deactivate();
 54568            return;
 569        }
 570
 300571        if (_id >= 0)
 296572            _context!.Physics2D.DessimilateCollider(this);
 573
 300574        _isActive = false;
 300575        ClearBindingState();
 300576    }
 577
 578    /// <summary>Refreshes bodyless collider shape and broad-phase state for one simulation step.</summary>
 579    public void Simulate()
 580    {
 41787581        ThrowIfCompoundPartLifecycle(nameof(Simulate));
 582
 41786583        if (!IsActive)
 1584            return;
 585
 41785586        Rebuild();
 41781587    }
 588
 589    internal bool Rebuild(bool geometryOnly = false)
 590    {
 58478591        if (!RebuildRuntimeShapeState(geometryOnly))
 50079592            return false;
 593
 8394594        if (_id >= 0)
 8387595            return _context!.Collisions2D.RefreshColliderPartitionAfterShapeChange(this);
 596
 7597        return true;
 598    }
 599
 600    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 601    internal bool RebuildRuntimeShapeOnly(bool skipUnchangedMassProperties = false) =>
 23042602        RebuildRuntimeShapeState(skipUnchangedMassProperties: skipUnchangedMassProperties);
 603
 604    internal void ValidateCurrentRuntimeTransform() =>
 1139605        PrepareRuntimeShape(
 1139606            CaptureShapeSnapshot(),
 1139607            includeBodyAttachment: true);
 608
 609    /// <summary>Assigns a 2D hierarchy parent used for collision exclusion.</summary>
 610    public void SetParent(LSCollider2D parent)
 611    {
 21612        ThrowIfCompoundPartLifecycle(nameof(SetParent));
 21613        if (_hierarchyState.SetParent(this, parent))
 614        {
 20615            MarkContactDependencyChanged();
 20616            _body?.Wake();
 617        }
 18618    }
 619
 620    /// <summary>Assigns a 3D hierarchy parent used for mixed collision exclusion.</summary>
 621    public void SetParent(LSCollider parent)
 622    {
 11623        ThrowIfCompoundPartLifecycle(nameof(SetParent));
 11624        if (_hierarchyState.SetParent(this, parent))
 625        {
 10626            MarkContactDependencyChanged();
 10627            _body?.Wake();
 628        }
 4629    }
 630
 631    /// <summary>Removes this collider from its current hierarchy parent.</summary>
 632    public void ClearParent()
 633    {
 507634        ThrowIfCompoundPartLifecycle(nameof(ClearParent));
 507635        if (_hierarchyState.ClearParent(this))
 636        {
 3637            MarkContactDependencyChanged();
 3638            _body?.Wake();
 639        }
 506640    }
 641
 642    /// <summary>Gets whether hierarchy rules exclude collision with another 2D collider.</summary>
 643    public bool IsSibling(LSCollider2D other) =>
 31687644        _hierarchyState.ExcludesCollisionWith(other._hierarchyState, HierarchyKey, other.HierarchyKey);
 645
 646    internal bool ExcludesMixedCollisionWith(LSCollider other) =>
 1647        _hierarchyState.ExcludesCollisionWith(other.HierarchyState, HierarchyKey, other.HierarchyKey);
 648
 649    internal SwiftList<WorldVoxelIndex> GetOrCreatePartitionCoordinates()
 650    {
 23786651        _partitionState.Coordinates ??= new();
 23786652        return _partitionState.Coordinates;
 653    }
 654
 655    internal SwiftList<WorldVoxelIndex> GetOrCreateMixedPartitionCoordinates()
 656    {
 8690657        _mixedPartitionState.Coordinates ??= new();
 8690658        return _mixedPartitionState.Coordinates;
 659    }
 660
 661    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 662    internal bool MatchesPartitionGridBounds(Vector2d min, Vector2d max, int partitionKind) =>
 14913663        _partitionState.MatchesGridBounds(min, max, partitionKind);
 664
 665    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 666    internal bool MatchesMixedPartitionGridBounds(Vector3d min, Vector3d max, int partitionKind) =>
 35655667        _mixedPartitionState.IsPartitioned
 35655668        && _mixedPartitionState.LastGridBoundsMin == min
 35655669        && _mixedPartitionState.LastGridBoundsMax == max
 35655670        && _mixedPartitionState.LastPartitionKind == partitionKind;
 671
 672    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 673    internal void MarkPartitioned(Vector2d min, Vector2d max, int partitionKind)
 674    {
 22046675        _partitionState.SetPreviousGridBounds(min, max, partitionKind);
 22046676        _partitionState.MarkPartitioned();
 22046677    }
 678
 679    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 680    internal void MarkMixedPartitioned(Vector3d min, Vector3d max, int partitionKind)
 681    {
 8631682        _mixedPartitionState.SetPreviousGridBounds(min, max, partitionKind);
 8631683        _mixedPartitionState.MarkPartitioned();
 8631684    }
 685
 686    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 2258687    internal void MarkUnpartitioned() => _partitionState.MarkUnpartitioned();
 688
 689    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 178690    internal void MarkMixedUnpartitioned() => _mixedPartitionState.MarkUnpartitioned();
 691
 692    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 520693    internal void ClearPartitionCoordinates() => _partitionState.ClearCoordinates();
 694
 695    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 119696    internal void ClearMixedPartitionCoordinates() => _mixedPartitionState.ClearCoordinates();
 697
 698    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 699    internal bool IsPositionInPlanarBounds(Fixed64 cellEdge, Vector3d worldPosition)
 700    {
 270908701        Fixed64 padding = cellEdge * Fixed64.Half;
 270908702        return worldPosition.X >= MinX - padding
 270908703            && worldPosition.X <= MaxX + padding
 270908704            && worldPosition.Z >= MinY - padding
 270908705            && worldPosition.Z <= MaxY + padding;
 706    }
 707
 708    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 709    internal bool IsPositionInMixedBounds(Fixed64 cellEdge, Vector3d worldPosition)
 710    {
 937157711        Fixed64 padding = cellEdge * Fixed64.Half;
 937157712        return worldPosition.X >= _mixedBounds3D.Min.X - padding
 937157713            && worldPosition.X <= _mixedBounds3D.Max.X + padding
 937157714            && worldPosition.Y >= _mixedBounds3D.Min.Y - padding
 937157715            && worldPosition.Y <= _mixedBounds3D.Max.Y + padding
 937157716            && worldPosition.Z >= _mixedBounds3D.Min.Z - padding
 937157717            && worldPosition.Z <= _mixedBounds3D.Max.Z + padding;
 718    }
 719
 720    internal bool TryGetCollisionPair(int otherId, out CollisionPair2D? collisionPair) =>
 19363721        _pairState.TryGetCollisionPair(otherId, out collisionPair);
 722
 723    internal bool TryAddCollisionPair(int otherId, CollisionPair2D collisionPair) =>
 545724        _pairState.TryAddCollisionPair(otherId, collisionPair);
 725
 726    internal bool TryRemoveCollisionPair(int otherId, out CollisionPair2D? collisionPair) =>
 180727        _pairState.TryRemoveCollisionPair(otherId, out collisionPair);
 728
 543729    internal bool TryAddCollisionPairHolder(int otherId) => _pairState.TryAddCollisionPairHolder(otherId);
 730
 180731    internal bool TryRemoveCollisionPairHolder(int otherId) => _pairState.TryRemoveCollisionPairHolder(otherId);
 732
 733    internal void ClearCollisionPairState()
 734    {
 504735        _pairState.ClearCollisionPairs();
 504736        _pairState.ClearCollisionPairHolders();
 504737    }
 738
 739    internal void ClearRuntimeRelationships()
 740    {
 504741        ClearChildParentReferences();
 504742        ClearParent();
 504743    }
 744
 745    private Fixed64 ResolveAgentRotation()
 746    {
 1458747        return _agent == null
 1458748            ? Fixed64.Zero
 1458749            : _agent.Transform.WorldRotationXZRadians;
 750    }
 751
 752    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 753    internal void BindContext(GravitasWorldContext context)
 754    {
 4755        ChronicleGuard.ThrowIfNull(context, nameof(context));
 3756        ChronicleGuard.ThrowIfArgument(
 3757            _context != null && !ReferenceEquals(_context, context),
 3758            nameof(context),
 3759            "2D collider is already bound to a different GravitasWorldContext.");
 2760        _context = context;
 2761    }
 762
 763    internal void ReserveCompoundPart(
 764        LSCompoundCollider2D owner,
 765        Fixed64 localRotation,
 766        Vector2d localScale)
 767    {
 478768        ChronicleGuard.ThrowIfNull(owner, nameof(owner));
 478769        ChronicleGuard.ThrowIfArgument(
 478770            HasHostBinding,
 478771            nameof(owner),
 478772            "2D compound collider parts cannot be initialized as standalone colliders.");
 477773        ChronicleGuard.ThrowIfArgument(
 477774            _compoundOwner != null && !ReferenceEquals(_compoundOwner, owner),
 477775            nameof(owner),
 477776            "2D compound collider part is already owned by another compound collider.");
 777
 476778        _compoundOwner = owner;
 476779        _compoundLocalRotation = localRotation;
 476780        _compoundLocalScale = localScale;
 476781    }
 782
 783    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 784    private void ThrowIfCompoundPartLifecycle(string operation)
 785    {
 52437786        ChronicleGuard.ThrowIfTrue(
 52437787            _compoundOwner != null,
 52437788            operation,
 52437789            "2D compound collider parts are geometry owned by LSCompoundCollider2D and cannot run standalone lifecycle o
 52436790    }
 791
 792    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 793    internal ExactMassPoint2D TransformRelativeMassPropertyPointExact(
 794        Vector2d partRelativePoint)
 795    {
 88787796        GetCurrentScaleFactors(
 88787797            out Vector2d ownerScale,
 88787798            out _);
 88787799        return _compoundOwner == null
 88787800            ? ExactMassPoint2D.CreateScaledLocalComposition(
 88787801                LocalOffset,
 88787802                ownerScale,
 88787803                Vector2d.Zero,
 88787804                Vector2d.One,
 88787805                partRelativePoint,
 88787806                Fixed64.Zero)
 88787807            : ExactMassPoint2D.CreateScaledLocalComposition(
 88787808                _compoundOwner.LocalOffset,
 88787809                ownerScale,
 88787810                LocalOffset,
 88787811                ownerScale,
 88787812                partRelativePoint,
 88787813                _compoundLocalRotation);
 814    }
 815
 182816    internal Fixed64 CompoundLocalRotation => _compoundLocalRotation;
 817
 818    /// <summary>Rotates a planar vector and removes fixed-point epsilon residue.</summary>
 819    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 820    protected static Vector2d Rotate(Vector2d value, Fixed64 radians)
 821    {
 5679822        if (radians == Fixed64.Zero)
 4071823            return value;
 824
 1608825        return ClampNearZero(Vector2d.Rotate(value, radians));
 826    }
 827
 828    /// <summary>Replaces vector components within fixed-point epsilon of zero.</summary>
 829    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 830    protected static Vector2d ClampNearZero(Vector2d value)
 831    {
 1610832        Fixed64 x = value.X.Abs() <= Fixed64.Epsilon ? Fixed64.Zero : value.X;
 1610833        Fixed64 y = value.Y.Abs() <= Fixed64.Epsilon ? Fixed64.Zero : value.Y;
 1610834        return new Vector2d(x, y);
 835    }
 836
 837    private void SetTrigger(bool value)
 838    {
 156839        if (_isTrigger == value)
 36840            return;
 841
 120842        if (value)
 107843            ThrowIfCannotEnableTrigger(nameof(IsTrigger));
 844
 119845        _isTrigger = value;
 119846        StaticSurface?.Invalidate(this);
 14847    }
 848
 849    internal void MarkContactDependencyChanged(bool notifySurface = true, bool surfaceNeighborsChanged = true)
 850    {
 7384851        LSCollider2D owner = this;
 7408852        while (owner._compoundOwner != null)
 24853            owner = owner._compoundOwner;
 7384854        owner.ContactDependencyVersion++;
 9975855        if (notifySurface) owner.StaticSurface?.Invalidate(owner, includeNeighbors: surfaceNeighborsChanged);
 4869856    }
 857
 858    private void ThrowIfCannotEnableTrigger(string operation)
 859    {
 107860        ChronicleGuard.ThrowIfArgument(
 107861            _body != null,
 107862            operation,
 107863            "2D trigger colliders must be initialized without a SolidBody2D. Use InitializeWithNoBody for trigger volume
 106864        ChronicleGuard.ThrowIfArgument(
 106865            _compoundOwner != null,
 106866            operation,
 106867            "2D compound collider parts are not trigger identities. Set IsTrigger on the owning compound collider.");
 106868    }
 869
 870    private void ThrowIfTriggerWouldAttachToBody(string operation)
 871    {
 6474872        ChronicleGuard.ThrowIfArgument(
 6474873            _isTrigger,
 6474874            operation,
 6474875            "2D trigger colliders must be initialized without a SolidBody2D. Use InitializeWithNoBody for trigger volume
 6473876    }
 877
 878    private void ThrowIfLoadedTriggerHasBody(string operation)
 879    {
 110880        ChronicleGuard.ThrowIfArgument(
 110881            _isTrigger && _body != null,
 110882            operation,
 110883            "Loaded 2D trigger state is invalid for a collider attached to a SolidBody2D.");
 108884    }
 885
 886    /// <inheritdoc/>
 887    public void RecordData(IChronicler chronicler)
 888    {
 197889        RecordValues.Look(chronicler, ref _isActive, "Active", true);
 197890        RecordValues.Look(chronicler, ref _isTrigger, "IsTrigger", false);
 197891        RecordValues.Look(chronicler, ref _layer, "Layer", new());
 197892        RecordValues.Look(chronicler, ref _ignoredCollisionLayers, "IgnoredCollisionLayers", PhysicsLayerMask.None);
 197893        RecordValues.Look(chronicler, ref _material, "Material", PhysicsMaterial.Default);
 197894        RecordValues.Look(chronicler, ref _localOffset, "LocalOffset", Vector2d.Zero);
 197895        RecordValues.Look(chronicler, ref _mixedHalfThicknessOverride, "MixedHalfThicknessOverride");
 197896        RecordShapeData(chronicler);
 897
 195898        if (chronicler.Mode == SerializationMode.Loading)
 899        {
 112900            ChronicleGuard.ThrowIfArgument(_mixedHalfThicknessOverride <= Fixed64.Zero,
 112901                nameof(MixedHalfThicknessOverride), "2D mixed half-thickness override must be greater than zero.");
 110902            ThrowIfLoadedTriggerHasBody(nameof(IsTrigger));
 108903            ApplyLoadedState();
 904        }
 188905    }
 906
 907    /// <summary>Records derived authored shape data.</summary>
 1908    protected virtual void RecordShapeData(IChronicler chronicler) { }
 909
 910    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 433692911    internal bool IgnoresCollisionLayer(PhysicsLayer layer) => _ignoredCollisionLayers.Includes(layer);
 912
 913    private void ApplyLoadedState()
 914    {
 108915        _runtimeShapeState.MarkDirty();
 108916        if (_context == null)
 14917            return;
 918
 94919        RebuildRuntimeShapeState();
 920
 91921        if (_id < 0)
 1922            return;
 923
 90924        if (!_isActive)
 925        {
 10926            if (IsPartitioned)
 6927                _context.Collisions2D.ClearPartitionedCollider(this, force: true);
 10928            MarkUnpartitioned();
 10929            ClearPartitionCoordinates();
 930
 10931            if (IsMixedPartitioned)
 2932                _context.MixedCollisions.ClearPartitioned2DCollider(this, force: true);
 10933            MarkMixedUnpartitioned();
 10934            ClearMixedPartitionCoordinates();
 10935            return;
 936        }
 937
 80938        _context.Collisions2D.RefreshColliderPartition(this);
 80939        if (_context.Settings.RuntimeMode.RunsMixedContacts())
 9940            _context.MixedCollisions.Refresh2DColliderPartition(this);
 80941    }
 942}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.Geometry.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.Geometry.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using System.Runtime.CompilerServices;
 10using FixedMathSharp;
 11using FixedMathSharp.Geometry;
 12
 13namespace Gravitas.Colliders;
 14
 15/// <content>
 16/// Resolves planar pose, scale, offsets, and bounds for standalone colliders and compound parts.
 17/// </content>
 18public abstract partial class LSCollider2D
 19{
 20    /// <summary>Gets the planar runtime position.</summary>
 570521    public Vector2d Position => _compoundOwner != null
 570522        ? _compoundOwner.Center
 570523        : ResolveStandalonePosition();
 24
 25    /// <summary>Gets the committed planar rotation in radians.</summary>
 26    public Fixed64 Rotation
 27    {
 28        get
 29        {
 21518230            if (_hasCommittedShape)
 21033831                return _committedRotation;
 484432            if (_compoundOwner == null)
 466533                return ResolveStandaloneRotation();
 34
 17935            return PlanarRotation.Combine(
 17936                _compoundOwner.Rotation,
 17937                _compoundLocalRotation);
 38        }
 39    }
 40
 41    /// <summary>Gets the combined planar owner and compound-part scale.</summary>
 42    public virtual Vector2d LocalScale
 43    {
 44        get
 45        {
 1246            bool representable = TryGetLocalScale(out Vector2d scale);
 1247            ChronicleGuard.ThrowIfTrue(
 1248                !representable,
 1249                nameof(LocalScale),
 1250                "The combined 2D collider scale is outside the Fixed64 coordinate domain.");
 1151            return scale;
 52        }
 53    }
 54
 55    /// <summary>
 56    /// Attempts to materialize the combined owner and compound-part scale.
 57    /// Shape preparation retains those factors separately and does not require
 58    /// their product to be representable.
 59    /// </summary>
 60    public bool TryGetLocalScale(out Vector2d scale)
 61    {
 1462        GetCurrentScaleFactors(
 1463            out Vector2d ownerScale,
 1464            out Vector2d partScale);
 65
 1466        bool representable = Fixed64.TryMultiplyDivide(
 1467                ownerScale.X,
 1468                partScale.X,
 1469                Fixed64.One,
 1470                out Fixed64 x)
 1471            & Fixed64.TryMultiplyDivide(
 1472                ownerScale.Y,
 1473                partScale.Y,
 1474                Fixed64.One,
 1475                out Fixed64 y);
 1476        scale = representable ? new Vector2d(x, y) : default;
 1477        return representable;
 78    }
 79
 80    /// <summary>
 81    /// Gets the component-scaled local offset.
 82    /// </summary>
 83    /// <exception cref="InvalidOperationException">
 84    /// The scaled offset itself is outside the Fixed64 coordinate domain. The
 85    /// collider may still have a representable world center through exact
 86    /// transform cancellation.
 87    /// </exception>
 1188    public Vector2d ScaledLocalOffset => GetCurrentScaledOffset();
 89
 90    /// <summary>
 91    /// Attempts to materialize the component-scaled local offset independently
 92    /// from the collider's complete world transform.
 93    /// </summary>
 94    public bool TryGetScaledLocalOffset(out Vector2d scaledLocalOffset) =>
 395        TryGetCurrentScaledOffset(out scaledLocalOffset);
 96
 97    /// <summary>Gets the collider center in planar world coordinates.</summary>
 41748498    public Vector2d Center => _hasCommittedShape
 41748499        ? _committedCenter
 417484100        : GetUncommittedCenter();
 101
 102    /// <summary>Gets whether a planar world-space point lies inside this collider.</summary>
 103    public abstract bool ContainsPoint(Vector2d point);
 104
 105    /// <summary>Gets the closest representable point on this collider to a planar world-space point.</summary>
 106    public abstract Vector2d GetClosestPoint(Vector2d point);
 107
 108    /// <summary>Gets the farthest representable point along a planar world-space direction.</summary>
 109    public abstract Vector2d GetSupportPoint(Vector2d direction);
 110
 111    internal int VertexCount
 112    {
 113        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 223557114        get => this is IConvexVertexSource2D source ? source.VertexCount : 0;
 115    }
 116
 117    internal Fixed64 ConvexRotation =>
 211524118        ((IConvexVertexSource2D)this).Rotation;
 119
 120    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 121    internal Vector2d GetScaledLocalVertexUnchecked(int index) =>
 246862122        ((IConvexVertexSource2D)this).GetScaledLocalVertexUnchecked(index);
 123
 124    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 125    internal FixedPointAnchor2d GetConvexSupportAnchor(Vector2d direction) =>
 7126        ((IConvexVertexSource2D)this).GetSupportAnchor(direction);
 127
 128    internal bool TryGetClosestBoundaryAnchor(
 129        Vector2d point,
 130        out FixedPointAnchor2d boundary)
 131    {
 3582132        switch (this)
 133        {
 134            case LSCircleCollider2D circle:
 930135                boundary = GetRoundBoundaryAnchor(
 930136                    circle.Center,
 930137                    circle.Rotation,
 930138                    Vector2d.Forward,
 930139                    Fixed64.Zero,
 930140                    circle.ScaledRadius,
 930141                    point,
 930142                    Vector2d.Right);
 930143                return true;
 144            case LSCapsuleCollider2D capsule:
 95145                boundary = GetRoundBoundaryAnchor(
 95146                    capsule.Center,
 95147                    capsule.Rotation,
 95148                    Vector2d.Forward,
 95149                    capsule.AxisLength,
 95150                    capsule.ScaledRadius,
 95151                    point,
 95152                    capsule.GetNormalFromCenteredAxis(point));
 95153                return true;
 154            case LSAABBoxCollider2D box:
 1069155                return TryGetAABoxBoundaryAnchor(
 1069156                    box,
 1069157                    point,
 1069158                    out boundary);
 159            case LSPolygonCollider2D polygon:
 1268160                return TryGetConvexBoundaryAnchor(
 1268161                    polygon.Center,
 1268162                    polygon.Rotation,
 1268163                    polygon.ScaledLocalVertices,
 1268164                    point,
 1268165                    out boundary);
 166            case LSCompoundCollider2D compound:
 219167                return TryGetCompoundBoundaryAnchor(
 219168                    compound,
 219169                    point,
 219170                    out boundary);
 171            default:
 1172                boundary = default;
 1173                return false;
 174        }
 175    }
 176
 177    internal bool TryGetClosestBoundaryAnchor(
 178        Vector2d point,
 179        out FixedPointAnchor2d boundary,
 180        out Fixed64 distance)
 181    {
 1238182        if (TryGetClosestBoundaryAnchor(
 1238183                point,
 1238184                out boundary)
 1238185            && TryGetAnchorDistance(
 1238186                point,
 1238187                boundary,
 1238188                out distance))
 189        {
 1231190            return true;
 191        }
 192
 7193        boundary = default;
 7194        distance = default;
 7195        return false;
 196    }
 197
 198    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 199    internal bool TryGetVertex(int index, out Vector2d vertex) =>
 288200        Vector2d.TryTransformPoint(
 288201            Center,
 288202            GetScaledLocalVertexUnchecked(index),
 288203            ConvexRotation,
 288204            out vertex);
 205
 206    private static FixedPointAnchor2d GetRoundBoundaryAnchor(
 207        Vector2d center,
 208        Fixed64 rotation,
 209        Vector2d localAxis,
 210        Fixed64 axisLength,
 211        Fixed64 radius,
 212        Vector2d point,
 213        Vector2d fallbackNormal)
 214    {
 1025215        Vector2d normal = FixedSegment2d.GetDirectionFromCenteredAxis(
 1025216            point,
 1025217            center,
 1025218            rotation,
 1025219            axisLength);
 1025220        if (normal == Vector2d.Zero)
 118221            normal = fallbackNormal;
 222
 1025223        Vector2d localNormal =
 1025224            Vector2d.Rotate(normal, -rotation).Normalized;
 1025225        return FixedSegment2d.GetSurfaceAnchorOnCenteredCapsule(
 1025226            point,
 1025227            center,
 1025228            rotation,
 1025229            localAxis,
 1025230            axisLength,
 1025231            radius,
 1025232            localNormal);
 233    }
 234
 235    private static bool TryGetAABoxBoundaryAnchor(
 236        LSAABBoxCollider2D box,
 237        Vector2d point,
 238        out FixedPointAnchor2d boundary)
 239    {
 1069240        Vector2d halfExtents = box.ScaledHalfExtents;
 1069241        Span<Vector2d> offsets = stackalloc Vector2d[4];
 1069242        offsets[0] = new Vector2d(-halfExtents.X, halfExtents.Y);
 1069243        offsets[1] = new Vector2d(-halfExtents.X, -halfExtents.Y);
 1069244        offsets[2] = new Vector2d(halfExtents.X, -halfExtents.Y);
 1069245        offsets[3] = new Vector2d(halfExtents.X, halfExtents.Y);
 1069246        return TryGetConvexBoundaryAnchor(
 1069247            box.Center,
 1069248            Fixed64.Zero,
 1069249            offsets,
 1069250            point,
 1069251            out boundary);
 252    }
 253
 254    private static bool TryGetConvexBoundaryAnchor(
 255        Vector2d center,
 256        Fixed64 rotation,
 257        ReadOnlySpan<Vector2d> offsets,
 258        Vector2d point,
 259        out FixedPointAnchor2d boundary)
 260    {
 2337261        boundary =
 2337262            FixedConvex2dRelations.GetClosestPointAnchor(
 2337263                point,
 2337264                center,
 2337265                rotation,
 2337266                offsets);
 2337267        return true;
 268    }
 269
 270    private static bool TryGetCompoundBoundaryAnchor(
 271        LSCompoundCollider2D compound,
 272        Vector2d point,
 273        out FixedPointAnchor2d boundary)
 274    {
 219275        var reference = new FixedPointAnchor2d(
 219276            point,
 219277            Fixed64.Zero,
 219278            Vector2d.Zero);
 219279        if (TryGetCompoundBoundaryAnchor(
 219280                compound,
 219281                point,
 219282                reference,
 219283                containingPartsOnly: true,
 219284                out boundary))
 285        {
 2286            return true;
 287        }
 288
 217289        return TryGetCompoundBoundaryAnchor(
 217290            compound,
 217291            point,
 217292            reference,
 217293            containingPartsOnly: false,
 217294            out boundary);
 295    }
 296
 297    private static bool TryGetCompoundBoundaryAnchor(
 298        LSCompoundCollider2D compound,
 299        Vector2d point,
 300        in FixedPointAnchor2d reference,
 301        bool containingPartsOnly,
 302        out FixedPointAnchor2d boundary)
 303    {
 436304        boundary = default;
 436305        bool found = false;
 2606306        for (int i = 0; i < compound.PartCount; i++)
 307        {
 867308            LSCollider2D part = compound.GetPartCollider(i);
 867309            if (containingPartsOnly && !part.ContainsPoint(point))
 310                continue;
 311
 312            // Compound definitions materialize only built-in semantic shapes.
 434313            _ = part.TryGetClosestBoundaryAnchor(
 434314                point,
 434315                out FixedPointAnchor2d candidate);
 434316            if (found
 434317                && reference.CompareSquaredDistance(
 434318                    candidate,
 434319                    boundary) >= 0)
 320            {
 321                continue;
 322            }
 323
 431324            boundary = candidate;
 431325            found = true;
 326        }
 327
 436328        return found;
 329    }
 330
 331    private static bool TryGetAnchorDistance(
 332        Vector2d point,
 333        in FixedPointAnchor2d anchor,
 334        out Fixed64 distance)
 335    {
 1238336        if (anchor.TryGetOffsetFrom(
 1238337                new FixedPointAnchor2d(
 1238338                    point,
 1238339                    Fixed64.Zero,
 1238340                    Vector2d.Zero),
 1238341                out Vector2d difference)
 1238342            && Vector2d.TryGetMagnitude(difference, out distance))
 343        {
 1231344            return true;
 345        }
 346
 7347        distance = default;
 7348        return false;
 349    }
 350
 351    /// <summary>
 352    /// Calculates the body-local center of mass implied by this 2D collider's current shape state.
 353    /// </summary>
 354    public virtual Vector2d CalculateLocalCenterOfMassOffset()
 355    {
 30554356        ExactMassPoint2D point = CalculateLocalMassPoint();
 30553357        ChronicleGuard.ThrowIfTrue(
 30553358            !point.TryGetPoint(out Vector2d center),
 30553359            nameof(CalculateLocalCenterOfMassOffset),
 30553360            "The 2D collider's body-local center of mass is outside the Fixed64 coordinate domain.");
 30550361        return center;
 362    }
 363
 364    internal virtual ExactMassPoint2D CalculateLocalMassPoint() =>
 33016365        TransformRelativeMassPropertyPointExact(Vector2d.Zero);
 366
 367    internal virtual ExactMassPoint2D CalculatePreparedLocalMassPoint() =>
 805368        TransformPreparedPartMassPropertyPointExact(Vector2d.Zero);
 369
 370    /// <summary>
 371    /// Calculates the scalar moment of inertia about a requested body-local reference point.
 372    /// </summary>
 373    public virtual Fixed64 CalculateMomentOfInertia(
 374        Fixed64 mass,
 375        Vector2d localReferencePoint)
 376    {
 16320377        if (mass <= Fixed64.Zero)
 3378            return Fixed64.Zero;
 379
 16317380        Fixed64 centerMoment =
 16317381            CalculateCenterOfMassMoment(mass);
 16317382        ExactMassPoint2D massPoint = CalculateLocalMassPoint();
 16317383        if (massPoint.TryAddParallelAxisMoment(
 16317384                centerMoment,
 16317385                mass,
 16317386                localReferencePoint,
 16317387                out Fixed64 moment))
 388        {
 16306389            return moment;
 390        }
 391
 11392        if (!massPoint.TryGetPoint(out Vector2d center))
 393        {
 1394            ChronicleGuard.ThrowIfTrue(
 1395                true,
 1396                nameof(localReferencePoint),
 1397                "The requested moment of inertia is outside the Fixed64 scalar domain.");
 398        }
 399
 10400        Vector2d delta = localReferencePoint - center;
 10401        return centerMoment
 10402            + mass * delta.MagnitudeSquared;
 403    }
 404
 405    internal abstract Fixed64 CalculateCenterOfMassMoment(Fixed64 mass);
 406
 407    internal abstract ExactMassWeight CalculateAreaForMassProperties();
 408
 409    internal abstract ExactMassWeight CalculatePreparedAreaForMassProperties();
 410
 411    /// <summary>Updates derived material state after <see cref="Material"/> changes.</summary>
 2386412    protected virtual void OnMaterialChanged() { }
 413
 414    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 415    internal ExactMassPoint2D TransformPreparedPartMassPropertyPointExact(
 416        Vector2d partRelativePoint) =>
 417        // Prepared mass points are consumed only by the compound's leaf reduction.
 1787418        ExactMassPoint2D.CreateScaledLocalComposition(
 1787419                _compoundOwner!._preparedSnapshot.LocalOffset,
 1787420                _preparedSnapshot.OwnerScale,
 1787421                _preparedSnapshot.LocalOffset,
 1787422                _preparedSnapshot.OwnerScale,
 1787423                partRelativePoint,
 1787424                _preparedCompoundLocalRotation);
 425
 426    /// <summary>Marks derived runtime shape state for deterministic rebuilding.</summary>
 427    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 428    protected void MarkShapeDirty()
 429    {
 12131430        _shapeVersion++;
 12131431        _runtimeShapeState.MarkDirty();
 12131432        if (_compoundOwner != null)
 433        {
 4434            _compoundOwner.MarkShapeDirty();
 4435            return;
 436        }
 437
 12127438        _body?.Wake();
 60439    }
 440
 441    private bool RebuildRuntimeShapeState(bool geometryOnly = false, bool skipUnchangedMassProperties = false)
 442    {
 81617443        ColliderShapeSnapshot2D snapshot = CaptureShapeSnapshot();
 444        // Preserve pose-only publication and solver-cache lifetime at the normal
 445        // lifecycle boundary; only pending physical geometry must precede CCD.
 81614446        if (geometryOnly && !_runtimeShapeState.IsDirty && snapshot.OwnerScale == _committedOwnerScale
 81614447            && snapshot.MixedSlabCenterY == _mixedSlabCenterY && snapshot.MixedHalfThickness == _mixedHalfThickness)
 15656448            return false;
 65958449        if (!_runtimeShapeState.ShouldRebuild(snapshot))
 40752450            return false;
 451
 452        // Integration and solver correction publish dynamic pose without
 453        // changing the accepted contact dependency. Authored geometry does.
 25206454        bool contactDependencyChanged = _runtimeShapeState.IsDirty
 25206455            || snapshot.OwnerScale != _committedOwnerScale
 25206456            || snapshot.MixedSlabCenterY != _mixedSlabCenterY
 25206457            || snapshot.MixedHalfThickness != _mixedHalfThickness
 25206458            || _body?.IsDynamic != true;
 25206459        PrepareRuntimeShape(
 25206460            snapshot,
 25206461            includeBodyAttachment:
 25206462                _body != null);
 25201463        PublishPreparedShape(contactDependencyChanged);
 25201464        if (!skipUnchangedMassProperties || contactDependencyChanged)
 21355465            _body?.RefreshMassPropertiesFromColliderShape();
 25201466        return true;
 467    }
 468
 469    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 470    private Vector2d ResolveStandalonePosition() =>
 5709471        _body?.Position
 5709472        ?? _agent?.Transform.WorldPositionXZ
 5709473        ?? Vector2d.Zero;
 474
 475    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 476    private Fixed64 ResolveStandaloneRotation() =>
 4673477        _body?.Rotation ?? ResolveAgentRotation();
 478}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.GeometryAdmission.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.GeometryAdmission.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using FixedMathSharp;
 9
 10namespace Gravitas.Colliders;
 11
 12/// <content>Preflights planar mutations against the complete owner envelope before waking.</content>
 13public abstract partial class LSCollider2D
 14{
 15    private protected void ValidateGeometryMutation(Vector2d? offset = null,
 16        Fixed64? radius = null, Fixed64? height = null, Vector2d? size = null,
 17        Fixed64? halfThickness = null, PhysicsRuntimeMode? runtimeMode = null)
 18    {
 985019        LSCollider2D root = _compoundOwner ?? this;
 985020        if (root._agent == null)
 971121            return;
 22
 13923        Vector2d ownerScale = ColliderScalePolicy.CapturePlanar(root._agent.Transform,
 13924            out _, out _, captureRotation: false);
 13925        Vector2d partScale = _compoundOwner == null ? Vector2d.One : _compoundLocalScale;
 13926        Fixed64 intrinsic = this is LSCompoundCollider2D
 13927            ? Fixed64.Zero : GetCandidateGeometryReach(ownerScale, partScale, radius, height, size);
 13928        Fixed64 reach = root is LSCompoundCollider2D compound
 13929            ? compound.GetMutationGeometryReach(this, ownerScale, intrinsic, offset ?? _localOffset)
 13930            : intrinsic;
 13931        if (root._body != null)
 7732            reach = ColliderGeometryPolicy.Add(ColliderGeometryPolicy.Attachment(
 7733                ReferenceEquals(root, this) ? offset ?? _localOffset : root._localOffset, ownerScale), reach);
 13934        if ((runtimeMode ?? root._context!.Settings.RuntimeMode).RunsMixedContacts())
 35        {
 7536            Fixed64 thickness = ReferenceEquals(root, this) && halfThickness.HasValue
 7537                ? halfThickness.Value
 7538                : root._mixedHalfThicknessOverride ?? root._context!.Settings.Mixed2DHalfThickness;
 7539            reach = ColliderGeometryPolicy.Mixed(reach, thickness);
 40        }
 13941        ColliderGeometryPolicy.ValidateReach(reach, nameof(intrinsic));
 12042    }
 43
 44    internal void ValidateMixedGeometry(Fixed64 defaultHalfThickness) =>
 1145        ValidateGeometryMutation(halfThickness: _mixedHalfThicknessOverride ?? defaultHalfThickness,
 1146            runtimeMode: PhysicsRuntimeMode.Mixed);
 47
 48    internal Fixed64 GetCandidateGeometryReach(Vector2d ownerScale, Vector2d partScale,
 49        Fixed64? radius = null, Fixed64? height = null, Vector2d? size = null)
 50    {
 13951        switch (this)
 52        {
 53            case LSCircleCollider2D circle:
 9154                Fixed64 r = radius ?? circle.Radius;
 9155                return FixedMath.Max(ColliderScalePolicy.ScalePositive(r, ownerScale.X, partScale.X),
 9156                    ColliderScalePolicy.ScalePositive(r, ownerScale.Y, partScale.Y));
 57            case LSCapsuleCollider2D capsule:
 1158                LSCapsuleCollider2D.GetScaledGeometry(radius ?? capsule.Radius, height ?? capsule.Height,
 1159                    ownerScale, partScale, out Fixed64 scaledRadius, out Fixed64 length);
 1160                return ColliderGeometryPolicy.Capsule(scaledRadius, length);
 61            case LSAABBoxCollider2D box:
 3162                return ColliderGeometryPolicy.Magnitude(ColliderScalePolicy.ScalePositive(
 3163                    size ?? box.Size, ownerScale, partScale, Fixed64.Two));
 64            case LSPolygonCollider2D polygon:
 565                return polygon.GetCandidateGeometryReach(ownerScale, partScale);
 66            default:
 167                return Fixed64.MaxValue;
 68        }
 69    }
 70}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.Hierarchy.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.Hierarchy.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using SwiftCollections;
 9
 10namespace Gravitas.Colliders;
 11
 12/// <content>Manages planar collider parent and child links used for hierarchy filtering.</content>
 13public abstract partial class LSCollider2D
 14{
 15    private void ClearChildParentReferences()
 16    {
 50417        SwiftHashSet<ulong>? children = _hierarchyState.Children;
 50418        if (children == null || _context == null)
 50219            return;
 20
 821        foreach (ulong childPackedKey in children)
 22        {
 223            ColliderHierarchyKey childKey = ColliderHierarchyKey.FromPacked(childPackedKey);
 224            if (((IColliderHierarchyNode)this).TryGetHierarchyColliderByKey(
 225                    childKey,
 226                    out IColliderHierarchyNode? child))
 27            {
 228                child!.ClearParentReference();
 29            }
 30        }
 31
 232        _hierarchyState.ClearChildren();
 233    }
 34
 35    void IColliderHierarchyNode.AddChild(ColliderHierarchyKey key)
 36    {
 2737        ThrowIfCompoundPartLifecycle(nameof(IColliderHierarchyNode.AddChild));
 2738        _hierarchyState.AddChild(key);
 2739    }
 40
 41    void IColliderHierarchyNode.RemoveChild(ColliderHierarchyKey key)
 42    {
 343        ThrowIfCompoundPartLifecycle(nameof(IColliderHierarchyNode.RemoveChild));
 344        _hierarchyState.RemoveChild(key);
 345    }
 46
 47    void IColliderHierarchyNode.ClearParentReference()
 48    {
 649        if (_hierarchyState.ClearParentReference())
 50        {
 551            MarkContactDependencyChanged();
 552            _body?.Wake();
 53        }
 454    }
 55
 56    bool IColliderHierarchyNode.TryGetHierarchyColliderByKey(
 57        ColliderHierarchyKey key,
 58        out IColliderHierarchyNode? collider)
 59    {
 760        collider = null;
 761        if (!key.IsValid || _context == null)
 162            return false;
 63
 664        if (key.Is2D
 665            && _context.Physics2D.TryGetColliderById(
 666                key.Id,
 667                out LSCollider2D? collider2D))
 68        {
 269            collider = collider2D;
 270            return true;
 71        }
 72
 473        if (key.Is3D
 474            && _context.Physics.TryGetColliderById(
 475                key.Id,
 476                out LSCollider? collider3D))
 77        {
 278            collider = collider3D;
 279            return true;
 80        }
 81
 282        return false;
 83    }
 84}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.Notifications.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.Notifications.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8namespace Gravitas.Colliders;
 9
 10/// <content>Dispatches planar and mixed contact notifications to collider subscribers.</content>
 11public abstract partial class LSCollider2D
 12{
 13    internal void NotifyContact(LSCollider2D other, bool isColliding, bool isChanged) =>
 2114        NotifyContact(
 2115            other,
 2116            other.Body,
 2117            isColliding,
 2118            isChanged,
 2119            allowInactive: false,
 2120            new ColliderLifetimeToken2D(this),
 2121            new ColliderLifetimeToken2D(other),
 2122            IsTrigger || other.IsTrigger,
 2123            ColliderTriggerEventPolicy.ShouldRaise(this, other));
 24
 25    internal void NotifyContact(
 26        LSCollider2D other,
 27        SolidBody2D? otherBody,
 28        bool isColliding,
 29        bool isChanged,
 30        bool allowInactive,
 31        in ColliderLifetimeToken2D registration,
 32        in ColliderLifetimeToken2D otherRegistration,
 33        bool isTriggerPair,
 34        bool shouldRaiseTrigger)
 35    {
 1222036        if (isColliding
 1222037            ? !registration.IsActive || !otherRegistration.IsActive
 1222038            : allowInactive ? !registration.IsCurrentLifetime : !registration.IsActive)
 39        {
 440            return;
 41        }
 42
 1221643        if (isColliding)
 44        {
 1185645            if (isTriggerPair)
 46            {
 17247                if (shouldRaiseTrigger)
 48                {
 16949                    if (isChanged)
 50                    {
 8451                        OnTriggerEnter?.Invoke(other);
 8452                        if (!registration.IsActive || !otherRegistration.IsActive)
 253                            return;
 54                    }
 55
 16756                    OnTriggerStay?.Invoke(other);
 57                }
 58
 2359                return;
 60            }
 61
 1168462            if (isChanged && otherBody != null)
 63            {
 85764                OnContactEnter?.Invoke(otherBody);
 85665                if (!registration.IsActive || !otherRegistration.IsActive)
 966                    return;
 67            }
 68
 1167469            if (otherBody != null)
 899470                OnContact?.Invoke(otherBody);
 285471            return;
 72        }
 73
 36074        if (!isChanged)
 175            return;
 76
 35977        if (isTriggerPair)
 78        {
 4079            if (shouldRaiseTrigger)
 3880                OnTriggerExit?.Invoke(other);
 81
 1882            return;
 83        }
 84
 31985        if (otherBody != null)
 23986            OnContactExit?.Invoke(otherBody);
 13787    }
 88
 89    internal void NotifyMixedContact(LSCollider other, bool isColliding, bool isChanged, bool isTriggerPair) =>
 1590        NotifyMixedContact(
 1591            other,
 1592            isColliding,
 1593            isChanged,
 1594            isTriggerPair,
 1595            allowInactive: false,
 1596            new ColliderLifetimeToken2D(this),
 1597            new ColliderLifetimeToken(other),
 1598            ColliderTriggerEventPolicy.ShouldRaise(other, this));
 99
 100    internal void NotifyMixedContact(
 101        LSCollider other,
 102        bool isColliding,
 103        bool isChanged,
 104        bool isTriggerPair,
 105        bool allowInactive,
 106        in ColliderLifetimeToken2D registration,
 107        in ColliderLifetimeToken otherRegistration,
 108        bool shouldRaiseTrigger)
 109    {
 16281110        if (isColliding
 16281111            ? !registration.IsActive || !otherRegistration.IsActive
 16281112            : allowInactive
 16281113                ? !registration.IsCurrentLifetime || !otherRegistration.IsCurrentLifetime
 16281114                : !registration.IsActive)
 115        {
 5116            return;
 117        }
 118
 16276119        if (isColliding)
 120        {
 16097121            if (isTriggerPair)
 122            {
 131123                if (shouldRaiseTrigger)
 124                {
 126125                    if (isChanged)
 126                    {
 51127                        OnMixedTriggerEnter?.Invoke(other);
 51128                        if (!registration.IsActive || !otherRegistration.IsActive)
 2129                            return;
 130                    }
 131
 124132                    OnMixedTriggerStay?.Invoke(other);
 133                }
 134
 17135                return;
 136            }
 137
 15966138            if (isChanged)
 139            {
 624140                OnMixedContactEnter?.Invoke(other);
 624141                if (!registration.IsActive || !otherRegistration.IsActive)
 3142                    return;
 143            }
 144
 15963145            OnMixedContact?.Invoke(other);
 123146            return;
 147        }
 148
 179149        if (!isChanged)
 1150            return;
 151
 178152        if (isTriggerPair)
 153        {
 15154            if (shouldRaiseTrigger)
 13155                OnMixedTriggerExit?.Invoke(other);
 156
 13157            return;
 158        }
 159
 163160        OnMixedContactExit?.Invoke(other);
 80161    }
 162}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.ReplayHash.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.ReplayHash.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using Chronicler.Hashing;
 10using FixedMathSharp.Chronicler;
 11using Gravitas.Materials;
 12
 13namespace Gravitas.Colliders;
 14
 15/// <content>Writes authoritative planar collider state and hierarchy references in replay order.</content>
 16public abstract partial class LSCollider2D
 17{
 18    internal void ContributeReplayHash(
 19        ref ChronicleHashWriter writer,
 20        GravitasReplayHashMode mode)
 21    {
 568222        writer.WriteSection("collider.2d", 4);
 568223        writer.WriteInt32(_replayOrdinal);
 568224        writer.WriteBool(_isActive);
 568225        writer.WriteBool(_isTrigger);
 568226        writer.WritePhysicsLayer(_layer);
 568227        writer.WritePhysicsLayerMask(_ignoredCollisionLayers);
 568228        WriteMaterial(ref writer, _material);
 568229        writer.WriteEnum(Shape);
 568230        writer.WriteInt32(Priority);
 568231        writer.WriteVector2d(_localOffset);
 568232        writer.WriteBool(_mixedHalfThicknessOverride.HasValue);
 568233        if (_mixedHalfThicknessOverride.HasValue)
 10334            writer.WriteFixed64(_mixedHalfThicknessOverride.Value);
 568235        writer.WriteVector2d(Position);
 568236        writer.WriteFixed64(Rotation);
 568237        writer.WriteVector2d(_committedOwnerScale);
 568238        writer.WriteVector2d(_committedPartScale);
 568239        writer.WriteVector2d(Center);
 568240        writer.WriteFixed64(_mixedHalfThickness);
 568241        writer.WriteFixed64(_mixedSlabCenterY);
 568242        writer.WriteInt32(HierarchyChildCount);
 568243        WriteReplayHierarchyKey(ref writer, HierarchyKey);
 568244        WriteReplayHierarchyKey(ref writer, ParentKey);
 568245        WriteReplayHierarchyKey(ref writer, TopParentKey);
 46
 568247        ContributeShapeReplayHash(ref writer);
 48
 568249        if (mode != GravitasReplayHashMode.AuthoritativeWithSolverCaches)
 355350            return;
 51
 212952        writer.WriteSection("collider.2d.caches", 1);
 212953        writer.WriteUInt32(RuntimeShapeVersion);
 212954        writer.WriteUInt32(_shapeVersion);
 212955        writer.WriteInt32(_serviceIndex);
 212956        writer.WriteBool(IsPartitioned);
 212957        writer.WriteBool(IsMixedPartitioned);
 212958        writer.WriteInt32(PartitionKind);
 212959        writer.WriteInt32(MixedPartitionKind);
 212960        writer.WriteUInt32(BroadPhaseVersion);
 212961        writer.WriteUInt32(RaycastVersion);
 212962        writer.WriteUInt32(CircleQueryVersion);
 212963        writer.WriteFixed64(MinX);
 212964        writer.WriteFixed64(MinY);
 212965        writer.WriteFixed64(MaxX);
 212966        writer.WriteFixed64(MaxY);
 212967        writer.WriteVector3d(_mixedBounds3D.Min);
 212968        writer.WriteVector3d(_mixedBounds3D.Max);
 212969        writer.WriteInt32(CollisionPairCount);
 212970        writer.WriteInt32(CollisionPairHolderCount);
 212971    }
 72
 73    private void ContributeShapeReplayHash(ref ChronicleHashWriter writer)
 74    {
 568275        writer.WriteSection("collider.2d.shape", 3);
 568276        switch (this)
 77        {
 78            case LSCircleCollider2D circle:
 131979                writer.WriteFixed64(circle.Radius);
 131980                writer.WriteFixed64(circle.ScaledRadius);
 131981                break;
 82
 83            case LSAABBoxCollider2D box:
 420884                writer.WriteVector2d(box.Size);
 420885                writer.WriteVector2d(box.ScaledHalfExtents);
 420886                break;
 87
 88            case LSCapsuleCollider2D capsule:
 8689                writer.WriteFixed64(capsule.Radius);
 8690                writer.WriteFixed64(capsule.Height);
 8691                writer.WriteVector2d(capsule.Center);
 8692                writer.WriteFixed64(capsule.AxisLength);
 8693                writer.WriteFixed64(capsule.ScaledRadius);
 8694                break;
 95
 96            case LSCompoundCollider2D compound:
 5597                writer.WriteInt32(compound.PartCount);
 5598                ReadOnlySpan<CompoundColliderPart2D> parts = compound.Parts;
 29499                for (int i = 0; i < parts.Length; i++)
 92100                    ContributeCompoundPartReplayHash(ref writer, parts[i]);
 101                break;
 102        }
 103
 5682104        writer.WriteInt32(VertexCount);
 45136105        for (int i = 0; i < VertexCount; i++)
 16886106            writer.WriteVector2d(GetScaledLocalVertexUnchecked(i));
 5682107    }
 108
 109    private void WriteReplayHierarchyKey(ref ChronicleHashWriter writer, ColliderHierarchyKey key)
 110    {
 17046111        if (!TryResolveReplayHierarchyOrdinal(key, out int replayOrdinal))
 112        {
 11352113            writer.WriteUInt64(0UL);
 11352114            return;
 115        }
 116
 5694117        writer.WriteUInt64(((ulong)key.Dimension << 32) | (uint)replayOrdinal);
 5694118    }
 119
 120    private bool TryResolveReplayHierarchyOrdinal(ColliderHierarchyKey key, out int replayOrdinal)
 121    {
 17046122        replayOrdinal = -1;
 17046123        if (!key.IsValid || _context == null)
 11352124            return false;
 125
 5694126        if (key.Is2D)
 127        {
 5684128            _context.Physics2D.TryGetColliderById(key.Id, out LSCollider2D? collider);
 5684129            replayOrdinal = collider!.ReplayOrdinal;
 5684130            return replayOrdinal >= 0;
 131        }
 132
 10133        _context.Physics.TryGetColliderById(key.Id, out LSCollider? collider3D);
 10134        replayOrdinal = collider3D!.ReplayOrdinal;
 10135        return replayOrdinal >= 0;
 136    }
 137
 138    private static void ContributeCompoundPartReplayHash(
 139        ref ChronicleHashWriter writer,
 140        CompoundColliderPart2D part)
 141    {
 92142        writer.WriteVector2d(part.LocalOffset);
 92143        writer.WriteFixed64(part.LocalRotation);
 92144        writer.WriteVector2d(part.LocalScale);
 92145        writer.WriteBool(part.HasMaterial);
 92146        if (part.TryGetMaterial(out PhysicsMaterial material))
 34147            WriteMaterial(ref writer, material);
 92148        ContributeShapeDefinitionReplayHash(ref writer, part.Shape);
 92149    }
 150
 151    private static void ContributeShapeDefinitionReplayHash(
 152        ref ChronicleHashWriter writer,
 153        ColliderShapeDefinition2D definition)
 154    {
 92155        writer.WriteEnum(definition.Kind);
 92156        writer.WriteBool(definition.HasMaterial);
 92157        if (definition.HasMaterial)
 10158            WriteMaterial(ref writer, definition.Material);
 92159        writer.WriteFixed64(definition.Radius);
 92160        writer.WriteVector2d(definition.Size);
 92161        writer.WriteInt32(definition.PolygonVertexCount);
 308162        for (int i = 0; i < definition.PolygonVertexCount; i++)
 62163            writer.WriteVector2d(definition.GetPolygonVertex(i));
 92164    }
 165
 166    private static void WriteMaterial(ref ChronicleHashWriter writer, PhysicsMaterial material)
 167    {
 5726168        writer.WriteFixed64(material.StaticFriction);
 5726169        writer.WriteFixed64(material.DynamicFriction);
 5726170        writer.WriteFixed64(material.Restitution);
 5726171        writer.WriteEnum(material.FrictionCombine);
 5726172        writer.WriteEnum(material.RestitutionCombine);
 5726173    }
 174}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Colliders/2D/LSCollider2D.ShapeTransaction.cs

#LineLine coverage
 1//=======================================================================
 2// LSCollider2D.ShapeTransaction.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using FixedMathSharp;
 9using FixedMathSharp.Geometry;
 10
 11namespace Gravitas.Colliders;
 12
 13/// <content>Prepares and commits planar shape changes, including geometry used for mixed slab admission.</content>
 14public abstract partial class LSCollider2D
 15{
 16    private Vector2d _committedCenter;
 17    private Fixed64 _committedRotation;
 1017418    private Vector2d _committedOwnerScale = Vector2d.One;
 1017419    private Vector2d _committedPartScale = Vector2d.One;
 20    private bool _hasCommittedShape;
 21    private Fixed64 _committedGeometryReach;
 22
 23    /// <summary>Gets whether this collider has committed runtime shape state.</summary>
 43902424    protected bool HasCommittedShape => _hasCommittedShape;
 25
 26    private ColliderShapeSnapshot2D _preparedSnapshot;
 27    private FixedBoundArea _preparedBounds;
 28    private FixedBoundBox _preparedMixedBounds;
 1017429    private Fixed64 _canonicalCenteredProxyRadius = Fixed64.MaxValue;
 1017430    private Fixed64 _canonicalPivotProxyRadius = Fixed64.MaxValue;
 31    private Fixed64 _preparedAttachmentReach;
 1017432    private Fixed64 _preparedGeometryReach = Fixed64.MaxValue;
 33
 178934    internal Fixed64 PreparedGeometryReach => _preparedGeometryReach;
 178835    internal Fixed64 PreparedAttachmentReach => _preparedAttachmentReach;
 36
 37    internal void ValidateCommittedMixedGeometry() =>
 938        ColliderGeometryPolicy.ValidateReach(new Vector2d(_committedGeometryReach, _mixedHalfThickness), nameof(MixedHal
 39    private Fixed64 _canonicalGroundProbeRadius;
 40    private GravitasWorldContext? _preparedContext;
 41    private Fixed64 _preparedCompoundLocalRotation;
 42
 357243    private protected GravitasWorldContext PreparedContext => _preparedContext!;
 44
 357645    internal FixedBoundArea PreparedShapeBounds => _preparedBounds;
 46
 47    internal bool TryPrepareRecoveryPose(Vector2d position, Fixed64 rotation, out Vector2d center)
 48    {
 10249        center = default;
 50        // Recovery may translate committed geometry, never combine a pending
 51        // authored/host-scale change with the old collision shape.
 10252        if (_runtimeShapeState.IsDirty || !TryPrepareBodyPose(position, rotation)
 10553            || _preparedSnapshot.OwnerScale != _committedOwnerScale) return false;
 9954        center = _preparedSnapshot.Center;
 9955        return true;
 56    }
 57
 58    internal Fixed64 CanonicalCenteredProxyRadius =>
 919959        _canonicalCenteredProxyRadius;
 60
 2769461    internal Fixed64 CanonicalPivotProxyRadius => _canonicalPivotProxyRadius;
 62
 63    internal Fixed64 CanonicalGroundProbeRadius =>
 1496964        _canonicalGroundProbeRadius;
 65
 675966    internal Vector2d CanonicalCenter => _committedCenter;
 67
 68    internal bool TryGetCommittedOwnerScale(out Vector2d scale)
 69    {
 42970        if (_hasCommittedShape)
 71        {
 42572            scale = _committedOwnerScale;
 42573            return true;
 74        }
 75
 476        scale = default;
 477        return false;
 78    }
 79
 80    private Vector2d GetCurrentOwnerScale()
 81    {
 11189682        if (_hasCommittedShape)
 9210583            return _committedOwnerScale;
 1979184        if (_compoundOwner != null)
 118585            return _compoundOwner.GetCurrentOwnerScale();
 1860686        if (_agent == null)
 97887            return Vector2d.One;
 88
 1762889        return ColliderScalePolicy.CapturePlanar(
 1762890            _agent.Transform,
 1762891            out _,
 1762892            out _,
 1762893            captureRotation: false);
 94    }
 95
 96    /// <summary>Gets the current owner and compound-part scale factors separately.</summary>
 97    protected void GetCurrentScaleFactors(
 98        out Vector2d ownerScale,
 99        out Vector2d partScale)
 100    {
 110661101        ownerScale = GetCurrentOwnerScale();
 110661102        partScale = _hasCommittedShape
 110661103            ? _committedPartScale
 110661104            : _compoundOwner != null
 110661105                ? _compoundLocalScale
 110661106                : Vector2d.One;
 110661107    }
 108
 109    internal bool TryGetCurrentScaledOffset(out Vector2d scaledOffset)
 110    {
 28111        Vector2d ownerScale = GetCurrentOwnerScale();
 28112        bool representable = Fixed64.TryMultiplyDivide(
 28113                _localOffset.X,
 28114                ownerScale.X,
 28115                Fixed64.One,
 28116                out Fixed64 x)
 28117            & Fixed64.TryMultiplyDivide(
 28118                _localOffset.Y,
 28119                ownerScale.Y,
 28120                Fixed64.One,
 28121                out Fixed64 y);
 28122        scaledOffset = representable ? new Vector2d(x, y) : default;
 28123        return representable;
 124    }
 125
 126    internal Vector2d GetCurrentScaledOffset()
 127    {
 11128        bool representable =
 11129            TryGetCurrentScaledOffset(out Vector2d scaledOffset);
 11130        ChronicleGuard.ThrowIfTrue(
 11131            !representable,
 11132            nameof(ScaledLocalOffset),
 11133            "The scaled 2D collider offset is outside the Fixed64 coordinate domain.");
 10134        return scaledOffset;
 135    }
 136
 137    private Vector2d GetUncommittedCenter()
 138    {
 22139        Vector2d ownerScale = GetCurrentOwnerScale();
 22140        bool representable = Vector2d.TryTransformScaledPoint(
 22141            Position,
 22142            _localOffset,
 22143            ownerScale,
 22144            _compoundOwner?.Rotation ?? Rotation,
 22145            out Vector2d center);
 22146        ChronicleGuard.ThrowIfTrue(
 22147            !representable,
 22148            nameof(Center),
 22149            "The 2D collider center is outside the Fixed64 coordinate domain.");
 22150        return center;
 151    }
 152
 153    private ColliderShapeSnapshot2D CreateStandaloneSnapshot(
 154        IMatterAgent agent,
 155        bool useRequestedPose,
 156        Vector2d requestedPosition,
 157        Fixed64 requestedRotation)
 158    {
 95605159        Vector2d ownerScale = ColliderScalePolicy.CapturePlanar(
 95605160            agent.Transform,
 95605161            out Fixed4x4 worldMatrix,
 95605162            out Fixed64 matrixRotation,
 95605163            captureRotation: !useRequestedPose);
 164        Vector2d center;
 165        Fixed64 rotation;
 95586166        if (useRequestedPose)
 167        {
 71037168            rotation = PlanarRotation.Canonicalize(requestedRotation);
 71037169            bool representable = Vector2d.TryTransformScaledPoint(
 71037170                requestedPosition,
 71037171                _localOffset,
 71037172                ownerScale,
 71037173                rotation,
 71037174                out center);
 71037175            ChronicleGuard.ThrowIfArgument(
 71037176                !representable,
 71037177                nameof(requestedPosition),
 71037178                "2D collider center must be representable after applying the requested body pose.");
 179        }
 180        else
 181        {
 24549182            rotation = matrixRotation;
 24549183            ChronicleGuard.ThrowIfArgument(
 24549184                !Fixed4x4.TryTransformAffinePoint(
 24549185                    worldMatrix,
 24549186                    _localOffset.ToVector3d(Fixed64.Zero),
 24549187                    out Vector3d transformed),
 24549188                nameof(agent),
 24549189                "2D collider center must be representable after applying the host transform.");
 24549190            center = transformed.ToVector2d();
 191        }
 192
 95580193        return new ColliderShapeSnapshot2D(
 95580194            center,
 95580195            rotation,
 95580196            ownerScale,
 95580197            Vector2d.One,
 95580198            _localOffset,
 95580199            _shapeVersion,
 95580200            worldMatrix.M42,
 95580201            _mixedHalfThicknessOverride ?? agent.Context.Settings.Mixed2DHalfThickness);
 202    }
 203
 204    private ColliderShapeSnapshot2D CaptureShapeSnapshot()
 205    {
 82756206        if (_compoundOwner != null)
 207        {
 1208            return CreateCompoundPartSnapshot(
 1209                _compoundOwner._preparedSnapshot,
 1210                _compoundLocalRotation,
 1211                _compoundLocalScale);
 212        }
 213
 82755214        IMatterAgent? agent = _agent;
 82755215        if (agent == null)
 216        {
 8217            Vector2d ownerScale = Vector2d.One;
 8218            Fixed64 rotation = PlanarRotation.Canonicalize(
 8219                ResolveStandaloneRotation());
 8220            _ = Vector2d.TryTransformScaledPoint(
 8221                ResolveStandalonePosition(),
 8222                _localOffset,
 8223                ownerScale,
 8224                rotation,
 8225                out Vector2d center);
 8226            return new ColliderShapeSnapshot2D(
 8227                center,
 8228                rotation,
 8229                ownerScale,
 8230                Vector2d.One,
 8231                _localOffset,
 8232                _shapeVersion,
 8233                Fixed64.Zero,
 8234                _mixedHalfThicknessOverride ?? PhysicsSettings.DefaultMixed2DHalfThickness);
 235        }
 236
 82747237        return _body == null
 82747238            ? CreateStandaloneSnapshot(
 82747239                agent,
 82747240                useRequestedPose: false,
 82747241                default,
 82747242                default)
 82747243            : CreateStandaloneSnapshot(
 82747244                agent,
 82747245                useRequestedPose: true,
 82747246                _body.Position,
 82747247                _body.Rotation);
 248    }
 249
 250    private ColliderShapeSnapshot2D CreateCompoundPartSnapshot(
 251        in ColliderShapeSnapshot2D ownerSnapshot,
 252        Fixed64 localRotation,
 253        Vector2d localScale)
 254    {
 1795255        ColliderScalePolicy.Validate(localScale);
 1795256        bool representable = Vector2d.TryTransformScaledPoint(
 1795257            ownerSnapshot.Center,
 1795258            _localOffset,
 1795259            ownerSnapshot.OwnerScale,
 1795260            ownerSnapshot.Rotation,
 1795261            out Vector2d center);
 1795262        ChronicleGuard.ThrowIfArgument(
 1795263            !representable,
 1795264            nameof(_localOffset),
 1795265            "Compound-part center must be representable in the owner's world frame.");
 1795266        return new ColliderShapeSnapshot2D(
 1795267            center,
 1795268            PlanarRotation.Combine(ownerSnapshot.Rotation, localRotation),
 1795269            ownerSnapshot.OwnerScale,
 1795270            localScale,
 1795271            _localOffset,
 1795272            _shapeVersion,
 1795273            ownerSnapshot.MixedSlabCenterY,
 1795274            ownerSnapshot.MixedHalfThickness);
 275    }
 276
 277    private void PrepareRuntimeShape(
 278        in ColliderShapeSnapshot2D snapshot,
 279        bool includeBodyAttachment)
 280    {
 40977281        _preparedContext ??= _context;
 40977282        _preparedSnapshot = snapshot;
 40977283        _preparedGeometryReach = Fixed64.MaxValue;
 40977284        PrepareShape(snapshot);
 40961285        _preparedAttachmentReach = ColliderGeometryPolicy.Attachment(snapshot.LocalOffset, snapshot.OwnerScale);
 40961286        Fixed64 completeReach = _preparedGeometryReach;
 40961287        if (includeBodyAttachment)
 36057288            completeReach = ColliderGeometryPolicy.Add(
 36057289                _preparedAttachmentReach, completeReach);
 40961290        if (_compoundOwner == null && _preparedContext?.Settings.RuntimeMode.RunsMixedContacts() == true)
 22204291            completeReach = ColliderGeometryPolicy.Mixed(completeReach, snapshot.MixedHalfThickness);
 40961292        ColliderGeometryPolicy.ValidateReach(completeReach, nameof(snapshot));
 40940293        Vector2d min = _preparedBounds.Min;
 40940294        Vector2d max = _preparedBounds.Max;
 40940295        _preparedMixedBounds = FixedBoundBox.FromMinMax(
 40940296            new Vector3d(
 40940297                min.X,
 40940298                snapshot.MixedSlabCenterY - snapshot.MixedHalfThickness,
 40940299                min.Y),
 40940300            new Vector3d(
 40940301                max.X,
 40940302                snapshot.MixedSlabCenterY + snapshot.MixedHalfThickness,
 40940303                max.Y));
 40940304    }
 305
 306    private void PublishPreparedShape(bool contactDependencyChanged = true)
 307    {
 39572308        _committedCenter = _preparedSnapshot.Center;
 39572309        _committedRotation = _preparedSnapshot.Rotation;
 39572310        _committedOwnerScale = _preparedSnapshot.OwnerScale;
 39572311        _committedPartScale = _preparedSnapshot.PartScale;
 39572312        _bounds = _preparedBounds;
 39572313        _mixedBounds3D = _preparedMixedBounds;
 39572314        _mixedSlabCenterY = _preparedSnapshot.MixedSlabCenterY;
 39572315        _mixedHalfThickness = _preparedSnapshot.MixedHalfThickness;
 316        // Queries must not read preparation scratch after a rejected transaction.
 39572317        _committedGeometryReach = _body == null ? _preparedGeometryReach
 39572318            : ColliderGeometryPolicy.Add(_preparedAttachmentReach, _preparedGeometryReach);
 39572319        PublishShape();
 320        Fixed64 intrinsic;
 39572321        if (this is LSCompoundCollider2D compound)
 1425322            _canonicalCenteredProxyRadius = ColliderCanonicalBounds2D.GetCompoundCenteredProxyRadius(compound, out intri
 323        else
 324        {
 38147325            _canonicalCenteredProxyRadius = _preparedGeometryReach;
 38147326            intrinsic = this is LSCapsuleCollider2D or LSPolygonCollider2D
 38147327                ? ColliderGeometryPolicy.RotatedReach(_canonicalCenteredProxyRadius, planar: true)
 38147328                : _canonicalCenteredProxyRadius;
 329        }
 39572330        _canonicalPivotProxyRadius = ColliderGeometryPolicy.Add(
 39572331            ColliderGeometryPolicy.RotatedReach(_preparedAttachmentReach, planar: true), intrinsic);
 39572332        _canonicalGroundProbeRadius =
 39572333            ColliderCanonicalBounds2D.GetGroundProbeRadius(this);
 39572334        _runtimeShapeState.Commit(_preparedSnapshot);
 39572335        _hasCommittedShape = true;
 39572336        if (contactDependencyChanged)
 337        {
 20861338            ContactDependencyVersion++;
 20861339            StaticSurface?.Invalidate(this);
 340        }
 18729341    }
 342
 343    internal bool TryPrepareBodyPose(
 344        Vector2d position,
 345        Fixed64 rotation)
 346    {
 347        try
 348        {
 3284349            ColliderShapeSnapshot2D snapshot = _agent != null
 3284350                ? CreateStandaloneSnapshot(
 3284351                    _agent,
 3284352                    useRequestedPose: true,
 3284353                    position,
 3284354                    rotation)
 3284355                : CreateDetachedBodySnapshot(position, rotation);
 3278356            PrepareRuntimeShape(
 3278357                snapshot,
 3278358                includeBodyAttachment: true);
 3277359            return true;
 360        }
 6361        catch (System.ArgumentException)
 362        {
 6363            return false;
 364        }
 1365        catch (System.InvalidOperationException)
 366        {
 1367            return false;
 368        }
 3284369    }
 370
 371    private ColliderShapeSnapshot2D CreateDetachedBodySnapshot(
 372        Vector2d position,
 373        Fixed64 rotation)
 374    {
 2375        bool representable = Vector2d.TryTransformScaledPoint(
 2376            position,
 2377            _localOffset,
 2378            _committedOwnerScale,
 2379            rotation,
 2380            out Vector2d center);
 2381        ChronicleGuard.ThrowIfArgument(
 2382            !representable,
 2383            nameof(position),
 2384            "2D collider center must be representable after applying the detached body pose.");
 2385        return new ColliderShapeSnapshot2D(
 2386            center,
 2387            rotation,
 2388            _committedOwnerScale,
 2389            Vector2d.One,
 2390            _localOffset,
 2391            _shapeVersion,
 2392            _mixedSlabCenterY,
 2393            _mixedHalfThickness);
 394    }
 395
 396    internal void PublishPreparedBodyPose()
 397    {
 522398        PublishPreparedShape(contactDependencyChanged: false);
 522399    }
 400
 401    internal void PublishPreparedExplicitBodyPose(bool poseChanged = true)
 402    {
 2475403        bool contactDependencyChanged = poseChanged || _runtimeShapeState.IsDirty
 2475404            || _preparedSnapshot.OwnerScale != _committedOwnerScale
 2475405            || _preparedSnapshot.MixedSlabCenterY != _mixedSlabCenterY
 2475406            || _preparedSnapshot.MixedHalfThickness != _mixedHalfThickness;
 2475407        PublishPreparedShape(contactDependencyChanged);
 2475408        _body?.RefreshMassPropertiesFromColliderShape();
 2475409        if (_id >= 0)
 2474410            _context!.Collisions2D.RefreshColliderPartitionAfterShapeChange(this);
 2475411    }
 412
 413    private void PrepareStandaloneInitialization(
 414        IMatterAgent agent,
 415        bool useRequestedPose,
 416        Vector2d requestedPosition,
 417        Fixed64 requestedRotation)
 418    {
 9576419        ColliderShapeSnapshot2D snapshot = CreateStandaloneSnapshot(
 9576420            agent,
 9576421            useRequestedPose,
 9576422            requestedPosition,
 9576423            requestedRotation);
 9563424        _preparedContext = agent.Context;
 9563425        PrepareRuntimeShape(
 9563426            snapshot,
 9563427            includeBodyAttachment: useRequestedPose);
 9538428    }
 429
 430    internal void PrepareCompoundPart(
 431        in ColliderShapeSnapshot2D ownerSnapshot,
 432        Fixed64 localRotation,
 433        Vector2d localScale,
 434        GravitasWorldContext context)
 435    {
 1794436        ChronicleGuard.ThrowIfArgument(
 1794437            _context != null && !ReferenceEquals(_context, context),
 1794438            nameof(context),
 1794439            "2D compound collider part is already bound to a different GravitasWorldContext.");
 1794440        ColliderShapeSnapshot2D snapshot = CreateCompoundPartSnapshot(
 1794441            ownerSnapshot,
 1794442            localRotation,
 1794443            localScale);
 1794444        _preparedContext = context;
 1794445        _preparedCompoundLocalRotation = localRotation;
 1794446        PrepareRuntimeShape(
 1794447            snapshot,
 1794448            includeBodyAttachment: false);
 1788449    }
 450
 451    internal void PublishCompoundPart(
 452        Fixed64 localRotation,
 453        Vector2d localScale,
 454        GravitasWorldContext context)
 455    {
 1778456        _compoundLocalRotation = localRotation;
 1778457        _compoundLocalScale = localScale;
 1778458        _context = context;
 1778459        PublishPreparedShape();
 1778460    }
 461
 462    private protected void SetPreparedGeometryReach(Fixed64 reach) =>
 40960463        _preparedGeometryReach = reach;
 464
 465    /// <summary>Sets the bounds for the shape transaction being prepared.</summary>
 466    protected void SetPreparedBounds(FixedBoundArea bounds) =>
 40961467        _preparedBounds = bounds;
 468
 469    private protected abstract void PrepareShape(in ColliderShapeSnapshot2D snapshot);
 470
 471    private protected abstract void PublishShape();
 472}

Methods/Properties

PrepareDetachedBodyReconfigurationCandidate(Gravitas.SolidBody2D,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
MatchesCommittedReconfigurationCandidate(Gravitas.Colliders.LSCollider2D)
PublishBodyReconfigurationCandidate(Gravitas.Colliders.LSCollider2D)
CreateReconfigurationSnapshot(Gravitas.Colliders.LSCollider2D,System.UInt32)
.ctor()
get_Id()
get_ReplayOrdinal()
get_LifetimeVersion()
get_CompoundOwner()
get_ServiceRefreshIndex()
get_IsPartitioned()
get_PartitionCoordinates()
get_PartitionKind()
get_IsMixedPartitioned()
get_MixedPartitionCoordinates()
get_MixedPartitionKind()
get_BroadPhaseVersion()
get_RuntimeShapeVersion()
get_HasHostBinding()
get_CollisionPairCount()
get_CollisionPairHolderCount()
get_CollisionPairs()
get_CollisionPairHolders()
get_Body()
get_IsStatic()
get_RequiresServiceSideRefresh()
get_Agent()
get_AgentOrNull()
get_Context()
get_IsActive()
set_IsActive(System.Boolean)
get_IsTrigger()
set_IsTrigger(System.Boolean)
get_Layer()
set_Layer(Gravitas.Support.PhysicsLayer)
get_IgnoredCollisionLayers()
set_IgnoredCollisionLayers(Gravitas.Support.PhysicsLayerMask)
get_Material()
set_Material(Gravitas.Materials.PhysicsMaterial)
get_Priority()
get_RaycastVersion()
set_RaycastVersion(System.UInt32)
get_CircleQueryVersion()
set_CircleQueryVersion(System.UInt32)
get_IsChild()
get_IsParent()
get_ParentId()
get_Parent2D()
get_Parent3D()
get_TopParent2D()
get_TopParent3D()
get_HierarchyChildCount()
get_HierarchyKey()
get_ParentKey()
get_TopParentKey()
get_HierarchyState()
Gravitas.Colliders.IColliderHierarchyNode.get_HierarchyKey()
Gravitas.Colliders.IColliderHierarchyNode.get_HierarchyParent()
get_LocalOffset()
set_LocalOffset(FixedMathSharp.Vector2d)
get_Bounds()
get_MixedBounds3D()
get_MixedHalfThickness()
get_MixedSlabCenterY()
get_MixedHalfThicknessOverride()
set_MixedHalfThicknessOverride(System.Nullable`1<FixedMathSharp.Fixed64>)
get_MinX()
get_MaxX()
get_MinY()
get_MaxY()
Initialize(Gravitas.SolidBody2D)
InitializeWithNoBody(Gravitas.IMatterAgent)
PreflightBodyInitialization(Gravitas.SolidBody2D,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
PreflightInitialization(Gravitas.IMatterAgent,System.Boolean,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
InitCore(Gravitas.IMatterAgent,Gravitas.SolidBody2D)
OnBeforeInitialize(Gravitas.IMatterAgent)
SetPhysicsState(System.Int32,System.Int32,System.Int32)
SetServiceIndex(System.Int32)
SetReplayOrdinal(System.Int32)
SetServiceRefreshIndex(System.Int32)
ClearServiceRefreshIndex()
ClearPhysicsState()
Gravitas.Colliders.IPhysicsColliderRegistryItem.SetRegistryState(System.Int32,System.Int32,System.Int32)
Gravitas.Colliders.IPhysicsColliderRegistryItem.get_ServiceIndex()
Gravitas.Colliders.IPhysicsColliderRegistryItem.get_ReplayOrder()
Gravitas.Colliders.IPhysicsColliderRegistryItem.SetRegistryServiceIndex(System.Int32)
Gravitas.Colliders.IPhysicsColliderRegistryItem.SetRegistryReplayOrdinal(System.Int32)
Gravitas.Colliders.IPhysicsColliderRegistryItem.ClearRegistryState()
ClearBindingState()
Deactivate()
Simulate()
Rebuild(System.Boolean)
RebuildRuntimeShapeOnly(System.Boolean)
ValidateCurrentRuntimeTransform()
SetParent(Gravitas.Colliders.LSCollider2D)
SetParent(Gravitas.Colliders.LSCollider)
ClearParent()
IsSibling(Gravitas.Colliders.LSCollider2D)
ExcludesMixedCollisionWith(Gravitas.Colliders.LSCollider)
GetOrCreatePartitionCoordinates()
GetOrCreateMixedPartitionCoordinates()
MatchesPartitionGridBounds(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,System.Int32)
MatchesMixedPartitionGridBounds(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,System.Int32)
MarkPartitioned(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,System.Int32)
MarkMixedPartitioned(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,System.Int32)
MarkUnpartitioned()
MarkMixedUnpartitioned()
ClearPartitionCoordinates()
ClearMixedPartitionCoordinates()
IsPositionInPlanarBounds(FixedMathSharp.Fixed64,FixedMathSharp.Vector3d)
IsPositionInMixedBounds(FixedMathSharp.Fixed64,FixedMathSharp.Vector3d)
TryGetCollisionPair(System.Int32,Gravitas.CollisionPair2D&)
TryAddCollisionPair(System.Int32,Gravitas.CollisionPair2D)
TryRemoveCollisionPair(System.Int32,Gravitas.CollisionPair2D&)
TryAddCollisionPairHolder(System.Int32)
TryRemoveCollisionPairHolder(System.Int32)
ClearCollisionPairState()
ClearRuntimeRelationships()
ResolveAgentRotation()
BindContext(Gravitas.GravitasWorldContext)
ReserveCompoundPart(Gravitas.Colliders.LSCompoundCollider2D,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d)
ThrowIfCompoundPartLifecycle(System.String)
TransformRelativeMassPropertyPointExact(FixedMathSharp.Vector2d)
get_CompoundLocalRotation()
Rotate(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
ClampNearZero(FixedMathSharp.Vector2d)
SetTrigger(System.Boolean)
MarkContactDependencyChanged(System.Boolean,System.Boolean)
ThrowIfCannotEnableTrigger(System.String)
ThrowIfTriggerWouldAttachToBody(System.String)
ThrowIfLoadedTriggerHasBody(System.String)
RecordData(Chronicler.IChronicler)
RecordShapeData(Chronicler.IChronicler)
IgnoresCollisionLayer(Gravitas.Support.PhysicsLayer)
ApplyLoadedState()
get_Position()
get_Rotation()
get_LocalScale()
TryGetLocalScale(FixedMathSharp.Vector2d&)
get_ScaledLocalOffset()
TryGetScaledLocalOffset(FixedMathSharp.Vector2d&)
get_Center()
get_VertexCount()
get_ConvexRotation()
GetScaledLocalVertexUnchecked(System.Int32)
GetConvexSupportAnchor(FixedMathSharp.Vector2d)
TryGetClosestBoundaryAnchor(FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&)
TryGetClosestBoundaryAnchor(FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&,FixedMathSharp.Fixed64&)
TryGetVertex(System.Int32,FixedMathSharp.Vector2d&)
GetRoundBoundaryAnchor(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
TryGetAABoxBoundaryAnchor(Gravitas.Colliders.LSAABBoxCollider2D,FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&)
TryGetConvexBoundaryAnchor(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&)
TryGetCompoundBoundaryAnchor(Gravitas.Colliders.LSCompoundCollider2D,FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&)
TryGetCompoundBoundaryAnchor(Gravitas.Colliders.LSCompoundCollider2D,FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&,System.Boolean,FixedMathSharp.Geometry.FixedPointAnchor2d&)
TryGetAnchorDistance(FixedMathSharp.Vector2d,FixedMathSharp.Geometry.FixedPointAnchor2d&,FixedMathSharp.Fixed64&)
CalculateLocalCenterOfMassOffset()
CalculateLocalMassPoint()
CalculatePreparedLocalMassPoint()
CalculateMomentOfInertia(FixedMathSharp.Fixed64,FixedMathSharp.Vector2d)
OnMaterialChanged()
TransformPreparedPartMassPropertyPointExact(FixedMathSharp.Vector2d)
MarkShapeDirty()
RebuildRuntimeShapeState(System.Boolean,System.Boolean)
ResolveStandalonePosition()
ResolveStandaloneRotation()
ValidateGeometryMutation(System.Nullable`1<FixedMathSharp.Vector2d>,System.Nullable`1<FixedMathSharp.Fixed64>,System.Nullable`1<FixedMathSharp.Fixed64>,System.Nullable`1<FixedMathSharp.Vector2d>,System.Nullable`1<FixedMathSharp.Fixed64>,System.Nullable`1<Gravitas.PhysicsRuntimeMode>)
ValidateMixedGeometry(FixedMathSharp.Fixed64)
GetCandidateGeometryReach(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,System.Nullable`1<FixedMathSharp.Fixed64>,System.Nullable`1<FixedMathSharp.Fixed64>,System.Nullable`1<FixedMathSharp.Vector2d>)
ClearChildParentReferences()
Gravitas.Colliders.IColliderHierarchyNode.AddChild(Gravitas.Colliders.ColliderHierarchyKey)
Gravitas.Colliders.IColliderHierarchyNode.RemoveChild(Gravitas.Colliders.ColliderHierarchyKey)
Gravitas.Colliders.IColliderHierarchyNode.ClearParentReference()
Gravitas.Colliders.IColliderHierarchyNode.TryGetHierarchyColliderByKey(Gravitas.Colliders.ColliderHierarchyKey,Gravitas.Colliders.IColliderHierarchyNode&)
NotifyContact(Gravitas.Colliders.LSCollider2D,System.Boolean,System.Boolean)
NotifyContact(Gravitas.Colliders.LSCollider2D,Gravitas.SolidBody2D,System.Boolean,System.Boolean,System.Boolean,Gravitas.Colliders.ColliderLifetimeToken2D&,Gravitas.Colliders.ColliderLifetimeToken2D&,System.Boolean,System.Boolean)
NotifyMixedContact(Gravitas.Colliders.LSCollider,System.Boolean,System.Boolean,System.Boolean)
NotifyMixedContact(Gravitas.Colliders.LSCollider,System.Boolean,System.Boolean,System.Boolean,System.Boolean,Gravitas.Colliders.ColliderLifetimeToken2D&,Gravitas.Colliders.ColliderLifetimeToken&,System.Boolean)
ContributeReplayHash(Chronicler.Hashing.ChronicleHashWriter&,Gravitas.GravitasReplayHashMode)
ContributeShapeReplayHash(Chronicler.Hashing.ChronicleHashWriter&)
WriteReplayHierarchyKey(Chronicler.Hashing.ChronicleHashWriter&,Gravitas.Colliders.ColliderHierarchyKey)
TryResolveReplayHierarchyOrdinal(Gravitas.Colliders.ColliderHierarchyKey,System.Int32&)
ContributeCompoundPartReplayHash(Chronicler.Hashing.ChronicleHashWriter&,Gravitas.Colliders.CompoundColliderPart2D)
ContributeShapeDefinitionReplayHash(Chronicler.Hashing.ChronicleHashWriter&,Gravitas.Colliders.ColliderShapeDefinition2D)
WriteMaterial(Chronicler.Hashing.ChronicleHashWriter&,Gravitas.Materials.PhysicsMaterial)
.ctor()
get_HasCommittedShape()
get_PreparedGeometryReach()
get_PreparedAttachmentReach()
ValidateCommittedMixedGeometry()
get_PreparedContext()
get_PreparedShapeBounds()
TryPrepareRecoveryPose(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d&)
get_CanonicalCenteredProxyRadius()
get_CanonicalPivotProxyRadius()
get_CanonicalGroundProbeRadius()
get_CanonicalCenter()
TryGetCommittedOwnerScale(FixedMathSharp.Vector2d&)
GetCurrentOwnerScale()
GetCurrentScaleFactors(FixedMathSharp.Vector2d&,FixedMathSharp.Vector2d&)
TryGetCurrentScaledOffset(FixedMathSharp.Vector2d&)
GetCurrentScaledOffset()
GetUncommittedCenter()
CreateStandaloneSnapshot(Gravitas.IMatterAgent,System.Boolean,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
CaptureShapeSnapshot()
CreateCompoundPartSnapshot(Gravitas.Colliders.ColliderShapeSnapshot2D&,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d)
PrepareRuntimeShape(Gravitas.Colliders.ColliderShapeSnapshot2D&,System.Boolean)
PublishPreparedShape(System.Boolean)
TryPrepareBodyPose(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
CreateDetachedBodySnapshot(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
PublishPreparedBodyPose()
PublishPreparedExplicitBodyPose(System.Boolean)
PrepareStandaloneInitialization(Gravitas.IMatterAgent,System.Boolean,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
PrepareCompoundPart(Gravitas.Colliders.ColliderShapeSnapshot2D&,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,Gravitas.GravitasWorldContext)
PublishCompoundPart(FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,Gravitas.GravitasWorldContext)
SetPreparedGeometryReach(FixedMathSharp.Fixed64)
SetPreparedBounds(FixedMathSharp.Geometry.FixedBoundArea)