fix: dig_rng sequential multiply-add mixing

Switch from add-then-XOR pattern to proper sequential multiply-add
avalanche. Each coordinate feeds into the next multiply, preventing
correlation between adjacent tiles when rare drops are introduced.
This commit is contained in:
2026-03-21 17:10:52 +00:00
parent 2622144cdf
commit 776d3caefc
+9 -5
View File
@@ -54,12 +54,16 @@ impl DropTable {
pub fn dig_rng(pos: IVec3) -> u32 { pub fn dig_rng(pos: IVec3) -> u32 {
let mut h = (SEED as u64) let mut h = (SEED as u64)
.wrapping_add(pos.x as u64)
.wrapping_mul(0x9e3779b97f4a7c15) .wrapping_mul(0x9e3779b97f4a7c15)
^ (pos.y as u64).wrapping_mul(0x6c62272e07bb0142) .wrapping_add(pos.x as u64)
^ (pos.z as u64).wrapping_mul(0x94d049bb133111eb); .wrapping_mul(0x6c62272e07bb0142)
let h32 = (h ^ (h >> 32)) as u32; .wrapping_add(pos.y as u64)
h32 ^ (h32 >> 16) .wrapping_mul(0x94d049bb133111eb)
.wrapping_add(pos.z as u64);
h ^= h >> 32;
h = h.wrapping_mul(0xbf58476d1ce4e5b9);
h ^= h >> 32;
h as u32
} }
#[derive(Deserialize)] #[derive(Deserialize)]