BackendStarted 2023

Spatium

Collection of spatial partitioning techniques (BVH, K-D Tree, Quadtree, Octree) optimized for real-time use with strong performance on dense scenes and large point searches.

C++17BVHK-D TreeQuadtreeOctreeSAHPremake
Spatium project preview
Role
Independent C++ Engineer
Development Began
2023
Status
Open-Source Research Library

Evidence at a Glance

~16K
Meshes in a Dense BVH Scene

Validated against an unevenly distributed 3D workload.

~870K
K-D Tree Triangles Tested

Measured with the Stanford Dragon model.

~18×
Point-Search Speed-Up

A 10-million-point Quadtree/Octree test versus naïve search.

Overview

Spatium is a collection of spatial-partitioning structures built for real-time applications and coursework: multiple Bounding Volume Hierarchies, a K-D Tree, Quadtree, and Octree. The project compares construction strategies rather than stopping at one textbook implementation.

The BVH work spans top-down SAH construction, a two-pass bottom-up merge using priority-driven candidate pairing, and incremental insertion with volume heuristics and self-balancing. The K-D Tree samples candidate split positions along each AABB axis and chooses the lowest-cost Surface Area Heuristic result.

Memory behavior is part of the design. Bit packing, locational codes, and compact node representations reduce per-node overhead and improve traversal locality for large point and triangle sets.

The Challenge

Spatial structures trade construction time, memory, update cost, and traversal performance against one another. A strategy that wins for a static mesh may be wrong for a changing scene or a large point query.

The implementation therefore needed repeatable workloads and enough instrumentation to compare not just whether each tree worked, but where it began to struggle.

Key Engineering Decisions

01

Implement Three BVH Construction Families

Top-down, bottom-up, and incremental approaches make construction and update trade-offs directly comparable in one codebase.

02

Use SAH Where Split Quality Matters

Candidate positions are evaluated against estimated traversal cost instead of selecting a midpoint blindly.

03

Keep Point Structures Compact

Bit packing and locational codes reduce node overhead for Quadtree and Octree workloads at multi-million-point scale.

04

Test Against Recognisable Dense Geometry

Stanford models and uneven 3D scenes provide workloads that are easier to inspect and reproduce than synthetic success cases alone.

What I Owned

Implemented top-down, bottom-up, and incremental BVH construction.
Built K-D Tree splitting around sampled Surface Area Heuristics.
Implemented Quadtree and Octree searches with compact locational representations.
Validated BVH behavior around 16,000 meshes and K-D Tree behavior around 870,000 triangles.
Measured approximately 18× faster search over 10 million points than a naïve scan.
Published source, visual tests, videos, and a Premake-based C++17 build.

Results

Produced one test bed for choosing spatial structures according to workload rather than familiarity.
Demonstrated that a two-pass bottom-up BVH could sometimes outperform the sampled top-down build in the tested real-time scenario.
Preserved implementation and benchmark evidence in a public repository and recorded visual tests.

Gallery

Spatium project view 2
Spatium project view 3

Videos

Valuable Lessons

Construction strategy has to be evaluated alongside query cost; the cheapest tree to build is not always the cheapest structure to use.

A future benchmark pass should publish hardware, build time, query time, and memory on the same chart for every structure.