[Bf-blender-cvs] [65ecbc3c257] temp-gpencil-interpolate: GPencil: Change sequence operator and other UI changes
Antonio Vazquez
noreply at git.blender.org
Tue Dec 22 17:05:15 CET 2020
Commit: 65ecbc3c2578d9e3f1206093d338e627a11f8132
Author: Antonio Vazquez
Date: Tue Dec 22 17:05:11 2020 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rB65ecbc3c2578d9e3f1206093d338e627a11f8132
GPencil: Change sequence operator and other UI changes
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenloader/intern/versioning_290.c
M source/blender/editors/gpencil/gpencil_interpolate.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index f8c27e330ac..6d6f59de36e 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2117,7 +2117,7 @@ class _defs_gpencil_edit:
def draw_settings(context, layout, tool):
props = tool.operator_properties("gpencil.interpolate")
row = layout.row()
- row.prop(props, "interpolate_all_layers")
+ row.prop(props, "layers")
row.prop(props, "interpolate_selected_only")
row.prop(props, "flip")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index c7aa293f06d..7711a58b3c2 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1690,32 +1690,9 @@ class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
def draw(self, context):
layout = self.layout
settings = context.tool_settings.gpencil_interpolate
-
- col = layout.column(align=True)
- # col.label(text="Interpolate Strokes")
- # col.operator("gpencil.interpolate_sequence", text="Sequence")
- # col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
-
col = layout.column(align=True)
- # col.label(text="Options:")
- gpd = context.gpencil_data
-
- col = layout.column(align=True)
- col.label(text="Sequence Options:")
- col.prop(settings, "type")
- if settings.type == 'CUSTOM':
- # TODO: Options for loading/saving curve presets?
- col.template_curve_mapping(settings, "interpolation_curve", brush=True,
- use_negative_slope=True)
- elif settings.type != 'LINEAR':
- col.prop(settings, "easing")
-
- if settings.type == 'BACK':
- layout.prop(settings, "back")
- elif settings.type == 'ELASTIC':
- sub = layout.column(align=True)
- sub.prop(settings, "amplitude")
- sub.prop(settings, "period")
+ col.template_curve_mapping(settings, "interpolation_curve", brush=True,
+ use_negative_slope=True)
# Grease Pencil stroke sculpting tools
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index cd5939b7e63..336ed2bc8ac 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -996,14 +996,6 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Set the minimum sequence interpolate for grease pencil. */
- if (!DNA_struct_elem_find(fd->filesdna, "GP_Interpolate_Settings", "int", "step")) {
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
- ToolSettings *ts = scene->toolsettings;
- ts->gp_interpolate.step = 1;
- }
- }
-
/* Hair and PointCloud attributes. */
for (Hair *hair = bmain->hairs.first; hair != NULL; hair = hair->id.next) {
do_versions_point_attributes(&hair->pdata);
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 9cdc2737207..9b52b694f69 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -523,9 +523,8 @@ static bool gpencil_interpolate_set_init_values(bContext *C, wmOperator *op, tGP
/* set interpolation weight */
tgpi->shift = RNA_float_get(op->ptr, "shift");
- SET_FLAG_FROM_TEST(tgpi->flag,
- RNA_boolean_get(op->ptr, "interpolate_all_layers"),
- GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS);
+ SET_FLAG_FROM_TEST(
+ tgpi->flag, (RNA_enum_get(op->ptr, "layers") == 1), GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS);
SET_FLAG_FROM_TEST(tgpi->flag,
RNA_boolean_get(op->ptr, "interpolate_selected_only"),
GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED);
@@ -763,6 +762,12 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
+ static const EnumPropertyItem gpencil_interpolation_layer_items[] = {
+ {0, "ACTIVE", 0, "Active", ""},
+ {1, "ALL", 0, "All Layers", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
/* properties */
RNA_def_float_percentage(
ot->srna,
@@ -775,11 +780,12 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
-0.9f,
0.9f);
- RNA_def_boolean(ot->srna,
- "interpolate_all_layers",
- 0,
- "All Layers",
- "Interpolate all layers, not only active");
+ RNA_def_enum(ot->srna,
+ "layers",
+ gpencil_interpolation_layer_items,
+ 0,
+ "Layer",
+ "Layers included in the interpolation");
RNA_def_boolean(ot->srna,
"interpolate_selected_only",
@@ -800,20 +806,22 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot)
/* ****************** Interpolate Sequence *********************** */
/* Helper: Perform easing equation calculations for GP interpolation operator */
-static float gpencil_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_settings, float time)
+static float gpencil_interpolate_seq_easing_calc(wmOperator *op,
+ GP_Interpolate_Settings *ipo_settings,
+ float time)
{
const float begin = 0.0f;
const float change = 1.0f;
const float duration = 1.0f;
- const float back = ipo_settings->back;
- const float amplitude = ipo_settings->amplitude;
- const float period = ipo_settings->period;
+ const float back = RNA_float_get(op->ptr, "back");
+ const float amplitude = RNA_float_get(op->ptr, "amplitude");
+ const float period = RNA_float_get(op->ptr, "period");
+ const eBezTriple_Easing easing = RNA_enum_get(op->ptr, "easing");
- eBezTriple_Easing easing = ipo_settings->easing;
float result = time;
- switch (ipo_settings->type) {
+ switch (RNA_enum_get(op->ptr, "type")) {
case GP_IPO_BACK:
switch (easing) {
case BEZT_IPO_EASE_IN:
@@ -996,7 +1004,7 @@ static float gpencil_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_se
break;
default:
- printf("%s: Unknown interpolation type - %d\n", __func__, ipo_settings->type);
+ printf("%s: Unknown interpolation type\n", __func__);
break;
}
@@ -1015,8 +1023,14 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
const int step = RNA_int_get(op->ptr, "step");
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
- const bool all_layers = RNA_boolean_get(op->ptr, "interpolate_all_layers");
+ const bool all_layers = (bool)(RNA_enum_get(op->ptr, "layers") == 1);
const bool only_selected = RNA_boolean_get(op->ptr, "interpolate_selected_only");
+ const int type = RNA_enum_get(op->ptr, "type");
+
+ if (ipo_settings->custom_ipo == NULL) {
+ ipo_settings->custom_ipo = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ }
+ BKE_curvemapping_init(ipo_settings->custom_ipo);
/* Cannot interpolate if not between 2 frames. */
bGPDframe *gpf_prv = gpencil_get_previous_keyframe(active_gpl, cfra);
@@ -1092,7 +1106,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
CLAMP_MIN(framerange, 1.0f);
float factor = (float)(cframe - prevFrame->framenum) / framerange;
- if (ipo_settings->type == GP_IPO_CURVEMAP) {
+ if (type == GP_IPO_CURVEMAP) {
/* custom curvemap */
if (ipo_settings->custom_ipo) {
factor = BKE_curvemapping_evaluateF(ipo_settings->custom_ipo, 0, factor);
@@ -1102,9 +1116,9 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
continue;
}
}
- else if (ipo_settings->type >= GP_IPO_BACK) {
+ else if (type >= GP_IPO_BACK) {
/* easing equation... */
- factor = gpencil_interpolate_seq_easing_calc(ipo_settings, factor);
+ factor = gpencil_interpolate_seq_easing_calc(op, ipo_settings, factor);
}
/* Apply the factor to all pair of strokes. */
@@ -1161,8 +1175,142 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static void gpencil_interpolate_seq_ui(bContext *C, wmOperator *op)
+{
+ uiLayout *layout = op->layout;
+ uiLayout *col, *row;
+ PointerRNA ptr;
+
+ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+
+ int type = RNA_enum_get(&ptr, "type");
+
+ uiLayoutSetPropSep(layout, true);
+ uiLayoutSetPropDecorate(layout, false);
+
+ col = uiLayoutColumn(layout, true);
+ uiItemR(col, &ptr, "step", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "layers", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "interpolate_selected_only", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "flip", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "type", 0, NULL, ICON_NONE);
+
+ if (type == GP_IPO_CURVEMAP) {
+ /* Get an RNA pointer to ToolSettings to give to the custom curve. */
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
+ PointerRNA gpsettings_ptr;
+ RNA_pointer_create(
+ &scene->id, &RNA_GPencilInterpolateSettings, &ts->gp_interpolate, &gpsettings_ptr);
+ uiTemplateCurveProfile(layout, &gpsettings_ptr, "interpolation_curve");
+
+ // PointerRNA toolsettings_ptr;
+ // RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
+ // uiTemplateCurveProfile(layout, &toolsettings_ptr, "custom_bevel_profile_preset");
+ }
+ else if (type != GP_IPO_LINEAR) {
+ row = uiLayoutRow(layout, false);
+ uiItemR(row, &ptr, "easing", 0, NULL, ICON_NONE);
+ if (type == GP_IPO_BACK) {
+ row = uiLayoutRow(layout, fals
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list