I'm trying to hash a 3d coordinate to make a unique ID for an index to a map
my approach is currently
return hash(x + hash(y + hash(z)));
Or in c++
struct ChunkHasher
{
std::size_t operator()(FLOAT3 const& vec) const
{
return std::hash<float>()(
vec.x + std::hash<float>()(
vec.y + std::hash<float>() (vec.z)
)
);
}
}chunkHasher;
but the problem is i'm getting loads of hash collisions...
just running this test, both vec(0,0,0) and vec(-1,0,0) map onto each other
I feel like this should work, hash collisions should approach happening only 2.32831e-08% of the time by my rough calculations... am I missing something?
Edit: Within an execution of my program a given input should hash into the same output whenever calculated, so having some kind of internal state to the hasher that is changed with each call is not possible