< Summary

Information
Class: GridForge.Grids.GridNavigationBodyTraceCandidate
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/GridNavigationBodyTraceScratch.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 105
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%
WithPhysicalEvidence(...)100%11100%
WithVisited()100%11100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// GridNavigationBodyTraceScratch.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 GridForge.Spatial;
 9using GridForge.Grids.Topology;
 10using SwiftCollections;
 11
 12namespace GridForge.Grids;
 13
 14/// <summary>Owns reusable caller-side storage for allocation-free warmed navigation-body traces.</summary>
 15/// <remarks>Instances retain capacity and are not thread-safe.</remarks>
 16public sealed class GridNavigationBodyTraceScratch
 17{
 18    internal SwiftList<ushort> CandidateGrids { get; }
 19
 20    internal SwiftList<GridNavigationBodyTraceCandidate> AddressCandidates { get; }
 21
 22    internal SwiftList<int> UnionMembers { get; }
 23
 24    /// <summary>Creates scratch with expected grid and address counts.</summary>
 25    public GridNavigationBodyTraceScratch(int gridCapacity = 0, int addressCapacity = 0)
 26    {
 27        SwiftThrowHelper.ThrowIfNegative(gridCapacity, nameof(gridCapacity));
 28        SwiftThrowHelper.ThrowIfNegative(addressCapacity, nameof(addressCapacity));
 29
 30        CandidateGrids = new SwiftList<ushort>(gridCapacity);
 31        AddressCandidates = new SwiftList<GridNavigationBodyTraceCandidate>(addressCapacity);
 32        UnionMembers = new SwiftList<int>(addressCapacity);
 33    }
 34
 35    /// <summary>Clears temporary values while retaining capacity.</summary>
 36    public void Clear()
 37    {
 38        CandidateGrids.Clear();
 39        AddressCandidates.Clear();
 40        UnionMembers.Clear();
 41    }
 42}
 43
 44internal readonly struct GridNavigationBodyTraceCandidate
 45{
 46    internal GridNavigationBodyTraceCandidate(
 47        VoxelGrid grid,
 48        VoxelIndex index,
 49        GridCellPrism prism,
 50        bool hasPositiveOverlap,
 51        bool isClosure,
 52        bool isPhysicallyPresent = false,
 53        ulong gridLastChangeSequence = 0UL,
 54        bool isVisited = false)
 55    {
 43356        Grid = grid;
 43357        Index = index;
 43358        Prism = prism;
 43359        HasPositiveOverlap = hasPositiveOverlap;
 43360        IsClosure = isClosure;
 43361        IsPhysicallyPresent = isPhysicallyPresent;
 43362        GridLastChangeSequence = gridLastChangeSequence;
 43363        IsVisited = isVisited;
 43364    }
 65
 66    internal VoxelGrid Grid { get; }
 67
 68    internal VoxelIndex Index { get; }
 69
 70    internal GridCellPrism Prism { get; }
 71
 72    internal bool HasPositiveOverlap { get; }
 73
 74    internal bool IsClosure { get; }
 75
 76    internal bool IsPhysicallyPresent { get; }
 77
 78    internal ulong GridLastChangeSequence { get; }
 79
 80    internal bool IsVisited { get; }
 81
 82    internal GridNavigationBodyTraceCandidate WithPhysicalEvidence(
 83        bool isPhysicallyPresent,
 84        ulong gridLastChangeSequence) =>
 14485        new(
 14486            Grid,
 14487            Index,
 14488            Prism,
 14489            HasPositiveOverlap,
 14490            IsClosure,
 14491            isPhysicallyPresent,
 14492            gridLastChangeSequence,
 14493            IsVisited);
 94
 95    internal GridNavigationBodyTraceCandidate WithVisited() =>
 13696        new(
 13697            Grid,
 13698            Index,
 13699            Prism,
 136100            HasPositiveOverlap,
 136101            IsClosure,
 136102            IsPhysicallyPresent,
 136103            GridLastChangeSequence,
 136104            isVisited: true);
 105}