diff --git a/include/zeus/CColor.hpp b/include/zeus/CColor.hpp index 73bde95..e5aece4 100644 --- a/include/zeus/CColor.hpp +++ b/include/zeus/CColor.hpp @@ -331,3 +331,16 @@ inline CColor operator*(float lhs, const CColor& rhs) { return CColor(simd(lhs) / rhs.mSimd).Clamp(); } } // namespace zeus + +namespace std { +template <> +struct hash { + size_t operator()(const zeus::CColor& color) const noexcept { + size_t ret = std::hash()(color.r()); + zeus::hash_combine_impl(ret, std::hash()(color.g())); + zeus::hash_combine_impl(ret, std::hash()(color.b())); + zeus::hash_combine_impl(ret, std::hash()(color.a())); + return ret; + } +}; +} \ No newline at end of file diff --git a/include/zeus/Global.hpp b/include/zeus/Global.hpp index 5eb25d6..303b33f 100644 --- a/include/zeus/Global.hpp +++ b/include/zeus/Global.hpp @@ -14,6 +14,11 @@ using simd = athena::simd; using simd_floats = athena::simd_floats; using simd_doubles = athena::simd_doubles; #endif + +template +constexpr void hash_combine_impl(SizeT& seed, SizeT value) { + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); +} } // namespace zeus constexpr int rotr(int x, int n) { return ((x >> n) | (x << (32 - n))); }