< Summary

Information
Class: Trailblazer.Pathing.NavigationRayWorkspace
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/Ray/NavigationRayWorkspace.cs
Line coverage
100%
Covered lines: 39
Uncovered lines: 0
Coverable lines: 39
Total lines: 100
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/Ray/NavigationRayWorkspace.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationRayWorkspace.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 System;
 9using FixedMathSharp;
 10using GridForge.Grids;
 11using SwiftCollections;
 12
 13namespace Trailblazer.Pathing;
 14
 15/// <summary>Owns fixed caller-side storage for one exclusive navigation ray.</summary>
 16internal sealed class NavigationRayWorkspace
 17{
 1803718    internal NavigationRayWorkspace(
 1803719        int mapCapacity,
 1803720        int pageCapacity,
 1803721        int componentCapacity,
 1803722        int coveredAddressCapacity,
 1803723        int traceIntervalCapacity)
 24    {
 1803725        SwiftThrowHelper.ThrowIfNegative(mapCapacity, nameof(mapCapacity));
 1803726        SwiftThrowHelper.ThrowIfNegative(pageCapacity, nameof(pageCapacity));
 1803727        SwiftThrowHelper.ThrowIfNegative(componentCapacity, nameof(componentCapacity));
 1803728        SwiftThrowHelper.ThrowIfNegative(
 1803729            coveredAddressCapacity,
 1803730            nameof(coveredAddressCapacity));
 1803731        SwiftThrowHelper.ThrowIfNegative(
 1803732            traceIntervalCapacity,
 1803733            nameof(traceIntervalCapacity));
 1803734        SwiftThrowHelper.ThrowIfArgument(
 1803735            traceIntervalCapacity > coveredAddressCapacity,
 1803736            nameof(traceIntervalCapacity),
 1803737            "Trace-interval capacity cannot exceed covered-address capacity.");
 38
 1803739        MapCapacity = mapCapacity;
 1803740        CoveredAddressCapacity = coveredAddressCapacity;
 1803741        TraceIntervalCapacity = traceIntervalCapacity;
 1803742        TraceScratch = new GridTraceIntervalScratch(mapCapacity, coveredAddressCapacity);
 1803743        TraceIntervals = new SwiftList<GridTraceInterval>(traceIntervalCapacity);
 1803744        BodyTraceCells = new SwiftList<GridNavigationBodyTraceCell>(coveredAddressCapacity);
 1803745        BodyTraceScratch = new GridNavigationBodyTraceScratch(
 1803746            mapCapacity,
 1803747            coveredAddressCapacity);
 1803748        ChainRecords = traceIntervalCapacity == 0
 1803749            ? Array.Empty<NavigationRayChainRecord>()
 1803750            : new NavigationRayChainRecord[traceIntervalCapacity];
 1803751        Dependencies = new NavigationDependencyWorkspace(pageCapacity, componentCapacity);
 1803752    }
 53
 54    internal int MapCapacity { get; }
 55
 56    internal int CoveredAddressCapacity { get; }
 57
 58    internal int TraceIntervalCapacity { get; }
 59
 60    internal GridTraceIntervalScratch TraceScratch { get; }
 61
 62    internal SwiftList<GridTraceInterval> TraceIntervals { get; }
 63
 64    internal SwiftList<GridNavigationBodyTraceCell> BodyTraceCells { get; }
 65
 66    internal GridNavigationBodyTraceScratch BodyTraceScratch { get; }
 67
 68    internal NavigationRayChainRecord[] ChainRecords { get; }
 69
 70    internal NavigationDependencyWorkspace Dependencies { get; }
 71
 72    internal void Reset()
 73    {
 777174        TraceScratch.Clear();
 777175        TraceIntervals.Clear();
 777176        BodyTraceCells.Clear();
 777177        BodyTraceScratch.Clear();
 777178        Dependencies.Reset();
 777179    }
 80}
 81
 82internal enum NavigationRayChainRecordState : byte
 83{
 84    Unavailable,
 85    Unreached,
 86    Ready,
 87    Expanded
 88}
 89
 90internal struct NavigationRayChainRecord
 91{
 92    internal NavigationNodeRef Node;
 93    internal int PredecessorOrdinal;
 94    internal int RootOrdinal;
 95    internal Fixed64 ArrivalParameter;
 96    internal Fixed64 TraversalCost;
 97    internal NavigationExplicitConnectionRecord IncomingExplicitConnection;
 98    internal NavigationRayChainRecordState State;
 99    internal bool IsSemanticCostNeutral;
 100}