Struct pasture_core::math::MortonIndex64WithDepth[][src]

pub struct MortonIndex64WithDepth { /* fields omitted */ }

64-bit 3D Morton index with depth information. This is the more efficient, but more constraint version of DynamicMortonIndex because it can store at maximum 21 levels. Important note: Since a Morton index defines a node in an octree, one has to define what index the root node has. As each 3 bits within a 3D Morton index identify an octant at a certain level, there is no level that defines the root node since it is just a single node. We now define that the root node is always at level 0, so the level parameter of this structure is always relative to the root node. A MortonIndex64WithLevel with a level of 0 is therefore always zero. The first octant lies at level 1. This can be a bit confusing because it makes the code prone to off-by-one errors, however it is better than the alternative (IMO) where root node has level -1, or None.

Implementations

impl MortonIndex64WithDepth[src]

pub fn from_octants(octants: &[Octant]) -> Self[src]

Creates a new MortonIndex64WithDepth from the given octants. octants.len() must be <= MortonIndex64::LEVELS

Example

// Create a Morton index for the octants 1->2->4 (octant 4 of octant 2 of octant 1 of the root node)
let morton_index_with_depth = MortonIndex64WithDepth::from_octants(&[Octant::ONE, Octant::TWO, Octant::FOUR]);
assert_eq!(3, morton_index_with_depth.depth());
assert_eq!(Some(Octant::ONE), morton_index_with_depth.get_octant_at_level(1));
assert_eq!(Some(Octant::TWO), morton_index_with_depth.get_octant_at_level(2));
assert_eq!(Some(Octant::FOUR), morton_index_with_depth.get_octant_at_level(3));

pub fn raw_index(&self) -> u64[src]

Returns the raw integer value of the associated MortonIndex64WithDepth. This index is similar to what MortonIndex64::index() returns, however only the highest 3 * depth() bits are used (ignoring the MSB which is always unused for 64 bit Morton indices). All lower bits (and the MSB) are zero!

pub fn depth(&self) -> u8[src]

Returns the depth of the octree node represented by the associated MortonIndex64WithDepth. A depth of zero represents the root node and corresponds to a raw_index() where no bits are used

pub fn get_octant_at_level(&self, level: u8) -> Option<Octant>[src]

Returns the octant index relative to the parent node for the node at the given level. Since level zero represents the root node, and the root node has no parent, None is returned for level zero.

Panics

If level is greater than depth()

pub fn child(&self, octant: Octant) -> Option<Self>[src]

Returns the child node at the given octant from the associated MortonIndex64WithDepth. If the associated index is already of maximum depth (MortonIndex64::LEVELS), returns None

pub fn with_lower_depth(&self, lower_depth: u8) -> Self[src]

Returns a version of the associated MortonIndex64WithDepth with the given lower depth

pub fn as_grid_index(&self) -> Vector3<u32>[src]

Converts the associated MortonIndex64WithDepth into an XYZ index within a 3D grid of size (2^self.depth)x(2^self.depth)x(2^self.depth)

pub fn to_string(&self, naming: MortonIndexNaming) -> String[src]

Returns a string representation of the associated MortonIndex64WithDepth with the given MortonIndexNaming

Trait Implementations

impl Clone for MortonIndex64WithDepth[src]

impl Debug for MortonIndex64WithDepth[src]

impl Default for MortonIndex64WithDepth[src]

impl Eq for MortonIndex64WithDepth[src]

impl From<&'_ MortonIndex64WithDepth> for DynamicMortonIndex[src]

impl From<MortonIndex64WithDepth> for DynamicMortonIndex[src]

impl Hash for MortonIndex64WithDepth[src]

impl PartialEq<MortonIndex64WithDepth> for MortonIndex64WithDepth[src]

impl StructuralEq for MortonIndex64WithDepth[src]

impl StructuralPartialEq for MortonIndex64WithDepth[src]

impl TryFrom<&'_ DynamicMortonIndex> for MortonIndex64WithDepth[src]

type Error = DynamicMortonIndexTooLargeError

The type returned in the event of a conversion error.

impl TryFrom<DynamicMortonIndex> for MortonIndex64WithDepth[src]

type Error = DynamicMortonIndexTooLargeError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,