[Bf-blender-cvs] [69e4e9c0c4f] greasepencil-edit-curve: GPencil: Apply GSoC changes
Antonio Vazquez
noreply at git.blender.org
Fri Jun 19 23:01:20 CEST 2020
Commit: 69e4e9c0c4fa42adb73214d94fac0373b3594d07
Author: Antonio Vazquez
Date: Fri Jun 19 22:57:05 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rB69e4e9c0c4fa42adb73214d94fac0373b3594d07
GPencil: Apply GSoC changes
===================================================================
M source/blender/editors/gpencil/gpencil_select.c
M source/blender/editors/transform/transform_convert_gpencil.c
M source/blender/editors/transform/transform_mode_gpopacity.c
M source/blender/editors/transform/transform_mode_gpshrinkfatten.c
M source/blender/makesdna/DNA_curve_types.h
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 6accc06d175..dd04664f5b6 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -151,9 +151,9 @@ static void gpencil_select_ui(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ob->data;
- if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) && error_threshold_display_poll(C)) {
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) { // && error_threshold_display_poll(C)) {
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiItemR(layout, &ptr, "error_threshold", 0, NULL, ICON_NONE);
+ uiItemR(layout, &ptr, "error_threshold", 0, "Error Threshold", ICON_NONE);
}
}
@@ -1822,7 +1822,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* Perform selection operations... */
if (whole) {
/* select all curve points */
- if (hit_curve != NULL || (is_curve_edit && hit_point != NULL)) {
+ if (hit_curve != NULL) {
for (int i = 0; i < hit_curve->tot_curve_points; i++) {
bGPDcurve_point *gpc_pt = &hit_curve->curve_points[i];
BezTriple *bezt = &gpc_pt->bezt;
diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 0972af1b07f..425131c1af0 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -44,6 +44,34 @@
*
* \{ */
+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) {
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (bezt->f1 & SELECT) {
+ add_v3_v3(r_center, bezt->vec[0]);
+ tot_sel++;
+ }
+ if (bezt->f2 & SELECT) {
+ add_v3_v3(r_center, bezt->vec[0]);
+ tot_sel++;
+ }
+ if (bezt->f3 & SELECT) {
+ add_v3_v3(r_center, bezt->vec[0]);
+ 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 +152,63 @@ 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 * 3;
+ }
+ }
+ else {
+ /* Everything goes - connection status doesn't matter. */
+ tc->data_len += gpc->tot_curve_points * 3;
}
}
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) {
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (bezt->f1 & SELECT) {
+ tc->data_len++;
+ }
+ if (bezt->f2 & SELECT) {
+ tc->data_len++;
+ }
+ if (bezt->f3 & SELECT) {
+ tc->data_len++;
+ }
+ }
+ }
}
}
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++;
+ 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++;
+ }
}
}
}
@@ -228,7 +291,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,114 +303,195 @@ 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) {
- bGPDspoint *pt;
- int i;
-
- /* save falloff factor */
- gps->runtime.multi_frame_falloff = falloff;
-
- /* calculate stroke center */
+ if (stroke_ok && tot_points > 0) {
float center[3];
- createTransGPencil_center_get(gps, center);
+ bool point_ok;
- /* add all necessary points... */
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- bool point_ok;
+ if (is_curve_edit) {
+ gps->runtime.multi_frame_falloff = falloff;
+ createTransGPencil_curve_center_get(gpc, center);
- /* 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;
+ for (int i = 0; i < tot_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
+ if (is_prop_edit) {
+ point_ok = true;
+ }
+ else {
+ point_ok = (gpc_pt->flag & GP_CURVE_POINT_SELECT) != 0;
+ }
+
+ if (point_ok) {
+ BezTriple *bezt = &gpc_pt->bezt;
+ for (int j = 0; j < 3; j++) {
+ td->flag = 0;
+ if (BEZT_ISSEL_IDX(bezt, j)) {
+ copy_v3_v3(td->iloc, bezt->vec[j]);
+ 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[j]);
+ }
+
+ td->loc = bezt->vec[j];
+ td->flag |= TD_SELECTED;
+
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list