Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-04-01 13:16:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-01 13:35:19 +0300
commitd5cefc1844cfd679b5d1f134386635f6165ae2e3 (patch)
treea79bc8141ac349ee7c0caa223016221b67f81462
parent8a144b73c0116a014ed6f081048ffb6b84255d0b (diff)
Fix T50103: Transform not working if scale is zero
If any axis of the scale of an object was zero, transforming failed. This was because `td->smtx` was set to a zero matrix. orthogonalize_m3_zero_axes is used to fill in the zeroed axes. Thanks to @filedescriptor for the initial fix: D10869.
-rw-r--r--source/blender/editors/transform/transform_convert_object.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c
index b546f1d0b4c..c217478bd04 100644
--- a/source/blender/editors/transform/transform_convert_object.c
+++ b/source/blender/editors/transform/transform_convert_object.c
@@ -282,9 +282,17 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
*/
BKE_object_to_mat3(ob, obmtx);
copy_m3_m4(totmat, ob->obmat);
- invert_m3_m3(obinv, totmat);
+
+ /* If the object scale is zero on any axis, this might result in a zero matrix.
+ * In this case, the transformation would not do anything, see: T50103. */
+ orthogonalize_m3_zero_axes(obmtx, 1.0f);
+ orthogonalize_m3_zero_axes(totmat, 1.0f);
+
+ /* Use safe invert even though the input matrices have had zero axes set to unit length,
+ * in the unlikely case of failure (float precision for eg) this uses unit matrix fallback. */
+ invert_m3_m3_safe_ortho(obinv, totmat);
mul_m3_m3m3(td->smtx, obmtx, obinv);
- invert_m3_m3(td->mtx, td->smtx);
+ invert_m3_m3_safe_ortho(td->mtx, td->smtx);
}
else {
/* no conversion to/from dataspace */