Commit: e2b872ccc8acfd1e6f7667d6da63fba36410a783 Author: Joshua Leung Date: Sat Oct 11 17:43:21 2014 +1300 Branches: GPencil_EditStrokes https://developer.blender.org/rBe2b872ccc8acfd1e6f7667d6da63fba36410a783
Proportional editing now works for Grease Pencil stroke transforms too
There's also support for "connected" propedit mode, but without access to that
in the Object Mode (or in other contexts), it may not be available for use.
(Hence, that support is currently still untested)
===================================================================
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 1bbe532..be9876c 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -7209,6 +7209,10 @@ static void createTransGPencil(bContext *C, TransInfo *t)
TransData *td = NULL;
float mtx[3][3], smtx[3][3];
+ const int propedit = (t->flag & T_PROP_EDIT);
+ const int propedit_connected = (t->flag & T_PROP_CONNECTED);
+
+
/* == Grease Pencil Strokes to Transform Data ==
* Grease Pencil stroke points can be a mixture of 2D (screen-space),
* or 3D coordinates. However, they're always saved as 3D points.
@@ -7231,18 +7235,32 @@ static void createTransGPencil(bContext *C, TransInfo
*t)
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
- /* only selected stroke points are considered */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
- 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++;
+ if (propedit) {
+ /* Proportional Editing... */
+ if (propedit_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++;
+ }
+ }
+ }
}
}
}
@@ -7268,12 +7286,33 @@ static void createTransGPencil(bContext *C, TransInfo
*t)
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
- /* only selected strokes are considered */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
- if ((gps->flag & GP_STROKE_SELECT) &&
(gps->totpoints)) {
+ TransData *head = td;
+ TransData *tail = td;
+ bool stroke_ok;
+
+ /* What we need to include depends on
proportional editing settings... */
+ if (propedit) {
+ if (propedit_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
propedit breaks */
const float ninv = 1.0f /
gps->totpoints;
float center[3] = {0.0f};
@@ -7281,15 +7320,33 @@ static void createTransGPencil(bContext *C, TransInfo
*t)
for (i = 0, pt = gps->points; i <
gps->totpoints; i++, pt++) {
madd_v3_v3v3fl(center, center,
&pt->x, ninv);
}
+#endif
- /* add all selected points... */
+ /* add all necessary points... */
for (i = 0, pt = gps->points; i <
gps->totpoints; i++, pt++) {
- if (pt->flag &
GP_SPOINT_SELECT) {
+ bool point_ok;
+
+ /* include point? */
+ if (propedit) {
+ /* 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,
center); // XXX: what about t->around == local?
+ copy_v3_v3(td->center,
&pt->x); // XXX: what about t->around == local?
td->loc = &pt->x;
- td->flag = TD_SELECTED;
+
+ td->flag = 0;
+
+ if (pt->flag &
GP_SPOINT_SELECT)
+ td->flag |=
TD_SELECTED;
/* configure 2D points
so that they don't play up... */
if (gps->flag &
(GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) {
@@ -7302,8 +7359,15 @@ static void createTransGPencil(bContext *C, TransInfo *t)
unit_m3(td->axismtx);
// XXX?
td++;
+ tail++;
}
}
+
+ /* March over these points, and
calculate the proportional editing distances */
+ if (propedit && (head != tail)) {
+ /* XXX: for now, we are similar
enough that this works... */
+ calc_distanceCurveVerts(head,
tail - 1);
+ }
}
}
}
@@ -7334,6 +7398,12 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->options & CTX_GPENCIL_STROKES) {
t->flag |= T_POINTS; // XXX...
createTransGPencil(C, t);
+
+ if (t->data && (t->flag & T_PROP_EDIT)) {
+ sort_trans_data(t); // makes selected become first in
array
+ set_prop_dist(t, 1);
+ sort_trans_data_dist(t);
+ }
}
else if (t->spacetype == SPACE_IMAGE) {
t->flag |= T_POINTS | T_2D_EDIT;
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs
