-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
GridForge is a deterministic, framework-agnostic voxel grid library for spatial partitioning, simulation, and game-development workflows. It is built around fixed-point math, global grid registration, fast scan-based queries, obstacle and occupant tracking, and allocation-conscious internals.
This page is the wiki's anchor document. The README.md is a concise entry point, while the wiki is the deeper technical companion for consumers and contributors. When the project evolves, update this page first so the rest of the wiki has a stable anchor.
- Deterministic voxel-grid spatial partitioning using
FixedMathSharp - Global registration and lookup across one or more grids
- Snapped world-space bounds through
GridConfiguration - Fast proximity and coverage queries via voxels and scan cells
- Obstacle, blocker, occupant, and partition workflows
- Allocation-conscious internals backed by pooling and
SwiftCollections - Cross-target support for
netstandard2.1andnet8.0
- Library consumers who need to get a grid online quickly and safely
- Contributors who need a map of the codebase and its invariants
- Maintainers who need a shared documentation source of truth for future pages
The wiki is organized as a set of focused pages. Home stays broad and stable; the rest of the pages serve as targeted deep dives.
| Page | Focus |
|---|---|
| Home | Shared project context, architecture snapshot, invariants, and documentation roadmap |
| Getting Started | Installation, first grid setup, basic queries, and logging setup |
| Core Concepts | Grids, voxels, scan cells, occupants, blockers, partitions, and snapped bounds |
| Common Workflows | Create a grid, resolve a voxel, scan nearby space, apply a blocker, attach a partition |
| Architecture Overview | How the major subsystems fit together and where responsibilities live |
| GlobalGridManager | Setup/reset lifecycle, registration, hashing, and top-level query behavior |
| VoxelGrid and Voxel Model | Grid generation, voxel state, neighbor relationships, and cached data |
| Scan Cells and Query Flow | Scan-cell overlay structure, neighborhood lookups, and query performance |
| GridTracer and Coverage | Line and bounds tracing, covered voxel sets, and multi-grid implications |
| Blockers and Obstacles |
Blocker, BoundsBlocker, obstacle propagation, stacked blockers, and removals |
| Occupants and Partitions |
IVoxelOccupant, IVoxelPartition, PartitionProvider, and lifecycle rules |
| Diagnostics and Logging |
GridForgeLogger, verbosity, tracing support, and safe debugging patterns |
| Repository Layout and Build | Solution structure, package generation, CI expectations, and release notes |
| Testing and Benchmarking | xUnit layout, global-state isolation, benchmark usage, and validation strategy |
| Determinism, Snapping, and Pooling | Core invariants that must remain true across framework targets |
| Recipes | End-to-end usage patterns for gameplay, simulation, and server-side systems |
| FAQ and Troubleshooting | Common mistakes, debugging checklists, and "why is this voxel result odd?" guidance |
- Language: C# 11
- Main library:
src/GridForge - Test suite:
tests/GridForge.Tests - Benchmarks:
tests/GridForge.Benchmarks - Target frameworks:
netstandard2.1,net8.0 - Test framework: xUnit v3
- Benchmark framework: BenchmarkDotNet
- Key packages:
FixedMathSharp,SwiftCollections,MemoryPack - Packaging note:
GeneratePackageOnBuildis enabled, so library builds also emit NuGet packages
The library is easiest to reason about in this order:
- Define world-space bounds with
GridConfiguration. - Register the grid through
GlobalGridManager. - Resolve world positions into a
VoxelGridandVoxel. - Use scan cells and tracing helpers for broader spatial queries.
- Apply blockers, occupants, or partitions to mutate grid state.
- Reset global state explicitly when tests or tools need a clean world.
The most important architectural reality is that GridForge is not primarily instance-scoped. Shared global state is part of the design, and most contributor mistakes come from forgetting setup, reset, snapping, or pooled lifetime rules.
| Type | Role |
|---|---|
GlobalGridManager |
Static entry point for setup, reset, grid registration, spatial hashing, and top-level queries |
VoxelGrid |
Owns a single grid's dimensions, voxels, scan cells, neighbor relationships, and versioned state |
Voxel |
Represents one snapped cell and tracks occupants, obstacles, partitions, and cached neighbor data |
ScanCell |
Overlay node used to accelerate neighborhood and area queries |
GridTracer |
Converts lines and bounds into covered voxel sets across one or more grids |
GridObstacleManager |
Applies and clears obstacle state on voxels |
GridOccupantManager |
Adds, removes, and queries occupant state |
GridScanManager |
Performs scan-driven spatial queries |
Blocker / BoundsBlocker
|
Turns traced world-space regions into obstacle mutations |
IVoxelOccupant / IVoxelPartition / PartitionProvider
|
Extension points for custom occupancy and metadata workflows |
| Path | Purpose |
|---|---|
src/GridForge/Configuration |
Grid configuration and identity types such as GridConfiguration
|
src/GridForge/Grids/Managers |
Global and per-grid behavior managers |
src/GridForge/Grids/Nodes |
Voxel and ScanCell node types |
src/GridForge/Grids/Support |
Event info types and pools |
src/GridForge/Spatial |
Shared indices, directions, occupants, partitions, and awareness abstractions |
src/GridForge/Blockers |
World-space blocker abstractions built on grid coverage |
src/GridForge/Utility |
Tracing and logging helpers |
tests/GridForge.Tests/Grids |
Grid and manager behavior tests |
tests/GridForge.Tests/Blockers |
Blocker coverage and removal tests |
tests/GridForge.Tests/Spatial |
Spatial type and index tests |
tests/GridForge.Tests/Utility |
Logger and tracer tests |
- Call
GlobalGridManager.Setup()before using most grid APIs. - Call
GlobalGridManager.Reset()when tests or tools need isolated global state. - Keep core spatial logic in fixed-point math. Do not casually introduce
floatordouble. - Expect bounds and incoming positions to be snapped to voxel size.
- Treat pooled objects and collections as short-lived unless ownership is explicit.
- Preserve deterministic behavior across both target frameworks.
- Respect existing synchronization around shared mutable state.
- Route logging through
GridForgeLogger, not direct console output.
Useful commands when working in the repository:
dotnet restore GridForge.sln
dotnet build GridForge.sln --configuration Debug
dotnet test GridForge.sln --configuration Debug --no-build
dotnet run --project tests/GridForge.Benchmarks/GridForge.Benchmarks.csproj -c Release -- listBenchmarks are most valuable when changing tracing, registration, pooling, caching, or other allocation-sensitive paths.
- Keep the README concise and external-facing; use the wiki for depth.
- Prefer one focused page per subsystem instead of one giant reference dump.
- When a new page is added, link it from
Homeand state the page's scope clearly. - If code behavior changes in a way that affects setup, determinism, pooling, tracing, blockers, or tests, reflect that here before expanding the deeper pages.
- Treat source and tests as the behavioral contract when README examples lag behind the implementation.
If you are new to the project, read in this order:
README.md- This
Homepage src/GridForge/GridForge.csprojsrc/GridForge/Grids/Managers/GlobalGridManager.cssrc/GridForge/Grids/VoxelGrid.cssrc/GridForge/Grids/Nodes/Voxel.cssrc/GridForge/Utility/GridTracer.cs- The closest matching test file under
tests/GridForge.Tests
The wiki is not trying to restate every public API member in prose. Its job is to make the library understandable quickly: what the system does, where behavior lives, which invariants matter, and where someone should go next. If we keep this page accurate, the rest of the wiki stays easier to extend without drifting.