From 1644b09d966622d324fab8a588974d30264f56ae Mon Sep 17 00:00:00 2001 From: fuyingdi Date: Sat, 11 Jul 2026 23:36:38 +0800 Subject: [PATCH] Fix Color hash component order (cherry picked from commit 2acda9628a653a0f43ebf585cfde55455422e294) --- core/math/color.h | 2 +- tests/core/math/test_color.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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);