feat: store color directly in Cell (reality layer)
Each cell now stores its own fg/bg color inline, instead of looking up from MaterialRegistry every frame. Cell struct: - fg: [u8; 3] — foreground color (for rendering) - bg: [u8; 3] — background color (for rendering) - temp: f32 — temperature (already there) - material: MaterialId — for physics property lookup - variant: u8 — visual/behavioral variant - updated_this_tick: bool — CA flag Colors are copied from MaterialRegistry at Cell::new() time. This allows per-cell color variation in the future (water depth shading, lava gradient, damaged materials, etc.) without registry changes. MaterialRegistry still stores physics properties (density, solid, liquid, flammable, etc.) — looked up only during CA/physics steps, not during rendering. Renderers (terminal, ascii, graphics) updated to use cell.fg/cell.bg directly — no more registry lookup in render path. Cell size: ~16 bytes (was ~12). 250x250 grid = 1MB (was 750KB). 126 tests, 0 failures
This commit is contained in:
@@ -207,7 +207,6 @@ impl VulkanRenderer {
|
||||
('?', [80, 80, 80, 255], bg_default)
|
||||
} else {
|
||||
let cell = grid.get(wx, wy);
|
||||
let mat = reg.get(cell.material);
|
||||
if cell.is_empty() {
|
||||
(' ', [10, 10, 15, 255], bg_default)
|
||||
} else {
|
||||
@@ -215,10 +214,10 @@ impl VulkanRenderer {
|
||||
let r = 200u8.saturating_add(cell.variant / 2);
|
||||
[r, 60, 20, 255]
|
||||
} else {
|
||||
[mat.color_fg.0, mat.color_fg.1, mat.color_fg.2, 255]
|
||||
[cell.fg[0], cell.fg[1], cell.fg[2], 255]
|
||||
};
|
||||
let bg = [mat.color_bg.0, mat.color_bg.1, mat.color_bg.2, 255];
|
||||
(mat.display_char, fg, bg)
|
||||
let bg = [cell.bg[0], cell.bg[1], cell.bg[2], 255];
|
||||
(cell.material.display_char(), fg, bg)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user