diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-04 00:21:14 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-04 00:21:14 +0100 |
commit | 2c008ac8c5353a23afb625ed94e8a672cdc35f84 (patch) | |
tree | a8e3a2636bdc0ed4bb9d12c0ae186193c5dc0dc5 /core/math/basis.cpp | |
parent | b0598dcdb7cd96e2614b687a57a64ce12245e19e (diff) | |
parent | 1459b9c24c9bf7c4781fde3ea55c0dbd9b020e2f (diff) |
Merge pull request #72669 from TokageItLab/fix-scale-subgizmo
Fix broken `scaled_orthogonal()` & subgizmo global scaling
Diffstat (limited to 'core/math/basis.cpp')
-rw-r--r-- | core/math/basis.cpp | 7 |
1 files changed, 6 insertions, 1 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; } |