diff --git a/src/__comm__/_pt3_hash.scad b/src/__comm__/_pt3_hash.scad index aed42b89..f2b0b12a 100644 --- a/src/__comm__/_pt3_hash.scad +++ b/src/__comm__/_pt3_hash.scad @@ -1 +1,11 @@ -function _pt3_hash(p) = floor(abs(p * [73856093, 19349669, 83492791])); \ No newline at end of file +function _pt3_hash(p) = + let( + x = p.x >= 0 ? 2 * p.x : -2 * p.x - 1, + y = p.y >= 0 ? 2 * p.y : -2 * p.y - 1, + z = p.z >= 0 ? 2 * p.z : -2 * p.z - 1, + mx = max(x, y, z), + hash = mx ^ 3 + (2 * mx * z) + z + ) + mx == z ? hash + max(x, y) ^ 2 : + y >= x ? hash + x + y : + hash + y; \ No newline at end of file