[Bf-blender-cvs] [18412744c8c] master: Fix T93687: Transform Gpencil vertices not working if scale is zero

Germano Cavalcante noreply at git.blender.org
Thu Dec 9 22:17:33 CET 2021


Commit: 18412744c8c4231216133f958f74bc38cce54e75
Author: Germano Cavalcante
Date:   Thu Dec 9 18:14:49 2021 -0300
Branches: master
https://developer.blender.org/rB18412744c8c4231216133f958f74bc38cce54e75

Fix T93687: Transform Gpencil vertices not working if scale is zero

Solution similar to rBd5cefc1844cf.

Basically the problem occurs because `td->smtx` was set to zero matrix.

===================================================================

M	source/blender/editors/transform/transform_convert_gpencil.c

===================================================================

diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 9c8671c80f3..e52dcb17806 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -496,8 +496,8 @@ static void createTransGPencil_strokes(bContext *C,
     if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
       const int cfra = (gpl->flag & GP_LAYER_FRAMELOCK) ? gpl->actframe->framenum : cfra_scene;
       bGPDframe *gpf = gpl->actframe;
-      float diff_mat[4][4];
-      float inverse_diff_mat[4][4];
+      float diff_mat[3][3];
+      float inverse_diff_mat[3][3];
 
       bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
       /* Init multiframe falloff options. */
@@ -509,9 +509,14 @@ static void createTransGPencil_strokes(bContext *C,
       }
 
       /* Calculate difference matrix. */
-      BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat);
-      /* Undo matrix. */
-      invert_m4_m4(inverse_diff_mat, diff_mat);
+      {
+        float diff_mat_tmp[4][4];
+        BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat_tmp);
+        copy_m3_m4(diff_mat, diff_mat_tmp);
+      }
+
+      /* Use safe invert for cases where the input matrix has zero axes. */
+      invert_m3_m3_safe_ortho(inverse_diff_mat, diff_mat);
 
       /* Make a new frame to work on if the layer's frame
        * and the current scene frame don't match up.
@@ -651,9 +656,9 @@ static void createTransGPencil_strokes(bContext *C,
                     }
                   }
                   /* apply parent transformations */
-                  copy_m3_m4(td->smtx, inverse_diff_mat); /* final position */
-                  copy_m3_m4(td->mtx, diff_mat);          /* display position */
-                  copy_m3_m4(td->axismtx, diff_mat);      /* axis orientation */
+                  copy_m3_m3(td->smtx, inverse_diff_mat); /* final position */
+                  copy_m3_m3(td->mtx, diff_mat);          /* display position */
+                  copy_m3_m3(td->axismtx, diff_mat);      /* axis orientation */
 
                   /* Triangulation must be calculated again,
                    * so save the stroke for recalc function */



More information about the Bf-blender-cvs mailing list