< Summary

Information
Class: GridForge.Grids.GridTraceInterval
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/GridTraceInterval.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 146
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
WithTie(...)100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/GridTraceInterval.cs

#LineLine coverage
 1//=======================================================================
 2// GridTraceInterval.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
 8using FixedMathSharp;
 9using GridForge.Configuration;
 10using GridForge.Spatial;
 11
 12namespace GridForge.Grids;
 13
 14/// <summary>
 15/// Reports completion or a deterministic caller-supplied trace ceiling.
 16/// </summary>
 17public enum GridTraceIntervalStatus : byte
 18{
 19    /// <summary>The complete trace was written.</summary>
 20    Complete,
 21    /// <summary>The candidate-address ceiling was exhausted.</summary>
 22    AddressCandidateLimitExceeded,
 23    /// <summary>The output interval ceiling was exceeded.</summary>
 24    OutputLimitExceeded,
 25    /// <summary>A candidate grid cell could not be represented exactly.</summary>
 26    UnrepresentableGeometry,
 27    /// <summary>The candidate-grid ceiling was exhausted.</summary>
 28    GridCandidateLimitExceeded,
 29    /// <summary>The combined candidate-grid and candidate-address work ceiling was exhausted.</summary>
 30    CandidateWorkLimitExceeded
 31}
 32
 33/// <summary>
 34/// Describes the exact closed parameter interval where a segment intersects one grid address.
 35/// </summary>
 36public readonly struct GridTraceInterval
 37{
 38    /// <summary>The exact world, grid-generation, and topology-local address.</summary>
 39    public WorldVoxelIndex Cell { get; }
 40
 41    /// <summary>The normalized grid binding key, independent of the recyclable runtime slot.</summary>
 42    public GridConfigurationKey ConfigurationKey { get; }
 43
 44    /// <summary>Whether physical storage currently contains the addressed voxel.</summary>
 45    public bool IsPhysicallyPresent { get; }
 46
 47    /// <summary>The last committed sequence applied to the traced grid generation.</summary>
 48    public ulong GridLastChangeSequence { get; }
 49
 50    /// <summary>The first inclusive segment parameter in the cell prism.</summary>
 51    public Fixed64 TEnter { get; }
 52
 53    /// <summary>The last inclusive segment parameter in the cell prism.</summary>
 54    public Fixed64 TExit { get; }
 55
 56    /// <summary>
 57    /// Stable group for peers whose interval interiors overlap, or point peers at one exact parameter.
 58    /// </summary>
 59    /// <remarks>
 60    /// Closed intervals that merely hand off at one endpoint remain successive groups. Group membership
 61    /// expresses simultaneous geometric coverage only; it does not imply voxel adjacency.
 62    /// </remarks>
 63    public int TieGroupId { get; }
 64
 65    /// <summary>The canonical identity order within <see cref="TieGroupId"/>.</summary>
 66    public int TieOrder { get; }
 67
 68    internal GridTraceInterval(
 69        WorldVoxelIndex cell,
 70        GridConfigurationKey configurationKey,
 71        bool isPhysicallyPresent,
 72        ulong gridLastChangeSequence,
 73        Fixed64 tEnter,
 74        Fixed64 tExit,
 75        int tieGroupId = -1,
 76        int tieOrder = -1)
 77    {
 40978        Cell = cell;
 40979        ConfigurationKey = configurationKey;
 40980        IsPhysicallyPresent = isPhysicallyPresent;
 40981        GridLastChangeSequence = gridLastChangeSequence;
 40982        TEnter = tEnter;
 40983        TExit = tExit;
 40984        TieGroupId = tieGroupId;
 40985        TieOrder = tieOrder;
 40986    }
 87
 88    internal GridTraceInterval WithTie(int tieGroupId, int tieOrder) =>
 20489        new(
 20490            Cell,
 20491            ConfigurationKey,
 20492            IsPhysicallyPresent,
 20493            GridLastChangeSequence,
 20494            TEnter,
 20495            TExit,
 20496            tieGroupId,
 20497            tieOrder);
 98}
 99
 100/// <summary>
 101/// Summarizes one bounded ordered trace.
 102/// </summary>
 103public readonly struct GridTraceIntervalReport
 104{
 105    /// <summary>The completion status.</summary>
 106    public GridTraceIntervalStatus Status { get; }
 107
 108    /// <summary>The number of candidate grids discovered.</summary>
 109    public int GridCandidateCount { get; }
 110
 111    /// <summary>The number of unique candidate addresses enumerated.</summary>
 112    public int AddressCandidateCount { get; }
 113
 114    /// <summary>The number of intervals written.</summary>
 115    public int IntervalCount { get; }
 116
 117    /// <summary>The number of simultaneous-coverage groups.</summary>
 118    public int TieGroupCount { get; }
 119
 120    /// <summary>Whether all parameters from zero through one are covered by grid addresses.</summary>
 121    public bool HasContinuousAddressCoverage { get; }
 122
 123    /// <summary>Whether all parameters from zero through one are covered by physically present voxels.</summary>
 124    public bool HasContinuousPhysicalCoverage { get; }
 125
 126    /// <summary>Whether the complete trace was written.</summary>
 127    public bool IsComplete => Status == GridTraceIntervalStatus.Complete;
 128
 129    internal GridTraceIntervalReport(
 130        GridTraceIntervalStatus status,
 131        int gridCandidateCount,
 132        int candidateCount,
 133        int intervalCount,
 134        int tieGroupCount,
 135        bool hasContinuousAddressCoverage,
 136        bool hasContinuousPhysicalCoverage)
 137    {
 138        Status = status;
 139        GridCandidateCount = gridCandidateCount;
 140        AddressCandidateCount = candidateCount;
 141        IntervalCount = intervalCount;
 142        TieGroupCount = tieGroupCount;
 143        HasContinuousAddressCoverage = hasContinuousAddressCoverage;
 144        HasContinuousPhysicalCoverage = hasContinuousPhysicalCoverage;
 145    }
 146}