feat: data-oriented chunks optimization with tile registry
- Phase 1: Bit-packed standability (ChunkData with bitsets) - Phase 2: Reactive connectivity (dirty chunks) - Phase 3: Async terrain baking (AsyncComputeTaskPool) - Pathfinding weight system (rock=50 preferred, bedrock=150 avoided) - Movement speed affected by tile weight - External tiles.toml for hot-reloadable tile definitions - TileRegistry singleton for async-safe tile lookups - Fixed world_to_chunk to use CHUNK_SIZE_TILE (128) not CHUNK_SIZE (8) - Fixed infinite spawner with Local<bool> state guards - Fixed spawn coordinate grid alignment Note: Zigzag pathfinding bug introduced - needs investigation
This commit is contained in:
@@ -269,4 +269,18 @@ impl TileMap {
|
||||
|
||||
(can_stand_in_floor || can_stand_in_fixture) && (can_stand_on_floor || can_stand_on_fixture)
|
||||
}
|
||||
|
||||
/// Get A* pathfinding weight for a tile position.
|
||||
/// Returns 100 (default) if tile not found. Lower is better.
|
||||
pub fn get_astar_weight(&self, world_pos: IVec3) -> u8 {
|
||||
let chunk_pos = world_to_chunk(world_pos);
|
||||
if let Some(chunk) = self.chunks.get(&chunk_pos) {
|
||||
let (local_x, local_y, z) = ChunkData::world_to_local(world_pos);
|
||||
return chunk.get_astar_weight(local_x, local_y, z);
|
||||
}
|
||||
self.floor_tiles
|
||||
.get(&world_pos)
|
||||
.map(|t| t.astar_weight)
|
||||
.unwrap_or(100)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user