Merge pull request #71103 from AThousandShips/array_find_fix_3_x

[3.x] Fix for comparisons with PoolArrays
This commit is contained in:
Rémi Verschelde 2023-01-09 14:19:18 +01:00
commit 111de09c03
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -2738,28 +2738,28 @@ uint32_t Variant::hash() const {
} }
#define hash_compare_scalar(p_lhs, p_rhs) \ #define hash_compare_scalar(p_lhs, p_rhs) \
((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)) (((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)))
#define hash_compare_vector2(p_lhs, p_rhs) \ #define hash_compare_vector2(p_lhs, p_rhs) \
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ (hash_compare_scalar((p_lhs).x, (p_rhs).x) && \
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) hash_compare_scalar((p_lhs).y, (p_rhs).y))
#define hash_compare_vector3(p_lhs, p_rhs) \ #define hash_compare_vector3(p_lhs, p_rhs) \
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ (hash_compare_scalar((p_lhs).x, (p_rhs).x) && \
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \ hash_compare_scalar((p_lhs).y, (p_rhs).y) && \
(hash_compare_scalar((p_lhs).z, (p_rhs).z)) hash_compare_scalar((p_lhs).z, (p_rhs).z))
#define hash_compare_quat(p_lhs, p_rhs) \ #define hash_compare_quat(p_lhs, p_rhs) \
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ (hash_compare_scalar((p_lhs).x, (p_rhs).x) && \
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \ hash_compare_scalar((p_lhs).y, (p_rhs).y) && \
(hash_compare_scalar((p_lhs).z, (p_rhs).z)) && \ hash_compare_scalar((p_lhs).z, (p_rhs).z) && \
(hash_compare_scalar((p_lhs).w, (p_rhs).w)) hash_compare_scalar((p_lhs).w, (p_rhs).w))
#define hash_compare_color(p_lhs, p_rhs) \ #define hash_compare_color(p_lhs, p_rhs) \
(hash_compare_scalar((p_lhs).r, (p_rhs).r)) && \ (hash_compare_scalar((p_lhs).r, (p_rhs).r) && \
(hash_compare_scalar((p_lhs).g, (p_rhs).g)) && \ hash_compare_scalar((p_lhs).g, (p_rhs).g) && \
(hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \ hash_compare_scalar((p_lhs).b, (p_rhs).b) && \
(hash_compare_scalar((p_lhs).a, (p_rhs).a)) hash_compare_scalar((p_lhs).a, (p_rhs).a))
#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \ #define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \
const PoolVector<p_type> &l = *reinterpret_cast<const PoolVector<p_type> *>(p_lhs); \ const PoolVector<p_type> &l = *reinterpret_cast<const PoolVector<p_type> *>(p_lhs); \
@ -2807,8 +2807,8 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Rect2 *l = reinterpret_cast<const Rect2 *>(_data._mem); const Rect2 *l = reinterpret_cast<const Rect2 *>(_data._mem);
const Rect2 *r = reinterpret_cast<const Rect2 *>(p_variant._data._mem); const Rect2 *r = reinterpret_cast<const Rect2 *>(p_variant._data._mem);
return (hash_compare_vector2(l->position, r->position)) && return hash_compare_vector2(l->position, r->position) &&
(hash_compare_vector2(l->size, r->size)); hash_compare_vector2(l->size, r->size);
} break; } break;
case TRANSFORM2D: { case TRANSFORM2D: {
@ -2816,7 +2816,7 @@ bool Variant::hash_compare(const Variant &p_variant) const {
Transform2D *r = p_variant._data._transform2d; Transform2D *r = p_variant._data._transform2d;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (!(hash_compare_vector2(l->elements[i], r->elements[i]))) { if (!hash_compare_vector2(l->elements[i], r->elements[i])) {
return false; return false;
} }
} }
@ -2835,16 +2835,16 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Plane *l = reinterpret_cast<const Plane *>(_data._mem); const Plane *l = reinterpret_cast<const Plane *>(_data._mem);
const Plane *r = reinterpret_cast<const Plane *>(p_variant._data._mem); const Plane *r = reinterpret_cast<const Plane *>(p_variant._data._mem);
return (hash_compare_vector3(l->normal, r->normal)) && return hash_compare_vector3(l->normal, r->normal) &&
(hash_compare_scalar(l->d, r->d)); hash_compare_scalar(l->d, r->d);
} break; } break;
case AABB: { case AABB: {
const ::AABB *l = _data._aabb; const ::AABB *l = _data._aabb;
const ::AABB *r = p_variant._data._aabb; const ::AABB *r = p_variant._data._aabb;
return (hash_compare_vector3(l->position, r->position) && return hash_compare_vector3(l->position, r->position) &&
(hash_compare_vector3(l->size, r->size))); hash_compare_vector3(l->size, r->size);
} break; } break;
@ -2860,7 +2860,7 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Basis *r = p_variant._data._basis; const Basis *r = p_variant._data._basis;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (!(hash_compare_vector3(l->elements[i], r->elements[i]))) { if (!hash_compare_vector3(l->elements[i], r->elements[i])) {
return false; return false;
} }
} }
@ -2873,7 +2873,7 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Transform *r = p_variant._data._transform; const Transform *r = p_variant._data._transform;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i]))) { if (!hash_compare_vector3(l->basis.elements[i], r->basis.elements[i])) {
return false; return false;
} }
} }