From f62204718bf8efc1661fd61cf85d24bc8268f763 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 10 Jul 2020 12:53:50 +0200 Subject: BLI: initial hash function for Color4b and float4x4 --- source/blender/blenlib/BLI_float4x4.hh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/blenlib/BLI_float4x4.hh') 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 -- cgit v1.2.3