Module bismuth::cube [] [src]

This module provides an oct-tree of Cubes, which are the basic building blocks of Bismuth.

The tree is internally comprised of Nodes. BranchNodes contain links to sub-trees and LeafNodes contain geometric data associated with their respective spatial partition. However, Nodes 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 Nodes in the tree and provides the primary interface for interacting with trees.

Leaf Cubes provide the geometric and spatial data that together represent the shape and layout of the game world.

Cubes reference Nodes in the tree, and abstract over the mutability of those references. This module exposes the CubeRef and CubeMut type definitions for immutable and mutable Cubes, respectively.

Because Cubes reference Nodes and Nodes may reference other Nodes in a tree, orphan types are provided that only expose payloads and no links. This is useful when collecting Cubes, 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. Trees expose Cubes 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.

Geometry
LeafNode
LeafPayload
Partition

A cubic spatial partition. Partitions are represented as an origin and a width.

RayIntersection

Details of intersection with an FRay3.

Tree

Enums

Axis

An axis in the tree space.

Direction

A direction along an Axis.

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 FRay3.

Spatial

A spatial (cubic) element in a tree.

Type Definitions

CubeMut
CubeRef
LogWidth

Logarithmic width. Most uses of the term "width" refer to LogWidth.

Offset

Edge offset.

OrphanCubeMut
OrphanCubeRef