< Summary

Information
Class: GridForge.Grids.VoxelGrid
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/VoxelGrid.cs
Line coverage
100%
Covered lines: 318
Uncovered lines: 0
Coverable lines: 318
Total lines: 1053
Line coverage: 100%
Branch coverage
100%
Covered branches: 186
Total branches: 186
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_BoundsMin()100%11100%
get_BoundsMax()100%11100%
get_BoundsCenter()100%11100%
get_ConfiguredVoxelCount()100%22100%
get_StorageKind()100%22100%
get_Voxels()100%11100%
get_NeighborSlotCount()100%22100%
get_TopologyKind()100%22100%
get_IsConjoined()100%22100%
get_ScanCellSize()100%11100%
get_ScanCells()100%22100%
get_IsOccupied()100%22100%
.ctor()100%11100%
get_Topology()100%11100%
get_ScanWidth()100%11100%
get_ScanHeight()100%11100%
get_ScanLength()100%11100%
Initialize(...)100%22100%
Reset()100%22100%
ReleaseActiveScanCells()100%22100%
ReleaseNeighbors()100%44100%
ClearDimensions()100%11100%
IncrementVersion()100%22100%
ConfigureScanDimensions()100%11100%
GetRectangularNeighborDirection(...)100%22100%
GetHexNeighborDirection(...)100%22100%
TryGetNeighborSlot(...)100%88100%
TryGetNeighborSlot(...)100%88100%
GetNeighborOffset(...)100%11100%
TryGetNeighborSlot(...)100%44100%
TryGetNeighborSlot(...)100%44100%
TryAddGridNeighbor(...)100%88100%
TryRemoveGridNeighbor(...)100%66100%
TryGetGridNeighborSet(...)100%44100%
ReleaseNeighborSetIfEmpty(...)100%22100%
IsOnBoundary(...)100%1010100%
IsInBounds(...)100%22100%
GetAllGridNeighbors()100%88100%
IsValidVoxelIndex(...)100%66100%
IsVoxelIndexInBounds(...)100%44100%
IsFacingBoundary(...)100%22100%
IsFacingBoundary(...)100%22100%
TryGetVoxelIndex(...)100%44100%
TryGetVoxelIndex(...)100%11100%
TryGetVoxelIndex(...)100%11100%
IsVoxelAllocated(...)100%22100%
ContainsVoxel(...)100%11100%
TryAddVoxel(...)100%88100%
TryRemoveVoxel(...)100%1010100%
CanMutateSparseVoxel(...)100%44100%
CanRemoveSparseVoxel(...)100%88100%
TryGetVoxel(...)100%22100%
EnumerateVoxels()100%44100%
VisitVoxels(...)100%22100%
AddVoxelsInIndexRange(...)100%22100%
TryGetVoxel(...)100%11100%
TryGetVoxel(...)100%22100%
TryGetClosestVoxel(...)100%11100%
TryGetClosestVoxel(...)100%44100%
TryGetVoxel(...)100%11100%
TryGetVoxel(...)100%11100%
TryGetClosestVoxel(...)100%11100%
TryGetClosestVoxel(...)100%11100%
GetScanCellKey(...)100%22100%
GetScanCellKey(...)100%44100%
GetScanCellKey(...)100%66100%
TryGetScanCell(...)100%22100%
TryGetScanCell(...)100%11100%
TryGetScanCell(...)100%22100%
AddScanCellsInRange(...)100%22100%
GetActiveScanCells()100%88100%
CeilToGrid(...)100%11100%
FloorToGrid(...)100%11100%
SnapToScanCell(...)100%11100%
NormalizeBounds(...)100%11100%
GetWorldPosition(...)100%11100%
GetWorldOffset(...)100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/VoxelGrid.cs

#LineLine coverage
 1//=======================================================================
 2// VoxelGrid.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 System.Collections.Generic;
 10using System.Runtime.CompilerServices;
 11using FixedMathSharp;
 12using GridForge.Configuration;
 13using GridForge.Grids.Storage;
 14using GridForge.Grids.Topology;
 15using GridForge.Spatial;
 16using SwiftCollections;
 17using SwiftCollections.Dimensions;
 18using SwiftCollections.Pool;
 19
 20namespace GridForge.Grids;
 21
 22/// <summary>
 23/// Represents a 3D grid structure for spatial organization, managing voxels and scan cells.
 24/// Handles initialization, neighbor relationships, and occupancy tracking.
 25/// </summary>
 26public class VoxelGrid
 27{
 28    #region Fields & Properties
 29
 30    /// <summary>
 31    /// Nonzero 64-bit world-local allocation generation identifying this active grid instance.
 32    /// Zero indicates an inactive or unallocated grid.
 33    /// </summary>
 34    public long SpawnToken { get; private set; }
 35
 36    /// <summary>
 37    /// World-local index of the grid within its owning world.
 38    /// </summary>
 39    public ushort GridIndex { get; private set; }
 40
 41    /// <summary>
 42    /// The world that owns this grid instance.
 43    /// </summary>
 44    public GridWorld? World { get; private set; }
 45
 46    /// <summary>
 47    /// Synchronizes obstacle mutations for this grid.
 48    /// </summary>
 49    internal object ObstacleSyncRoot { get; } = new object();
 50
 51    /// <summary>
 52    /// Synchronizes occupant mutations for this grid.
 53    /// </summary>
 54    internal object OccupantSyncRoot { get; } = new object();
 55
 56    /// <inheritdoc cref="GridConfiguration"/>
 57    public GridConfiguration Configuration { get; private set; }
 58
 59    /// <summary>
 60    /// Minimum bounds of the grid in world coordinates.
 61    /// </summary>
 37681562    public Vector3d BoundsMin => Configuration.BoundsMin;
 63
 64    /// <summary>
 65    /// Maximum bounds of the grid in world coordinates.
 66    /// </summary>
 1837667    public Vector3d BoundsMax => Configuration.BoundsMax;
 68
 69    /// <summary>
 70    /// Center position of the grid in world space.
 71    /// </summary>
 57872    public Vector3d BoundsCenter => Configuration.GridCenter;
 73
 74    /// <summary>
 75    /// Grid width in number of voxels.
 76    /// </summary>
 77    public int Width { get; private set; }
 78
 79    /// <summary>
 80    /// Grid height in number of voxels.
 81    /// </summary>
 82    public int Height { get; private set; }
 83
 84    /// <summary>
 85    /// Grid length in number of voxels.
 86    /// </summary>
 87    public int Length { get; private set; }
 88
 89    /// <summary>
 90    /// Total addressable voxel count within the grid bounds.
 91    /// </summary>
 92    public int Size { get; private set; }
 93
 94    /// <summary>
 95    /// The number of physical voxels configured in the grid storage.
 96    /// Dense grids report <see cref="Size"/>; sparse grids report configured voxels only.
 97    /// </summary>
 98    public int ConfiguredVoxelCount
 99    {
 100        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 261101        get => _storage?.ConfiguredVoxelCount ?? 0;
 102    }
 103
 104    /// <summary>
 105    /// The physical voxel storage strategy used by this grid.
 106    /// </summary>
 107    public GridStorageKind StorageKind
 108    {
 109        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 12643110        get => _storage?.Kind ?? GridStorageKind.Dense;
 111    }
 112
 113    /// <summary>
 114    /// The dense 3D collection of voxels managed by this grid when dense storage is active.
 115    /// </summary>
 116    internal SwiftArray3D<Voxel>? Voxels
 117    {
 118        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 3119        get => _denseStorage.Voxels;
 120    }
 121
 122    /// <summary>
 123    /// Stores topology-local neighbor slots for neighboring grids based on their relative positions.
 124    /// </summary>
 125    /// <remarks>
 126    /// Each topology-local slot can contain multiple neighboring grid IDs. Contact
 127    /// queries can also return multiple voxel contacts across different grid cell sizes.
 128    /// </remarks>
 129    public SwiftSparseMap<SwiftHashSet<int>>? Neighbors { get; private set; }
 130
 131    /// <summary>
 132    /// Count of currently linked neighboring grids.
 133    /// </summary>
 134    public byte NeighborCount { get; private set; }
 135
 136    /// <summary>
 137    /// Count of topology-local neighbor slots supported by this grid.
 138    /// </summary>
 397139    internal int NeighborSlotCount => _topology?.NeighborSlotCount ?? 0;
 140
 141    /// <summary>
 142    /// The active topology kind for this grid.
 143    /// </summary>
 125144    internal GridTopologyKind? TopologyKind => _topology?.Kind;
 145
 146    /// <summary>
 147    /// Determines whether this grid has any linked neighbors.
 148    /// </summary>
 111149    public bool IsConjoined => Neighbors != null && NeighborCount > 0;
 150
 151    /// <summary>
 152    /// Size of a scan cell used for spatial partitioning.
 153    /// </summary>
 1046762154    public int ScanCellSize => Configuration.ScanCellSize;
 155
 156    /// <summary>
 157    /// Collection of scan cells indexed by their grid-local scan cell key.
 158    /// </summary>
 159    internal SwiftSparseMap<ScanCell>? ScanCells
 160    {
 161        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 3162        get => _storage?.ScanCells;
 163    }
 164
 165    /// <summary>
 166    /// Stores currently active (occupied) scan cells within the grid.
 167    /// </summary>
 168    public SwiftHashSet<int>? ActiveScanCells { get; internal set; }
 169
 170    /// <summary>
 171    /// Indicates whether the grid is currently active.
 172    /// </summary>
 173    public bool IsActive { get; private set; }
 174
 175    /// <summary>
 176    /// Determines whether the grid is occupied (active and containing occupants).
 177    /// </summary>
 32178    public bool IsOccupied => ActiveScanCells?.Count > 0;
 179
 180    /// <summary>
 181    /// Tracks the number of obstacles currently registered in the grid.
 182    /// </summary>
 183    public int ObstacleCount { get; internal set; }
 184
 185    /// <summary>
 186    /// Tracks the version of the grid, incremented when a <see cref="Voxel"/> is modified.
 187    /// </summary>
 188    public uint Version { get; private set; }
 189
 190    internal ulong LastChangeSequence { get; set; }
 191
 192    private int _scanWidth;
 193    private int _scanHeight;
 194    private int _scanLength;
 195    private int _scanLayerSize;
 196
 197    private IGridTopology? _topology;
 198    private IVoxelGridStorage? _storage;
 102199    private readonly DenseVoxelGridStorage _denseStorage = new();
 102200    private readonly SparseVoxelGridStorage _sparseStorage = new();
 201
 487178202    internal IGridTopology Topology => _topology!;
 203
 204    internal int ScanWidth
 205    {
 206        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 3031207        get => _scanWidth;
 208    }
 209
 210    internal int ScanHeight
 211    {
 212        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 3683213        get => _scanHeight;
 214    }
 215
 216    internal int ScanLength
 217    {
 218        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 12621219        get => _scanLength;
 220    }
 221
 222    #endregion
 223
 224    #region Initialization & Reset
 225
 226    /// <summary>
 227    /// Initializes the grid with an explicit owning world and configured sparse voxel set.
 228    /// </summary>
 229    /// <param name="world">The world that will own this grid.</param>
 230    /// <param name="gridIndex">The unique index of this grid in the world.</param>
 231    /// <param name="spawnToken">The world-local allocation generation for this grid.</param>
 232    /// <param name="configuration">The normalized configuration settings for the grid.</param>
 233    /// <param name="topology">The validated topology instance for this grid.</param>
 234    /// <param name="configuredVoxels">The validated sparse voxel indices to materialize.</param>
 235    internal void Initialize(
 236        GridWorld world,
 237        ushort gridIndex,
 238        long spawnToken,
 239        GridConfiguration configuration,
 240        IGridTopology topology,
 241        VoxelIndex[] configuredVoxels)
 242    {
 1226243        Version = 1;
 244
 1226245        World = world;
 1226246        GridIndex = gridIndex;
 247
 1226248        Configuration = configuration;
 1226249        _topology = topology;
 250
 1226251        SpawnToken = spawnToken;
 252
 253        // +1 to account for inclusive bounds and to ensure that even the smallest grids (1x1x1) remain valid.
 1226254        GridDimensions dimensions = topology.CalculateDimensions(BoundsMin, BoundsMax);
 1226255        Width = dimensions.Width;
 1226256        Height = dimensions.Height;
 1226257        Length = dimensions.Length;
 1226258        Size = Width * Height * Length;
 259
 1226260        ConfigureScanDimensions();
 1226261        if (configuration.StorageKind == GridStorageKind.Sparse)
 262        {
 182263            _sparseStorage.Initialize(this, configuredVoxels);
 182264            _storage = _sparseStorage;
 265        }
 266        else
 267        {
 1044268            _denseStorage.Initialize(this);
 1044269            _storage = _denseStorage;
 270        }
 271
 1226272        IsActive = true;
 1226273    }
 274
 275    /// <summary>
 276    /// Resets the grid, clearing all voxels and scan cells.
 277    /// </summary>
 278    internal void Reset()
 279    {
 1228280        if (!IsActive)
 2281            return;
 282
 1226283        _storage!.Reset(this);
 1226284        _storage = null;
 285
 286        // Just in case since voxels should have already cleared any registered obstacles.
 1226287        ObstacleCount = 0;
 288
 1226289        ReleaseActiveScanCells();
 1226290        ReleaseNeighbors();
 291
 1226292        Configuration = default;
 1226293        World = null;
 1226294        _topology = null;
 295
 1226296        SpawnToken = 0;
 1226297        Version = 0;
 1226298        LastChangeSequence = 0;
 299
 1226300        GridIndex = ushort.MaxValue;
 301
 1226302        ClearDimensions();
 303
 1226304        IsActive = false;
 1226305    }
 306
 307    private void ReleaseActiveScanCells()
 308    {
 1226309        if (ActiveScanCells == null)
 1145310            return;
 311
 81312        SwiftHashSetPool<int>.Shared.Release(ActiveScanCells);
 81313        ActiveScanCells = null;
 81314    }
 315
 316    private void ReleaseNeighbors()
 317    {
 1226318        if (Neighbors == null)
 1097319            return;
 320
 546321        foreach (SwiftHashSet<int> neighbors in Neighbors.Values)
 144322            SwiftHashSetPool<int>.Shared.Release(neighbors);
 323
 129324        Neighbors = null;
 129325        NeighborCount = 0;
 129326    }
 327
 328    private void ClearDimensions()
 329    {
 1226330        Width = 0;
 1226331        Height = 0;
 1226332        Length = 0;
 1226333        Size = 0;
 1226334        _scanWidth = 0;
 1226335        _scanHeight = 0;
 1226336        _scanLength = 0;
 1226337        _scanLayerSize = 0;
 1226338    }
 339
 340    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 341    internal uint IncrementVersion()
 342    {
 2232343        Version = Version == uint.MaxValue ? 1u : Version + 1u;
 2232344        return Version;
 345    }
 346
 347    #endregion
 348
 349    #region Grid Construction
 350
 351    private void ConfigureScanDimensions()
 352    {
 1226353        _scanWidth = ((Width - 1) / ScanCellSize) + 1;
 1226354        _scanHeight = ((Height - 1) / ScanCellSize) + 1;
 1226355        _scanLength = ((Length - 1) / ScanCellSize) + 1;
 1226356        _scanLayerSize = _scanWidth * _scanHeight;
 1226357    }
 358
 359    #endregion
 360
 361    #region Boundary Management
 362
 363    /// <summary>
 364    /// Determines the rectangular-prism direction from grid <paramref name="a"/> to neighboring grid <paramref name="b"
 365    /// </summary>
 366    /// <param name="a">The source rectangular-prism grid.</param>
 367    /// <param name="b">The neighboring rectangular-prism grid.</param>
 368    /// <returns>The rectangular direction from <paramref name="a"/> to <paramref name="b"/>, or <see cref="RectangularD
 369    public static RectangularDirection GetRectangularNeighborDirection(VoxelGrid a, VoxelGrid b)
 370    {
 8371        return TryGetNeighborSlot(a, b, GridTopologyKind.RectangularPrism, out int slot)
 8372            ? (RectangularDirection)slot
 8373            : RectangularDirection.None;
 374    }
 375
 376    /// <summary>
 377    /// Determines the hex-prism direction from grid <paramref name="a"/> to neighboring grid <paramref name="b"/>.
 378    /// </summary>
 379    /// <param name="a">The source hex-prism grid.</param>
 380    /// <param name="b">The neighboring hex-prism grid.</param>
 381    /// <returns>The hex direction from <paramref name="a"/> to <paramref name="b"/>, or <see cref="HexDirection.None"/>
 382    public static HexDirection GetHexNeighborDirection(VoxelGrid a, VoxelGrid b)
 383    {
 7384        return TryGetNeighborSlot(a, b, GridTopologyKind.HexPrism, out int slot)
 7385            ? (HexDirection)slot
 7386            : HexDirection.None;
 387    }
 388
 389    private static bool TryGetNeighborSlot(VoxelGrid a, VoxelGrid b, GridTopologyKind expectedKind, out int slot)
 390    {
 15391        if (a._topology?.Kind != expectedKind || b._topology?.Kind != expectedKind)
 392        {
 10393            slot = -1;
 10394            return false;
 395        }
 396
 5397        return TryGetNeighborSlot(a, b, out slot);
 398    }
 399
 400    private static bool TryGetNeighborSlot(VoxelGrid a, VoxelGrid b, out int slot)
 401    {
 329402        slot = -1;
 403
 329404        if (a._topology == null
 329405            || b._topology == null
 329406            || a._topology.Kind != b._topology.Kind)
 407        {
 40408            return false;
 409        }
 410
 289411        return a._topology.TryGetNeighborSlotFromWorldDelta(b.BoundsCenter - a.BoundsCenter, out slot)
 289412            && (uint)slot < (uint)a._topology.NeighborSlotCount;
 413    }
 414
 415    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 455416    internal VoxelIndex GetNeighborOffset(int slot) => Topology.GetNeighborOffset(slot);
 417
 418    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 419    internal bool TryGetNeighborSlot(RectangularDirection direction, out int slot)
 420    {
 131421        slot = (int)direction;
 131422        return _topology?.Kind == GridTopologyKind.RectangularPrism
 131423            && (uint)slot < (uint)_topology.NeighborSlotCount;
 424    }
 425
 426    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 427    internal bool TryGetNeighborSlot(HexDirection direction, out int slot)
 428    {
 14429        slot = (int)direction;
 14430        return _topology?.Kind == GridTopologyKind.HexPrism
 14431            && (uint)slot < (uint)_topology.NeighborSlotCount;
 432    }
 433
 434    /// <summary>
 435    /// Adds a neighboring grid and updates relationships.
 436    /// </summary>
 437    /// <param name="neighborGrid">The neighboring grid to add.</param>
 438    internal bool TryAddGridNeighbor(VoxelGrid neighborGrid)
 439    {
 296440        if (!TryGetNeighborSlot(this, neighborGrid, out int neighborSlot))
 85441            return false;
 442
 443        // Ensure the neighbor array is allocated and store the new neighbor
 211444        Neighbors ??= new SwiftSparseMap<SwiftHashSet<int>>();
 211445        if (!Neighbors.TryGetValue(neighborSlot, out SwiftHashSet<int> neighborSet))
 446        {
 160447            neighborSet = SwiftHashSetPool<int>.Shared.Rent();
 160448            Neighbors.Add(neighborSlot, neighborSet);
 449        }
 450
 211451        if (!neighborSet.Add(neighborGrid.GridIndex))
 1452            return false;
 453
 210454        NeighborCount++;
 210455        IncrementVersion();
 456
 210457        return true;
 458    }
 459
 460    /// <summary>
 461    /// Removes a neighboring grid relationship.
 462    /// </summary>
 463    /// <param name="neighborGrid">The neighboring grid to remove.</param>
 464    internal bool TryRemoveGridNeighbor(VoxelGrid neighborGrid)
 465    {
 27466        if (!TryGetGridNeighborSet(neighborGrid, out int neighborSlot, out SwiftHashSet<int>? neighborSet))
 2467            return false;
 468
 25469        if (!neighborSet!.Remove(neighborGrid.GridIndex))
 1470            return false;
 471
 24472        ReleaseNeighborSetIfEmpty(neighborSlot, neighborSet);
 473
 24474        if (--NeighborCount == 0)
 13475            Neighbors = null;
 476
 24477        IncrementVersion();
 478
 24479        return true;
 480    }
 481
 482    private bool TryGetGridNeighborSet(
 483        VoxelGrid neighborGrid,
 484        out int neighborSlot,
 485        out SwiftHashSet<int>? neighborSet)
 486    {
 27487        neighborSet = null;
 27488        neighborSlot = -1;
 489
 27490        if (!IsConjoined)
 1491            return false;
 492
 26493        return TryGetNeighborSlot(this, neighborGrid, out neighborSlot)
 26494            && Neighbors!.TryGetValue(neighborSlot, out neighborSet);
 495    }
 496
 497    private void ReleaseNeighborSetIfEmpty(int neighborIndex, SwiftHashSet<int> neighborSet)
 498    {
 24499        if (neighborSet.Count > 0)
 8500            return;
 501
 16502        GridForgeLogger.Channel.Info($"Releasing unused neighbor collection.");
 16503        SwiftHashSetPool<int>.Shared.Release(neighborSet);
 16504        Neighbors!.Remove(neighborIndex);
 16505    }
 506
 507    #endregion
 508
 509    #region Grid Queries
 510
 511    /// <summary>
 512    /// Determines if a voxel coordinate is at the boundary of the grid.
 513    /// Used to determine if a voxel should update when a neighboring grid is added/removed.
 514    /// </summary>
 515    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 516    public bool IsOnBoundary(VoxelIndex coord) =>
 346702517         coord.x == 0 || coord.x == Width - 1
 346702518      || coord.y == 0 || coord.y == Height - 1
 346702519      || coord.z == 0 || coord.z == Length - 1;
 520
 521    /// <summary>
 522    /// Checks whether a given position falls within the grid bounds.
 523    /// </summary>
 524    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 525    public bool IsInBounds(Vector3d target) =>
 89526        IsActive && Topology.IsInBounds(BoundsMin, BoundsMax, Width, Height, Length, target);
 527
 528    /// <summary>
 529    /// Retrieves all neighboring grids connected to this grid.
 530    /// </summary>
 531    /// <returns>An enumeration of all neighboring grids.</returns>
 532    public IEnumerable<VoxelGrid> GetAllGridNeighbors()
 533    {
 13534        if (!IsConjoined)
 5535            yield break;
 536
 8537        var values = Neighbors!.DenseValues;
 8538        int count = Neighbors.Count;
 539
 38540        for (int i = 0; i < count; i++)
 541        {
 11542            SwiftHashSet<int> neighborSet = values[i];
 44543            foreach (int neighborIndex in neighborSet)
 544            {
 11545                if (World!.TryGetGrid(neighborIndex, out VoxelGrid? neighborGrid))
 546                {
 11547                    yield return neighborGrid!;
 548                }
 549            }
 550        }
 8551    }
 552
 553    /// <summary>
 554    /// Determines whether the given voxel coordinates are within the valid range of the grid.
 555    /// </summary>
 556    public bool IsValidVoxelIndex(int x, int y, int z)
 557    {
 4694558        if (!IsActive)
 559        {
 6560            GridForgeLogger.Channel.Warn($"This Grid is not currently active.");
 6561            return false;
 562        }
 563
 4688564        bool result = IsVoxelIndexInBounds(x, y, z);
 565
 4688566        if (!result)
 260567            GridForgeLogger.Channel.Info($"The coordinate {(x, y, z)} is not valid for this grid.");
 568
 4688569        return result;
 570    }
 571
 572    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 573    private bool IsVoxelIndexInBounds(int x, int y, int z) =>
 4688574         (uint)x < (uint)Width
 4688575      && (uint)y < (uint)Height
 4688576      && (uint)z < (uint)Length;
 577
 578    /// <summary>
 579    /// Determines if a topology-local voxel index is facing the rectangular-prism boundary in the supplied direction.
 580    /// </summary>
 581    public bool IsFacingBoundary(VoxelIndex voxelIndex, RectangularDirection direction) =>
 56582        TryGetNeighborSlot(direction, out int slot)
 56583        && _topology!.IsFacingBoundary(voxelIndex, slot, Width, Height, Length);
 584
 585    /// <summary>
 586    /// Determines if a topology-local voxel index is facing the hex-prism boundary in the supplied direction.
 587    /// </summary>
 588    public bool IsFacingBoundary(VoxelIndex voxelIndex, HexDirection direction) =>
 5589        TryGetNeighborSlot(direction, out int slot)
 5590        && _topology!.IsFacingBoundary(voxelIndex, slot, Width, Height, Length);
 591
 592    /// <summary>
 593    /// Converts a world position to a topology-local voxel index within the grid.
 594    /// Rectangular-prism grids return X/Y/Z coordinates; hex-prism grids return axial Q, layer, and axial R in X/Y/Z fi
 595    /// </summary>
 596    public bool TryGetVoxelIndex(Vector3d position, out VoxelIndex result)
 597    {
 3308598        result = default;
 599
 3308600        if (!IsActive)
 601        {
 3602            GridForgeLogger.Channel.Warn($"This Grid is not currently allocated.");
 3603            return false;
 604        }
 605
 3305606        if (!Topology.TryGetVoxelIndex(BoundsMin, BoundsMax, Width, Height, Length, position, out VoxelIndex voxelIndex)
 607        {
 18608            GridForgeLogger.Channel.Warn($"Position does not fall in the bounds of this grid");
 18609            return false;
 610        }
 611
 3287612        result = voxelIndex;
 3287613        return true;
 614    }
 615
 616    /// <summary>
 617    /// Converts a 2D XZ-plane world position on the default world Y layer to a voxel index within the grid.
 618    /// </summary>
 619    /// <param name="position">The 2D position whose X component maps to world X and Y component maps to world Z.</param
 620    /// <param name="result">The resolved voxel index, if found.</param>
 621    /// <returns>True if the position resolved to an allocated voxel index; otherwise false.</returns>
 622    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 623    public bool TryGetVoxelIndex(Vector2d position, out VoxelIndex result) =>
 1624        TryGetVoxelIndex(position, default, out result);
 625
 626    /// <summary>
 627    /// Converts a 2D XZ-plane world position on the supplied world Y layer to a voxel index within the grid.
 628    /// </summary>
 629    /// <param name="position">The 2D position whose X component maps to world X and Y component maps to world Z.</param
 630    /// <param name="layerY">The world Y layer to resolve. Defaults to zero when omitted by paired overloads.</param>
 631    /// <param name="result">The resolved voxel index, if found.</param>
 632    /// <returns>True if the position resolved to an allocated voxel index; otherwise false.</returns>
 633    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 634    public bool TryGetVoxelIndex(Vector2d position, Fixed64 layerY, out VoxelIndex result) =>
 5635        TryGetVoxelIndex(GridPlane2d.ToWorld(position, layerY), out result);
 636
 637    /// <summary>
 638    /// Checks if a voxel at the given topology-local coordinates is allocated within the grid.
 639    /// </summary>
 640    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 641    public bool IsVoxelAllocated(int x, int y, int z) =>
 69642        IsValidVoxelIndex(x, y, z) && _storage!.TryGetVoxel(x, y, z, out _);
 643
 644    /// <summary>
 645    /// Checks whether a physical voxel is configured at the supplied grid-local index.
 646    /// </summary>
 647    /// <param name="voxelIndex">The grid-local voxel index to test.</param>
 648    /// <returns>True when the index resolves to a configured voxel; otherwise false.</returns>
 649    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 650    public bool ContainsVoxel(VoxelIndex voxelIndex) =>
 61651        IsVoxelAllocated(voxelIndex.x, voxelIndex.y, voxelIndex.z);
 652
 653    /// <summary>
 654    /// Configures a sparse voxel at runtime. Dense grids, invalid indices, and already-configured
 655    /// sparse voxels return false.
 656    /// </summary>
 657    /// <param name="voxelIndex">The grid-local voxel index to configure.</param>
 658    /// <param name="voxel">The configured voxel when the operation succeeds.</param>
 659    /// <returns>True when a new sparse voxel was configured; otherwise false.</returns>
 660    public bool TryAddVoxel(VoxelIndex voxelIndex, out Voxel? voxel)
 661    {
 172662        voxel = null;
 663        bool drainCommittedChanges;
 172664        GridWorld? world = World;
 172665        if (world == null)
 1666            return false;
 667
 171668        world.EnterReadLock();
 669        try
 670        {
 171671            lock (world.ChangeSyncRoot)
 672            {
 171673                if (!CanMutateSparseVoxel(voxelIndex)
 171674                    || !_sparseStorage.TryAddVoxel(this, voxelIndex, out voxel))
 675                {
 2676                    return false;
 677                }
 678
 169679                uint gridVersion = IncrementVersion();
 169680                voxel!.CachedGridVersion = gridVersion;
 169681                GridEventInfo eventInfo = world.CreateGridEventInfo(
 169682                    this,
 169683                    GridEventKind.SparseVoxelAdded,
 169684                    voxelIndex,
 169685                    voxel.WorldPosition,
 169686                    voxel.WorldPosition,
 169687                    world.AllocateChangeStamp(),
 169688                    hasVoxelState: true,
 169689                    isVoxelPresent: true,
 169690                    obstacleCount: 0);
 169691                drainCommittedChanges = world.EnqueueCommittedChange(new GridCommittedChange(eventInfo));
 169692            }
 693        }
 694        finally
 695        {
 171696            world.ExitReadLock();
 171697        }
 698
 169699        if (drainCommittedChanges)
 168700            world.DrainCommittedChanges();
 169701        return true;
 2702    }
 703
 704    /// <summary>
 705    /// Removes a configured sparse voxel at runtime when it has no unsafe runtime state.
 706    /// Dense grids, missing voxels, occupied voxels, voxels with obstacle tokens, partitioned voxels,
 707    /// and voxels with active event subscribers return false.
 708    /// </summary>
 709    /// <param name="voxelIndex">The grid-local voxel index to remove.</param>
 710    /// <returns>True when the sparse voxel was removed; otherwise false.</returns>
 711    public bool TryRemoveVoxel(VoxelIndex voxelIndex)
 712    {
 713        bool drainCommittedChanges;
 154714        GridWorld? world = World;
 154715        if (world == null)
 1716            return false;
 717
 153718        world.EnterReadLock();
 719        try
 720        {
 153721            lock (world.ChangeSyncRoot)
 722            {
 153723                if (!CanMutateSparseVoxel(voxelIndex)
 153724                    || !TryGetVoxel(voxelIndex, out Voxel? voxel)
 153725                    || !CanRemoveSparseVoxel(voxel!))
 726                {
 8727                    return false;
 728                }
 729
 145730                Vector3d affectedPosition = voxel!.WorldPosition;
 145731                _sparseStorage.TryRemoveVoxel(this, voxelIndex, out _);
 732
 145733                IncrementVersion();
 145734                GridEventInfo eventInfo = world.CreateGridEventInfo(
 145735                    this,
 145736                    GridEventKind.SparseVoxelRemoved,
 145737                    voxelIndex,
 145738                    affectedPosition,
 145739                    affectedPosition,
 145740                    world.AllocateChangeStamp(),
 145741                    hasVoxelState: true,
 145742                    isVoxelPresent: false,
 145743                    obstacleCount: 0);
 145744                drainCommittedChanges = world.EnqueueCommittedChange(new GridCommittedChange(eventInfo));
 145745            }
 746        }
 747        finally
 748        {
 153749            world.ExitReadLock();
 153750        }
 751
 145752        if (drainCommittedChanges)
 144753            world.DrainCommittedChanges();
 145754        return true;
 8755    }
 756
 757    private bool CanMutateSparseVoxel(VoxelIndex voxelIndex) =>
 324758        IsActive
 324759        && StorageKind == GridStorageKind.Sparse
 324760        && IsValidVoxelIndex(voxelIndex.x, voxelIndex.y, voxelIndex.z);
 761
 762    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 763    private static bool CanRemoveSparseVoxel(Voxel voxel) =>
 151764        voxel.IsAllocated
 151765        && !voxel.IsOccupied
 151766        && voxel.ObstacleCount == 0
 151767        && !voxel.IsPartioned
 151768        && !voxel.HasEventSubscribers;
 769
 770    /// <summary>
 771    /// Retrieves the <see cref="Voxel"/> at the specified topology-local coordinates, if allocated.
 772    /// </summary>
 773    public bool TryGetVoxel(int x, int y, int z, out Voxel? result)
 774    {
 4287775        result = null;
 776
 4287777        if (!IsValidVoxelIndex(x, y, z))
 258778            return false;
 779
 4029780        return _storage!.TryGetVoxel(x, y, z, out result);
 781    }
 782
 783    /// <summary>
 784    /// Enumerates physical voxels configured in this grid in deterministic storage order.
 785    /// </summary>
 786    public IEnumerable<Voxel> EnumerateVoxels() =>
 11787        _storage?.EnumerateVoxels() ?? Array.Empty<Voxel>();
 788
 789    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 790    internal void VisitVoxels<TVisitor>(ref TVisitor visitor)
 791        where TVisitor : struct, IVoxelStorageVisitor =>
 91792        _storage?.VisitVoxels(ref visitor);
 793
 794    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 795    internal void AddVoxelsInIndexRange(
 796        VoxelIndex min,
 797        VoxelIndex max,
 798        SwiftList<Voxel> results,
 799        SwiftHashSet<Voxel> redundancy) =>
 549800        _storage?.AddVoxelsInIndexRange(min, max, results, redundancy);
 801
 802    /// <summary>
 803    /// Retrieves a grid voxel from a topology-local coordinate.
 804    /// </summary>
 805    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 806    public bool TryGetVoxel(VoxelIndex voxelIndex, out Voxel? result) =>
 3106807         TryGetVoxel(voxelIndex.x, voxelIndex.y, voxelIndex.z, out result);
 808
 809    /// <summary>
 810    /// Retrieve <see cref="Voxel"/> from world <see cref="Vector3d"/> points
 811    /// </summary>
 812    /// <returns><see cref="Voxel"/> at the given position or null if the position is not valid.</returns>
 813    public bool TryGetVoxel(Vector3d position, out Voxel? result)
 814    {
 1013815        result = null;
 1013816        return TryGetVoxelIndex(position, out VoxelIndex coordinate)
 1013817            && TryGetVoxel(coordinate.x, coordinate.y, coordinate.z, out result);
 818    }
 819
 820    /// <summary>
 821    /// Retrieves the physical voxel whose center is nearest to the supplied world position.
 822    /// Sparse grids only consider configured physical voxels.
 823    /// </summary>
 824    /// <param name="position">The world position to resolve.</param>
 825    /// <param name="result">The closest physical voxel, if found.</param>
 826    /// <returns>True if a physical voxel was resolved; otherwise false.</returns>
 827    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 828    public bool TryGetClosestVoxel(Vector3d position, out Voxel? result) =>
 103829        TryGetClosestVoxel(position, out result, out _);
 830
 831    internal bool TryGetClosestVoxel(
 832        Vector3d position,
 833        out Voxel? result,
 834        out Fixed64 distanceSquared)
 835    {
 207836        result = null;
 207837        distanceSquared = Fixed64.MaxValue;
 838
 207839        if (!IsActive)
 840        {
 5841            GridForgeLogger.Channel.Warn($"This Grid is not currently allocated.");
 5842            return false;
 843        }
 844
 202845        if (ConfiguredVoxelCount == 0)
 3846            return false;
 847
 199848        VoxelIndex closestIndex = Topology.GetClosestVoxelIndex(BoundsMin, Width, Height, Length, position);
 199849        return _storage!.TryGetClosestVoxel(this, closestIndex, position, out result, out distanceSquared);
 850    }
 851
 852    /// <summary>
 853    /// Retrieves a <see cref="Voxel"/> from a 2D XZ-plane world position on the default world Y layer.
 854    /// </summary>
 855    /// <param name="position">The 2D position whose X component maps to world X and Y component maps to world Z.</param
 856    /// <param name="result">The resolved voxel, if found.</param>
 857    /// <returns>True if the voxel was resolved; otherwise false.</returns>
 858    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 859    public bool TryGetVoxel(Vector2d position, out Voxel? result) =>
 2860        TryGetVoxel(position, default, out result);
 861
 862    /// <summary>
 863    /// Retrieves a <see cref="Voxel"/> from a 2D XZ-plane world position on the supplied world Y layer.
 864    /// </summary>
 865    /// <param name="position">The 2D position whose X component maps to world X and Y component maps to world Z.</param
 866    /// <param name="layerY">The world Y layer to resolve. Defaults to zero when omitted by paired overloads.</param>
 867    /// <param name="result">The resolved voxel, if found.</param>
 868    /// <returns>True if the voxel was resolved; otherwise false.</returns>
 869
 870    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 871    public bool TryGetVoxel(Vector2d position, Fixed64 layerY, out Voxel? result) =>
 6872        TryGetVoxel(GridPlane2d.ToWorld(position, layerY), out result);
 873
 874    /// <summary>
 875    /// Retrieves the physical voxel whose center is nearest to a 2D XZ-plane world position on the default world Y laye
 876    /// Sparse grids only consider configured physical voxels.
 877    /// </summary>
 878    /// <param name="position">The 2D position whose X component maps to world X and Y component maps to world Z.</param
 879    /// <param name="result">The closest physical voxel, if found.</param>
 880    /// <returns>True if a physical voxel was resolved; otherwise false.</returns>
 881    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 882    public bool TryGetClosestVoxel(Vector2d position, out Voxel? result) =>
 1883        TryGetClosestVoxel(position, default, out result);
 884
 885    /// <summary>
 886    /// Retrieves the physical voxel whose center is nearest to a 2D XZ-plane world position on the supplied world Y lay
 887    /// Sparse grids only consider configured physical voxels.
 888    /// </summary>
 889    /// <param name="position">The 2D position whose X component maps to world X and Y component maps to world Z.</param
 890    /// <param name="layerY">The world Y layer to resolve. Defaults to zero when omitted by paired overloads.</param>
 891    /// <param name="result">The closest physical voxel, if found.</param>
 892    /// <returns>True if a physical voxel was resolved; otherwise false.</returns>
 893    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 894    public bool TryGetClosestVoxel(Vector2d position, Fixed64 layerY, out Voxel? result) =>
 2895        TryGetClosestVoxel(GridPlane2d.ToWorld(position, layerY), out result);
 896
 897    /// <summary>
 898    /// Computes the scan cell key for a given world position.
 899    /// </summary>
 900    public int GetScanCellKey(Vector3d position)
 901    {
 50902        if (!TryGetVoxelIndex(position, out VoxelIndex voxelIndex))
 1903            return -1;
 904
 49905        return GetScanCellKey(voxelIndex);
 906    }
 907
 908    /// <summary>
 909    /// Calculates the spatial cell index for a given position.
 910    /// </summary>
 911    public int GetScanCellKey(VoxelIndex voxelIndex)
 912    {
 347109913        (int x, int y, int z) = (
 347109914                voxelIndex.x / ScanCellSize,
 347109915                voxelIndex.y / ScanCellSize,
 347109916                voxelIndex.z / ScanCellSize
 347109917            );
 918
 347109919        int scanCellKey = GetScanCellKey(x, y, z);
 347109920        if (scanCellKey == -1)
 921        {
 5922            GridForgeLogger.Channel.Warn($"Position {voxelIndex} is not in the bounds for this grids Scan Cell overlay."
 5923            return -1;
 924        }
 925
 347104926        return scanCellKey;
 927    }
 928
 929    /// <summary>
 930    /// Calculates a unique scan cell key from grid-local scan cell coordinates.
 931    /// </summary>
 932    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 933    internal int GetScanCellKey(int x, int y, int z)
 934    {
 360439935        if ((uint)x >= (uint)_scanWidth
 360439936            || (uint)y >= (uint)_scanHeight
 360439937            || (uint)z >= (uint)_scanLength)
 938        {
 9939            return -1;
 940        }
 941
 360430942        return x + y * _scanWidth + z * _scanLayerSize;
 943    }
 944
 945    /// <summary>
 946    /// Retrieves a scan cell from the grid using its key.
 947    /// </summary>
 948    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 949    public bool TryGetScanCell(int key, out ScanCell? outScanCell)
 950    {
 1091951        outScanCell = null;
 1091952        return _storage?.TryGetScanCell(key, out outScanCell) == true;
 953    }
 954
 955    /// <summary>
 956    /// Retrieves the scan cell corresponding to a given world position.
 957    /// </summary>
 958    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 959    public bool TryGetScanCell(Vector3d position, out ScanCell? outScanCell)
 960    {
 45961        int key = GetScanCellKey(position);
 45962        return TryGetScanCell(key, out outScanCell);
 963    }
 964
 965    /// <summary>
 966    /// Retrieves the scan cell associated with the given voxel index.
 967    /// </summary>
 968    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 969    public bool TryGetScanCell(VoxelIndex voxelIndex, out ScanCell? outScanCell)
 970    {
 9971        outScanCell = null;
 9972        return TryGetVoxel(voxelIndex, out Voxel? voxel)
 9973            && TryGetScanCell(voxel!.ScanCellKey, out outScanCell);
 974    }
 975
 976    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 977    internal void AddScanCellsInRange(
 978        int xMin,
 979        int yMin,
 980        int zMin,
 981        int xMax,
 982        int yMax,
 983        int zMax,
 984        SwiftList<ScanCell> results,
 985        SwiftHashSet<ScanCell> redundancy) =>
 680986        _storage?.AddScanCellsInRange(
 680987            this,
 680988            xMin,
 680989            yMin,
 680990            zMin,
 680991            xMax,
 680992            yMax,
 680993            zMax,
 680994            results,
 680995            redundancy);
 996
 997    /// <summary>
 998    /// Enumerates all currently active scan cells within the grid.
 999    /// </summary>
 1000    public IEnumerable<ScanCell> GetActiveScanCells()
 1001    {
 51002        if (!IsActive || !IsOccupied)
 41003            yield break;
 1004
 61005        foreach (int activeCellKey in ActiveScanCells!)
 1006        {
 21007            if (_storage!.TryGetScanCell(activeCellKey, out ScanCell? scanCell))
 21008                yield return scanCell!;
 1009        }
 11010    }
 1011
 1012    /// <summary>
 1013    /// Helper function to ceil snap a <see cref="Vector3d"/> through this grid's topology, ensuring it stays within gri
 1014    /// </summary>
 1015    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1016    public Vector3d CeilToGrid(Vector3d position) =>
 91017         Topology.CeilToGrid(BoundsMin, BoundsMax, Width, Height, Length, position);
 1018
 1019    /// <summary>
 1020    /// Helper function to floor snap a <see cref="Vector3d"/> through this grid's topology, ensuring it stays within gr
 1021    /// </summary>
 1022    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1023    public Vector3d FloorToGrid(Vector3d position) =>
 3881024        Topology.FloorToGrid(BoundsMin, BoundsMax, Width, Height, Length, position);
 1025
 1026    /// <summary>
 1027    /// Snaps a given position to the topology-local scan cell in the grid.
 1028    /// </summary>
 1029    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1030    public (int x, int y, int z) SnapToScanCell(Vector3d position) =>
 12491031        Topology.SnapToScanCell(BoundsMin, position, ScanCellSize);
 1032
 1033    /// <summary>
 1034    /// Normalizes world-space bounds to this grid's topology-aligned coverage bounds.
 1035    /// </summary>
 1036    /// <param name="min">The first world-space bounds corner.</param>
 1037    /// <param name="max">The second world-space bounds corner.</param>
 1038    /// <param name="padding">Optional non-negative padding applied before normalization.</param>
 1039    /// <returns>Topology-aligned minimum and maximum bounds suitable for deterministic coverage scans.</returns>
 1040    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1041    public (Vector3d min, Vector3d max) NormalizeBounds(Vector3d min, Vector3d max, Fixed64? padding = null) =>
 16791042        Topology.NormalizeBounds(min, max, padding);
 1043
 1044    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1045    internal Vector3d GetWorldPosition(VoxelIndex index) =>
 3547221046        Topology.GetWorldPosition(BoundsMin, index);
 1047
 1048    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 1049    internal Vector3d GetWorldOffset((int x, int y, int z) offset) =>
 921050        Topology.GetWorldOffset(offset);
 1051
 1052    #endregion
 1053}

Methods/Properties

get_BoundsMin()
get_BoundsMax()
get_BoundsCenter()
get_ConfiguredVoxelCount()
get_StorageKind()
get_Voxels()
get_NeighborSlotCount()
get_TopologyKind()
get_IsConjoined()
get_ScanCellSize()
get_ScanCells()
get_IsOccupied()
.ctor()
get_Topology()
get_ScanWidth()
get_ScanHeight()
get_ScanLength()
Initialize(GridForge.Grids.GridWorld,System.UInt16,System.Int64,GridForge.Configuration.GridConfiguration,GridForge.Grids.Topology.IGridTopology,GridForge.Spatial.VoxelIndex[])
Reset()
ReleaseActiveScanCells()
ReleaseNeighbors()
ClearDimensions()
IncrementVersion()
ConfigureScanDimensions()
GetRectangularNeighborDirection(GridForge.Grids.VoxelGrid,GridForge.Grids.VoxelGrid)
GetHexNeighborDirection(GridForge.Grids.VoxelGrid,GridForge.Grids.VoxelGrid)
TryGetNeighborSlot(GridForge.Grids.VoxelGrid,GridForge.Grids.VoxelGrid,GridForge.Grids.Topology.GridTopologyKind,System.Int32&)
TryGetNeighborSlot(GridForge.Grids.VoxelGrid,GridForge.Grids.VoxelGrid,System.Int32&)
GetNeighborOffset(System.Int32)
TryGetNeighborSlot(GridForge.Spatial.RectangularDirection,System.Int32&)
TryGetNeighborSlot(GridForge.Spatial.HexDirection,System.Int32&)
TryAddGridNeighbor(GridForge.Grids.VoxelGrid)
TryRemoveGridNeighbor(GridForge.Grids.VoxelGrid)
TryGetGridNeighborSet(GridForge.Grids.VoxelGrid,System.Int32&,SwiftCollections.SwiftHashSet`1<System.Int32>&)
ReleaseNeighborSetIfEmpty(System.Int32,SwiftCollections.SwiftHashSet`1<System.Int32>)
IsOnBoundary(GridForge.Spatial.VoxelIndex)
IsInBounds(FixedMathSharp.Vector3d)
GetAllGridNeighbors()
IsValidVoxelIndex(System.Int32,System.Int32,System.Int32)
IsVoxelIndexInBounds(System.Int32,System.Int32,System.Int32)
IsFacingBoundary(GridForge.Spatial.VoxelIndex,GridForge.Spatial.RectangularDirection)
IsFacingBoundary(GridForge.Spatial.VoxelIndex,GridForge.Spatial.HexDirection)
TryGetVoxelIndex(FixedMathSharp.Vector3d,GridForge.Spatial.VoxelIndex&)
TryGetVoxelIndex(FixedMathSharp.Vector2d,GridForge.Spatial.VoxelIndex&)
TryGetVoxelIndex(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,GridForge.Spatial.VoxelIndex&)
IsVoxelAllocated(System.Int32,System.Int32,System.Int32)
ContainsVoxel(GridForge.Spatial.VoxelIndex)
TryAddVoxel(GridForge.Spatial.VoxelIndex,GridForge.Grids.Voxel&)
TryRemoveVoxel(GridForge.Spatial.VoxelIndex)
CanMutateSparseVoxel(GridForge.Spatial.VoxelIndex)
CanRemoveSparseVoxel(GridForge.Grids.Voxel)
TryGetVoxel(System.Int32,System.Int32,System.Int32,GridForge.Grids.Voxel&)
EnumerateVoxels()
VisitVoxels(TVisitor&)
AddVoxelsInIndexRange(GridForge.Spatial.VoxelIndex,GridForge.Spatial.VoxelIndex,SwiftCollections.SwiftList`1<GridForge.Grids.Voxel>,SwiftCollections.SwiftHashSet`1<GridForge.Grids.Voxel>)
TryGetVoxel(GridForge.Spatial.VoxelIndex,GridForge.Grids.Voxel&)
TryGetVoxel(FixedMathSharp.Vector3d,GridForge.Grids.Voxel&)
TryGetClosestVoxel(FixedMathSharp.Vector3d,GridForge.Grids.Voxel&)
TryGetClosestVoxel(FixedMathSharp.Vector3d,GridForge.Grids.Voxel&,FixedMathSharp.Fixed64&)
TryGetVoxel(FixedMathSharp.Vector2d,GridForge.Grids.Voxel&)
TryGetVoxel(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,GridForge.Grids.Voxel&)
TryGetClosestVoxel(FixedMathSharp.Vector2d,GridForge.Grids.Voxel&)
TryGetClosestVoxel(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,GridForge.Grids.Voxel&)
GetScanCellKey(FixedMathSharp.Vector3d)
GetScanCellKey(GridForge.Spatial.VoxelIndex)
GetScanCellKey(System.Int32,System.Int32,System.Int32)
TryGetScanCell(System.Int32,GridForge.Grids.ScanCell&)
TryGetScanCell(FixedMathSharp.Vector3d,GridForge.Grids.ScanCell&)
TryGetScanCell(GridForge.Spatial.VoxelIndex,GridForge.Grids.ScanCell&)
AddScanCellsInRange(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,SwiftCollections.SwiftList`1<GridForge.Grids.ScanCell>,SwiftCollections.SwiftHashSet`1<GridForge.Grids.ScanCell>)
GetActiveScanCells()
CeilToGrid(FixedMathSharp.Vector3d)
FloorToGrid(FixedMathSharp.Vector3d)
SnapToScanCell(FixedMathSharp.Vector3d)
NormalizeBounds(FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,System.Nullable`1<FixedMathSharp.Fixed64>)
GetWorldPosition(GridForge.Spatial.VoxelIndex)
GetWorldOffset(System.ValueTuple`3<System.Int32,System.Int32,System.Int32>)