fix: treat absent tiles as air in visibility, full-column occlusion refresh
- calculate_visibility: None from floor_tiles.get() now breaks touches_air=true. Absent tile = open space = air for visibility purposes. Previously, removed tiles left their below-neighbours with all-zero visible_range (black). - rabbit_dig_system: fire TileOcclusionEvent for full Z_BELOW+1 level column below the dug tile + 8 XY neighbours each, not just 3x3x3. calculate_visibility traces up to Z_TOTAL+Z_BELOW+1 tiles above each tile, so removing one tile can expose visibility arbitrarily deep below.
This commit is contained in:
@@ -134,14 +134,15 @@ pub fn rabbit_dig_system(
|
||||
if tilemap.remove_floor(&below_pos).is_some() {
|
||||
tile_changed.write(TileChangedEvent { pos: below_pos });
|
||||
|
||||
// Refresh visibility for the dug tile and all 26 neighbours.
|
||||
// Removing a tile changes what is visible from every adjacent position.
|
||||
for dz in -1..=1i32 {
|
||||
// Refresh the full column below the dig and its XY neighbours.
|
||||
// calculate_visibility traces up to Z_TOTAL+Z_BELOW+1 tiles above each tile,
|
||||
// so removing one tile can affect visibility arbitrarily deep below.
|
||||
for dz in 0..=crate::world::chunks::Z_BELOW as i32 {
|
||||
for dy in -1..=1i32 {
|
||||
for dx in -1..=1i32 {
|
||||
occlusion.write(TileOcclusionEvent {
|
||||
tile_position: below_pos
|
||||
+ IVec3::new(dx * ITILE_SIZE, dy * ITILE_SIZE, dz * ITILE_SIZE),
|
||||
- IVec3::new(dx * ITILE_SIZE, dy * ITILE_SIZE, dz * ITILE_SIZE),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,8 @@ pub fn calculate_visibility(pos: IVec3, tilemap: &TileMap) -> [u32; 8] {
|
||||
);
|
||||
match tilemap.floor_tiles.get(&neighbor_pos) {
|
||||
Some(tile) if tile.id == 0 => break 'neighbor_check true,
|
||||
None => {}
|
||||
// Absent tile means open space — treat as air for visibility.
|
||||
None => break 'neighbor_check true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user