mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Rewrite HashMapHasherDefault based on type traits - it is now possible to declare a default hashing function for any type.
Remove cross-project includes from `hashfuncs.h`. Improve hashing function for `Color` (based on values instead of `String`). Move `Variant` comparison from `hash_map.h` to `dictionary.cpp` (`VariantComparatorDictionary`), where it's used. Remove now unnecessary `HashableHasher`.
This commit is contained in:
parent
06827c91c6
commit
ad600125df
29 changed files with 253 additions and 222 deletions
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/templates/hashfuncs.h"
|
||||
#include "core/typedefs.h"
|
||||
|
||||
class String;
|
||||
|
|
@ -146,6 +147,14 @@ struct [[nodiscard]] Vector4 {
|
|||
explicit operator String() const;
|
||||
operator Vector4i() const;
|
||||
|
||||
uint32_t hash() const {
|
||||
uint32_t h = hash_murmur3_one_real(x);
|
||||
h = hash_murmur3_one_real(y, h);
|
||||
h = hash_murmur3_one_real(z, h);
|
||||
h = hash_murmur3_one_real(w, h);
|
||||
return hash_fmix32(h);
|
||||
}
|
||||
|
||||
constexpr Vector4() :
|
||||
x(0), y(0), z(0), w(0) {}
|
||||
constexpr Vector4(real_t p_x, real_t p_y, real_t p_z, real_t p_w) :
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue