Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-02-19 19:18:12 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-02-19 19:41:28 +0300
commit6bba830589860c32a2543b14cd2c9bcd2b9e4948 (patch)
tree079027534dc4c6ea10d49816cde608c751602476 /source/blender/editors/gpencil/gpencil_select.c
parent2441886c58e1258645195214e0aa1987c29f0c35 (diff)
GPencil: Interpolate Tools refactor
Following with the changes included to interpolate strokes of different number of points, a full review has been done in the interpolation tools. * Interpolate now is a tool and not an operator. It was not logic to have this tool as a button. * Interpolate tool parameters have been moved to topbar. * Interpolate popover has been removed from topbar and interpolate `Sequence` operator has been moved to grease pencil menu. * Interpolate Sequence now include a Redo panel. * Interpolate tool now allows to select the strokes by pairs. This allows to interpolate any stroke with any stroke and not as before that it was only possible by drawing order. If no stroke is selected, the interpolation is done as before. * Now is possible interpolate again if a previous keyframe exist. Before, it was impossible to interpolate two times in same frame and this made impossible to do the interpolation by groups of frames. * New automatic option to `Flip strokes` if the stroke and end are not in the right position. Also the flip can be set manually for corner cases. * Cleanup of menus related to interpolate. * Fixed some bugs and removed parameters from scene because now all are tool or operator contained. * Some code cleanup and function renames. This commit also includes the some codebase to future implementation of the concept `Vertex Active` that now does not exist in grease pencil.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index d1d8abd6775..fd5c5bb5346 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -156,6 +156,11 @@ static bool gpencil_3d_point_to_screen_space(ARegion *region,
/* helper to deselect all selected strokes/points */
static void deselect_all_selected(bContext *C)
{
+ /* Set selection index to 0. */
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ob->data;
+ gpd->select_last_index = 0;
+
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
/* deselect stroke and its points if selected */
if (gps->flag & GP_STROKE_SELECT) {
@@ -169,6 +174,7 @@ static void deselect_all_selected(bContext *C)
/* deselect stroke itself too */
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
}
/* deselect curve and curve points */
@@ -187,7 +193,7 @@ static void deselect_all_selected(bContext *C)
CTX_DATA_END;
}
-static void select_all_curve_points(bGPDstroke *gps, bGPDcurve *gpc, bool deselect)
+static void select_all_curve_points(bGPdata *gpd, bGPDstroke *gps, bGPDcurve *gpc, bool deselect)
{
for (int i = 0; i < gpc->tot_curve_points; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -205,10 +211,12 @@ static void select_all_curve_points(bGPDstroke *gps, bGPDcurve *gpc, bool desele
if (deselect == false) {
gpc->flag |= GP_CURVE_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
}
else {
gpc->flag &= ~GP_CURVE_SELECT;
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
}
}
@@ -423,7 +431,7 @@ static int gpencil_select_alternate_exec(bContext *C, wmOperator *op)
BEZT_DESEL_ALL(&gpc_pt->bezt);
}
- BKE_gpencil_curve_sync_selection(gps);
+ BKE_gpencil_curve_sync_selection(gpd, gps);
changed = true;
}
}
@@ -562,6 +570,7 @@ static bool gpencil_select_same_layer(bContext *C)
}
gpc->flag |= GP_CURVE_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
changed = true;
}
@@ -578,6 +587,7 @@ static bool gpencil_select_same_layer(bContext *C)
}
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
changed = true;
}
@@ -622,6 +632,7 @@ static bool gpencil_select_same_material(bContext *C)
}
gpc->flag |= GP_CURVE_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
changed = true;
}
@@ -640,6 +651,7 @@ static bool gpencil_select_same_material(bContext *C)
}
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
changed = true;
}
@@ -756,6 +768,8 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op)
BEZT_SEL_ALL(&gpc->curve_points[0].bezt);
gpc->flag |= GP_CURVE_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+
if ((extend == false) && (gps->totpoints > 1)) {
for (int i = 1; i < gpc->tot_curve_points; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -769,6 +783,7 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op)
else {
gps->points->flag |= GP_SPOINT_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
/* deselect rest? */
if ((extend == false) && (gps->totpoints > 1)) {
@@ -863,6 +878,7 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op)
BEZT_SEL_ALL(&gpc->curve_points[gpc->tot_curve_points - 1].bezt);
gpc->flag |= GP_CURVE_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
if ((extend == false) && (gps->totpoints > 1)) {
for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -876,6 +892,7 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op)
else {
gps->points[gps->totpoints - 1].flag |= GP_SPOINT_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
/* deselect rest? */
if ((extend == false) && (gps->totpoints > 1)) {
@@ -1272,10 +1289,12 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *gpd,
if (select) {
pt_active->flag |= GP_SPOINT_SELECT;
gps_active->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps_active, false);
}
else {
pt_active->flag &= ~GP_SPOINT_SELECT;
gps_active->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps_active, true);
}
changed = true;
/* if stroke mode, don't check more points */
@@ -1314,13 +1333,13 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *gpd,
BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps_active);
gps_active->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
/* Select all curve points. */
- select_all_curve_points(gps_active, gps_active->editcurve, false);
+ select_all_curve_points(gpd, gps_active, gps_active->editcurve, false);
BKE_gpencil_stroke_geometry_update(gpd, gps_active);
changed = true;
}
/* Ensure that stroke selection is in sync with its points. */
- BKE_gpencil_stroke_sync_selection(gps_active);
+ BKE_gpencil_stroke_sync_selection(gpd, gps_active);
return changed;
}
@@ -1338,6 +1357,9 @@ static bool gpencil_do_curve_circle_sel(bContext *C,
{
ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
+ Object *ob = CTX_data_active_object(C);
+ bGPdata *gpd = ob->data;
+
const bool only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED);
bool hit = false;
@@ -1411,7 +1433,7 @@ static bool gpencil_do_curve_circle_sel(bContext *C,
}
}
- BKE_gpencil_curve_sync_selection(gps);
+ BKE_gpencil_curve_sync_selection(gpd, gps);
return hit;
}
@@ -1631,7 +1653,7 @@ static bool gpencil_stroke_fill_isect_rect(ARegion *region,
#endif
static bool gpencil_generic_curve_select(bContext *C,
- Object *UNUSED(ob),
+ Object *ob,
GPencilTestFn is_inside_fn,
rcti UNUSED(box),
GP_SelectUserData *user_data,
@@ -1640,6 +1662,7 @@ static bool gpencil_generic_curve_select(bContext *C,
{
ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
+ bGPdata *gpd = ob->data;
const bool handle_only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED);
const bool handle_all = (v3d->overlay.handle_display == CURVE_HANDLE_ALL);
@@ -1771,7 +1794,7 @@ static bool gpencil_generic_curve_select(bContext *C,
}
}
- BKE_gpencil_curve_sync_selection(gps);
+ BKE_gpencil_curve_sync_selection(gpd, gps);
}
GP_EDITABLE_CURVES_END(gps_iter);
@@ -1797,6 +1820,8 @@ static bool gpencil_generic_stroke_select(bContext *C,
/* deselect all strokes first? */
if (SEL_OP_USE_PRE_DESELECT(sel_op) || (GPENCIL_PAINT_MODE(gpd))) {
+ /* Set selection index to 0. */
+ gpd->select_last_index = 0;
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
bGPDspoint *pt;
@@ -1807,6 +1832,7 @@ static bool gpencil_generic_stroke_select(bContext *C,
}
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
}
CTX_DATA_END;
@@ -1891,13 +1917,13 @@ static bool gpencil_generic_stroke_select(bContext *C,
BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps_active);
gps_active->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
/* Select all curve points. */
- select_all_curve_points(gps_active, gps_active->editcurve, false);
+ select_all_curve_points(gpd, gps_active, gps_active->editcurve, false);
BKE_gpencil_stroke_geometry_update(gpd, gps_active);
changed = true;
}
/* Ensure that stroke selection is in sync with its points */
- BKE_gpencil_stroke_sync_selection(gps_active);
+ BKE_gpencil_stroke_sync_selection(gpd, gps_active);
}
GP_EVALUATED_STROKES_END(gpstroke_iter);
@@ -2313,7 +2339,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
}
/* select all curve points */
if (hit_curve != NULL) {
- select_all_curve_points(hit_stroke, hit_curve, deselect);
+ select_all_curve_points(gpd, hit_stroke, hit_curve, deselect);
}
else {
bGPDspoint *pt;
@@ -2332,9 +2358,11 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* stroke too... */
if (deselect == false) {
hit_stroke->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, hit_stroke, false);
}
else {
hit_stroke->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, hit_stroke, true);
}
}
}
@@ -2346,11 +2374,13 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
BEZT_SEL_IDX(&hit_curve_point->bezt, hit_curve_handle);
hit_curve->flag |= GP_CURVE_SELECT;
hit_stroke->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, hit_stroke, false);
}
else {
/* we're adding selection, so selection must be true */
hit_point->flag |= GP_SPOINT_SELECT;
hit_stroke->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, hit_stroke, false);
/* expand selection to segment */
int selectmode;
@@ -2378,14 +2408,14 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
if (!BEZT_ISSEL_ANY(&hit_curve_point->bezt)) {
hit_curve_point->flag &= ~GP_CURVE_POINT_SELECT;
}
- BKE_gpencil_curve_sync_selection(hit_stroke);
+ BKE_gpencil_curve_sync_selection(gpd, hit_stroke);
}
else {
/* deselect point */
hit_point->flag &= ~GP_SPOINT_SELECT;
/* ensure that stroke is selected correctly */
- BKE_gpencil_stroke_sync_selection(hit_stroke);
+ BKE_gpencil_stroke_sync_selection(gpd, hit_stroke);
}
}
}
@@ -2572,6 +2602,7 @@ static int gpencil_select_vertex_color_exec(bContext *C, wmOperator *op)
if (gps_selected) {
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
/* Extend stroke selection. */
if (selectmode == GP_SELECTMODE_STROKE) {