[Bf-blender-cvs] [c787419600f] greasepencil-object: WIP: Implement new cuve for multiframe falloff
Antonio Vazquez
noreply at git.blender.org
Thu Nov 30 20:13:35 CET 2017
Commit: c787419600f303b6d10fd7410a3f71eb260c3926
Author: Antonio Vazquez
Date: Thu Nov 30 17:34:48 2017 +0100
Branches: greasepencil-object
https://developer.blender.org/rBc787419600f303b6d10fd7410a3f71eb260c3926
WIP: Implement new cuve for multiframe falloff
Still need to define curve with bell shape and apply the falloff to multiedit.
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/intern/scene.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/blenloader/intern/writefile.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index a9ba46d55c8..377736fa5cb 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -509,6 +509,38 @@ class GreasePencilStrokeSculptPanel:
layout.prop(brush, "affect_pressure")
+class GreasePencilMultiFramePanel:
+ bl_label = "Multiframe"
+ bl_category = "Tools"
+ bl_region_type = 'TOOLS'
+
+ @classmethod
+ def poll(cls, context):
+ if context.gpencil_data is None:
+ return False
+
+ gpd = context.gpencil_data
+ if context.editable_gpencil_strokes:
+ is_3d_view = context.space_data.type == 'VIEW_3D'
+ if is_3d_view:
+ return bool(gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode)
+
+ return False
+
+ @staticmethod
+ def draw(self, context):
+ layout = self.layout
+ settings = context.tool_settings.gpencil_sculpt
+
+ row = layout.row()
+ row.prop(settings, "use_multiframe_falloff")
+
+ # Falloff curve
+ layout.label("Falloff")
+ box = layout.box()
+ box.template_curve_mapping(settings, "multiframe_falloff_curve", brush=True)
+
+
class GreasePencilAppearancePanel:
bl_label = "Appearance"
bl_category = "Options"
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index cf45fb873cc..dfc7c1b52ae 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -25,6 +25,7 @@ from .properties_grease_pencil_common import (
GreasePencilAnimationPanel,
GreasePencilInterpolatePanel,
GreasePencilStrokeSculptPanel,
+ GreasePencilMultiFramePanel,
GreasePencilBrushPanel,
GreasePencilBrushOptionsPanel,
GreasePencilBrushCurvesPanel,
@@ -2071,6 +2072,11 @@ class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel)
bl_space_type = 'VIEW_3D'
+# Grease Pencil multiframe falloff tools
+class VIEW3D_PT_tools_grease_pencil_falloff(GreasePencilMultiFramePanel, Panel):
+ bl_space_type = 'VIEW_3D'
+
+
# Grease Pencil drawing brushes
class VIEW3D_PT_tools_grease_pencil_brush(GreasePencilBrushPanel, Panel):
bl_space_type = 'VIEW_3D'
@@ -2122,6 +2128,7 @@ classes = (
VIEW3D_PT_tools_add_object,
VIEW3D_PT_tools_grease_pencil_edit,
VIEW3D_PT_tools_grease_pencil_sculpt,
+ VIEW3D_PT_tools_grease_pencil_falloff,
VIEW3D_PT_tools_grease_pencil_brush,
VIEW3D_PT_tools_grease_pencil_brush_option,
VIEW3D_PT_tools_grease_pencil_brushcurves,
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 36c34eb4bdd..7c7fa2b9cfa 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -373,6 +373,8 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
/* duplicate Grease Pencil interpolation curve */
ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo);
+ /* duplicate Grease Pencil multiframe fallof */
+ ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff);
}
/* make a private copy of the avicodecdata */
@@ -486,6 +488,8 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
/* duplicate Grease Pencil interpolation curve */
ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo);
+ /* duplicate Grease Pencil multiframe fallof */
+ ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff);
}
/* make a private copy of the avicodecdata */
@@ -636,7 +640,11 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
if (sce->toolsettings->gp_interpolate.custom_ipo) {
curvemapping_free(sce->toolsettings->gp_interpolate.custom_ipo);
}
-
+ /* free Grease Pencil multiframe falloff curve */
+ if (sce->toolsettings->gp_sculpt.cur_falloff) {
+ curvemapping_free(sce->toolsettings->gp_sculpt.cur_falloff);
+ }
+
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;
}
@@ -856,6 +864,16 @@ void BKE_scene_init(Scene *sce)
sce->toolsettings->imapaint.normal_angle = 80;
sce->toolsettings->imapaint.seam_bleed = 2;
+ /* grease pencil multiframe falloff curve */
+ sce->toolsettings->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ CurveMapping *gp_falloff_curve = sce->toolsettings->gp_sculpt.cur_falloff;
+ curvemapping_set_defaults(gp_falloff_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(gp_falloff_curve);
+ curvemap_reset(gp_falloff_curve->cm,
+ &gp_falloff_curve->clipr,
+ CURVE_PRESET_ROUND,
+ CURVEMAP_SLOPE_POSITIVE);
+
sce->physics_settings.gravity[0] = 0.0f;
sce->physics_settings.gravity[1] = 0.0f;
sce->physics_settings.gravity[2] = -9.81f;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 715105b2f34..8815c26ca2a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6266,6 +6266,11 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
if (sce->toolsettings->gp_interpolate.custom_ipo) {
direct_link_curvemapping(fd, sce->toolsettings->gp_interpolate.custom_ipo);
}
+ /* relink grease pencil multiframe falloff curve */
+ sce->toolsettings->gp_sculpt.cur_falloff = newdataadr(fd, sce->toolsettings->gp_sculpt.cur_falloff);
+ if (sce->toolsettings->gp_sculpt.cur_falloff) {
+ direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_falloff);
+ }
}
if (sce->ed) {
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 907cf857eb4..f1b1dc95f77 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -53,6 +53,7 @@
#include "BKE_collection.h"
#include "BKE_customdata.h"
+#include "BKE_colortools.h"
#include "BKE_freestyle.h"
#include "BKE_idprop.h"
#include "BKE_layer.h"
@@ -887,6 +888,22 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
+ /* Grease pencil multiframe falloff curve */
+ if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "CurveMapping", "cur_falloff")) {
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ /* sculpt brushes */
+ GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+ if (gset) {
+ gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ curvemapping_initialize(gset->cur_falloff);
+ curvemap_reset(gset->cur_falloff->cm,
+ &gset->cur_falloff->clipr,
+ CURVE_PRESET_MID9,
+ CURVEMAP_SLOPE_POSITIVE);
+ }
+ }
+ }
+
if (!DNA_struct_elem_find(fd->filesdna, "bGPDbrush", "float", "curcolor[3]")) {
float curcolor[3], curcolor_add[3], curcolor_sub[3];
ARRAY_SET_ITEMS(curcolor, 1.0f, 1.0f, 1.0f);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 6cab3e245e5..dd243ae8b3b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2673,7 +2673,10 @@ static void write_scene(WriteData *wd, Scene *sce)
if (tos->gp_interpolate.custom_ipo) {
write_curvemapping(wd, tos->gp_interpolate.custom_ipo);
}
-
+ /* write grease-pencil multiframe falloff curve to file */
+ if (tos->gp_sculpt.cur_falloff) {
+ write_curvemapping(wd, tos->gp_sculpt.cur_falloff);
+ }
write_paint(wd, &tos->imapaint.paint);
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 500d01a179f..2c797e1766d 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1209,6 +1209,7 @@ typedef struct GP_BrushEdit_Settings {
*/
int weighttype; /* eGP_EditBrush_Types (weight paint) */
char pad[4];
+ struct CurveMapping *cur_falloff; /* multiframe edit falloff effect by frame */
} GP_BrushEdit_Settings;
/* GP_BrushEdit_Settings.flag */
@@ -1223,6 +1224,8 @@ typedef enum eGP_BrushEdit_SettingsFlag {
GP_BRUSHEDIT_FLAG_APPLY_THICKNESS = (1 << 3),
/* apply brush to thickness */
GP_BRUSHEDIT_FLAG_WEIGHT_MODE = (1 << 4),
+ /* apply brush to thickness */
+ GP_BRUSHEDIT_FLAG_FRAME_FALLOFF = (1 << 5),
} eGP_BrushEdit_SettingsFlag;
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index f3dba7f4539..ef64b10293e 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -1092,13 +1092,25 @@ 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, "selection_alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "alpha");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Alpha", "Alpha value for selected vertices");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "use_multiframe_falloff", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSHEDIT_FLAG_FRAME_FALLOFF);
+ RNA_def_property_ui_text(prop, "Use Falloff", "Use falloff effect when edit in multiframe mode to compute brush effect by frame");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ /* custom falloff curve */
+ prop = RNA_def_property(srna, "multiframe_falloff_curve", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "cur_falloff");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Curve",
+ "Custom curve to control falloff of brush effec
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list