mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Re-apply clang-format to all files
Some badly formatted code has managed to pass through our CI...
This commit is contained in:
139
core/variant.cpp
139
core/variant.cpp
@@ -2840,74 +2840,74 @@ uint32_t Variant::hash() const {
|
||||
#define hash_compare_scalar(p_lhs, 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).y, (p_rhs).y))
|
||||
(hash_compare_scalar((p_lhs).y, (p_rhs).y))
|
||||
|
||||
#define hash_compare_vector3(p_lhs, p_rhs)\
|
||||
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
|
||||
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \
|
||||
(hash_compare_scalar((p_lhs).z, (p_rhs).z))
|
||||
#define hash_compare_vector3(p_lhs, p_rhs) \
|
||||
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
|
||||
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \
|
||||
(hash_compare_scalar((p_lhs).z, (p_rhs).z))
|
||||
|
||||
#define hash_compare_quat(p_lhs, p_rhs)\
|
||||
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
|
||||
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \
|
||||
(hash_compare_scalar((p_lhs).z, (p_rhs).z)) && \
|
||||
(hash_compare_scalar((p_lhs).w, (p_rhs).w))
|
||||
#define hash_compare_quat(p_lhs, p_rhs) \
|
||||
(hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
|
||||
(hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \
|
||||
(hash_compare_scalar((p_lhs).z, (p_rhs).z)) && \
|
||||
(hash_compare_scalar((p_lhs).w, (p_rhs).w))
|
||||
|
||||
#define hash_compare_color(p_lhs, p_rhs)\
|
||||
(hash_compare_scalar((p_lhs).r, (p_rhs).r)) && \
|
||||
(hash_compare_scalar((p_lhs).g, (p_rhs).g)) && \
|
||||
(hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \
|
||||
(hash_compare_scalar((p_lhs).a, (p_rhs).a))
|
||||
#define hash_compare_color(p_lhs, p_rhs) \
|
||||
(hash_compare_scalar((p_lhs).r, (p_rhs).r)) && \
|
||||
(hash_compare_scalar((p_lhs).g, (p_rhs).g)) && \
|
||||
(hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \
|
||||
(hash_compare_scalar((p_lhs).a, (p_rhs).a))
|
||||
|
||||
#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func)\
|
||||
const DVector<p_type>& l = *reinterpret_cast<const DVector<p_type>*>(p_lhs);\
|
||||
const DVector<p_type>& r = *reinterpret_cast<const DVector<p_type>*>(p_rhs);\
|
||||
\
|
||||
if(l.size() != r.size()) \
|
||||
return false; \
|
||||
\
|
||||
DVector<p_type>::Read lr = l.read(); \
|
||||
DVector<p_type>::Read rr = r.read(); \
|
||||
\
|
||||
for(int i = 0; i < l.size(); ++i) { \
|
||||
if(! p_compare_func((lr[0]), (rr[0]))) \
|
||||
return false; \
|
||||
}\
|
||||
\
|
||||
return true
|
||||
#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \
|
||||
const DVector<p_type> &l = *reinterpret_cast<const DVector<p_type> *>(p_lhs); \
|
||||
const DVector<p_type> &r = *reinterpret_cast<const DVector<p_type> *>(p_rhs); \
|
||||
\
|
||||
if (l.size() != r.size()) \
|
||||
return false; \
|
||||
\
|
||||
DVector<p_type>::Read lr = l.read(); \
|
||||
DVector<p_type>::Read rr = r.read(); \
|
||||
\
|
||||
for (int i = 0; i < l.size(); ++i) { \
|
||||
if (!p_compare_func((lr[0]), (rr[0]))) \
|
||||
return false; \
|
||||
} \
|
||||
\
|
||||
return true
|
||||
|
||||
bool Variant::hash_compare(const Variant& p_variant) const {
|
||||
bool Variant::hash_compare(const Variant &p_variant) const {
|
||||
if (type != p_variant.type)
|
||||
return false;
|
||||
|
||||
switch( type ) {
|
||||
switch (type) {
|
||||
case REAL: {
|
||||
return hash_compare_scalar(_data._real, p_variant._data._real);
|
||||
} break;
|
||||
|
||||
case VECTOR2: {
|
||||
const Vector2* l = reinterpret_cast<const Vector2*>(_data._mem);
|
||||
const Vector2* r = reinterpret_cast<const Vector2*>(p_variant._data._mem);
|
||||
const Vector2 *l = reinterpret_cast<const Vector2 *>(_data._mem);
|
||||
const Vector2 *r = reinterpret_cast<const Vector2 *>(p_variant._data._mem);
|
||||
|
||||
return hash_compare_vector2(*l, *r);
|
||||
} break;
|
||||
|
||||
case RECT2: {
|
||||
const Rect2* l = reinterpret_cast<const Rect2*>(_data._mem);
|
||||
const Rect2* r = reinterpret_cast<const Rect2*>(p_variant._data._mem);
|
||||
const Rect2 *l = reinterpret_cast<const Rect2 *>(_data._mem);
|
||||
const Rect2 *r = reinterpret_cast<const Rect2 *>(p_variant._data._mem);
|
||||
|
||||
return (hash_compare_vector2(l->pos, r->pos)) &&
|
||||
(hash_compare_vector2(l->size, r->size));
|
||||
(hash_compare_vector2(l->size, r->size));
|
||||
} break;
|
||||
|
||||
case MATRIX32: {
|
||||
Matrix32* l = _data._matrix32;
|
||||
Matrix32* r = p_variant._data._matrix32;
|
||||
Matrix32 *l = _data._matrix32;
|
||||
Matrix32 *r = p_variant._data._matrix32;
|
||||
|
||||
for(int i=0;i<3;i++) {
|
||||
if (! (hash_compare_vector2(l->elements[i], r->elements[i])))
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!(hash_compare_vector2(l->elements[i], r->elements[i])))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2915,23 +2915,23 @@ bool Variant::hash_compare(const Variant& p_variant) const {
|
||||
} break;
|
||||
|
||||
case VECTOR3: {
|
||||
const Vector3* l = reinterpret_cast<const Vector3*>(_data._mem);
|
||||
const Vector3* r = reinterpret_cast<const Vector3*>(p_variant._data._mem);
|
||||
const Vector3 *l = reinterpret_cast<const Vector3 *>(_data._mem);
|
||||
const Vector3 *r = reinterpret_cast<const Vector3 *>(p_variant._data._mem);
|
||||
|
||||
return hash_compare_vector3(*l, *r);
|
||||
} break;
|
||||
|
||||
case PLANE: {
|
||||
const Plane* l = reinterpret_cast<const Plane*>(_data._mem);
|
||||
const Plane* r = reinterpret_cast<const Plane*>(p_variant._data._mem);
|
||||
const Plane *l = reinterpret_cast<const Plane *>(_data._mem);
|
||||
const Plane *r = reinterpret_cast<const Plane *>(p_variant._data._mem);
|
||||
|
||||
return (hash_compare_vector3(l->normal, r->normal)) &&
|
||||
(hash_compare_scalar(l->d, r->d));
|
||||
(hash_compare_scalar(l->d, r->d));
|
||||
} break;
|
||||
|
||||
case _AABB: {
|
||||
const AABB* l = _data._aabb;
|
||||
const AABB* r = p_variant._data._aabb;
|
||||
const AABB *l = _data._aabb;
|
||||
const AABB *r = p_variant._data._aabb;
|
||||
|
||||
return (hash_compare_vector3(l->pos, r->pos) &&
|
||||
(hash_compare_vector3(l->size, r->size)));
|
||||
@@ -2939,18 +2939,18 @@ bool Variant::hash_compare(const Variant& p_variant) const {
|
||||
} break;
|
||||
|
||||
case QUAT: {
|
||||
const Quat* l = reinterpret_cast<const Quat*>(_data._mem);
|
||||
const Quat* r = reinterpret_cast<const Quat*>(p_variant._data._mem);
|
||||
const Quat *l = reinterpret_cast<const Quat *>(_data._mem);
|
||||
const Quat *r = reinterpret_cast<const Quat *>(p_variant._data._mem);
|
||||
|
||||
return hash_compare_quat(*l, *r);
|
||||
} break;
|
||||
|
||||
case MATRIX3: {
|
||||
const Matrix3* l = _data._matrix3;
|
||||
const Matrix3* r = p_variant._data._matrix3;
|
||||
const Matrix3 *l = _data._matrix3;
|
||||
const Matrix3 *r = p_variant._data._matrix3;
|
||||
|
||||
for(int i=0;i<3;i++) {
|
||||
if (! (hash_compare_vector3(l->elements[i], r->elements[i])))
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!(hash_compare_vector3(l->elements[i], r->elements[i])))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2958,11 +2958,11 @@ bool Variant::hash_compare(const Variant& p_variant) const {
|
||||
} break;
|
||||
|
||||
case TRANSFORM: {
|
||||
const Transform* l = _data._transform;
|
||||
const Transform* r = p_variant._data._transform;
|
||||
const Transform *l = _data._transform;
|
||||
const Transform *r = p_variant._data._transform;
|
||||
|
||||
for(int i=0;i<3;i++) {
|
||||
if (! (hash_compare_vector3(l->basis.elements[i], r->basis.elements[i])))
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i])))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2970,21 +2970,21 @@ bool Variant::hash_compare(const Variant& p_variant) const {
|
||||
} break;
|
||||
|
||||
case COLOR: {
|
||||
const Color* l = reinterpret_cast<const Color*>(_data._mem);
|
||||
const Color* r = reinterpret_cast<const Color*>(p_variant._data._mem);
|
||||
const Color *l = reinterpret_cast<const Color *>(_data._mem);
|
||||
const Color *r = reinterpret_cast<const Color *>(p_variant._data._mem);
|
||||
|
||||
return hash_compare_color(*l, *r);
|
||||
} break;
|
||||
|
||||
case ARRAY: {
|
||||
const Array& l = *(reinterpret_cast<const Array*>(_data._mem));
|
||||
const Array& r = *(reinterpret_cast<const Array*>(p_variant._data._mem));
|
||||
const Array &l = *(reinterpret_cast<const Array *>(_data._mem));
|
||||
const Array &r = *(reinterpret_cast<const Array *>(p_variant._data._mem));
|
||||
|
||||
if(l.size() != r.size())
|
||||
if (l.size() != r.size())
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < l.size(); ++i) {
|
||||
if(! l[0].hash_compare(r[0]))
|
||||
for (int i = 0; i < l.size(); ++i) {
|
||||
if (!l[0].hash_compare(r[0]))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3010,14 +3010,13 @@ bool Variant::hash_compare(const Variant& p_variant) const {
|
||||
default:
|
||||
bool v;
|
||||
Variant r;
|
||||
evaluate(OP_EQUAL,*this,p_variant,r,v);
|
||||
evaluate(OP_EQUAL, *this, p_variant, r, v);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Variant::is_ref() const {
|
||||
|
||||
return type == OBJECT && !_get_obj().ref.is_null();
|
||||
|
||||
Reference in New Issue
Block a user