mirror of https://github.com/AxioDL/zeus.git
CColor hash
This commit is contained in:
parent
92733a3bb7
commit
6c13d089fe
|
@ -331,3 +331,16 @@ inline CColor operator*(float lhs, const CColor& rhs) { return CColor(simd<float
|
||||||
|
|
||||||
inline CColor operator/(float lhs, const CColor& rhs) { return CColor(simd<float>(lhs) / rhs.mSimd).Clamp(); }
|
inline CColor operator/(float lhs, const CColor& rhs) { return CColor(simd<float>(lhs) / rhs.mSimd).Clamp(); }
|
||||||
} // namespace zeus
|
} // namespace zeus
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
template <>
|
||||||
|
struct hash<zeus::CColor> {
|
||||||
|
size_t operator()(const zeus::CColor& color) const noexcept {
|
||||||
|
size_t ret = std::hash<float>()(color.r());
|
||||||
|
zeus::hash_combine_impl(ret, std::hash<float>()(color.g()));
|
||||||
|
zeus::hash_combine_impl(ret, std::hash<float>()(color.b()));
|
||||||
|
zeus::hash_combine_impl(ret, std::hash<float>()(color.a()));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -14,6 +14,11 @@ using simd = athena::simd<T>;
|
||||||
using simd_floats = athena::simd_floats;
|
using simd_floats = athena::simd_floats;
|
||||||
using simd_doubles = athena::simd_doubles;
|
using simd_doubles = athena::simd_doubles;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template <typename SizeT>
|
||||||
|
constexpr void hash_combine_impl(SizeT& seed, SizeT value) {
|
||||||
|
seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||||
|
}
|
||||||
} // namespace zeus
|
} // namespace zeus
|
||||||
|
|
||||||
constexpr int rotr(int x, int n) { return ((x >> n) | (x << (32 - n))); }
|
constexpr int rotr(int x, int n) { return ((x >> n) | (x << (32 - n))); }
|
||||||
|
|
Loading…
Reference in New Issue