Part of #776 — SOLID architecture debt umbrella.
Phase: P1 · Finding: M5
Problem
modules/world-runtime/src/world_mutation.zig:53-92, 137-422 is marketed as 'the single path for block edits' but embeds a complete BFS lighting propagation engine (~285 lines): spreadSkylight, spreadBlockLight, seedSunlightColumn, seedLightFromNeighbors, recomputeLoadedLightingArea, relightAfterBlockRemoval.
Evidence
world_mutation.zig:53-92 — one coordinator doing block-write + GPU signal + flood-fill lighting:
pub fn applyBlockMutation(...) !?MutationResult {
...
data.chunk.setBlock(local.x, local.y, local.z, block);
if (self.gpu_mesher_active) { ... buf.updateBlock(...); }
...
if (block == .air and old_def.isOpaque() ...) {
try self.relightAfterBlockRemoval(...); // BFS engine
} else if (...) {
try self.recomputeLoadedLightingArea(...); // BFS engine
}
}
Fix
Extract the BFS engine into a LightingEngine module (e.g. modules/world-runtime/src/lighting_engine.zig or world-lighting). The coordinator invokes lightingEngine.afterBlockRemoval(...) / .recomputeArea(...).
Verification
nix develop --command zig build test (includes shader validation)
- If rendering-touching: capture headless screenshot baseline before/after (
-Dskip-present)
- If behavior-preserving refactor: golden-output test must stay green
Constraints
- Small reviewable PR targeting
dev; conventional commit (refactor: / feat:)
- Preserve current behavior unless this issue explicitly changes it
- Keep worker-thread RHI isolation intact (no RHI calls off main thread)
Notes
Behavior-preserving. The lighting algorithm is unchanged — only its home moves.
Tracking: #776
Part of #776 — SOLID architecture debt umbrella.
Phase: P1 · Finding: M5
Problem
modules/world-runtime/src/world_mutation.zig:53-92, 137-422is marketed as 'the single path for block edits' but embeds a complete BFS lighting propagation engine (~285 lines):spreadSkylight,spreadBlockLight,seedSunlightColumn,seedLightFromNeighbors,recomputeLoadedLightingArea,relightAfterBlockRemoval.Evidence
world_mutation.zig:53-92— one coordinator doing block-write + GPU signal + flood-fill lighting:Fix
Extract the BFS engine into a
LightingEnginemodule (e.g.modules/world-runtime/src/lighting_engine.zigorworld-lighting). The coordinator invokeslightingEngine.afterBlockRemoval(...)/.recomputeArea(...).Verification
nix develop --command zig build test(includes shader validation)-Dskip-present)Constraints
dev; conventional commit (refactor:/feat:)Notes
Behavior-preserving. The lighting algorithm is unchanged — only its home moves.
Tracking: #776