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/blenkernel/intern
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/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/gpencil.c28
-rw-r--r--source/blender/blenkernel/intern/gpencil_curve.c12
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c1
-rw-r--r--source/blender/blenkernel/intern/scene.c2
4 files changed, 35 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 1aec1ad296d..4167f60e880 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1134,7 +1134,7 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
* Ensure selection status of stroke is in sync with its points.
* \param gps: Grease pencil stroke
*/
-void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
+void BKE_gpencil_stroke_sync_selection(bGPdata *gpd, bGPDstroke *gps)
{
bGPDspoint *pt;
int i;
@@ -1148,6 +1148,7 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
* so initially, we must deselect
*/
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
@@ -1155,9 +1156,13 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
break;
}
}
+
+ if (gps->flag & GP_STROKE_SELECT) {
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+ }
}
-void BKE_gpencil_curve_sync_selection(bGPDstroke *gps)
+void BKE_gpencil_curve_sync_selection(bGPdata *gpd, bGPDstroke *gps)
{
bGPDcurve *gpc = gps->editcurve;
if (gpc == NULL) {
@@ -1165,6 +1170,7 @@ void BKE_gpencil_curve_sync_selection(bGPDstroke *gps)
}
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
gpc->flag &= ~GP_CURVE_SELECT;
bool is_selected = false;
@@ -1187,6 +1193,19 @@ void BKE_gpencil_curve_sync_selection(bGPDstroke *gps)
if (is_selected) {
gpc->flag |= GP_CURVE_SELECT;
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+ }
+}
+
+/* Assign unique stroke ID for selection. */
+void BKE_gpencil_stroke_select_index_set(bGPdata *gpd, bGPDstroke *gps, const bool reset)
+{
+ if (!reset) {
+ gpd->select_last_index++;
+ gps->select_index = gpd->select_last_index;
+ }
+ else {
+ gps->select_index = 0;
}
}
@@ -2512,6 +2531,11 @@ bool BKE_gpencil_from_image(
pt->flag |= GP_SPOINT_SELECT;
}
}
+
+ if (gps->flag & GP_STROKE_SELECT) {
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+ }
+
BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index be14d74de7a..6707fb53aa3 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -781,7 +781,7 @@ void BKE_gpencil_stroke_editcurve_update(bGPdata *gpd, bGPDlayer *gpl, bGPDstrok
/**
* Sync the selection from stroke to editcurve
*/
-void BKE_gpencil_editcurve_stroke_sync_selection(bGPDstroke *gps, bGPDcurve *gpc)
+void BKE_gpencil_editcurve_stroke_sync_selection(bGPdata *gpd, bGPDstroke *gps, bGPDcurve *gpc)
{
if (gps->flag & GP_STROKE_SELECT) {
gpc->flag |= GP_CURVE_SELECT;
@@ -808,10 +808,11 @@ void BKE_gpencil_editcurve_stroke_sync_selection(bGPDstroke *gps, bGPDcurve *gpc
/**
* Sync the selection from editcurve to stroke
*/
-void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc)
+void BKE_gpencil_stroke_editcurve_sync_selection(bGPdata *gpd, bGPDstroke *gps, bGPDcurve *gpc)
{
if (gpc->flag & GP_CURVE_SELECT) {
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -865,6 +866,7 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc
}
else {
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
pt->flag &= ~GP_SPOINT_SELECT;
@@ -1089,6 +1091,7 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps,
/* deselect */
pt->flag &= ~GP_SPOINT_SELECT;
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
return;
}
@@ -1131,6 +1134,7 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps,
pt->flag &= ~GP_SPOINT_SELECT;
}
gps->flag &= ~GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(NULL, gps, true);
/* free temp data */
MEM_freeN(points);
@@ -1375,7 +1379,7 @@ void BKE_gpencil_strokes_selected_update_editcurve(bGPdata *gpd)
BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
}
/* Update the selection from the stroke to the curve. */
- BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve);
+ BKE_gpencil_editcurve_stroke_sync_selection(gpd, gps, gps->editcurve);
gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
BKE_gpencil_stroke_geometry_update(gpd, gps);
@@ -1400,7 +1404,7 @@ void BKE_gpencil_strokes_selected_sync_selection_editcurve(bGPdata *gpd)
bGPDcurve *gpc = gps->editcurve;
if (gpc != NULL) {
/* Update the selection of every stroke that has an editcurve */
- BKE_gpencil_stroke_editcurve_sync_selection(gps, gpc);
+ BKE_gpencil_stroke_editcurve_sync_selection(gpd, gps, gpc);
}
}
}
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 2ef85439a46..2d10645a467 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -3444,6 +3444,7 @@ void BKE_gpencil_stroke_uniform_subdivide(bGPdata *gpd,
if (select) {
gps->flag |= GP_STROKE_SELECT;
+ BKE_gpencil_stroke_select_index_set(gpd, gps, false);
}
/* Free the sample points. Important to use the mutable loop here because we are erasing the list
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 25951fa3e6f..c7279dbc815 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -167,8 +167,6 @@ static void scene_init_data(ID *id)
&gp_primitive_curve->clipr,
CURVE_PRESET_BELL,
CURVEMAP_SLOPE_POSITIVE);
- /* Grease pencil interpolate. */
- scene->toolsettings->gp_interpolate.step = 1;
scene->unit.system = USER_UNIT_METRIC;
scene->unit.scale_length = 1.0f;