From 141c3755814cea60888c7ee548c7ce709550b784 Mon Sep 17 00:00:00 2001 From: reduz Date: Sat, 18 Jun 2022 16:20:55 +0200 Subject: Clean up Hash Functions Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934 * Clean up usage of murmur3 * Fixed usages of binary murmur3 on floats (this is invalid) * Changed DJB2 to use xor (which seems to be better) --- modules/lightmapper_rd/lightmapper_rd.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'modules/lightmapper_rd') diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h index 503f5f7009..bf9f9b5954 100644 --- a/modules/lightmapper_rd/lightmapper_rd.h +++ b/modules/lightmapper_rd/lightmapper_rd.h @@ -110,12 +110,12 @@ class LightmapperRD : public Lightmapper { struct EdgeHash { _FORCE_INLINE_ static uint32_t hash(const Edge &p_edge) { - uint32_t h = hash_djb2_one_float(p_edge.a.x); - h = hash_djb2_one_float(p_edge.a.y, h); - h = hash_djb2_one_float(p_edge.a.z, h); - h = hash_djb2_one_float(p_edge.b.x, h); - h = hash_djb2_one_float(p_edge.b.y, h); - h = hash_djb2_one_float(p_edge.b.z, h); + uint32_t h = hash_murmur3_one_float(p_edge.a.x); + h = hash_murmur3_one_float(p_edge.a.y, h); + h = hash_murmur3_one_float(p_edge.a.z, h); + h = hash_murmur3_one_float(p_edge.b.x, h); + h = hash_murmur3_one_float(p_edge.b.y, h); + h = hash_murmur3_one_float(p_edge.b.z, h); return h; } }; @@ -146,15 +146,15 @@ class LightmapperRD : public Lightmapper { struct VertexHash { _FORCE_INLINE_ static uint32_t hash(const Vertex &p_vtx) { - uint32_t h = hash_djb2_one_float(p_vtx.position[0]); - h = hash_djb2_one_float(p_vtx.position[1], h); - h = hash_djb2_one_float(p_vtx.position[2], h); - h = hash_djb2_one_float(p_vtx.uv[0], h); - h = hash_djb2_one_float(p_vtx.uv[1], h); - h = hash_djb2_one_float(p_vtx.normal_xy[0], h); - h = hash_djb2_one_float(p_vtx.normal_xy[1], h); - h = hash_djb2_one_float(p_vtx.normal_z, h); - return h; + uint32_t h = hash_murmur3_one_float(p_vtx.position[0]); + h = hash_murmur3_one_float(p_vtx.position[1], h); + h = hash_murmur3_one_float(p_vtx.position[2], h); + h = hash_murmur3_one_float(p_vtx.uv[0], h); + h = hash_murmur3_one_float(p_vtx.uv[1], h); + h = hash_murmur3_one_float(p_vtx.normal_xy[0], h); + h = hash_murmur3_one_float(p_vtx.normal_xy[1], h); + h = hash_murmur3_one_float(p_vtx.normal_z, h); + return hash_fmix32(h); } }; -- cgit v1.2.3