Merge pull request #2726 from kacpherek/fix/2709-dirtpath

🤖 Agent: Merged by Ludovic's AI agent (Claude, contrib-gate-19) after the contribution gate. Checked against vanilla 26.3 and proven in union/cg19-r2 (all round-2 PRs together: clippy, 1722 tests, 135 harnesses, lan_e2e in-frame and on the server thread) and union/cg19-r3 (the same PRs merged with today's main: 96/96 harnesses). Thanks @kacpherek.
This commit is contained in:
Ludovic Marie
2026-10-27 17:58:38 +01:00
committed by GitHub
3 changed files with 30 additions and 4 deletions
+4 -3
View File
@@ -61,7 +61,7 @@ pub struct TerrainVertex {
/// UV within the sprite, `UV_STEPS` per unit (`TerrainVertex::new`,
/// `terrain.wgsl`'s `terrain_uv`).
pub(crate) uv: [u16; 2],
/// Sprite array layer, with `OPAQUE_LAYER` for opaque leaves.
/// Sprite array layer, with `OPAQUE_LAYER` for opaque leaves and quads over opaque texels.
pub layer: u16,
/// Smooth light, 16x fixed point: sky in the low byte, block in the high one.
pub light: u16,
@@ -896,8 +896,9 @@ impl Mesher<'_> {
target.push(TerrainVertex::new(
[p[0] + origin[0], p[1] + origin[1], p[2] + origin[2]],
q.uv[i],
// Opaque leaves (forceOpaque) draw in the solid layer: no alpha cutout.
if !self.cutout_leaves && state.leaves {
// Opaque leaves (forceOpaque) and quads over opaque texels draw in the
// solid layer: no alpha cutout (a dirt path's side skips its clear top row).
if face.opaque && !face.translucent || !self.cutout_leaves && state.leaves {
face.layer as u16 | OPAQUE_LAYER
} else {
face.layer as u16
+3 -1
View File
@@ -28,6 +28,8 @@ use std::{
pub struct BakedFace {
pub quad: ModelQuad,
pub layer: u32,
/// The texels under the quad's UVs are all opaque (`SpriteContents.computeTransparency`):
/// drawn in the solid layer without an alpha test.
pub opaque: bool,
/// Fractional alpha: drawn in the sorted translucent pass.
pub translucent: bool,
@@ -230,9 +232,9 @@ impl StateModels {
Ok(BakedFace {
translucent: quad.material.force_translucent
|| sprites.translucent[layer as usize],
opaque: sprites.region_opaque(layer, &quad.uv),
quad,
layer,
opaque: sprites.opaque[layer as usize],
})
})
.collect::<Result<_>>()?;
+23
View File
@@ -115,6 +115,29 @@ impl Sprites {
pub fn count(&self) -> usize {
self.native.len()
}
/// `SpriteContents.computeTransparency(u0, v0, u1, v1)` is NONE: every texel under
/// the quad's UV box is fully opaque in every frame, so the quad needs no alpha test.
pub fn region_opaque(&self, layer: u32, uv: &[[f32; 2]; 4]) -> bool {
if self.opaque[layer as usize] {
return true;
}
let (side, frames, _) = &self.native[layer as usize];
let side = *side as usize;
let range = |axis: usize| {
let lo = uv.iter().map(|p| p[axis]).fold(f32::INFINITY, f32::min);
let hi = uv.iter().map(|p| p[axis]).fold(f32::NEG_INFINITY, f32::max);
let clamp = |v: f32| (v.max(0.0) as usize).min(side);
clamp((lo * side as f32).floor())..clamp((hi * side as f32).ceil())
};
let (columns, rows) = (range(0), range(1));
frames.iter().all(|frame| {
rows.clone().all(|y| {
columns
.clone()
.all(|x| frame[(y * side + x) * 4 + 3] == 255)
})
})
}
/// Lay every layer out at one size: the largest texture's (resource packs
/// may ship 32x, 64x... textures, like vanilla's stitched atlas), rounded
/// up to a power of two and limited to [`MAX_ARRAY_BYTES`]. Smaller