diff options
Diffstat (limited to 'source/blender/blenlib/BLI_float3.hh')
-rw-r--r-- | source/blender/blenlib/BLI_float3.hh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_float3.hh b/source/blender/blenlib/BLI_float3.hh index 0edee600ef6..a36cedad41d 100644 --- a/source/blender/blenlib/BLI_float3.hh +++ b/source/blender/blenlib/BLI_float3.hh @@ -128,6 +128,16 @@ struct float3 { return stream; } + friend bool operator==(const float3 &a, const float3 &b) + { + return a.x == b.x && a.y == b.y && a.z == b.z; + } + + friend bool operator!=(const float3 &a, const float3 &b) + { + return !(a == b); + } + float normalize_and_get_length() { return normalize_v3(*this); @@ -178,6 +188,14 @@ struct float3 { z = -z; } + uint32_t hash() const + { + uint32_t x1 = *(uint32_t *)&x; + uint32_t x2 = *(uint32_t *)&y; + uint32_t x3 = *(uint32_t *)&z; + return (x1 * 435109) ^ (x2 * 380867) ^ (x3 * 1059217); + } + static float dot(const float3 &a, const float3 &b) { return a.x * b.x + a.y * b.y + a.z * b.z; |