Fix Color hash component order
(cherry picked from commit 2acda9628a653a0f43ebf585cfde55455422e294)
This commit is contained in:
1 parent
04988f125f
commit
1644b09d96
2 files changed
+8
-1
No files matched your search
+1
-1
@@ -242,7 +242,7 @@ struct [[nodiscard]] Color {
|
||||
|
||||
uint32_t hash() const {
|
||||
uint32_t h = hash_murmur3_one_float(r);
|
||||
h = hash_murmur3_one_float(r, h);
|
||||
h = hash_murmur3_one_float(g, h);
|
||||
h = hash_murmur3_one_float(b, h);
|
||||
h = hash_murmur3_one_float(a, h);
|
||||
return hash_fmix32(h);
|
||||
|
||||
@@ -96,6 +96,13 @@ TEST_CASE("[Color] Operators") {
|
||||
"Color negation should behave as expected (affecting the alpha channel, unlike `invert()`).");
|
||||
}
|
||||
|
||||
TEST_CASE("[Color] Hash") {
|
||||
const Color red = Color(1, 0, 0, 1);
|
||||
const Color yellow = Color(1, 1, 0, 1);
|
||||
|
||||
CHECK(red.hash() != yellow.hash());
|
||||
}
|
||||
|
||||
TEST_CASE("[Color] Reading methods") {
|
||||
constexpr Color dark_blue = Color(0, 0, 0.5, 0.4);
|
||||
|
||||
|
||||
Reference in new issue
Block a user