Module bismuth::cube
[−]
[src]
This module provides an oct-tree of Cube
s, which are the basic building
blocks of Bismuth.
The tree is internally comprised of Node
s. BranchNode
s contain links to
sub-trees and LeafNode
s contain geometric data associated with their
respective spatial partition. However, Node
s do not contain any spatial
data (origin, partition, etc.); instead, this is calculated during
traversals by Cube
, which acts as a recursive view over the Node
s in the
tree and provides the primary interface for interacting with trees.
Leaf Cube
s provide the geometric and spatial data that together represent
the shape and layout of the game world.
Cube
s reference Node
s in the tree, and abstract over the mutability of
those references. This module exposes the CubeRef
and CubeMut
type
definitions for immutable and mutable Cube
s, respectively.
Because Cube
s reference Node
s and Node
s may reference other Node
s
in a tree, orphan types are provided that only expose payloads and no links.
This is useful when collecting Cube
s, because otherwise the references
into the rest of the tree would lead to aliasing. OrphanCubeRef
and
OrphanCubeMut
are the orphan analogues of CubeRef
and CubeMut
,
respectively. Orphans of course do not support indexing or traversal.
Tree
can be used to create a new tree, and owns the root Node
. Tree
s
expose Cube
s to manipulate the tree.
In the abstract, "cube" refers to the amalgamation of all the types used to represent elements in a tree, which together form the complete notion of a cube.
Examples
Subdividing and iterating over the cubes in a tree:
use bismuth::cube::{LogWidth, Spatial, Tree}; let mut tree = Tree::new(LogWidth::max_value()); let _ = tree.as_cube_mut().subdivide(); for cube in tree.as_cube().iter() { println!( "origin: {}; width: {}", cube.partition().origin(), cube.partition().width().to_inner() ); }
Modules
error |
Structs
AABB |
Axis-aligned bounding box. |
BranchNode | |
BranchPayload | |
Cursor |
A contiguous selection of cubes in a tree. |
Edge |
Edge of a cube's |
Geometry | |
LeafNode | |
LeafPayload | |
Partition |
A cubic spatial partition. |
RayIntersection |
Details of intersection with an |
Tree |
Enums
Axis |
An axis in the tree space. |
Direction |
A direction along an |
Node | |
Orientation |
An orientation in the tree space. |
OrphanNode |
Traits
Intersects |
Shape or primitive that can test for intersection with another shape or primitive. |
RayCast |
Shape or primitive that can test for intersection with an |
Spatial |
A spatial (cubic) element in a tree. |
Type Definitions
CubeMut | |
CubeRef | |
LogWidth |
Logarithmic width. Most uses of the term "width" refer to |
Offset |
Edge offset. |
OrphanCubeMut | |
OrphanCubeRef |