Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tested with coords x -100 to 100, y 0 to 255, z -100 to 100
- // Vec3.hashCode() has a 50:1 collision rate. (Out of 10327500 coords, had 10127195 collisions)
- // Algorithm below has a 0.0018:1 collision rate. (Out of 10327500 coords, had 18640 collisions)
- // Constants: Horizontal (x,z) and Vertical (y) ranges of values < 0
- final int H = 100;
- final int V = 0;
- // Make coords positive with different prime bases
- int xh = x + H + 31;
- int yh = y + V + 37;
- int zh = z + H + 41;
- // Not pretty, but best I've found yet
- hash = yh + ((yh * 43) * (xh+(xh * 47)) * zh) + (zh * 53);
Advertisement
Add Comment
Please, Sign In to add comment