Oktree
Fast octree implementation.
Could be used with the Bevy game engine for fast processing of voxel data or as a standalone tree.
Available methods:
-
Unsigned operations
-
Floating point operations (Bevy integration)
To enable bevy integrations:
[dependencies]
oktree = { version = "0.2.0", features = ["bevy"] }
Optimizations:
Unsigned
arithmetics, bitwise operations.- Tree structure is represented by flat, reusable pools. Removed data is marked only.
- Few memory allocations. Heapless structures are used.
- No smart pointers (RC, RefCell e.t.c)
Compensation for the inconvenience is perfomance.
Benchmark
Octree dimensions: 4096x4096x4096
Operation | Quantity | Time |
---|---|---|
insertion | 65536 cells | 25 ms |
removing | 65536 cells | 12 ms |
find | 65536 searches in 65536 cells | 13 ms |
ray intersection | 4096 rays against 65536 cells | 35 ms |
sphere intersection | 4096 spheres against 65536 cells | 8 ms |
box intersection | 4096 boxes against 65536 cells | 6 ms |
Run benchmark:
cargo bench --all-features
Example
You have to specify the type for the internal tree structure.
It must be any Unsigned
type (u8
, u16
, u32
, u64
, u128
or usize
).
Implement Position
for the handled type, so that it can return it's spatial coordinates.
use ;
use *;
Run bevy visual example:
cargo run --release --example bevy_tree --all-features
Feature and pull requests are welcomed.