diff --git a/core/math/color.h b/core/math/color.h index 5b5fd49575..4b23321da9 100644 --- a/core/math/color.h +++ b/core/math/color.h @@ -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); diff --git a/tests/core/math/test_color.cpp b/tests/core/math/test_color.cpp index 9f7a5620b8..4e4e39985a 100644 --- a/tests/core/math/test_color.cpp +++ b/tests/core/math/test_color.cpp @@ -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);