Compute and verify native full-face occlusion masks

This commit is contained in:
Ludovic Marie
2026-10-06 12:42:28 +02:00
parent c8d07903ef
commit bc45763047
7 changed files with 131 additions and 28 deletions
@@ -8,10 +8,10 @@
"registry_states": 35723,
"fixtures": 18096,
"sources_sha256": {
"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockPropertiesOracle.java": "99a396b9b983f6ca9149133251f3ece9aaf76d3d16dafa1f322378212a19490c",
"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockPropertiesOracle.java": "e871d3a01f15616a98ca9227c27a81e4d17e2d57ac4e68a5650a70fa29811497",
"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaCollisionOracle.java": "60ff9ef7c1d5e23c080f9aec95ab2e7d3b7c5b5bcd67b9efa9518776c400629a",
"tools/test_block_properties_parity.py": "083d09fe190a783b2939068b7ad01e98938d9277f9583c5273bb2453e870d713",
"tools/test_rust_parity.py": "7efa699a38c5820424f5fc8992ee601dbfe26d6482da9d2dab2c17c41fe8f12a",
"tools/test_block_properties_parity.py": "01cc525e4c02a254a6f7495ec6d04cc09513051ec318144036a776103ca549d6",
"tools/test_rust_parity.py": "29d3db08005873528894b45ca10dcd6278753650473b3eb574e53e06ede40ec6",
"tools/lab.py": "d00bf107fa01b6c579734a082c3ca4ade3018f0d6851d46844acf17574f66e64",
"Cargo.toml": "dc370d5fdde37238c3e4820046f11c3201020406a4edfa1308257c13edbdcda4",
"Cargo.lock": "7307d0c887364db36d327685ecf0671b75305e31e5ba5fbdcdbb15eaf156d20e",
@@ -75,23 +75,24 @@
"crates/horizon-core/src/ticks/mod.rs": "84852599dde78687d782f115a5b4b3ef6856c1f9cc92917255167e89c72ab01e",
"crates/horizon-world/src/bin/worldgen_parity.rs": "3143ceb9b56eecfd7667e5feb5f9f0cd13cfb8754b38d4ea338dbba97f2819da",
"crates/horizon-world/src/block_collision.rs": "cec2af81d212d5eed7a2196e4cf0be2daf4cecf53248f78cc68f2190e4d83f9a",
"crates/horizon-world/src/block_properties.rs": "b3caf26bd3afc9d10cdcca3f7e794c30abf5ba09afa1fe80ba8f44713acdb274",
"crates/horizon-world/src/block_placement.rs": "524f4892d50bab77b7d89d19f7b048ffe746996f2ed7f376db2c6ab00ed75c24",
"crates/horizon-world/src/block_properties.rs": "b0bd8a983336c48e488a20caa77dd5c39b1a74bbd14ebc03b3b64556a1c864fc",
"crates/horizon-world/src/block_support.rs": "ade4fbd47284b450dabdd682dc86138b2ac05a0fd379525d7110648908245476",
"crates/horizon-world/src/block_survival.rs": "2c882aeb095c27a8edfda1e934ac829102e4be136d53fd83110132150b7293b1",
"crates/horizon-world/src/block_survival.rs": "28ce64375e09819a4f13da9cfbe37c08b5ad0daf01b289c1c360b4567e50e811",
"crates/horizon-world/src/chunk.rs": "8843e6f48dbbc4245ce4e95564dfba3a4d7a051ba0b1577fb038c07adb0ff0f9",
"crates/horizon-world/src/collision.rs": "05313e0c1f3089524fe029f9aac3e439cd47f1c9584c8c7e154c9adcfa88c335",
"crates/horizon-world/src/compression.rs": "4db73e6ca9a0d552d415ce60e7e88b89c9cf2b7d060a669ff8328f518316e101",
"crates/horizon-world/src/dynamic_support.rs": "e799b31e5120cfdb04e0b342f2097d610ed98ef8c4be031620ee00368d82df59",
"crates/horizon-world/src/entity_obstruction.rs": "a4b28a19bf83b23611c59d94535c488db37e4aee24b22c973c545910894a809f",
"crates/horizon-world/src/fluid.rs": "8a2834a9347ee2c2db7cf1c86a064907ec06e9ac16ba9cc3936e315fc4ad49ca",
"crates/horizon-world/src/fluid.rs": "a0a1f34ba94d8b59dc975becee8952960764d67ae08cf2d6a8bcd40a614b15c4",
"crates/horizon-world/src/heightmap.rs": "a5edef082b5af40d814421ea17e129b3b06d70abee6434ed263e4bba58571698",
"crates/horizon-world/src/lib.rs": "09f697d8d4e709acacc8e9f7c35c5fd307bab6ab0df4a1339fe760afc655cdab",
"crates/horizon-world/src/lib.rs": "a8cd85f6223668c1446ff103276d80937b9707d9a7dc619a176b1b1ceed36a4a",
"crates/horizon-world/src/main.rs": "fce57418b8c22a6a0a9044baa89ed3d9c243bc2e8413fea3ff0f32985daba021",
"crates/horizon-world/src/nbt.rs": "60262c3de8c8f68bc2da0370ccb17393d32b85f5f5022c6358599a7d32119ea6",
"crates/horizon-world/src/piston_shape.rs": "399c2337103b8e7e0eb5667227c5aa14f9549d6a467b7be7da3d0717f0263500",
"crates/horizon-world/src/region.rs": "72b642e87fed37ed17f54d4c30f96c3b64d26c14bc0589c31ef40ff1616188fc",
"crates/horizon-world/src/registry/json.rs": "40974e8ddbca79f4a4f866f91f1241a7ac7289874527d4729483995dcf9b4f7e",
"crates/horizon-world/src/registry.rs": "566d7ef6a0d0d7e492d73b7f963ff0158544560a86ba33e179ef4d17e1274706",
"crates/horizon-world/src/registry/json.rs": "1eae82604d2b3377fd35aaa3a914a67e5af28f93923815a49e895b4d437433cd",
"crates/horizon-world/src/registry.rs": "f2e58b2b4d944ac8fc6226bd3352cefc3d2052d8473e02ccf7dc402b176df435",
"crates/horizon-world/src/tick_data.rs": "f8d04a69ea263f4168bce33f92e5b4ee2fe07d7caf50a1621c6b3ef6eb2479f3",
"crates/horizon-world/src/worldgen/anchor.rs": "d156b8a0b147a274cdd143409b441f4f43edecde6e8ee14ef9cf0309f743143a",
"crates/horizon-world/src/worldgen/aquifer/config.rs": "fcd2cc3a520c1527c88f095a3b5d38487e7ebb1ccecc5f757f93d04a069add4f",
@@ -104,7 +105,10 @@
"crates/horizon-world/src/worldgen/biome_source/runtime.rs": "f0b02c1521178e4d0377c6ca62694604b6a773f1f234f070ff0cde4685911d45",
"crates/horizon-world/src/worldgen/biome_source.rs": "e181e1736f3e0b75f7091a24c88de3fd116e01b98424d02382aea7a503d1eb54",
"crates/horizon-world/src/worldgen/biome_temperature.rs": "cde4bbab5e260c4065b113376c423b8511ade93c5aa5fd976e245ee8a58b5ad1",
"crates/horizon-world/src/worldgen/block_feature.rs": "82a424d3b20837dc401005f5fe038616659eb17b5bbd78d0c8c29f8bdeb1104a",
"crates/horizon-world/src/worldgen/block_blob.rs": "c608c57b3d77279646ecb89e50677dd8e452b0422ffd357ba755536c5589eb89",
"crates/horizon-world/src/worldgen/block_column.rs": "f72c21a9066ee0aa68c2fb79fba436d05afb14c6ef5a2cb012f1ed35fc17cd22",
"crates/horizon-world/src/worldgen/block_feature.rs": "5ce5c6eaa5f8a2557a620e533788217b1eb430654801dcf6135d6c92d7a012ac",
"crates/horizon-world/src/worldgen/block_pile.rs": "623e369b77e0526ed2756485a6c0bb09683cd28ad8876dea907360ca6665b39d",
"crates/horizon-world/src/worldgen/block_predicate.rs": "074c692367e3f2191a1bb28d87b23402430a843c246bd30a4ea838ee3500280e",
"crates/horizon-world/src/worldgen/bulk_section.rs": "eecf61532d7793f853884c5a18a7f436a59835c7b13d3ec9075804511553c9ba",
"crates/horizon-world/src/worldgen/carver/canyon.rs": "509c4d5a9d689849e98e894ab14a9fbf82d10707d38e9cc688ded3c4778df3e2",
@@ -116,10 +120,11 @@
"crates/horizon-world/src/worldgen/climate.rs": "1b9ad44407f40aee4c1cd5357a5c9c443c1b105728f01cf5c644072f99f8357e",
"crates/horizon-world/src/worldgen/decoration.rs": "75a79b20b21e133816e729f16e758be6165d0db18a64bfbd5fd3618325a2adf3",
"crates/horizon-world/src/worldgen/density.rs": "65a98c156a290a6b374ef670d28cd5dfbe0aa93171824d1bbd96422536273f84",
"crates/horizon-world/src/worldgen/disk.rs": "6f8f9e059755af44c9bfa1b91eba54a7d13fad811dce31717c5502d7f6df33d7",
"crates/horizon-world/src/worldgen/feature.rs": "40500af71ee6628dfb27518262d99f08d0383ae6c7b9397452feef0c213eadd9",
"crates/horizon-world/src/worldgen/feature_catalog.rs": "486fe9d8588eb09e0ee5707a0541b0df167b63b0b56c90a2709bfa09a0a3ad19",
"crates/horizon-world/src/worldgen/feature_graph.rs": "fe61a5e43179a7588737a71782ea246811fe2c8721e74793e1ac018c8eb93c34",
"crates/horizon-world/src/worldgen/feature_region.rs": "2c78e5f1bdb08307f8d982f231f1abbc3306cd54348d9023b86ee6ed3516fd33",
"crates/horizon-world/src/worldgen/feature_catalog.rs": "efc7b17b227e71622ef34108be9abd010f5675b68ea0409fcab82581d9aab88a",
"crates/horizon-world/src/worldgen/feature_graph.rs": "b7cbb8f464098f22aedbe4d954afd51cbb24d4f3be3f53f3c764015cf9d72d80",
"crates/horizon-world/src/worldgen/feature_region.rs": "3b893ceafbdd1d7b4264f4022dbdb6a7142dfc7001a5cf5c304f5ca7695dfaa0",
"crates/horizon-world/src/worldgen/feature_sort.rs": "3488a093dfe1321aaa29d8a30cfb115d8e666a81bf195514e87b170de626835c",
"crates/horizon-world/src/worldgen/fluid_predicate.rs": "e682d13a21f90605215b79f5d254bf2e524d35e89eab2e3b46384709af80b847",
"crates/horizon-world/src/worldgen/height_provider.rs": "368d4dc119854742a045c4a717679c921456da681fc5f71aa9b37102d6f33b47",
@@ -134,22 +139,25 @@
"crates/horizon-world/src/worldgen/material_surface.rs": "5d37b90099df3d6da0845dab164e71469fb287019c2ee74bc6714f3b9d6d6d5b",
"crates/horizon-world/src/worldgen/ore_feature.rs": "83b89fd3be691c5412c0215b6abefdcaa44119a05aa41217e061970eb7e12ebd",
"crates/horizon-world/src/worldgen/placement/chain.rs": "9218399b4d3757f7bbc550d7729a7201f32a1c83a7030865e0c12aab8a80d116",
"crates/horizon-world/src/worldgen/placement/context.rs": "cd1d2fe305ad4e205e7e01b32128ff895fa8aacc76fa11f200ad6c7c9fba1f49",
"crates/horizon-world/src/worldgen/placement/context.rs": "c04a1f7e9409b0cea0ed9b90fd033fc5a398b66f2688b7f6c0583facc473c457",
"crates/horizon-world/src/worldgen/placement/layer.rs": "a0f5ca776f33f9d4f72b8fdcd163426152e5e43cb4a7572fc1d4fc57bf965de1",
"crates/horizon-world/src/worldgen/placement.rs": "b0397e5818fae84358546193a95f84bcb0b5bffafce909e6fcb3386179ee8023",
"crates/horizon-world/src/worldgen/router.rs": "2cee7cf15a0d2ada12be6b39d83e78177fd3033922e4f4cce87a64073cec2847",
"crates/horizon-world/src/worldgen/rule_test.rs": "d1662ec492489ebaa4b87e20f9a8c809dcf3a223a151211bd65ec241a63692fc",
"crates/horizon-world/src/worldgen/settings.rs": "a8fe87752e1982ef11cb67f8d80d8e3428b2c27db178044cb425ba803e689e59",
"crates/horizon-world/src/worldgen/state_provider/catalog.rs": "fa0616353f07460975ab323357ab280b7f35e7bfe2de6edc08d304316766ed26",
"crates/horizon-world/src/worldgen/simple_block.rs": "9ba1a88d5db4925f8c37366557887f776c805f9a6444781615b5dbaff52e92a4",
"crates/horizon-world/src/worldgen/spring.rs": "830849e9b89fcdf09e9b06fbefdcdebe3c8c3f82804f60b8bd5de04ba303cb62",
"crates/horizon-world/src/worldgen/state_provider/catalog.rs": "c8687e15a4887a9200c8d365857d801efaa8f90e669eee3e600a1db4905119eb",
"crates/horizon-world/src/worldgen/state_provider/noise.rs": "7ee369c2a032e5620cb9bdf9ee7adad1f70870fb0a27efb7b7c514d92f83491f",
"crates/horizon-world/src/worldgen/state_provider/properties.rs": "9909139aaca1dc4f743957257fadaa9d423d21fa401fa9abc050505f79365139",
"crates/horizon-world/src/worldgen/state_provider.rs": "9cc353d474184f4db880c4305137ec6e35a564a983f602c76af39349ecb58541",
"crates/horizon-world/src/worldgen/state_provider.rs": "be29ada818826a90afe01ab60916360fdfc4cbde5af15c9359cd56b1f1f7b156",
"crates/horizon-world/src/worldgen/tags.rs": "d35ded93fe6e95ea045cadcf4925e656dc34ef832b742179b9ad0cc49f902f31",
"crates/horizon-world/src/worldgen/terrain.rs": "7fb7130111654563f7217f7b84563adde0b11c3ebd6a499a514dc98ebef7c733",
"crates/horizon-world/src/worldgen/value_provider.rs": "3358b563db8cb0bc8a9cfbbe2b8b3e70941cd2d37a0b519fbb6545f8d0dcbb69",
"crates/horizon-world/src/worldgen/vines.rs": "ee9b79b65012bd86a838241d2ef708680f7fe8eafc8aa656dae9cf2abf3c6418",
"crates/horizon-world/src/worldgen/weighted.rs": "839840aae25302933bbd97a81a2336330e2d03a0ad1684e1e16ac769ed408e6b",
"crates/horizon-world/src/worldgen.rs": "821981c893fc84312351503f2be0c06c681d8bc768dade14576697cf047a9f8f",
"crates/horizon-world/examples/block_properties_fixture.rs": "c5438e5397136631e29858e08eb5c09ad2c82647e20bf1913d7ce9160df530a4"
"crates/horizon-world/src/worldgen.rs": "16efd52eec5e625a5fdd6d4c0591e2d5b02ab4b641f1a1c193737056842ed7c1",
"crates/horizon-world/examples/block_properties_fixture.rs": "c997c376a79a48e524524d2afff8c4103bfef8fcc75c7424b332faacc17b6097"
},
"fixtures_sha256": {
".local/rust-block-properties-parity/inputs.txt": "b4d336ea8fc168df652a71651bb48e41e5f23fc22bb451b6969c8021140cfe53",
@@ -157,20 +165,20 @@
".local/rust-block-properties-parity/cached-collision.nbt": "f3a5c6a5b2d51dad6c52e486e2b9989e79fd55db1a9bda6196db399550b04078",
".local/rust-block-properties-parity/block-properties.nbt": "1aba22092f70d16b8092014c058ddc210e4aaa77bac32f6ec62e4d0e91d92a99"
},
"rust_output_sha256": "235f4a96d29c0753c31b8f142a22383031458be5606f12539b34e6c72217deb6",
"rust_output_sha256": "57375d2d438beec6df6cd4ba199c34c52d102abcca5f624ff62f5024bcf74a96",
"references": [
{
"side": "client",
"jar_sha256": "4508d006323f24fa02876310c192d739af56516eb259000ac50f0909a68c9a2d",
"output_sha256": "235f4a96d29c0753c31b8f142a22383031458be5606f12539b34e6c72217deb6",
"matched_output_lines": 143361
"output_sha256": "57375d2d438beec6df6cd4ba199c34c52d102abcca5f624ff62f5024bcf74a96",
"matched_output_lines": 197180
},
{
"side": "server",
"jar_sha256": "a362163eec5d1612d520772bc16e5b39c09e3b234fdc045f56bf544284ee8ae6",
"output_sha256": "235f4a96d29c0753c31b8f142a22383031458be5606f12539b34e6c72217deb6",
"matched_output_lines": 143361
"output_sha256": "57375d2d438beec6df6cd4ba199c34c52d102abcca5f624ff62f5024bcf74a96",
"matched_output_lines": 197180
}
],
"scope": "All pinned block-definition force-solid, replaceability, liquid and occlusion flags and raw occlusion geometry are imported privately; Rust computes legacy solidity from cached collision shapes and solid rendering from occlusion geometry. Actual native BlockState isSolid, liquid, canOcclude, isSolidRender and no-context canBeReplaced are compared for every state, together with raw cached bounds and synthetic force-flag/cache/shape threshold combinations using the private native solidity calculator and native full-shape test. Item/fluid replacement, block support, survival, dynamic collision and full gameplay remain pending."
"scope": "All pinned block-definition force-solid, replaceability, liquid and occlusion flags and raw occlusion geometry are imported privately; Rust computes legacy solidity from cached collision shapes and solid rendering from occlusion geometry. All six native face-occlusion full-shape tests are compared for every state and every synthetic shape/occlusion-flag case; Rust caches shared shape masks and retains typed errors for unknown state IDs. Actual native BlockState isSolid, liquid, canOcclude, isSolidRender and no-context canBeReplaced are compared for every state, together with raw cached bounds and synthetic force-flag/cache/shape threshold combinations using the private native solidity calculator and native full-shape test. Item/fluid replacement, block support, survival, dynamic collision and full gameplay remain pending."
}
@@ -1,4 +1,4 @@
use horizon_core::geometry::{Aabb, Axis, ShapeOp, Vec3, VoxelShape};
use horizon_core::geometry::{Aabb, Axis, Direction, ShapeOp, Vec3, VoxelShape};
use horizon_world::{
block_properties::{BlockDefinitionProperties, BlockPropertiesRegistry, BlockProperty},
collision::CachedCollisionRegistry,
@@ -37,6 +37,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut out = io::BufWriter::new(fs::File::create(dir.join("rust.txt"))?);
let solid = properties.bind(BlockProperty::Solid);
let replaceable = properties.bind(BlockProperty::Replaceable);
let faces = properties.bind_occlusion_faces();
assert!(
faces
.is_full(BlockStateId(registry.len() as u32), Direction::Up)
.is_err()
);
for id in 0..registry.len() {
let state = BlockStateId(id as u32);
let definition = properties
@@ -66,6 +72,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
properties.property(state, BlockProperty::SolidRender)?,
properties.bind(BlockProperty::SolidRender).contains(state)
);
let mut mask = 0;
for direction in Direction::ALL {
if faces.is_full(state, direction)? {
mask |= 1 << direction as u8;
}
}
writeln!(out, "occlusion {mask}")?;
match collisions.cached_shape(state)? {
None => writeln!(out, "cache none")?,
Some(shape) => match shape.bounds() {
@@ -137,6 +150,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
properties.calculate_solid(f["cached"].as_bool().unwrap().then_some(&shape))
)?;
writeln!(out, "render {}", properties.calculate_solid_render(&shape)?)?;
writeln!(
out,
"occlusion {}",
properties.calculate_full_occlusion_faces(&shape)?
)?;
}
Ok(())
}
+61 -2
View File
@@ -8,8 +8,12 @@ use crate::{
nbt::Tag,
registry::{BlockRegistry, BlockStateId},
};
use horizon_core::geometry::{ShapeError, ShapeOp, VoxelShape};
use std::{collections::BTreeMap, io, sync::Arc};
use horizon_core::geometry::{Direction, ShapeError, ShapeOp, VoxelShape};
use std::{
collections::{BTreeMap, HashMap},
io,
sync::Arc,
};
#[derive(Clone, Copy, Debug)]
pub struct BlockDefinitionProperties {
@@ -20,6 +24,20 @@ pub struct BlockDefinitionProperties {
pub can_occlude: bool,
}
impl BlockDefinitionProperties {
pub fn calculate_full_occlusion_faces(self, occlusion: &VoxelShape) -> Result<u8, ShapeError> {
let mut mask = 0;
if self.can_occlude {
for direction in Direction::ALL {
if !occlusion
.face_shape(direction)?
.join_is_not_empty(&VoxelShape::block(), ShapeOp::XOR)?
{
mask |= 1 << direction as u8;
}
}
}
Ok(mask)
}
pub fn calculate_solid_render(self, occlusion: &VoxelShape) -> Result<bool, ShapeError> {
Ok(self.can_occlude && !occlusion.join_is_not_empty(&VoxelShape::block(), ShapeOp::XOR)?)
}
@@ -72,10 +90,25 @@ impl BoundBlockProperty {
}
}
/// Immutable FULL face-occlusion results, independent of support/collision.
#[derive(Clone, Debug)]
pub struct BoundOcclusionFaces {
states: Arc<[u8]>,
}
impl BoundOcclusionFaces {
pub fn is_full(&self, state: BlockStateId, direction: Direction) -> io::Result<bool> {
self.states
.get(state.0 as usize)
.map(|mask| mask & (1 << direction as u8) != 0)
.ok_or_else(|| invalid("unknown occlusion state ID"))
}
}
pub struct BlockPropertiesRegistry<'r> {
registry: &'r BlockRegistry,
definitions: BTreeMap<String, BlockDefinitionProperties>,
states: Arc<[u8]>,
occlusion_faces: BoundOcclusionFaces,
}
impl<'r> BlockPropertiesRegistry<'r> {
pub fn from_nbt(tag: &Tag, collisions: &CachedCollisionRegistry<'r>) -> io::Result<Self> {
@@ -123,12 +156,32 @@ impl<'r> BlockPropertiesRegistry<'r> {
registry,
)?;
let mut result = Vec::with_capacity(registry.len());
let mut faces = Vec::with_capacity(registry.len());
let mut face_cache = HashMap::new();
for id in 0..registry.len() {
let id = BlockStateId(id as u32);
let state = registry.state(id).unwrap();
let properties = definitions
.get(&state.name)
.ok_or_else(|| invalid("missing block definition properties"))?;
let shape = occlusion
.cached_shape(id)?
.ok_or_else(|| invalid("missing block occlusion shape"))?;
let mask = if properties.can_occlude {
let key = std::ptr::from_ref(shape);
if let Some(mask) = face_cache.get(&key) {
*mask
} else {
let mask = properties
.calculate_full_occlusion_faces(shape)
.map_err(|e| invalid(e.to_string()))?;
face_cache.insert(key, mask);
mask
}
} else {
0
};
faces.push(mask);
result.push(
u8::from(properties.calculate_solid(collisions.cached_shape(id)?))
| (u8::from(properties.replaceable) << 1)
@@ -148,8 +201,14 @@ impl<'r> BlockPropertiesRegistry<'r> {
registry,
definitions,
states: result.into(),
occlusion_faces: BoundOcclusionFaces {
states: faces.into(),
},
})
}
pub fn bind_occlusion_faces(&self) -> BoundOcclusionFaces {
self.occlusion_faces.clone()
}
pub fn registry(&self) -> &'r BlockRegistry {
self.registry
}
@@ -22,6 +22,7 @@ pub struct FeatureBlockBindings<'r> {
crate::block_placement::BlockPlacementBindings<'r>,
)>,
physical_properties: Option<[BoundBlockProperty; 4]>,
pub(crate) occlusion_faces: Option<crate::block_properties::BoundOcclusionFaces>,
biomes: Option<Arc<super::biome_predicate::BiomePredicateBindings>>,
fluids: super::fluid_predicate::FluidPredicateBindings,
pub(crate) codec: BlockStateJsonCodec<'r>,
@@ -67,6 +68,7 @@ impl<'r> FeatureBlockBindings<'r> {
properties.bind(BlockProperty::Liquid),
properties.bind(BlockProperty::SolidRender),
]);
self.occlusion_faces = Some(properties.bind_occlusion_faces());
Ok(self)
}
pub fn with_biomes(
@@ -134,6 +136,7 @@ impl<'r> FeatureBlockBindings<'r> {
codec,
biomes: None,
physical_properties: None,
occlusion_faces: None,
fluids: super::fluid_predicate::FluidPredicateBindings::new(registry)?,
blocks: blocks
.into_iter()
+12
View File
@@ -499,3 +499,15 @@ every origin state and every state on each candidate face, support combinations,
wrapped positions, partial failures and composed placement. Workspace tests and
all-target Clippy pass. Vine growth, block updates and complete gameplay remain
pending; this fixture uses absent dynamic block entities.
## Full-face occlusion
Block property bindings now cache six full-face occlusion results per state,
sharing calculations for identical imported shapes. These results use native
occlusion rules independently of collision or support geometry. Unknown state
IDs produce an error.
The expanded [block-property comparison](../benchmarks/rust-block-properties-2026-10-06/scoped-parity.json)
matches **197,180 lines per reference JAR**, including all 35,723 states and
18,096 synthetic shape/flag combinations. Workspace tests and all-target Clippy
pass. Lighting and renderer integration remain separate work.
@@ -4,6 +4,7 @@ import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.Direction;
import net.minecraft.nbt.*;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.*;
@@ -37,6 +38,7 @@ public final class VanillaBlockPropertiesOracle {
var p=properties.get(state.getBlock());
out.printf("state %d %s %s %s %s%n",Block.getId(state),on.getBoolean(p),off.getBoolean(p),state.canBeReplaced(),state.isSolid());
out.printf("render %s %s %s%n",state.liquid(),state.canOcclude(),state.isSolidRender());
int mask=0;for(var direction:Direction.values())if(Block.isShapeFullBlock(state.getFaceOcclusionShape(direction)))mask|=1<<direction.ordinal();out.println("occlusion "+mask);
var c=cache.get(state);var s=c==null?null:(VoxelShape)collision.get(c);
if(s==null)out.println("cache none");else if(s.isEmpty())out.println("cache empty");else {
var b=s.bounds();out.printf("cache %016x %016x %016x %016x %016x %016x%n",Double.doubleToRawLongBits(b.minX),Double.doubleToRawLongBits(b.minY),Double.doubleToRawLongBits(b.minZ),Double.doubleToRawLongBits(b.maxX),Double.doubleToRawLongBits(b.maxY),Double.doubleToRawLongBits(b.maxZ));
@@ -49,6 +51,7 @@ public final class VanillaBlockPropertiesOracle {
on.setBoolean(p,f.get("on").getAsBoolean());off.setBoolean(p,f.get("off").getAsBoolean());cache.set(state,f.get("cached").getAsBoolean()?savedCache:null);collision.set(savedCache,s);
out.println("solid "+calculate.invoke(state));
out.println("render "+Block.isShapeFullBlock(f.get("occludes").getAsBoolean()?s:Shapes.empty()));
int mask=0;if(f.get("occludes").getAsBoolean())for(var direction:Direction.values())if(Block.isShapeFullBlock(s.getFaceShape(direction)))mask|=1<<direction.ordinal();out.println("occlusion "+mask);
}
} finally {cache.set(state,savedCache);collision.set(savedCache,savedShape);on.setBoolean(p,savedOn);off.setBoolean(p,savedOff);}
}
+1 -1
View File
@@ -66,7 +66,7 @@ def main():
references.append({'side':side,'jar_sha256':lab.digest(jar,'sha256'),'output_sha256':lab.digest(reference,'sha256'),'matched_output_lines':matched})
print(f'{side}: {matched:,} block-properties output lines match Rust',flush=True)
base.ensure_sources_unchanged(sources,tested_sources);base.ensure_sources_unchanged(fixture_paths,tested_fixtures)
report={'schema':1,'minecraft':lock['minecraft']['version'],'manifest_sha1':lock['minecraft']['manifest_sha1'],'platform':platform.platform(),'java':subprocess.check_output(['java','--version'],text=True).splitlines()[0],'rustc':subprocess.check_output(['rustc','--version'],text=True).strip(),'registry_states':35723,'fixtures':len(fixtures),'sources_sha256':tested_sources,'fixtures_sha256':tested_fixtures,'rust_output_sha256':lab.digest(build/'rust.txt','sha256'),'references':references,'scope':'All pinned block-definition force-solid, replaceability, liquid and occlusion flags and raw occlusion geometry are imported privately; Rust computes legacy solidity from cached collision shapes and solid rendering from occlusion geometry. Actual native BlockState isSolid, liquid, canOcclude, isSolidRender and no-context canBeReplaced are compared for every state, together with raw cached bounds and synthetic force-flag/cache/shape threshold combinations using the private native solidity calculator and native full-shape test. Item/fluid replacement, block support, survival, dynamic collision and full gameplay remain pending.'}
report={'schema':1,'minecraft':lock['minecraft']['version'],'manifest_sha1':lock['minecraft']['manifest_sha1'],'platform':platform.platform(),'java':subprocess.check_output(['java','--version'],text=True).splitlines()[0],'rustc':subprocess.check_output(['rustc','--version'],text=True).strip(),'registry_states':35723,'fixtures':len(fixtures),'sources_sha256':tested_sources,'fixtures_sha256':tested_fixtures,'rust_output_sha256':lab.digest(build/'rust.txt','sha256'),'references':references,'scope':'All pinned block-definition force-solid, replaceability, liquid and occlusion flags and raw occlusion geometry are imported privately; Rust computes legacy solidity from cached collision shapes and solid rendering from occlusion geometry. All six native face-occlusion full-shape tests are compared for every state and every synthetic shape/occlusion-flag case; Rust caches shared shape masks and retains typed errors for unknown state IDs. Actual native BlockState isSolid, liquid, canOcclude, isSolidRender and no-context canBeReplaced are compared for every state, together with raw cached bounds and synthetic force-flag/cache/shape threshold combinations using the private native solidity calculator and native full-shape test. Item/fluid replacement, block support, survival, dynamic collision and full gameplay remain pending.'}
lab.write_json(report_path,report);print(f'Scoped block-properties parity passed: {report_path}')