diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/math/basis.cpp | 7 | ||||
-rw-r--r-- | core/variant/array.cpp | 4 | ||||
-rw-r--r-- | core/variant/array.h | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/core/math/basis.cpp b/core/math/basis.cpp index 234a4ddb79..95a4187062 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -239,13 +239,18 @@ void Basis::scale_orthogonal(const Vector3 &p_scale) { Basis Basis::scaled_orthogonal(const Vector3 &p_scale) const { Basis m = *this; Vector3 s = Vector3(-1, -1, -1) + p_scale; + bool sign = signbit(s.x + s.y + s.z); + Basis b = m.orthonormalized(); + s = b.xform_inv(s); Vector3 dots; - Basis b; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { dots[j] += s[i] * abs(m.get_column(i).normalized().dot(b.get_column(j))); } } + if (sign != signbit(dots.x + dots.y + dots.z)) { + dots = -dots; + } m.scale_local(Vector3(1, 1, 1) + dots); return m; } diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 2d7dff0b27..2e1adb9167 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -629,14 +629,14 @@ void Array::shuffle() { } } -int Array::bsearch(const Variant &p_value, bool p_before) { +int Array::bsearch(const Variant &p_value, bool p_before) const { Variant value = p_value; ERR_FAIL_COND_V(!_p->typed.validate(value, "binary search"), -1); SearchArray<Variant, _ArrayVariantSort> avs; return avs.bisect(_p->array.ptrw(), _p->array.size(), value, p_before); } -int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) { +int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) const { Variant value = p_value; ERR_FAIL_COND_V(!_p->typed.validate(value, "custom binary search"), -1); diff --git a/core/variant/array.h b/core/variant/array.h index 4ef8ba8ce7..8b1f8c0678 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -83,8 +83,8 @@ public: void sort(); void sort_custom(const Callable &p_callable); void shuffle(); - int bsearch(const Variant &p_value, bool p_before = true); - int bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before = true); + int bsearch(const Variant &p_value, bool p_before = true) const; + int bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before = true) const; void reverse(); int find(const Variant &p_value, int p_from = 0) const; |