| | | 1 | | //======================================================================= |
| | | 2 | | // ColliderPartitionState.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 | | |
| | | 8 | | using FixedMathSharp; |
| | | 9 | | using GridForge.Spatial; |
| | | 10 | | using SwiftCollections; |
| | | 11 | | using System.Runtime.CompilerServices; |
| | | 12 | | |
| | | 13 | | namespace Gravitas.Colliders; |
| | | 14 | | |
| | | 15 | | internal struct ColliderPartitionState |
| | | 16 | | { |
| | | 17 | | public bool IsPartitioned { get; private set; } |
| | | 18 | | |
| | | 19 | | public bool PartitionChanged { get; set; } |
| | | 20 | | |
| | | 21 | | public uint BroadPhaseVersion { get; private set; } |
| | | 22 | | |
| | | 23 | | public Vector3d LastGridBoundsMin { get; private set; } |
| | | 24 | | |
| | | 25 | | public Vector3d LastGridBoundsMax { get; private set; } |
| | | 26 | | |
| | | 27 | | public int LastPartitionKind { get; private set; } |
| | | 28 | | |
| | | 29 | | public SwiftList<WorldVoxelIndex>? Coordinates; |
| | | 30 | | |
| | | 31 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 23936 | 32 | | public void MarkBroadPhaseChanged() => BroadPhaseVersion++; |
| | | 33 | | |
| | | 34 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 35 | | public void MarkPartitioned() |
| | | 36 | | { |
| | 24701 | 37 | | IsPartitioned = true; |
| | 24701 | 38 | | PartitionChanged = true; |
| | 24701 | 39 | | } |
| | | 40 | | |
| | | 41 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 19483 | 42 | | public void MarkUnpartitioned() => IsPartitioned = false; |
| | | 43 | | |
| | | 44 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 45 | | public void SetPreviousGridBounds(Vector3d min, Vector3d max, int partitionKind = 0) |
| | | 46 | | { |
| | 30373 | 47 | | LastGridBoundsMin = min; |
| | 30373 | 48 | | LastGridBoundsMax = max; |
| | 30373 | 49 | | LastPartitionKind = partitionKind; |
| | 30373 | 50 | | } |
| | | 51 | | |
| | | 52 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 19483 | 53 | | public void ClearCoordinates() => Coordinates?.Clear(); |
| | | 54 | | } |