diff options
| author | Ferenc Arn | 2017-01-05 11:31:39 -0600 |
|---|---|---|
| committer | Ferenc Arn | 2017-01-08 10:36:14 -0600 |
| commit | 6b1252cdfa5988b77917518bc291a0cc34e5066e (patch) | |
| tree | 05e0b10a1b80fcb97bbcaec8c6aca276a2502f49 /tools/editor/plugins/multimesh_editor_plugin.cpp | |
| parent | 76c2e8583e70e8c976a306e77a40e8e7226aa249 (diff) | |
| download | godot-6b1252cdfa5988b77917518bc291a0cc34e5066e.tar.gz godot-6b1252cdfa5988b77917518bc291a0cc34e5066e.tar.zst godot-6b1252cdfa5988b77917518bc291a0cc34e5066e.zip | |
Fix the order in which additional transformations are applied in Matrix3 and Transform.
This is a part of the breaking changes proposed in PR #6865, solving the issue regarding the order of affine transformations described in #2565. This PR also fixes the affected code within Godot codebase. Includes improvements to documentation too.
Another change is, Matrix3::get_scale() will now return negative scaling when the determinant of the matrix is negative. The rationale behind this is simple: when performing a polar decomposition on a basis matrix M = R.S, we have to ensure that the determinant of R is +1, such that it is a proper rotation matrix (with no reflections) which can be represented by Euler angles or a quaternion.
Also replaced the few instances of float with real_t in Matrix3 and Transform.
Furthermore, this PR fixes an issue introduced due to the API breakage in #6865. Namely Matrix3::get_euler() now only works with proper rotation matrices. As a result, the code that wants to get the rotation portion of a transform needs to use Matrix3::get_rotation() introduced in this commit, which complements Matrix3::get_scaled(), providing both parts of the polar decomposition.
Finally, it is now possible to construct a rotation matrix from Euler angles using the new constructor Matrix3::Matrix3(const Vector3 &p_euler).
Diffstat (limited to 'tools/editor/plugins/multimesh_editor_plugin.cpp')
| -rw-r--r-- | tools/editor/plugins/multimesh_editor_plugin.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index 9b1954226..4e9c4ebf9 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -238,9 +238,10 @@ void MultiMeshEditor::_populate() { Matrix3 post_xform; - post_xform.rotate(xform.basis.get_axis(0),-Math::random(-_tilt_random,_tilt_random)*Math_PI); - post_xform.rotate(xform.basis.get_axis(2),-Math::random(-_tilt_random,_tilt_random)*Math_PI); post_xform.rotate(xform.basis.get_axis(1),-Math::random(-_rotate_random,_rotate_random)*Math_PI); + post_xform.rotate(xform.basis.get_axis(2),-Math::random(-_tilt_random,_tilt_random)*Math_PI); + post_xform.rotate(xform.basis.get_axis(0),-Math::random(-_tilt_random,_tilt_random)*Math_PI); + xform.basis = post_xform * xform.basis; //xform.basis.orthonormalize(); |
