Commit: 4033f05c302a94f4ff4405752f3817b61aa61781 Author: Antonio Vazquez Date: Tue Aug 29 12:59:49 2017 +0200 Branches: greasepencil-object https://developer.blender.org/rB4033f05c302a94f4ff4405752f3817b61aa61781
Add transformation data for multiedit
===================================================================
M source/blender/editors/transform/transform_conversions.c
===================================================================
diff --git a/source/blender/editors/transform/transform_conversions.c
b/source/blender/editors/transform/transform_conversions.c
index 3c0947f2a3a..7a127c4f546 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -7823,6 +7823,7 @@ void flushTransPaintCurve(TransInfo *t)
static void createTransGPencil(bContext *C, TransInfo *t)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
+ bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
Object *obact = CTX_data_active_object(C);
bGPDlayer *gpl;
TransData *td = NULL;
@@ -7854,44 +7855,48 @@ static void createTransGPencil(bContext *C, TransInfo
*t)
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* only editable and visible layers are considered */
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
- bGPDframe *gpf = gpl->actframe;
+ bGPDframe *gpf;
bGPDstroke *gps;
-
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- /* skip strokes that are invalid for current
view */
- 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;
- }
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
- if (is_prop_edit) {
- /* Proportional Editing... */
- if (is_prop_edit_connected) {
- /* connected only - so only if
selected */
- if (gps->flag &
GP_STROKE_SELECT)
- t->total +=
gps->totpoints;
- }
- else {
- /* everything goes - connection
status doesn't matter */
- t->total += gps->totpoints;
- }
- }
- else {
- /* only selected stroke points are
considered */
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
-
- // TODO: 2D vs 3D?
- for (i = 0, pt = gps->points; i
< gps->totpoints; i++, pt++) {
- if (pt->flag &
GP_SPOINT_SELECT)
- t->total++;
+ for (gps = gpf->strokes.first; gps; gps
= gps->next) {
+ /* skip strokes that are
invalid for current view */
+ 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) {
+ /* connected
only - so only if selected */
+ if (gps->flag &
GP_STROKE_SELECT)
+
t->total += gps->totpoints;
+ }
+ else {
+ /* everything
goes - connection status doesn't matter */
+ t->total +=
gps->totpoints;
+ }
+ }
+ else {
+ /* only selected stroke
points are considered */
+ if (gps->flag &
GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
+
+ // TODO: 2D vs
3D?
+ for (i = 0, pt
= gps->points; i < gps->totpoints; i++, pt++) {
+ if
(pt->flag & GP_SPOINT_SELECT)
+
t->total++;
+ }
+ }
}
}
- }
+ }
}
}
}
@@ -7921,132 +7926,136 @@ static void createTransGPencil(bContext *C, TransInfo
*t)
ED_gpencil_parent_location(obact, gpd, 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
* - 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) {
+ // XXX: should this be allowed when framelock is
enabled?
+ if ((gpf->framenum != cfra) && (!is_multiedit)) {
gpf = BKE_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... */
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
- TransData *head = td;
- TransData *tail = td;
- bool stroke_ok;
-
- /* skip strokes that are invalid for current
view */
- 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) {
- /* A) "Connected" - Only those
in selected strokes */
- stroke_ok = (gps->flag &
GP_STROKE_SELECT) != 0;
- }
- else {
- /* B) All points, always */
- stroke_ok = true;
- }
- }
- else {
- /* C) Only selected points in selected
strokes */
- stroke_ok = (gps->flag &
GP_STROKE_SELECT) != 0;
- }
-
- /* Do stroke... */
- if (stroke_ok && gps->totpoints) {
- bGPDspoint *pt;
- int i;
-
-#if 0 /* XXX: this isn't needed anymore; cannot calculate center this way or
is_prop_edit breaks */
- const float ninv = 1.0f /
gps->totpoints;
- float center[3] = {0.0f};
-
- /* compute midpoint of stroke */
- for (i = 0, pt = gps->points; i <
gps->totpoints; i++, pt++) {
- madd_v3_v3v3fl(center, center,
&pt->x, ninv);
- }
-#endif
-
- /* add all necessary points... */
- for (i = 0, pt = gps->points; i <
gps->totpoints; i++, pt++) {
- bool point_ok;
-
- /* include point? */
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
+ for (gps = gpf->strokes.first; gps; gps
= gps->next) {
+ TransData *head = td;
+ TransData *tail = td;
+ bool stroke_ok;
+
+ /* skip strokes that are
invalid for current view */
+ 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) {
- /* Always all points in
strokes that get included */
- point_ok = true;
+ if
(is_prop_edit_connected) {
+ /* A)
"Connected" - Only those in selected strokes */
+ stroke_ok =
(gps->flag & GP_STROKE_SELECT) != 0;
+ }
+ else {
+ /* B) All
points, always */
+ stroke_ok =
true;
+ }
}
else {
- /* Only selected points
in selected strokes */
- point_ok = (pt->flag &
GP_SPOINT_SELECT) != 0;
+ /* C) Only selected
points in selected strokes */
+ stroke_ok = (gps->flag
& GP_STROKE_SELECT) != 0;
}
-
- /* do point... */
- if (point_ok) {
- copy_v3_v3(td->iloc,
&pt->x);
- copy_v3_v3(td->center,
&pt->x); // XXX: what about t->around == local?
-
- td->loc = &pt->x;
- td->flag = 0;
-
- if (pt->flag &
GP_SPOINT_SELECT)
- td->flag |=
TD_SELECTED;
-
- /* for other transform
modes (e.g. shrink-fatten), need to additional data */
- if (t->mode ==
TFM_GPENCIL_SHRINKFATTEN) {
- td->val =
&pt->pressure;
- td->ival =
pt->pressure;
- }
-
- /* screenspace needs
special matrices... */
- if ((gps->flag &
(GP_STROKE_3DSPACE | GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) == 0) {
- /* screenspace
*/
- td->protectflag
= OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
-
- /* 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 */
+ /* Do stroke... */
+ if (stroke_ok &&
gps->totpoints) {
+ bGPDspoint *pt;
+ int i;
+
+#if 0 /* XXX: this isn't needed anymore; cannot calculate center this way or
is_prop_edit breaks */
+ const float ninv = 1.0f
/ gps->totpoints;
+ float center[3] = {
0.0f };
+
+ /* compute midpoint of
stroke */
+ for (i = 0, pt =
gps->points; i < gps->totpoints; i++, pt++) {
+
madd_v3_v3v3fl(center, center, &pt->x, ninv);
}
- else {
- /* configure 2D
dataspace points so that they don't play up... */
- if (gps->flag &
(GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) {
-
td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
- // XXX:
matrices may need to be different?
+#endif
+
+ /* add all necessary
points... */
+ for (i = 0, pt =
gps->points; i < gps->totpoints; i++, pt++) {
+ bool point_ok;
+
+ /* include
point? */
+ if
(is_prop_edit) {
+ /*
Always all points in strokes that get included */
+
point_ok = true;
+ }
+ else {
+ /* Only
selected points in selected strokes */
+
point_ok = (pt->flag & GP_SPOINT_SELECT) != 0;
+ }
+
+ /* do point...
*/
+ if (point_ok) {
+
copy_v3_v3(td->iloc, &pt->x);
+
copy_v3_v3(td->center, &pt->x); // XXX: what about t->around == local?
+
+ td->loc
= &pt->x;
+
+
td->flag = 0;
+
+ if
(pt->flag & GP_SPOINT_SELECT)
+
td->flag |= TD_SELECTED;
+
+ /* for
other transform modes (e.g. shrink-fatten), need to additional data */
+ if
(t->mode == TFM_GPENCIL_SHRINKFATTEN) {
+
td->val = &pt->pressure;
+
td->ival = pt->pressure;
+ }
+
+ /*
screenspace needs special matrices... */
+ if
((gps->flag & (GP_STROKE_3DSPACE | GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) ==
0) {
+
/* screenspace */
+
td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ;
+
+
/* 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 */
+
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs
