| | | 1 | | //======================================================================= |
| | | 2 | | // GridDiagnosticCell.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024–present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using FixedMathSharp; |
| | | 9 | | using GridForge.Grids.Storage; |
| | | 10 | | using GridForge.Grids.Topology; |
| | | 11 | | using GridForge.Spatial; |
| | | 12 | | |
| | | 13 | | namespace GridForge.Diagnostics; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Immutable descriptor for a physical voxel or sparse address-space cell. |
| | | 17 | | /// </summary> |
| | | 18 | | public readonly struct GridDiagnosticCell |
| | | 19 | | { |
| | | 20 | | /// <summary> |
| | | 21 | | /// Identifies whether this descriptor represents a physical voxel or a |
| | | 22 | | /// missing sparse address-space cell. |
| | | 23 | | /// </summary> |
| | | 24 | | public readonly GridDiagnosticCellKind Kind; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Runtime token of the owning world when the descriptor was created. |
| | | 28 | | /// </summary> |
| | | 29 | | public readonly int WorldSpawnToken; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// World-local grid slot that owns this cell. |
| | | 33 | | /// </summary> |
| | | 34 | | public readonly ushort GridIndex; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Runtime token of the grid instance when the descriptor was created. |
| | | 38 | | /// </summary> |
| | | 39 | | public readonly int GridSpawnToken; |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Topology-local cell index. |
| | | 43 | | /// </summary> |
| | | 44 | | public readonly VoxelIndex Index; |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Topology-projected world-space center for the cell. |
| | | 48 | | /// </summary> |
| | | 49 | | public readonly Vector3d WorldPosition; |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Topology kind used to interpret the local index and geometry. |
| | | 53 | | /// </summary> |
| | | 54 | | public readonly GridTopologyKind TopologyKind; |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Storage kind of the grid that owns this descriptor. |
| | | 58 | | /// </summary> |
| | | 59 | | public readonly GridStorageKind StorageKind; |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Topology metrics used to derive diagnostic geometry. |
| | | 63 | | /// </summary> |
| | | 64 | | public readonly GridTopologyMetrics TopologyMetrics; |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Diagnostic state flags for filtering and adapter overlays. |
| | | 68 | | /// </summary> |
| | | 69 | | public readonly GridDiagnosticCellState State; |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// World-scoped identity for the cell. Missing sparse address cells use a |
| | | 73 | | /// potential identity and do not resolve to a physical voxel. |
| | | 74 | | /// </summary> |
| | | 75 | | public readonly WorldVoxelIndex WorldIndex; |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Initializes a diagnostic cell descriptor. |
| | | 79 | | /// </summary> |
| | | 80 | | public GridDiagnosticCell( |
| | | 81 | | GridDiagnosticCellKind kind, |
| | | 82 | | int worldSpawnToken, |
| | | 83 | | ushort gridIndex, |
| | | 84 | | int gridSpawnToken, |
| | | 85 | | VoxelIndex index, |
| | | 86 | | Vector3d worldPosition, |
| | | 87 | | GridTopologyKind topologyKind, |
| | | 88 | | GridStorageKind storageKind, |
| | | 89 | | GridTopologyMetrics topologyMetrics, |
| | | 90 | | GridDiagnosticCellState state, |
| | | 91 | | WorldVoxelIndex worldIndex) |
| | | 92 | | { |
| | 8708 | 93 | | Kind = kind; |
| | 8708 | 94 | | WorldSpawnToken = worldSpawnToken; |
| | 8708 | 95 | | GridIndex = gridIndex; |
| | 8708 | 96 | | GridSpawnToken = gridSpawnToken; |
| | 8708 | 97 | | Index = index; |
| | 8708 | 98 | | WorldPosition = worldPosition; |
| | 8708 | 99 | | TopologyKind = topologyKind; |
| | 8708 | 100 | | StorageKind = storageKind; |
| | 8708 | 101 | | TopologyMetrics = topologyMetrics; |
| | 8708 | 102 | | State = state; |
| | 8708 | 103 | | WorldIndex = worldIndex; |
| | 8708 | 104 | | } |
| | | 105 | | } |