diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-01-02 15:02:19 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-02 15:02:19 -0300 |
commit | 14772d22136ac87e2bbf2b94639f79242330ae0a (patch) | |
tree | 0b71fdeec9f78ed7b2526f53a3f5385105fa243c /core/math | |
parent | 9821562b300ecc2401ec1e42600a92053897e51f (diff) | |
parent | e9896b17a9804ba6392dab0bd6c484f4d2e294c1 (diff) |
Merge pull request #15083 from tagcup/spatial_rot_fix
Restore the behavior of Spatial rotations recently changed in c1153f5.
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/matrix3.cpp | 17 | ||||
-rw-r--r-- | core/math/matrix3.h | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index e1708a44b0..ceaff04ae8 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -228,12 +228,24 @@ void Basis::scale(const Vector3 &p_scale) { } Basis Basis::scaled(const Vector3 &p_scale) const { - Basis m = *this; m.scale(p_scale); return m; } +void Basis::scale_local(const Vector3 &p_scale) { + // performs a scaling in object-local coordinate system: + // M -> (M.S.Minv).M = M.S. + *this = scaled_local(p_scale); +} + +Basis Basis::scaled_local(const Vector3 &p_scale) const { + Basis b; + b.set_scale(p_scale); + + return (*this) * b; +} + void Basis::set_scale(const Vector3 &p_scale) { set_axis(0, get_axis(0).normalized() * p_scale.x); @@ -312,7 +324,8 @@ void Basis::rotate(const Vector3 &p_axis, real_t p_phi) { } void Basis::rotate_local(const Vector3 &p_axis, real_t p_phi) { - + // performs a rotation in object-local coordinate system: + // M -> (M.R.Minv).M = M.R. *this = rotated_local(p_axis, p_phi); } Basis Basis::rotated_local(const Vector3 &p_axis, real_t p_phi) const { diff --git a/core/math/matrix3.h b/core/math/matrix3.h index 71971bdea8..c426435729 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -103,6 +103,9 @@ public: void scale(const Vector3 &p_scale); Basis scaled(const Vector3 &p_scale) const; + void scale_local(const Vector3 &p_scale); + Basis scaled_local(const Vector3 &p_scale) const; + void set_scale(const Vector3 &p_scale); Vector3 get_scale() const; Vector3 get_signed_scale() const; |