pub struct TileCache { /* private fields */ }Expand description
Tile cache structure
Implementations§
Source§impl TileCache
impl TileCache
Sourcepub fn new(params: TileCacheParams) -> Result<Self, TileCacheError>
pub fn new(params: TileCacheParams) -> Result<Self, TileCacheError>
Creates a new tile cache
Sourcepub fn init(&mut self) -> Result<(), TileCacheError>
pub fn init(&mut self) -> Result<(), TileCacheError>
Initializes the tile cache with data
Attaches the tile cache to a navigation mesh with the specified builder configuration
Sourcepub fn add_tile(
&mut self,
data: &[u8],
flags: u8,
result: &mut PolyRef,
) -> Result<(), TileCacheError>
pub fn add_tile( &mut self, data: &[u8], flags: u8, result: &mut PolyRef, ) -> Result<(), TileCacheError>
Adds a tile to the cache with optional compression
Sourcepub fn remove_tile(&mut self, ref_val: PolyRef) -> Result<(), TileCacheError>
pub fn remove_tile(&mut self, ref_val: PolyRef) -> Result<(), TileCacheError>
Removes a tile from the cache
Sourcepub fn add_obstacle(
&mut self,
pos: [f32; 3],
radius: f32,
height: f32,
) -> Result<u32, TileCacheError>
pub fn add_obstacle( &mut self, pos: [f32; 3], radius: f32, height: f32, ) -> Result<u32, TileCacheError>
Adds a cylinder obstacle to the cache
Sourcepub fn add_box_obstacle(
&mut self,
bmin: [f32; 3],
bmax: [f32; 3],
) -> Result<u32, TileCacheError>
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
Sourcepub fn add_oriented_box_obstacle(
&mut self,
center: [f32; 3],
half_extents: [f32; 3],
y_radians: f32,
) -> Result<u32, TileCacheError>
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
Sourcepub fn remove_obstacle(
&mut self,
obstacle_ref: u32,
) -> Result<(), TileCacheError>
pub fn remove_obstacle( &mut self, obstacle_ref: u32, ) -> Result<(), TileCacheError>
Removes an obstacle from the cache
Sourcepub fn update(&mut self) -> Result<(), TileCacheError>
pub fn update(&mut self) -> Result<(), TileCacheError>
Updates the tile cache (processes pending obstacles)
Sourcepub fn update_with_status(&mut self, _dt: f32) -> Result<bool, TileCacheError>
pub fn update_with_status(&mut self, _dt: f32) -> Result<bool, TileCacheError>
Updates the tile cache and returns whether it’s up to date
Updates the tile cache and rebuilds tiles in the navigation mesh
Builds navigation mesh tiles at the specified tile coordinates
Builds a navigation mesh tile from a compressed tile reference
Rebuilds a tile using the attached navigation mesh integration
Sourcepub fn get_tile(&self, tile_idx: usize) -> Option<&TileCacheEntry>
pub fn get_tile(&self, tile_idx: usize) -> Option<&TileCacheEntry>
Gets a tile by index
Sourcepub fn get_tile_at(&self, x: i32, y: i32, layer: i32) -> Option<&TileCacheEntry>
pub fn get_tile_at(&self, x: i32, y: i32, layer: i32) -> Option<&TileCacheEntry>
Gets a tile at the specified coordinates
Sourcepub fn get_obstacle(&self, obstacle_idx: usize) -> Option<&Obstacle>
pub fn get_obstacle(&self, obstacle_idx: usize) -> Option<&Obstacle>
Gets an obstacle by index
Sourcepub fn get_obstacle_count(&self) -> usize
pub fn get_obstacle_count(&self) -> usize
Gets the number of obstacles
Sourcepub fn get_params(&self) -> &TileCacheParams
pub fn get_params(&self) -> &TileCacheParams
Gets the parameters of the tile cache
Sourcepub fn get_tile_compressed_data(&self, tile_idx: usize) -> Option<&[u8]>
pub fn get_tile_compressed_data(&self, tile_idx: usize) -> Option<&[u8]>
Gets the compressed data for a tile
Sourcepub fn get_tile_data(&self, tile_idx: usize) -> Result<Vec<u8>, TileCacheError>
pub fn get_tile_data(&self, tile_idx: usize) -> Result<Vec<u8>, TileCacheError>
Gets the decompressed data for a tile
Sourcepub fn compress_tile(&self, data: &[u8]) -> Result<Vec<u8>, TileCacheError>
pub fn compress_tile(&self, data: &[u8]) -> Result<Vec<u8>, TileCacheError>
Compresses tile data using LZ4
Sourcepub fn decompress_tile(
&self,
compressed_data: &[u8],
_uncompressed_size: Option<usize>,
) -> Result<Vec<u8>, TileCacheError>
pub fn decompress_tile( &self, compressed_data: &[u8], _uncompressed_size: Option<usize>, ) -> Result<Vec<u8>, TileCacheError>
Decompresses tile data using LZ4
Sourcepub fn encode_obstacle_ref(&self, salt: u16, idx: usize) -> u32
pub fn encode_obstacle_ref(&self, salt: u16, idx: usize) -> u32
Encodes an obstacle reference from salt and index
Sourcepub fn decode_obstacle_ref_salt(&self, ref_val: u32) -> u16
pub fn decode_obstacle_ref_salt(&self, ref_val: u32) -> u16
Decodes the salt from an obstacle reference
Sourcepub fn decode_obstacle_ref_idx(&self, ref_val: u32) -> usize
pub fn decode_obstacle_ref_idx(&self, ref_val: u32) -> usize
Decodes the index from an obstacle reference
Sourcepub fn get_obstacle_by_ref(&self, ref_val: u32) -> Option<&Obstacle>
pub fn get_obstacle_by_ref(&self, ref_val: u32) -> Option<&Obstacle>
Gets an obstacle by its reference
Sourcepub fn get_obstacle_ref(&self, obstacle_idx: usize) -> Option<u32>
pub fn get_obstacle_ref(&self, obstacle_idx: usize) -> Option<u32>
Gets the reference for an obstacle at the given index
Sourcepub fn query_tiles(
&self,
bmin: &[f32; 3],
bmax: &[f32; 3],
max_tiles: usize,
) -> Result<Vec<PolyRef>, TileCacheError>
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
Sourcepub fn get_tiles_at(
&self,
tx: i32,
ty: i32,
) -> Result<Vec<PolyRef>, TileCacheError>
pub fn get_tiles_at( &self, tx: i32, ty: i32, ) -> Result<Vec<PolyRef>, TileCacheError>
Gets all tiles at the given tile coordinates
Sourcepub fn calc_tight_tile_bounds(
&self,
header: &TileCacheLayerHeader,
) -> ([f32; 3], [f32; 3])
pub fn calc_tight_tile_bounds( &self, header: &TileCacheLayerHeader, ) -> ([f32; 3], [f32; 3])
Calculates tight bounds for a tile