diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2016-08-04 00:31:48 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2016-08-04 00:39:36 +0300 |
commit | eaea4ea51f665945e44ff2ffa534a594e9fb1938 (patch) | |
tree | 0791ec0d78a4506eebf3bcf3800a5b1423143494 /source/blender/editors/transform/transform_conversions.c | |
parent | 9d4ea8427770e8ca68149fc7f7760fe2273e5ce3 (diff) |
Grease Pencil v2 Branch
Improve current Grease Pencil in order to get a better 2D animation tool.
More info in WIKI pages: https://wiki.blender.org/index.php/User:Antoniov
Reviewed By: Severin, aligorith, campbellbarton
Patch by @antoniov, with edits by @Severin.
Differential Revision: https://developer.blender.org/D2115
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 1376b6bf4da..ad2b40bfef8 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -7687,7 +7687,11 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; } - + /* check if the color is editable */ + if (ED_gpencil_stroke_color_use(gpl, gps) == false) { + continue; + } + if (is_prop_edit) { /* Proportional Editing... */ if (is_prop_edit_connected) { @@ -7735,14 +7739,27 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps; + float diff_mat[4][4]; + float inverse_diff_mat[4][4]; + + /* calculate difference matrix if parent object */ + if (gpl->parent != NULL) { + ED_gpencil_parent_location(gpl, diff_mat); + /* undo matrix */ + invert_m4_m4(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 + /* Make a new frame to work on if the layer's frame and the current scene frame don't match up * - This is useful when animating as it saves that "uh-oh" moment when you realize you've * spent too much time editing the wrong frame... */ // XXX: should this be allowed when framelock is enabled? if (gpf->framenum != cfra) { gpf = gpencil_frame_addcopy(gpl, cfra); + /* in some weird situations (framelock enabled) return NULL */ + if (gpf == NULL) { + continue; + } } /* Loop over strokes, adding TransData for points as needed... */ @@ -7755,7 +7772,10 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; } - + /* check if the color is editable */ + if (ED_gpencil_stroke_color_use(gpl, gps) == false) { + continue; + } /* What we need to include depends on proportional editing settings... */ if (is_prop_edit) { if (is_prop_edit_connected) { @@ -7824,9 +7844,18 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* screenspace */ td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ; - copy_m3_m4(td->smtx, t->persmat); - copy_m3_m4(td->mtx, t->persinv); - unit_m3(td->axismtx); + /* apply parent transformations */ + if (gpl->parent == NULL) { + copy_m3_m4(td->smtx, t->persmat); + copy_m3_m4(td->mtx, t->persinv); + unit_m3(td->axismtx); + } + else { + /* apply matrix transformation relative to parent */ + 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 */ + } } else { /* configure 2D dataspace points so that they don't play up... */ @@ -7835,9 +7864,18 @@ static void createTransGPencil(bContext *C, TransInfo *t) // XXX: matrices may need to be different? } - copy_m3_m3(td->smtx, smtx); - copy_m3_m3(td->mtx, mtx); - unit_m3(td->axismtx); // XXX? + /* apply parent transformations */ + if (gpl->parent == NULL) { + copy_m3_m3(td->smtx, smtx); + copy_m3_m3(td->mtx, mtx); + unit_m3(td->axismtx); // XXX? + } + else { + /* apply matrix transformation relative to parent */ + 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 */ + } } /* Triangulation must be calculated again, so save the stroke for recalc function */ td->extra = gps; |