[Bf-blender-cvs] [f62204718bf] master: BLI: initial hash function for Color4b and float4x4
Jacques Lucke
noreply at git.blender.org
Fri Jul 10 12:58:23 CEST 2020
Commit: f62204718bf8efc1661fd61cf85d24bc8268f763
Author: Jacques Lucke
Date: Fri Jul 10 12:53:50 2020 +0200
Branches: master
https://developer.blender.org/rBf62204718bf8efc1661fd61cf85d24bc8268f763
BLI: initial hash function for Color4b and float4x4
===================================================================
M source/blender/blenlib/BLI_color.hh
M source/blender/blenlib/BLI_float4x4.hh
===================================================================
diff --git a/source/blender/blenlib/BLI_color.hh b/source/blender/blenlib/BLI_color.hh
index 1215affe837..265013c0013 100644
--- a/source/blender/blenlib/BLI_color.hh
+++ b/source/blender/blenlib/BLI_color.hh
@@ -118,6 +118,12 @@ struct Color4b {
{
return !(a == b);
}
+
+ uint32_t hash() const
+ {
+ return ((uint32_t)r * 1283591) ^ ((uint32_t)g * 850177) ^ ((uint32_t)b * 735391) ^
+ ((uint32_t)a * 442319);
+ }
};
} // namespace blender
diff --git a/source/blender/blenlib/BLI_float4x4.hh b/source/blender/blenlib/BLI_float4x4.hh
index 1e9bd12b12b..ef83f9ffc19 100644
--- a/source/blender/blenlib/BLI_float4x4.hh
+++ b/source/blender/blenlib/BLI_float4x4.hh
@@ -108,6 +108,16 @@ struct float4x4 {
interp_m4_m4m4(result, a.values, b.values, t);
return result;
}
+
+ uint32_t hash() const
+ {
+ uint32_t h = 435109;
+ for (uint i = 0; i < 16; i++) {
+ float value = ((const float *)this)[i];
+ h = h * 33 + (*(uint32_t *)&value);
+ }
+ return h;
+ }
};
} // namespace blender
More information about the Bf-blender-cvs
mailing list