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:
@@ -54,12 +54,16 @@ impl DropTable {
|
||||
|
||||
pub fn dig_rng(pos: IVec3) -> u32 {
|
||||
let mut h = (SEED as u64)
|
||||
.wrapping_add(pos.x as u64)
|
||||
.wrapping_mul(0x9e3779b97f4a7c15)
|
||||
^ (pos.y as u64).wrapping_mul(0x6c62272e07bb0142)
|
||||
^ (pos.z as u64).wrapping_mul(0x94d049bb133111eb);
|
||||
let h32 = (h ^ (h >> 32)) as u32;
|
||||
h32 ^ (h32 >> 16)
|
||||
.wrapping_add(pos.x as u64)
|
||||
.wrapping_mul(0x6c62272e07bb0142)
|
||||
.wrapping_add(pos.y as u64)
|
||||
.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)]
|
||||
|
||||
Reference in New Issue
Block a user