summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-20 14:01:06 +0200
committerGitHub <noreply@github.com>2022-06-20 14:01:06 +0200
commit66a30dab35f3788ae28c7e6171d3908fe75e7b75 (patch)
treecc5045d98995b754097d1dde100f0138033fc735 /modules
parent8e3d9a23aa0a724d3dd25fcf0e8085b5a438c233 (diff)
parent141c3755814cea60888c7ee548c7ce709550b784 (diff)
Merge pull request #62176 from reduz/cleanup-hashfuncs
Diffstat (limited to 'modules')
-rw-r--r--modules/csg/csg.h6
-rw-r--r--modules/csg/csg_shape.h6
-rw-r--r--modules/gdscript/gdscript_lambda_callable.cpp6
-rw-r--r--modules/gdscript/gdscript_rpc_callable.cpp2
-rw-r--r--modules/lightmapper_rd/lightmapper_rd.h30
-rw-r--r--modules/mono/managed_callable.cpp3
-rw-r--r--modules/mono/signal_awaiter_utils.cpp4
-rw-r--r--modules/raycast/raycast_occlusion_cull.h4
8 files changed, 30 insertions, 31 deletions
diff --git a/modules/csg/csg.h b/modules/csg/csg.h
index 53a9e5d722..738e3d68ea 100644
--- a/modules/csg/csg.h
+++ b/modules/csg/csg.h
@@ -130,9 +130,9 @@ struct CSGBrushOperation {
struct VertexKeyHash {
static _FORCE_INLINE_ uint32_t hash(const VertexKey &p_vk) {
- uint32_t h = hash_djb2_one_32(p_vk.x);
- h = hash_djb2_one_32(p_vk.y, h);
- h = hash_djb2_one_32(p_vk.z, h);
+ uint32_t h = hash_murmur3_one_32(p_vk.x);
+ h = hash_murmur3_one_32(p_vk.y, h);
+ h = hash_murmur3_one_32(p_vk.z, h);
return h;
}
};
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index 0eaf5c3727..0b49dc4609 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -74,9 +74,9 @@ private:
struct Vector3Hasher {
_ALWAYS_INLINE_ uint32_t hash(const Vector3 &p_vec3) const {
- uint32_t h = hash_djb2_one_float(p_vec3.x);
- h = hash_djb2_one_float(p_vec3.y, h);
- h = hash_djb2_one_float(p_vec3.z, h);
+ uint32_t h = hash_murmur3_one_float(p_vec3.x);
+ h = hash_murmur3_one_float(p_vec3.y, h);
+ h = hash_murmur3_one_float(p_vec3.z, h);
return h;
}
};
diff --git a/modules/gdscript/gdscript_lambda_callable.cpp b/modules/gdscript/gdscript_lambda_callable.cpp
index c43fa12c8c..a25bf9a306 100644
--- a/modules/gdscript/gdscript_lambda_callable.cpp
+++ b/modules/gdscript/gdscript_lambda_callable.cpp
@@ -91,7 +91,7 @@ GDScriptLambdaCallable::GDScriptLambdaCallable(Ref<GDScript> p_script, GDScriptF
function = p_function;
captures = p_captures;
- h = (uint32_t)hash_djb2_one_64((uint64_t)this);
+ h = (uint32_t)hash_murmur3_one_64((uint64_t)this);
}
bool GDScriptLambdaSelfCallable::compare_equal(const CallableCustom *p_a, const CallableCustom *p_b) {
@@ -161,7 +161,7 @@ GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Ref<RefCounted> p_self, G
function = p_function;
captures = p_captures;
- h = (uint32_t)hash_djb2_one_64((uint64_t)this);
+ h = (uint32_t)hash_murmur3_one_64((uint64_t)this);
}
GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Object *p_self, GDScriptFunction *p_function, const Vector<Variant> &p_captures) {
@@ -169,5 +169,5 @@ GDScriptLambdaSelfCallable::GDScriptLambdaSelfCallable(Object *p_self, GDScriptF
function = p_function;
captures = p_captures;
- h = (uint32_t)hash_djb2_one_64((uint64_t)this);
+ h = (uint32_t)hash_murmur3_one_64((uint64_t)this);
}
diff --git a/modules/gdscript/gdscript_rpc_callable.cpp b/modules/gdscript/gdscript_rpc_callable.cpp
index 07ef5aefcb..63ebd8acf5 100644
--- a/modules/gdscript/gdscript_rpc_callable.cpp
+++ b/modules/gdscript/gdscript_rpc_callable.cpp
@@ -71,7 +71,7 @@ GDScriptRPCCallable::GDScriptRPCCallable(Object *p_object, const StringName &p_m
object = p_object;
method = p_method;
h = method.hash();
- h = hash_djb2_one_64(object->get_instance_id(), h);
+ h = hash_murmur3_one_64(object->get_instance_id(), h);
node = Object::cast_to<Node>(object);
ERR_FAIL_COND_MSG(!node, "RPC can only be defined on class that extends Node.");
}
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);
}
};
diff --git a/modules/mono/managed_callable.cpp b/modules/mono/managed_callable.cpp
index 4f7783b765..c159bb9eea 100644
--- a/modules/mono/managed_callable.cpp
+++ b/modules/mono/managed_callable.cpp
@@ -66,9 +66,8 @@ bool ManagedCallable::compare_less(const CallableCustom *p_a, const CallableCust
}
uint32_t ManagedCallable::hash() const {
- // hmm
uint32_t hash = delegate_invoke->get_name().hash();
- return hash_djb2_one_64(delegate_handle.handle, hash);
+ return hash_murmur3_one_64(delegate_handle.handle, hash);
}
String ManagedCallable::get_as_text() const {
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index 315a9c29f6..618e1b58e0 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -63,7 +63,7 @@ bool SignalAwaiterCallable::compare_less(const CallableCustom *p_a, const Callab
uint32_t SignalAwaiterCallable::hash() const {
uint32_t hash = signal.hash();
- return hash_djb2_one_64(target_id, hash);
+ return hash_murmur3_one_64(target_id, hash);
}
String SignalAwaiterCallable::get_as_text() const {
@@ -164,7 +164,7 @@ bool EventSignalCallable::compare_less(const CallableCustom *p_a, const Callable
uint32_t EventSignalCallable::hash() const {
uint32_t hash = event_signal->field->get_name().hash();
- return hash_djb2_one_64(owner->get_instance_id(), hash);
+ return hash_murmur3_one_64(owner->get_instance_id(), hash);
}
String EventSignalCallable::get_as_text() const {
diff --git a/modules/raycast/raycast_occlusion_cull.h b/modules/raycast/raycast_occlusion_cull.h
index 4474031991..6562c4e9c4 100644
--- a/modules/raycast/raycast_occlusion_cull.h
+++ b/modules/raycast/raycast_occlusion_cull.h
@@ -87,8 +87,8 @@ private:
RID instance;
static uint32_t hash(const InstanceID &p_ins) {
- uint32_t h = hash_djb2_one_64(p_ins.scenario.get_id());
- return hash_djb2_one_64(p_ins.instance.get_id(), h);
+ uint32_t h = hash_murmur3_one_64(p_ins.scenario.get_id());
+ return hash_fmix32(hash_murmur3_one_64(p_ins.instance.get_id(), h));
}
bool operator==(const InstanceID &rhs) const {
return instance == rhs.instance && rhs.scenario == scenario;