< Summary

Information
Class: GridForge.Diagnostics.GridDiagnosticQuery
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Diagnostics/GridDiagnosticQuery.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 119
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%22100%
AllPhysical()100%11100%
ForGrid(...)100%11100%
ForBounds(...)100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Diagnostics/GridDiagnosticQuery.cs

#LineLine coverage
 1//=======================================================================
 2// GridDiagnosticQuery.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.Grids.Storage;
 10using GridForge.Grids.Topology;
 11
 12namespace GridForge.Diagnostics;
 13
 14/// <summary>
 15/// Immutable filter and budget settings for a diagnostic cell query.
 16/// </summary>
 17public readonly struct GridDiagnosticQuery
 18{
 19    /// <summary>
 20    /// Default maximum number of diagnostic cells returned by a single query.
 21    /// </summary>
 22    public const int DefaultMaxCells = 65536;
 23
 24    /// <summary>
 25    /// Optional world-local grid slot filter.
 26    /// </summary>
 27    public readonly ushort? GridIndex;
 28
 29    /// <summary>
 30    /// Optional topology filter.
 31    /// </summary>
 32    public readonly GridTopologyKind? TopologyKind;
 33
 34    /// <summary>
 35    /// Optional storage-kind filter.
 36    /// </summary>
 37    public readonly GridStorageKind? StorageKind;
 38
 39    /// <summary>
 40    /// Selects whether the query should return physical cells, missing sparse
 41    /// address cells, or both.
 42    /// </summary>
 43    public readonly GridDiagnosticAddressMode AddressMode;
 44
 45    /// <summary>
 46    /// State flags that a returned cell must contain.
 47    /// </summary>
 48    public readonly GridDiagnosticCellState RequiredStates;
 49
 50    /// <summary>
 51    /// State flags that exclude a cell from the result.
 52    /// </summary>
 53    public readonly GridDiagnosticCellState ExcludedStates;
 54
 55    /// <summary>
 56    /// Optional world-space minimum bounds for the query.
 57    /// </summary>
 58    public readonly Vector3d? BoundsMin;
 59
 60    /// <summary>
 61    /// Optional world-space maximum bounds for the query.
 62    /// </summary>
 63    public readonly Vector3d? BoundsMax;
 64
 65    /// <summary>
 66    /// Maximum number of cells this query may return before it is stopped.
 67    /// </summary>
 68    public readonly int MaxCells;
 69
 70    /// <summary>
 71    /// Allows missing sparse address-space queries to scan the whole grid
 72    /// address space when no bounds are supplied.
 73    /// </summary>
 74    public readonly bool AllowFullAddressSpaceScan;
 75
 76    /// <summary>
 77    /// Initializes a diagnostic query.
 78    /// </summary>
 79    public GridDiagnosticQuery(
 80        ushort? gridIndex = null,
 81        GridTopologyKind? topologyKind = null,
 82        GridStorageKind? storageKind = null,
 83        GridDiagnosticAddressMode addressMode = GridDiagnosticAddressMode.PhysicalOnly,
 84        GridDiagnosticCellState requiredStates = GridDiagnosticCellState.None,
 85        GridDiagnosticCellState excludedStates = GridDiagnosticCellState.None,
 86        Vector3d? boundsMin = null,
 87        Vector3d? boundsMax = null,
 88        int maxCells = DefaultMaxCells,
 89        bool allowFullAddressSpaceScan = false)
 90    {
 6791        GridIndex = gridIndex;
 6792        TopologyKind = topologyKind;
 6793        StorageKind = storageKind;
 6794        AddressMode = addressMode;
 6795        RequiredStates = requiredStates;
 6796        ExcludedStates = excludedStates;
 6797        BoundsMin = boundsMin;
 6798        BoundsMax = boundsMax;
 6799        MaxCells = maxCells > 0 ? maxCells : DefaultMaxCells;
 67100        AllowFullAddressSpaceScan = allowFullAddressSpaceScan;
 67101    }
 102
 103    /// <summary>
 104    /// Creates a query that returns physical cells from all active grids.
 105    /// </summary>
 39106    public static GridDiagnosticQuery AllPhysical() => new GridDiagnosticQuery(maxCells: DefaultMaxCells);
 107
 108    /// <summary>
 109    /// Creates a physical-cell query for one world-local grid slot.
 110    /// </summary>
 3111    public static GridDiagnosticQuery ForGrid(ushort gridIndex) => new(gridIndex: gridIndex);
 112
 113    /// <summary>
 114    /// Creates a physical-cell query clipped to world-space bounds.
 115    /// </summary>
 4116    public static GridDiagnosticQuery ForBounds(Vector3d min, Vector3d max) => new(
 4117        boundsMin: min,
 4118        boundsMax: max);
 119}