GNodeFactory

RoleAuthor
LicenseMIT
GNodeFactory running the Solar System Demo at 123 FPS

Contributions

Handle-based node allocation and recycling Pooled, data-oriented node storage Parent, child and sibling hierarchy linking Bulk and partial hierarchy resolution
Optional sphere BVH generation Metadata-masked hierarchy searches Frustum, sphere, AABB, OBB and capsule queries Thread-shared locking and parallel traversal

Pooled Node Storage
  • Transforms, states and metadata each get their own pool instead of one struct per node.
  •  
  • Every node is referenced by a single 64-bit handle, with the pool index and slot index packed into it.
  •  
  • Deleted slots get reused rather than freed. The factory also tracks how many nodes it has handed out and taken back.
GPool and GNodeHandle struct definitions
Hierarchy Resolution
  • Parenting, unparenting and connecting all take arrays, so an entire scene can be relinked in one call.
  •  
  • Resolving runs over the whole tree, or just the branches that actually moved.
  •  
  • Sphere bounds can be rebuilt during the same pass. Without that, the spatial queries go stale the moment a transform changes.
Code combining a child's local transform with its parent's world matrix
Spatial and Metadata Queries
  • Nodes can be searched against a frustum, sphere, AABB, OBB or capsule.
  •  
  • Each search takes a metadata mask, so you only get back the nodes you actually asked for.
  •  
  • Parent, child and sibling searches walk the full hierarchy and return every match, not just the immediate one.
Solar System Demo with every node matching the query highlighted in green
Threading
  • Pool access goes through a shared lock. Readers run together, writers get the pool to themselves.
  •  
  • The tree walk keeps its scratch buffers thread-local, so workers aren't fighting over the same memory.
Child-walking lambda copying its results under a shared write lock

The Solar System Demo driven entirely by GNodeFactory, running at 123 FPS.

Solar System Demo running at 123 FPS

Every node returned by a spatial query, highlighted in green.

Query results highlighted in green

The node pools and the packed 64-bit handle used to address them.

GPool and GNodeHandle struct definitions

Resolving a child's world transform from its parent.

Hierarchy resolution code

Writing search results back under a shared write lock.

Threaded child walk code