GP Interpolate: Move settings from "gp_sculpt" to a new toolsettings struct - "gp_interpolate"

The "gp_sculpt" settings should be strictly for stroke sculpting, and not abused by
other tools. (Similarly, if other general GP tools need one-off options, those should
go into the normal toolsettings->gpencil_flag)

Furthermore, this paves the way for introducing new settings for controlling the way
that GP interpolation takes place (e.g. with easing equations, or a custom curvemap)
This commit is contained in:
Joshua Leung
2017-01-18 16:43:17 +13:00
parent 4903a83235
commit 224ae23443
6 changed files with 99 additions and 31 deletions

View File

@@ -227,12 +227,7 @@ class GreasePencilStrokeEditPanel:
if is_3d_view:
layout.separator()
col = layout.column(align=True)
col.operator("gpencil.interpolate", text="Interpolate")
col.operator("gpencil.interpolate_sequence", text="Sequence")
settings = context.tool_settings.gpencil_sculpt
col.prop(settings, "interpolate_all_layers")
col.prop(settings, "interpolate_selected_only")
layout.separator()
col = layout.column(align=True)
@@ -249,6 +244,35 @@ class GreasePencilStrokeEditPanel:
layout.separator()
layout.operator("gpencil.reproject")
class GreasePencilInterpolatePanel:
# subclass must set
bl_space_type = 'VIEW_3D'
bl_label = "Interpolate..."
bl_category = "Grease Pencil"
bl_region_type = 'TOOLS'
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
if context.gpencil_data is None:
return False
elif context.space_data.type != 'VIEW_3D':
return False
gpd = context.gpencil_data
return bool(context.editable_gpencil_strokes) and bool(gpd.use_stroke_edit_mode)
@staticmethod
def draw(self, context):
layout = self.layout
settings = context.tool_settings.gpencil_interpolate
col = layout.column(align=True)
col.operator("gpencil.interpolate", text="Interpolate")
col.operator("gpencil.interpolate_sequence", text="Sequence")
col.prop(settings, "interpolate_all_layers")
col.prop(settings, "interpolate_selected_only")
class GreasePencilBrushPanel:
# subclass must set

View File

@@ -160,12 +160,12 @@ static void gp_interpolate_update_strokes(bContext *C, tGPDinterpolate *tgpi)
static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
{
ToolSettings *ts = CTX_data_tool_settings(C);
int flag = ts->gp_sculpt.flag;
eGP_Interpolate_SettingsFlag flag = ts->gp_interpolate.flag;
/* get layers */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* all layers or only active */
if (!(flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS) && !(gpl->flag & GP_LAYER_ACTIVE)) {
if (!(flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) && !(gpl->flag & GP_LAYER_ACTIVE)) {
continue;
}
/* only editable and visible layers are considered */
@@ -179,7 +179,7 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd)
int fFrame;
/* only selected */
if ((flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
continue;
}
/* skip strokes that are invalid for current view */
@@ -223,7 +223,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
tGPDinterpolate_layer *tgpil;
/* all layers or only active */
if (!(tgpi->flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS) && (gpl != active_gpl)) {
if (!(tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) && (gpl != active_gpl)) {
continue;
}
/* only editable and visible layers are considered */
@@ -257,7 +257,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
/* only selected */
if ((tgpi->flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
if ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
valid = false;
}
/* skip strokes that are invalid for current view */
@@ -424,7 +424,7 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte
tgpi->scene = CTX_data_scene(C);
tgpi->sa = CTX_wm_area(C);
tgpi->ar = CTX_wm_region(C);
tgpi->flag = ts->gp_sculpt.flag;
tgpi->flag = ts->gp_interpolate.flag;
/* set current frame number */
tgpi->cframe = tgpi->scene->r.cfra;
@@ -689,7 +689,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = CTX_data_tool_settings(C);
int flag = ts->gp_sculpt.flag;
GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
eGP_Interpolate_SettingsFlag flag = ipo_settings->flag;
/* cannot interpolate if not between 2 frames */
if (ELEM(NULL, actframe, actframe->next)) {
@@ -709,7 +710,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
int cframe, fFrame;
/* all layers or only active */
if (((flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) {
if (((flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) {
continue;
}
/* only editable and visible layers are considered */
@@ -734,7 +735,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
bGPDstroke *new_stroke;
/* only selected */
if ((flag & GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
continue;
}
/* skip strokes that are invalid for current view */

View File

@@ -1212,13 +1212,23 @@ typedef enum eGP_BrushEdit_SettingsFlag {
GP_BRUSHEDIT_FLAG_APPLY_STRENGTH = (1 << 2),
/* apply brush to thickness */
GP_BRUSHEDIT_FLAG_APPLY_THICKNESS = (1 << 3),
/* apply interpolation to all layers */
GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS = (1 << 4),
/* apply interpolation to only selected */
GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED = (1 << 5)
} eGP_BrushEdit_SettingsFlag;
/* Settings for GP Interpolation Operators */
typedef struct GP_Interpolate_Settings {
short flag; /* eGP_Interpolate_SettingsFlag */
} GP_Interpolate_Settings;
/* GP_Interpolate_Settings.flag */
typedef enum eGP_Interpolate_SettingsFlag {
/* apply interpolation to all layers */
GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS = (1 << 0),
/* apply interpolation to only selected */
GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED = (1 << 1),
} eGP_Interpolate_SettingsFlag;
/* *************************************************************** */
/* Transform Orientations */
@@ -1435,7 +1445,10 @@ typedef struct ToolSettings {
/* Grease Pencil Sculpt */
struct GP_BrushEdit_Settings gp_sculpt;
/* Grease Pencil Interpolation Tool(s) */
struct GP_Interpolate_Settings gp_interpolate;
/* Grease Pencil Drawing Brushes (bGPDbrush) */
ListBase gp_brushes;

View File

@@ -262,6 +262,7 @@ extern StructRNA RNA_GPencilLayer;
extern StructRNA RNA_GPencilPalette;
extern StructRNA RNA_GPencilPaletteColor;
extern StructRNA RNA_GPencilBrush;
extern StructRNA RNA_GPencilInterpolateSettings;
extern StructRNA RNA_GPencilStroke;
extern StructRNA RNA_GPencilStrokePoint;
extern StructRNA RNA_GPencilSculptSettings;

View File

@@ -447,6 +447,12 @@ EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
#include "FRS_freestyle.h"
#endif
/* Grease Pencil Interpolation settings */
static char *rna_GPencilInterpolateSettings_path(PointerRNA *UNUSED(ptr))
{
return BLI_strdup("tool_settings.gpencil_interpolate");
}
/* Grease pencil Drawing Brushes */
static bGPDbrush *rna_GPencil_brush_new(ToolSettings *ts, const char *name, int setactive)
{
@@ -2138,6 +2144,30 @@ static int rna_gpu_is_hq_supported_get(PointerRNA *UNUSED(ptr))
#else
/* Grease Pencil Interpolation tool settings */
static void rna_def_gpencil_interpolate(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "GPencilInterpolateSettings", NULL);
RNA_def_struct_sdna(srna, "GP_Interpolate_Settings");
RNA_def_struct_path_func(srna, "rna_GPencilInterpolateSettings_path");
RNA_def_struct_ui_text(srna, "Grease Pencil Interpolate Settings",
"Settings for Grease Pencil interpolation tools");
/* flags */
prop = RNA_def_property(srna, "interpolate_all_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS);
RNA_def_property_ui_text(prop, "Interpolate All Layers", "Interpolate all layers, not only active");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "interpolate_selected_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED);
RNA_def_property_ui_text(prop, "Interpolate Selected Strokes", "Interpolate only selected strokes in the original frame");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
}
/* Grease Pencil Drawing Brushes */
static void rna_def_gpencil_brush(BlenderRNA *brna)
{
@@ -2673,7 +2703,14 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "gp_sculpt");
RNA_def_property_struct_type(prop, "GPencilSculptSettings");
RNA_def_property_ui_text(prop, "Grease Pencil Sculpt", "");
RNA_def_property_ui_text(prop, "Grease Pencil Sculpt",
"Settings for stroke sculpting tools and brushes");
prop = RNA_def_property(srna, "gpencil_interpolate", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "gp_interpolate");
RNA_def_property_struct_type(prop, "GPencilInterpolateSettings");
RNA_def_property_ui_text(prop, "Grease Pencil Interpolate",
"Settings for Grease Pencil Interpolation tools");
/* Grease Pencil - Drawing brushes */
prop = RNA_def_property(srna, "gpencil_brushes", PROP_COLLECTION, PROP_NONE);
@@ -7267,6 +7304,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_define_animate_sdna(false);
rna_def_tool_settings(brna);
rna_def_gpencil_brush(brna);
rna_def_gpencil_interpolate(brna);
rna_def_unified_paint_settings(brna);
rna_def_curve_paint_settings(brna);
rna_def_statvis(brna);

View File

@@ -1047,15 +1047,6 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Affect Thickness", "The brush affects the thickness of the point");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "interpolate_all_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_INTERPOLATE_ALL_LAYERS);
RNA_def_property_ui_text(prop, "Interpolate All Layers", "Interpolate all layers, not only active");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "interpolate_selected_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_INTERPOLATE_ONLY_SELECTED);
RNA_def_property_ui_text(prop, "Interpolate Selected Strokes", "Interpolate only selected strokes in the original frame");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "selection_alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "alpha");