Godot Engine – Multi-platform 2D and 3D game engine
Fix Color hash component order
fuyingdi2acda9628a65
diff --git a/core/math/color.h b/core/math/color.hindex 5b5fd495752..4b23321da95 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.cppindex 9f7a5620b84..4e4e39985a3 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);