| | | 1 | | //======================================================================= |
| | | 2 | | // GridNavigationBodyTrace.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 GridForge.Configuration; |
| | | 9 | | using GridForge.Grids.Topology; |
| | | 10 | | using GridForge.Spatial; |
| | | 11 | | |
| | | 12 | | namespace GridForge.Grids; |
| | | 13 | | |
| | | 14 | | /// <summary>Reports the outcome of a bounded swept navigation-body trace.</summary> |
| | | 15 | | public enum GridNavigationBodyTraceStatus : byte |
| | | 16 | | { |
| | | 17 | | /// <summary>The complete physical prism union was written.</summary> |
| | | 18 | | Complete, |
| | | 19 | | /// <summary>The complete canonical set was written, but at least one required cell is physically absent.</summary> |
| | | 20 | | IncompletePhysicalCoverage, |
| | | 21 | | /// <summary>The inputs or an exact topology prism could not be represented.</summary> |
| | | 22 | | InvalidOrUnrepresentableGeometry, |
| | | 23 | | /// <summary>The candidate-address ceiling was exhausted.</summary> |
| | | 24 | | AddressLimitExceeded, |
| | | 25 | | /// <summary>The complete required and dependency-evidence output ceiling was exhausted.</summary> |
| | | 26 | | OutputLimitExceeded, |
| | | 27 | | /// <summary>The combined grid and address work ceiling was exhausted.</summary> |
| | | 28 | | CandidateWorkLimitExceeded, |
| | | 29 | | /// <summary>The candidate-grid ceiling was exhausted.</summary> |
| | | 30 | | GridCandidateLimitExceeded, |
| | | 31 | | /// <summary>Checked body-top or query-bounds arithmetic overflowed.</summary> |
| | | 32 | | ArithmeticOverflow |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary>Describes how one published trace cell participates in coverage validation.</summary> |
| | | 36 | | public enum GridNavigationBodyTraceCellRole : byte |
| | | 37 | | { |
| | | 38 | | /// <summary>The cell identity contributes directly to the required physical coverage.</summary> |
| | | 39 | | RequiredCoverage, |
| | | 40 | | /// <summary> |
| | | 41 | | /// The missing cell is an OR alternative whose mutation invalidates the negative proof without |
| | | 42 | | /// making the cell an additional physical requirement. |
| | | 43 | | /// </summary> |
| | | 44 | | PhysicalAlternativeDependency |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <summary>Identifies one topology cell and its physical generation evidence.</summary> |
| | | 48 | | public readonly struct GridNavigationBodyTraceCell |
| | | 49 | | { |
| | | 50 | | /// <summary>The exact world, grid-generation, and topology-local address.</summary> |
| | | 51 | | public WorldVoxelIndex Cell { get; } |
| | | 52 | | |
| | | 53 | | /// <summary>The normalized grid binding key, independent of its recyclable runtime slot.</summary> |
| | | 54 | | public GridConfigurationKey ConfigurationKey { get; } |
| | | 55 | | |
| | | 56 | | /// <summary>Whether physical storage contained this address during the trace.</summary> |
| | | 57 | | public bool IsPhysicallyPresent { get; } |
| | | 58 | | |
| | | 59 | | /// <summary>The last committed sequence applied to the owning grid generation.</summary> |
| | | 60 | | public ulong GridLastChangeSequence { get; } |
| | | 61 | | |
| | | 62 | | /// <summary>How this identity participates in the physical coverage proof.</summary> |
| | | 63 | | public GridNavigationBodyTraceCellRole Role { get; } |
| | | 64 | | |
| | | 65 | | internal GridNavigationBodyTraceCell( |
| | | 66 | | WorldVoxelIndex cell, |
| | | 67 | | GridConfigurationKey configurationKey, |
| | | 68 | | bool isPhysicallyPresent, |
| | | 69 | | ulong gridLastChangeSequence, |
| | | 70 | | GridNavigationBodyTraceCellRole role) |
| | | 71 | | { |
| | 116 | 72 | | Cell = cell; |
| | 116 | 73 | | ConfigurationKey = configurationKey; |
| | 116 | 74 | | IsPhysicallyPresent = isPhysicallyPresent; |
| | 116 | 75 | | GridLastChangeSequence = gridLastChangeSequence; |
| | 116 | 76 | | Role = role; |
| | 116 | 77 | | } |
| | | 78 | | } |
| | | 79 | | |
| | | 80 | | /// <summary>Summarizes one bounded swept navigation-body trace.</summary> |
| | | 81 | | public readonly struct GridNavigationBodyTraceReport |
| | | 82 | | { |
| | | 83 | | /// <summary>The completion status.</summary> |
| | | 84 | | public GridNavigationBodyTraceStatus Status { get; } |
| | | 85 | | |
| | | 86 | | /// <summary>The number of candidate grids examined.</summary> |
| | | 87 | | public int GridCandidateCount { get; } |
| | | 88 | | |
| | | 89 | | /// <summary>The number of candidate addresses examined.</summary> |
| | | 90 | | public int AddressCandidateCount { get; } |
| | | 91 | | |
| | | 92 | | /// <summary>The exact combined grid and address work completed.</summary> |
| | | 93 | | public long CandidateWorkCount { get; } |
| | | 94 | | |
| | | 95 | | /// <summary>The number of required and dependency-evidence cells written.</summary> |
| | | 96 | | public int CellCount { get; } |
| | | 97 | | |
| | | 98 | | /// <summary>The exact committed world revision observed by the trace.</summary> |
| | | 99 | | public GridCoveredAddressRunStamp RunStamp { get; } |
| | | 100 | | |
| | | 101 | | /// <summary>Whether the complete physical prism union was written.</summary> |
| | | 102 | | public bool IsComplete => Status == GridNavigationBodyTraceStatus.Complete; |
| | | 103 | | |
| | | 104 | | internal GridNavigationBodyTraceReport( |
| | | 105 | | GridNavigationBodyTraceStatus status, |
| | | 106 | | int gridCandidateCount, |
| | | 107 | | int addressCandidateCount, |
| | | 108 | | long candidateWorkCount, |
| | | 109 | | int cellCount, |
| | | 110 | | GridCoveredAddressRunStamp runStamp) |
| | | 111 | | { |
| | | 112 | | Status = status; |
| | | 113 | | GridCandidateCount = gridCandidateCount; |
| | | 114 | | AddressCandidateCount = addressCandidateCount; |
| | | 115 | | CandidateWorkCount = candidateWorkCount; |
| | | 116 | | CellCount = cellCount; |
| | | 117 | | RunStamp = runStamp; |
| | | 118 | | } |
| | | 119 | | } |