Skip to main content

TileCache

Struct TileCache 

Source
pub struct TileCache { /* private fields */ }
Expand description

Tile cache structure

Implementations§

Source§

impl TileCache

Source

pub fn new(params: TileCacheParams) -> Result<Self, TileCacheError>

Creates a new tile cache

Source

pub fn init(&mut self) -> Result<(), TileCacheError>

Initializes the tile cache with data

Source

pub fn attach_to_nav_mesh( &mut self, builder_config: TileCacheBuilderConfig, ) -> Result<(), TileCacheError>

Attaches the tile cache to a navigation mesh with the specified builder configuration

Source

pub fn add_tile( &mut self, data: &[u8], flags: u8, result: &mut PolyRef, ) -> Result<(), TileCacheError>

Adds a tile to the cache with optional compression

Source

pub fn remove_tile(&mut self, ref_val: PolyRef) -> Result<(), TileCacheError>

Removes a tile from the cache

Source

pub fn add_obstacle( &mut self, pos: [f32; 3], radius: f32, height: f32, ) -> Result<u32, TileCacheError>

Adds a cylinder obstacle to the cache

Source

pub fn add_box_obstacle( &mut self, bmin: [f32; 3], bmax: [f32; 3], ) -> Result<u32, TileCacheError>

Adds an axis-aligned box obstacle to the cache

Source

pub fn add_oriented_box_obstacle( &mut self, center: [f32; 3], half_extents: [f32; 3], y_radians: f32, ) -> Result<u32, TileCacheError>

Adds an oriented box obstacle to the cache

Source

pub fn remove_obstacle( &mut self, obstacle_ref: u32, ) -> Result<(), TileCacheError>

Removes an obstacle from the cache

Source

pub fn update(&mut self) -> Result<(), TileCacheError>

Updates the tile cache (processes pending obstacles)

Source

pub fn update_with_status(&mut self, _dt: f32) -> Result<bool, TileCacheError>

Updates the tile cache and returns whether it’s up to date

Source

pub fn update_with_nav_mesh( &mut self, _dt: f32, nav_mesh: &mut NavMesh, ) -> Result<bool, TileCacheError>

Updates the tile cache and rebuilds tiles in the navigation mesh

Source

pub fn build_nav_mesh_tiles_at( &mut self, tx: i32, ty: i32, nav_mesh: &mut NavMesh, ) -> Result<(), TileCacheError>

Builds navigation mesh tiles at the specified tile coordinates

Source

pub fn build_nav_mesh_tile( &mut self, tile_ref: PolyRef, nav_mesh: &mut NavMesh, ) -> Result<(), TileCacheError>

Builds a navigation mesh tile from a compressed tile reference

Source

pub fn rebuild_tile_in_nav_mesh( &mut self, nav_mesh: &mut NavMesh, tile_idx: usize, ) -> Result<Option<PolyRef>, TileCacheError>

Rebuilds a tile using the attached navigation mesh integration

Source

pub fn get_tile(&self, tile_idx: usize) -> Option<&TileCacheEntry>

Gets a tile by index

Source

pub fn get_tile_at(&self, x: i32, y: i32, layer: i32) -> Option<&TileCacheEntry>

Gets a tile at the specified coordinates

Source

pub fn get_obstacle(&self, obstacle_idx: usize) -> Option<&Obstacle>

Gets an obstacle by index

Source

pub fn get_obstacle_count(&self) -> usize

Gets the number of obstacles

Source

pub fn get_params(&self) -> &TileCacheParams

Gets the parameters of the tile cache

Source

pub fn get_tile_compressed_data(&self, tile_idx: usize) -> Option<&[u8]>

Gets the compressed data for a tile

Source

pub fn get_tile_data(&self, tile_idx: usize) -> Result<Vec<u8>, TileCacheError>

Gets the decompressed data for a tile

Source

pub fn compress_tile(&self, data: &[u8]) -> Result<Vec<u8>, TileCacheError>

Compresses tile data using LZ4

Source

pub fn decompress_tile( &self, compressed_data: &[u8], _uncompressed_size: Option<usize>, ) -> Result<Vec<u8>, TileCacheError>

Decompresses tile data using LZ4

Source

pub fn get_salt(&self) -> u32

Gets the current salt value

Source

pub fn encode_obstacle_ref(&self, salt: u16, idx: usize) -> u32

Encodes an obstacle reference from salt and index

Source

pub fn decode_obstacle_ref_salt(&self, ref_val: u32) -> u16

Decodes the salt from an obstacle reference

Source

pub fn decode_obstacle_ref_idx(&self, ref_val: u32) -> usize

Decodes the index from an obstacle reference

Source

pub fn get_obstacle_by_ref(&self, ref_val: u32) -> Option<&Obstacle>

Gets an obstacle by its reference

Source

pub fn get_obstacle_ref(&self, obstacle_idx: usize) -> Option<u32>

Gets the reference for an obstacle at the given index

Source

pub fn query_tiles( &self, bmin: &[f32; 3], bmax: &[f32; 3], max_tiles: usize, ) -> Result<Vec<PolyRef>, TileCacheError>

Queries tiles that overlap with the given bounding box

Source

pub fn get_tiles_at( &self, tx: i32, ty: i32, ) -> Result<Vec<PolyRef>, TileCacheError>

Gets all tiles at the given tile coordinates

Source

pub fn calc_tight_tile_bounds( &self, header: &TileCacheLayerHeader, ) -> ([f32; 3], [f32; 3])

Calculates tight bounds for a tile

Source

pub fn get_obstacle_bounds(&self, obstacle: &Obstacle) -> ([f32; 3], [f32; 3])

Gets the bounds of an obstacle

Trait Implementations§

Source§

impl Debug for TileCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.