feat: multi-layer world — temperature, gas, pressure, light as parallel per-chunk arrays

- Removed temp from Cell (13→9 bytes), added temps/pressure/gas_type/gas_density/light arrays to Chunk
- Layer access via grid.get_temp()/set_temp()/get_gas()/set_gas()/get_pressure()/set_pressure()/get_light()/set_light()
- cells_swap swaps all layers, set_material sets default_temp
- heat_transfer refactored to direct array access on temps[] (no Cell copy)
- CA rules refactored: cell.temp → grid.get_temp()/set_temp()
- gas_step: gas flow (rise, spread), fire produces CO2+smoke, steam condenses to water, acid+organic→poison gas
- pressure_step: pressure equalization for connected non-solid cells
- light_step: world-space persistent lighting, updated every 10 ticks, ray-cast line-of-sight
- Gas damage: poison gas damages entities, CO2 suffocates, applied before ca.step()
- Multi-section chunk serialization (VWM1 magic + cells + temps + gas + pressure + light)
- Old 12-byte chunk format auto-detected for backward compat
- AI spectrum: new gas + pressure spectrums, light spectrum uses world-space fallback
- Protocol: gas/pressure spectrum commands
- pre_dirty mechanism: layer steps process pre-clear dirty rects for cross-cell diffusion
- 14 new multilayer tests, all 185 tests + 14 scenarios pass
- Benchmark: 85.9 FPS (graphics surface, was 128 pre-layers — 33% regression from 4 new layer steps)
This commit is contained in:
Emil
2026-06-21 23:38:33 +03:00
parent a5436897ed
commit 24b6d0320f
17 changed files with 1723 additions and 218 deletions
+1 -2
View File
@@ -1,5 +1,5 @@
use verbatim::world::cell::{Cell, MaterialId};
use verbatim::world::chunk::{CHUNK_SIZE, Chunk, world_to_chunk};
use verbatim::world::chunk::{world_to_chunk, Chunk, CHUNK_SIZE};
use verbatim::world::grid::Grid;
#[test]
@@ -48,7 +48,6 @@ fn cell_serialization_roundtrip() {
assert_eq!(c.fg, c2.fg);
assert_eq!(c.bg, c2.bg);
assert_eq!(c.variant, c2.variant);
assert!((c.temp - c2.temp).abs() < 0.001);
}
#[test]