[][src]Trait zvxryb_broadphase::SpatialIndex

pub trait SpatialIndex: Clone + Copy + Default + Ord + Send + Debug {
    type Diff: VectorSpace<Scalar = u32>;
    type Point: Copy + EuclideanSpace<Diff = Self::Diff, Scalar = u32>;
    type SubdivideResult: AsRef<[Self]>;
    fn clamp_depth(_: u32) -> u32;
fn origin(self) -> Self::Point;
fn depth(self) -> u32;
fn set_origin(self, _: Self::Point) -> Self;
fn set_depth(self, _: u32) -> Self;
fn subdivide(self) -> Option<Self::SubdivideResult>;
fn overlaps(self, other: Self) -> bool;
fn same_cell_at_depth(lhs: Self, rhs: Self, depth: u32) -> bool; }

An index representing an object's position and scale

The Ord trait must be implemented such that sorting produces a topological ordering.

This may be accomplished using trivial comparison operators for a primitive integer type by:

  1. Packing bits such that origin is higher-significance than depth
  2. Storing the value of origin as a Morton code
  3. Truncating origin bits to the level specified by depth, such that it represents the minimum bound of the cell at the given scale

Currently, requirement #3 (truncating origin) is not the responsibility of the particular SpatialIndex implementation — an appropriately-truncated value must be passed as an argument to set_origin

Ord should be implemented such that an X-bit is lower significance (changes more rapidly) than the corresponding a Y-bit (which should, likewise, be lower significance than the corresponding Z-bit for 3D indices)

<SpatialIndex as Default>::default() is required to return an index which encompasses the entire system bounds (i.e. zero origin and zero depth)

Associated Types

type Diff: VectorSpace<Scalar = u32>

type Point: Copy + EuclideanSpace<Diff = Self::Diff, Scalar = u32>

type SubdivideResult: AsRef<[Self]>

Loading content...

Required methods

fn clamp_depth(_: u32) -> u32

clamps a depth value to the representable range

fn origin(self) -> Self::Point

fn depth(self) -> u32

fn set_origin(self, _: Self::Point) -> Self

fn set_depth(self, _: u32) -> Self

fn subdivide(self) -> Option<Self::SubdivideResult>

Subdivide the cell represented by this index into cells of depth + 1

This is required to return results in sorted order. Returns None if depth limit has been reached.

fn overlaps(self, other: Self) -> bool

Check if two indices represent overlapping regions of space

fn same_cell_at_depth(lhs: Self, rhs: Self, depth: u32) -> bool

Check if two indices would fall into the same cell at a given (truncated) depth

Loading content...

Implementors

impl SpatialIndex for Index64_3D[src]

type Diff = Vector3<u32>

type Point = Point3<u32>

type SubdivideResult = [Self; 8]

Loading content...