From fab71df1857dafcf3768f3d86afff40e210612da Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 01:21:23 +0200 Subject: [PATCH] Mesher: sort solid quads in the meshing workers, not in Mesher::mesh Mesher::mesh keeps model order, which the leaf-culling test pairs with the baked faces; the section and tile workers sort what they upload. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/lod.rs | 3 ++- crates/horizon-client/src/lod/mesh.rs | 6 ++---- crates/horizon-client/src/mesher.rs | 6 +++--- crates/horizon-client/src/streaming.rs | 3 ++- crates/horizon-client/tests/streaming_meshes.rs | 4 +++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/horizon-client/src/lod.rs b/crates/horizon-client/src/lod.rs index ee17acee1..a429863a7 100644 --- a/crates/horizon-client/src/lod.rs +++ b/crates/horizon-client/src/lod.rs @@ -689,7 +689,7 @@ impl Lod { } let finer = finer.remove(&key).unwrap_or_default(); let input = snapshot.mesh_input(key, finer); - let mesh = mesher.mesh( + let mut mesh = mesher.mesh( input.key, &input.columns(), &covered, @@ -698,6 +698,7 @@ impl Lod { &input.neighbors, &input.finer, ); + mesh.sort_solid(); meshes.push((input.key, mesh)); } Done::Mesh { diff --git a/crates/horizon-client/src/lod/mesh.rs b/crates/horizon-client/src/lod/mesh.rs index bdd77fbea..852f45e5b 100644 --- a/crates/horizon-client/src/lod/mesh.rs +++ b/crates/horizon-client/src/lod/mesh.rs @@ -67,7 +67,7 @@ impl Mesher { neighbors: &[Vec; 4], finer: &[TileKey], ) -> SectionMesh { - let mut mesh = mesh_columns_with_edges( + mesh_columns_with_edges( key, columns, covered, @@ -75,9 +75,7 @@ impl Mesher { neighbors, finer, |span, direction| self.material(span, direction, context), - ); - mesh.sort_solid(); - mesh + ) } fn material(&mut self, span: &Span, direction: Direction, context: &WorkerContext) -> Material { let styles = *self diff --git a/crates/horizon-client/src/mesher.rs b/crates/horizon-client/src/mesher.rs index d1b27bec9..c4bfffc1c 100644 --- a/crates/horizon-client/src/mesher.rs +++ b/crates/horizon-client/src/mesher.rs @@ -116,8 +116,9 @@ mod vertex_tests { } pub struct SectionMesh { pub solid: Vec, - /// The buckets `solid` is sorted in by the side its quads face - /// (`sort_solid`; empty until then). + /// The buckets `solid` is sorted in by the side its quads face: empty + /// until `sort_solid`, which the meshing workers call; `solid` is in + /// model order before. pub sides: Sides, pub translucent: Vec, /// VisGraph: bit `a * 6 + b` is set when faces `a` and `b` (Direction @@ -811,7 +812,6 @@ impl Mesher<'_> { } } } - out.sort_solid(); out } /// `BlockColors` tint source `index`, or `None` for an untinted (-1) layer. diff --git a/crates/horizon-client/src/streaming.rs b/crates/horizon-client/src/streaming.rs index 15ed1674e..5a52dfffe 100644 --- a/crates/horizon-client/src/streaming.rs +++ b/crates/horizon-client/src/streaming.rs @@ -507,7 +507,8 @@ impl Streaming { biomes: &context.biomes, visibility, }; - let mesh = mesher.mesh(&borrow(®ion), sy); + let mut mesh = mesher.mesh(&borrow(®ion), sy); + mesh.sort_solid(); faces = Some((context.tables.clone(), mesher.visibility)); Done::Meshed(x, sy, z, mesh, seq) } diff --git a/crates/horizon-client/tests/streaming_meshes.rs b/crates/horizon-client/tests/streaming_meshes.rs index f0b6fb038..142d31fde 100644 --- a/crates/horizon-client/tests/streaming_meshes.rs +++ b/crates/horizon-client/tests/streaming_meshes.rs @@ -222,7 +222,9 @@ fn relit_columns_keep_every_mesh_current() { biomes: &context.biomes, visibility: context.tables.visibility.clone(), }; - let fresh = mesher.mesh(&borrow(®ion), sy); + // The workers sort solid quads by side, as uploads expect. + let mut fresh = mesher.mesh(&borrow(®ion), sy); + fresh.sort_solid(); let bytes = |m: &SectionMesh| { [ bytemuck::cast_slice::<_, u8>(&m.solid).to_vec(),