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.
This commit is contained in:
Germano Cavalcante 2021-12-09 18:14:49 -03:00
parent 74a566d211
commit 18412744c8
Notes: blender-bot 2023-02-14 04:56:36 +01:00
Referenced by issue #93687, Greasepencil eidt mode can’t move vertices
1 changed files with 13 additions and 8 deletions

View File

@ -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 */