3232#define HASHFUNCS_H
3333
3434#include " core/math/aabb.h"
35+ #include " core/math/basis.h"
36+ #include " core/math/color.h"
3537#include " core/math/math_defs.h"
3638#include " core/math/math_funcs.h"
39+ #include " core/math/plane.h"
40+ #include " core/math/projection.h"
41+ #include " core/math/quaternion.h"
3742#include " core/math/rect2.h"
3843#include " core/math/rect2i.h"
44+ #include " core/math/transform_2d.h"
45+ #include " core/math/transform_3d.h"
3946#include " core/math/vector2.h"
4047#include " core/math/vector2i.h"
4148#include " core/math/vector3.h"
@@ -413,6 +420,13 @@ struct HashMapComparatorDefault<double> {
413420 }
414421};
415422
423+ template <>
424+ struct HashMapComparatorDefault <Color> {
425+ static bool compare (const Color &p_lhs, const Color &p_rhs) {
426+ return ((p_lhs.r == p_rhs.r ) || (Math::is_nan (p_lhs.r ) && Math::is_nan (p_rhs.r ))) && ((p_lhs.g == p_rhs.g ) || (Math::is_nan (p_lhs.g ) && Math::is_nan (p_rhs.g ))) && ((p_lhs.b == p_rhs.b ) || (Math::is_nan (p_lhs.b ) && Math::is_nan (p_rhs.b ))) && ((p_lhs.a == p_rhs.a ) || (Math::is_nan (p_lhs.a ) && Math::is_nan (p_rhs.a )));
427+ }
428+ };
429+
416430template <>
417431struct HashMapComparatorDefault <Vector2> {
418432 static bool compare (const Vector2 &p_lhs, const Vector2 &p_rhs) {
@@ -427,6 +441,87 @@ struct HashMapComparatorDefault<Vector3> {
427441 }
428442};
429443
444+ template <>
445+ struct HashMapComparatorDefault <Vector4> {
446+ static bool compare (const Vector4 &p_lhs, const Vector4 &p_rhs) {
447+ return ((p_lhs.x == p_rhs.x ) || (Math::is_nan (p_lhs.x ) && Math::is_nan (p_rhs.x ))) && ((p_lhs.y == p_rhs.y ) || (Math::is_nan (p_lhs.y ) && Math::is_nan (p_rhs.y ))) && ((p_lhs.z == p_rhs.z ) || (Math::is_nan (p_lhs.z ) && Math::is_nan (p_rhs.z ))) && ((p_lhs.w == p_rhs.w ) || (Math::is_nan (p_lhs.w ) && Math::is_nan (p_rhs.w )));
448+ }
449+ };
450+
451+ template <>
452+ struct HashMapComparatorDefault <Rect2> {
453+ static bool compare (const Rect2 &p_lhs, const Rect2 &p_rhs) {
454+ return HashMapComparatorDefault<Vector2>().compare (p_lhs.position , p_rhs.position ) && HashMapComparatorDefault<Vector2>().compare (p_lhs.size , p_rhs.size );
455+ }
456+ };
457+
458+ template <>
459+ struct HashMapComparatorDefault <AABB> {
460+ static bool compare (const AABB &p_lhs, const AABB &p_rhs) {
461+ return HashMapComparatorDefault<Vector3>().compare (p_lhs.position , p_rhs.position ) && HashMapComparatorDefault<Vector3>().compare (p_lhs.size , p_rhs.size );
462+ }
463+ };
464+
465+ template <>
466+ struct HashMapComparatorDefault <Plane> {
467+ static bool compare (const Plane &p_lhs, const Plane &p_rhs) {
468+ return HashMapComparatorDefault<Vector3>().compare (p_lhs.normal , p_rhs.normal ) && ((p_lhs.d == p_rhs.d ) || (Math::is_nan (p_lhs.d ) && Math::is_nan (p_rhs.d )));
469+ }
470+ };
471+
472+ template <>
473+ struct HashMapComparatorDefault <Transform2D> {
474+ static bool compare (const Transform2D &p_lhs, const Transform2D &p_rhs) {
475+ for (int i = 0 ; i < 3 ; ++i) {
476+ if (!HashMapComparatorDefault<Vector2>().compare (p_lhs.columns [i], p_rhs.columns [i])) {
477+ return false ;
478+ }
479+ }
480+
481+ return true ;
482+ }
483+ };
484+
485+ template <>
486+ struct HashMapComparatorDefault <Basis> {
487+ static bool compare (const Basis &p_lhs, const Basis &p_rhs) {
488+ for (int i = 0 ; i < 3 ; ++i) {
489+ if (!HashMapComparatorDefault<Vector3>().compare (p_lhs.rows [i], p_rhs.rows [i])) {
490+ return false ;
491+ }
492+ }
493+
494+ return true ;
495+ }
496+ };
497+
498+ template <>
499+ struct HashMapComparatorDefault <Transform3D> {
500+ static bool compare (const Transform3D &p_lhs, const Transform3D &p_rhs) {
501+ return HashMapComparatorDefault<Basis>().compare (p_lhs.basis , p_rhs.basis ) && HashMapComparatorDefault<Vector3>().compare (p_lhs.origin , p_rhs.origin );
502+ }
503+ };
504+
505+ template <>
506+ struct HashMapComparatorDefault <Projection> {
507+ static bool compare (const Projection &p_lhs, const Projection &p_rhs) {
508+ for (int i = 0 ; i < 4 ; ++i) {
509+ if (!HashMapComparatorDefault<Vector4>().compare (p_lhs.columns [i], p_rhs.columns [i])) {
510+ return false ;
511+ }
512+ }
513+
514+ return true ;
515+ }
516+ };
517+
518+ template <>
519+ struct HashMapComparatorDefault <Quaternion> {
520+ static bool compare (const Quaternion &p_lhs, const Quaternion &p_rhs) {
521+ return ((p_lhs.x == p_rhs.x ) || (Math::is_nan (p_lhs.x ) && Math::is_nan (p_rhs.x ))) && ((p_lhs.y == p_rhs.y ) || (Math::is_nan (p_lhs.y ) && Math::is_nan (p_rhs.y ))) && ((p_lhs.z == p_rhs.z ) || (Math::is_nan (p_lhs.z ) && Math::is_nan (p_rhs.z ))) && ((p_lhs.w == p_rhs.w ) || (Math::is_nan (p_lhs.w ) && Math::is_nan (p_rhs.w )));
522+ }
523+ };
524+
430525constexpr uint32_t HASH_TABLE_SIZE_MAX = 29 ;
431526
432527inline constexpr uint32_t hash_table_size_primes[HASH_TABLE_SIZE_MAX] = {
0 commit comments