diff options
author | Antonioya <blendergit@gmail.com> | 2019-04-19 18:07:45 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-04-19 18:08:37 +0300 |
commit | 7e4db169f2ab8dd62281f0b42a6f7e33be5f32d6 (patch) | |
tree | 1395cdf86188f3e4f6a942761ddbf81953a8ac60 | |
parent | 8f4ba1c0467d9e6169451e03be5efffbd1f7a896 (diff) |
T63644: Editing while parented is not rotating correctly
This commit tries to fix the rotation problem when the parent is at layer level.
The problem was the object location was not used, so all object not in origin got weird transformations.
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 1dffa901c32..fcaefc3d1dd 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1259,6 +1259,7 @@ void ED_gpencil_parent_location(const Depsgraph *depsgraph, else { if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) { mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->obmat[3]); return; } else if (gpl->partype == PARBONE) { @@ -1267,10 +1268,12 @@ void ED_gpencil_parent_location(const Depsgraph *depsgraph, float tmp_mat[4][4]; mul_m4_m4m4(tmp_mat, obparent_eval->obmat, pchan->pose_mat); mul_m4_m4m4(diff_mat, tmp_mat, gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->obmat[3]); } else { /* if bone not found use object (armature) */ mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->obmat[3]); } return; } @@ -1287,12 +1290,15 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata int i; float diff_mat[4][4]; float cur_mat[4][4]; + float gpl_loc[3]; + zero_v3(gpl_loc); for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpl->parent != NULL) { /* calculate new matrix */ if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) { invert_m4_m4(cur_mat, gpl->parent->obmat); + copy_v3_v3(gpl_loc, obact->obmat[3]); } else if (gpl->partype == PARBONE) { bPoseChannel *pchan = BKE_pose_channel_find_name(gpl->parent->pose, gpl->parsubstr); @@ -1300,6 +1306,7 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata float tmp_mat[4][4]; mul_m4_m4m4(tmp_mat, gpl->parent->obmat, pchan->pose_mat); invert_m4_m4(cur_mat, tmp_mat); + copy_v3_v3(gpl_loc, obact->obmat[3]); } } @@ -1307,6 +1314,9 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata if (!equals_m4m4(gpl->inverse, cur_mat)) { /* first apply current transformation to all strokes */ ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat); + /* undo local object */ + sub_v3_v3(diff_mat[3], gpl_loc); + for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { |