summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorSilc Renew <tokage.it.lab@gmail.com>2023-02-04 00:45:12 +0900
committerSilc Renew <tokage.it.lab@gmail.com>2023-02-04 00:46:04 +0900
commit1459b9c24c9bf7c4781fde3ea55c0dbd9b020e2f (patch)
treed38c5be867ee987248e4016b6282eea9e9798a23 /core/math
parent604493eb6ee3def65aca089c1d4bc71ea03ca19a (diff)
Fix scaled_orthogonal() & subgizmo global scaling
Diffstat (limited to 'core/math')
-rw-r--r--core/math/basis.cpp7
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;
}