[Bf-blender-cvs] [915f80ad483] soc-2020-greasepencil-curve: GPencil: Add transform of curve control points
Falk David
noreply at git.blender.org
Fri Jun 19 17:09:26 CEST 2020
Commit: 915f80ad4836d3e035f332498dbd032a4c2e01f7
Author: Falk David
Date: Fri Jun 19 17:06:33 2020 +0200
Branches: soc-2020-greasepencil-curve
https://developer.blender.org/rB915f80ad4836d3e035f332498dbd032a4c2e01f7
GPencil: Add transform of curve control points
This ignores handles for now. Only transforms control points.
===================================================================
M source/blender/editors/transform/transform_convert_gpencil.c
===================================================================
diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 0972af1b07f..9efb6626f47 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -44,6 +44,23 @@
*
* \{ */
+static void createTransGPencil_curve_center_get(bGPDcurve *gpc, float r_center[3])
+{
+ zero_v3(r_center);
+ int tot_sel = 0;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ add_v3_v3(r_center, gpc_pt->bezt.vec[1]);
+ tot_sel++;
+ }
+ }
+
+ if (tot_sel > 0) {
+ mul_v3_fl(r_center, 1.0f / tot_sel);
+ }
+}
+
static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3])
{
bGPDspoint *pt;
@@ -124,28 +141,54 @@ void createTransGPencil(bContext *C, TransInfo *t)
continue;
}
- if (is_prop_edit) {
- /* Proportional Editing... */
- if (is_prop_edit_connected) {
- /* Connected only - so only if selected. */
- if (gps->flag & GP_STROKE_SELECT) {
- tc->data_len += gps->totpoints;
+ if (is_curve_edit && gps->editcurve != NULL) {
+ bGPDcurve *gpc = gps->editcurve;
+ if (is_prop_edit) {
+ /* Proportional Editing... */
+ if (is_prop_edit_connected) {
+ /* Connected only - so only if selected. */
+ if (gpc->flag & GP_CURVE_SELECT) {
+ tc->data_len += gpc->tot_curve_points;
+ }
+ }
+ else {
+ /* Everything goes - connection status doesn't matter. */
+ tc->data_len += gpc->tot_curve_points;
}
}
else {
- /* Everything goes - connection status doesn't matter. */
- tc->data_len += gps->totpoints;
+ for (int i = 0; i < gpc->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ tc->data_len++;
+ }
+ }
}
}
else {
- /* Only selected stroke points are considered. */
- if (gps->flag & GP_STROKE_SELECT) {
- bGPDspoint *pt;
- int i;
+ if (is_prop_edit) {
+ /* Proportional Editing... */
+ if (is_prop_edit_connected) {
+ /* Connected only - so only if selected. */
+ if (gps->flag & GP_STROKE_SELECT) {
+ tc->data_len += gps->totpoints;
+ }
+ }
+ else {
+ /* Everything goes - connection status doesn't matter. */
+ tc->data_len += gps->totpoints;
+ }
+ }
+ else {
+ /* Only selected stroke points are considered. */
+ if (gps->flag & GP_STROKE_SELECT) {
+ bGPDspoint *pt;
+ int i;
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT) {
- tc->data_len++;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ tc->data_len++;
+ }
}
}
}
@@ -228,7 +271,9 @@ void createTransGPencil(bContext *C, TransInfo *t)
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
TransData *head = td;
TransData *tail = td;
+ bGPDcurve *gpc = gps->editcurve;
bool stroke_ok;
+ int tot_points;
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
@@ -238,86 +283,156 @@ void createTransGPencil(bContext *C, TransInfo *t)
if (ED_gpencil_stroke_color_use(obact, 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;
+
+ if (is_curve_edit && gpc != NULL) {
+ if (is_prop_edit) {
+ if (is_prop_edit_connected) {
+ stroke_ok = (gpc->flag & GP_CURVE_SELECT) != 0;
+ }
+ else {
+ stroke_ok = true;
+ }
}
else {
- /* B) All points, always */
- stroke_ok = true;
+ stroke_ok = (gpc->flag & GP_CURVE_SELECT) != 0;
}
+ tot_points = gpc->tot_curve_points;
}
else {
- /* C) Only selected points in selected strokes */
- stroke_ok = (gps->flag & GP_STROKE_SELECT) != 0;
+ /* 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;
+ }
+ tot_points = gps->totpoints;
}
/* Do stroke... */
- if (stroke_ok && gps->totpoints) {
+ if (stroke_ok && tot_points > 0) {
+ bGPDcurve_point *gpc_pt;
bGPDspoint *pt;
- int i;
-
- /* save falloff factor */
- gps->runtime.multi_frame_falloff = falloff;
-
- /* calculate stroke center */
float center[3];
- createTransGPencil_center_get(gps, center);
+ if (is_curve_edit) {
+ gps->runtime.multi_frame_falloff = falloff;
+ createTransGPencil_curve_center_get(gpc, center);
+ }
+ else {
+ /* save falloff factor */
+ gps->runtime.multi_frame_falloff = falloff;
+
+ /* calculate stroke center */
+ createTransGPencil_center_get(gps, center);
+ }
/* add all necessary points... */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ for (int i = 0; i < tot_points; i++) {
bool point_ok;
- /* include point? */
- if (is_prop_edit) {
- /* Always all points in strokes that get included. */
- point_ok = true;
+ if (is_curve_edit) {
+ gpc_pt = &gpc->curve_points[i];
+ if (is_prop_edit) {
+ point_ok = true;
+ }
+ else {
+ point_ok = (gpc_pt->flag & GP_CURVE_POINT_SELECT) != 0;
+ }
}
else {
- /* Only selected points in selected strokes. */
- point_ok = (pt->flag & GP_SPOINT_SELECT) != 0;
+ pt = &gps->points[i];
+ /* 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);
- /* Only copy center in local origins.
- * This allows get interesting effects also when move
- * using proportional editing. */
- if ((gps->flag & GP_STROKE_SELECT) &&
- (ts->transform_pivot_point == V3D_AROUND_LOCAL_ORIGINS)) {
- copy_v3_v3(td->center, center);
- }
- else {
- copy_v3_v3(td->center, &pt->x);
- }
- td->loc = &pt->x;
+ if (is_curve_edit) {
+ BezTriple *bezt = &gpc_pt->bezt;
+ copy_v3_v3(td->iloc, bezt->vec[1]);
+
+ if ((gpc->flag & GP_CURVE_SELECT) &&
+ (ts->transform_pivot_point == V3D_AROUND_LOCAL_ORIGINS)) {
+ copy_v3_v3(td->center, center);
+ }
+ else {
+ copy_v3_v3(td->center, bezt->vec[1]);
+ }
- td->flag = 0;
+ td->loc = bezt->vec[1];
+ td->flag = 0;
- if (pt->flag & GP_SPOINT_SELECT) {
- td->flag |= TD_SELECTED;
- }
+ if (bezt->f2 & SELECT) {
+ td->flag |= TD_SELECTED;
+ }
- /* For other transform modes (e.g. shrink-fatten), need to additional data
- * but never for mirror.
- */
- if (t->mode != TFM_MIRROR) {
- if (t->mode != TFM_GPENCIL_OPACITY) {
- if (is_scale_thickness) {
- td->val = &pt->pressure;
- td->ival = pt-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list