Files
VoxelEngine/World/WorldGen/WormHash.cs

22 lines
601 B
C#

namespace VoxelEngine.World.WorldGen;
// Deterministic 32-bit mixing hash for worm-cell coordinates.
// Cell coords can be negative; cast through unchecked to preserve bit pattern.
internal static class WormHash
{
public static uint Hash(int cellX, int cellY, int cellZ, int seed)
{
unchecked
{
uint h = (uint)seed;
h ^= (uint)cellX * 73856093u;
h ^= (uint)cellY * 19349663u;
h ^= (uint)cellZ * 83492791u;
h ^= h >> 13;
h *= 0x5bd1e995u;
h ^= h >> 15;
return h;
}
}
}