docs(pathfinding): add documentation and remove unused async infrastructure

- Add comprehensive module documentation explaining tier architecture
- Add TileMap documentation explaining design choices (FxHashMap, packed data)
- Remove unused async pathfinding code (StandableTileSnapshot, spawn_async_path_task)
- Remove unused imports (check_ready, rayon, StdHashMap)
- Fix unused variable warnings with underscore prefixes
- Add #[allow(dead_code)] for intentionally unused fields
This commit is contained in:
2026-03-18 22:08:27 +00:00
parent 4d6692c432
commit a5154f73dd
2 changed files with 84 additions and 175 deletions
+24 -2
View File
@@ -1,8 +1,30 @@
//! Tile map storage for pathfinding and rendering.
//!
//! # Design Choices
//!
//! ## FxHashMap over HashMap
//! Uses `rustc_hash::FxHashMap` instead of std HashMap. FxHash is 30-50% faster
//! for integer keys (IVec3) because it uses a simpler hash function optimized
//! for hashable-by-bit patterns. ~1.3M tiles are stored, so lookup speed matters.
//!
//! ## Packed Tile Data
//! FloorTileData is ~35 bytes vs 76 bytes for a naive tuple. FixtureTileData is
//! ~18 bytes vs 48 bytes. Bit-packing flags (can_stand_in/on, visibly_transparent)
//! reduces memory footprint and improves cache locality.
//!
//! ## Single-Threaded Access
//! No Arc wrapper because pathfinding runs on the main thread using thread-local
//! scratchpads. Async pathfinding was attempted but snapshot copying overhead
//! exceeded the benefit given current P99 (~357µs).
//!
//! ## Memory Layout
//! - floor_tiles: Primary pathfinding data (standability checks)
//! - fixture_tiles: Secondary checks (fixtures can be standable)
//! - item_tiles: Entity references per tile position
use bevy::prelude::*;
use rustc_hash::FxHashMap;
use crate::constants::ITILE_SIZE;
/// Packed floor tile data for efficient storage. ~35 bytes vs 76 bytes tuple.
#[derive(Clone, Copy, Debug)]
pub struct FloorTileData {