[][src]Trait amethyst_tiles::CoordinateEncoder

pub trait CoordinateEncoder: 'static + Clone + Default + Send + Sync {
    fn from_dimensions(dimensions: Vector3<u32>) -> Self;
fn encode(&self, x: u32, y: u32, z: u32) -> Option<u32>;
fn decode(&self, morton: u32) -> Option<(u32, u32, u32)>;
fn allocation_size(dimensions: Vector3<u32>) -> usize; }

Trait to provide generic access to various encoding schemas. All tile storages use this to encode their coordinates and provide different spatial encoding algorithms for efficiency.

Required methods

fn from_dimensions(dimensions: Vector3<u32>) -> Self

Constructor interface for Self which consumes the maps dimensions, which is required for some encoding types to fit within a given coordinate space.

fn encode(&self, x: u32, y: u32, z: u32) -> Option<u32>

Encode the provided x, y and z 3-dimensional coordinates into a 1-dimensional array index.

fn decode(&self, morton: u32) -> Option<(u32, u32, u32)>

Decode the provided 1-dimensional array index into its associated 3-dimensional coordinates.

fn allocation_size(dimensions: Vector3<u32>) -> usize

This function returns the actual number of elements allocated for a given dimension set and encoder.

Loading content...

Implementors

impl CoordinateEncoder for FlatEncoder[src]

impl CoordinateEncoder for MortonEncoder[src]

impl CoordinateEncoder for MortonEncoder2D[src]

Loading content...