From 65d8cfd82d790cfc902ab01686b3cb804e56cc4c Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 8 Jun 2023 17:42:36 -0400 Subject: [PATCH] BLI: Add hash function to quaternion type Just reuse the 4D vector hash. This allows creating a CPPType for math::Quaternion. --- source/blender/blenlib/BLI_math_quaternion_types.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/blenlib/BLI_math_quaternion_types.hh b/source/blender/blenlib/BLI_math_quaternion_types.hh index 685303330ed..c5ace7fc196 100644 --- a/source/blender/blenlib/BLI_math_quaternion_types.hh +++ b/source/blender/blenlib/BLI_math_quaternion_types.hh @@ -162,6 +162,11 @@ template struct QuaternionBase { return (a.w == b.w) && (a.x == b.x) && (a.y == b.y) && (a.z == b.z); } + uint64_t hash() const + { + return VecBase(*this).hash(); + } + friend std::ostream &operator<<(std::ostream &stream, const QuaternionBase &rot) { return stream << "Quaternion" << static_cast>(rot);