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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-15 00:22:27 +02:00
parent cfa6033535
commit 4f3326e983
+13 -5
View File
@@ -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