dkushner / grid-tree-rs

Pixel quadtrees and voxel octrees

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

grid-tree

Pixel quadtrees and voxel octrees.

Store any type in an OctreeI32, OctreeU32, QuadtreeI32, or QuadtreeU32, all of which are specific instances of the generic Tree. A Tree represents a map from (Level, Integer Coordinates) to T. Thus it is useful for storing pixel or voxel data with level-of-detail. The tree also requires that if a node slot is occupied (has data), then all ancestor slots are also filled.

Performance

This structure is optimized for iteration speed and spatial queries that benefit from a bounding volume hierarchy (like raycasting). Finding a single node by NodeKey starting from the root should be minimized as much as possible, so you might find it useful to cache NodePtrs or amortize the search with a full tree traversal. Memory usage is decent given the simplicity of the implementation, and the pointer overhead is easily amortized by using dense chunk values.

  • random access with NodeKey: O(depth)
  • random access with NodePtr: O(1)
  • iteration: O(nodes)
  • memory usage per node:
    • level 0: size_of::<T>() bytes
    • level N > 0: size_of::<T>() + CHILDREN * 4 bytes
    • where CHILDREN=4 for a quadtree and CHILDREN=8 for an octree

License: MIT OR Apache-2.0

About

Pixel quadtrees and voxel octrees

License:MIT License


Languages

Language:Rust 100.0%