From 4f3326e983eb19f945b7b4654640523695b993f6 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 00:22:27 +0200 Subject: [PATCH] Mesh a column once its neighbours' light has settled A new chunk relights its eight neighbours, and every finished light job dirties all sections of the 3x3 columns around it. Meshing waited only for the column itself to be lit, so sections near the loading frontier were meshed with half-settled light and again after each neighbour's relight: about 2.25 meshes per section while a world loads. Wait until no column of the 3x3 is being lit or queued for light. The final meshes are the same; they are built once. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/streaming.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/streaming.rs b/crates/horizon-client/src/streaming.rs index 664606fbe..1837216e5 100644 --- a/crates/horizon-client/src/streaming.rs +++ b/crates/horizon-client/src/streaming.rs @@ -821,13 +821,21 @@ impl Streaming { self.waiting.insert((x, sy, z)); continue; } - // Once per column: the 3x3 lit check would otherwise repeat for - // each of its sections every frame. - let lit = &self.lit; + // Once per column: the 3x3 check would otherwise repeat for each + // of its sections every frame. A neighbour being lit or waiting + // for light dirties this column again when it finishes (new + // chunks relight their eight neighbours), so mesh once its light + // has settled rather than once per neighbour. + let (lit, lighting, dirty_light) = (&self.lit, &self.lighting, &world.dirty_light); let ready = *ready_columns.entry((x, z)).or_insert_with(|| { - (-1..=1).all(|dz| (-1..=1).all(|dx| lit.contains(&(x + dx, z + dz)))) + (-1..=1).all(|dz| { + (-1..=1).all(|dx| { + let n = (x + dx, z + dz); + lit.contains(&n) && !lighting.contains_key(&n) && !dirty_light.contains(&n) + }) + }) }); - if !ready || self.lighting.contains_key(&(x, z)) { + if !ready { continue; } let region = columns