[Bf-blender-cvs] [fc97baf73a6] greasepencil-object: GP: Fix problems with primitive curve and add to Topbar

Antonioya noreply at git.blender.org
Fri Dec 7 12:49:24 CET 2018


Commit: fc97baf73a679c76cf48dcfba3e940a505d5049c
Author: Antonioya
Date:   Fri Dec 7 12:49:12 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBfc97baf73a679c76cf48dcfba3e940a505d5049c

GP: Fix problems with primitive curve and add to Topbar

===================================================================

M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 69e96d9d196..6d2e3aefb33 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -375,6 +375,17 @@ class _draw_left_context_mode:
 
                 draw_color_selector()
 
+                if tool.name == "Bezier":
+                    settings = context.tool_settings.gpencil_sculpt
+                    row = layout.row(align=True)
+                    row.prop(settings, "use_thickness_curve", text="", icon='CURVE_DATA')
+                    sub = row.row(align=True)
+                    sub.active = settings.use_thickness_curve
+                    sub.popover(
+                        panel="TOPBAR_PT_gpencil_primitive",
+                        text="Curve"
+                    )
+
         @staticmethod
         def GPENCIL_SCULPT(context, layout, tool):
             if (tool is None) or (not tool.has_datablock):
@@ -1031,6 +1042,25 @@ class TOPBAR_PT_active_tool(Panel):
         ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
 
 
+# Grease Pencil Object - Primitive curve
+class TOPBAR_PT_gpencil_primitive(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'HEADER'
+    bl_label = "Primitives"
+
+    @staticmethod
+    def draw(self, context):
+        settings = context.tool_settings.gpencil_sculpt
+
+        layout = self.layout
+        col = layout.column(align=True)
+        col.prop(settings, "use_thickness_curve")
+
+        # Curve
+        if settings.use_thickness_curve:
+            layout.template_curve_mapping(settings, "thickness_primitive_curve", brush=True)
+
+
 classes = (
     TOPBAR_HT_upper_bar,
     TOPBAR_HT_lower_bar,
@@ -1051,6 +1081,7 @@ classes = (
     TOPBAR_MT_help,
     TOPBAR_PT_active_tool,
     TOPBAR_PT_gpencil_layers,
+    TOPBAR_PT_gpencil_primitive,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 053ca38a57c..4c00ebe2bb3 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -188,6 +188,7 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag)
 	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);
+	ts->gp_sculpt.cur_primitive = curvemapping_copy(ts->gp_sculpt.cur_primitive);
 	return ts;
 }
 
@@ -226,6 +227,9 @@ void BKE_toolsettings_free(ToolSettings *toolsettings)
 	if (toolsettings->gp_sculpt.cur_falloff) {
 		curvemapping_free(toolsettings->gp_sculpt.cur_falloff);
 	}
+	if (toolsettings->gp_sculpt.cur_primitive) {
+		curvemapping_free(toolsettings->gp_sculpt.cur_primitive);
+	}
 
 	MEM_freeN(toolsettings);
 }
@@ -699,6 +703,14 @@ void BKE_scene_init(Scene *sce)
 		CURVE_PRESET_GAUSS,
 		CURVEMAP_SLOPE_POSITIVE);
 
+	sce->toolsettings->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+	CurveMapping *gp_primitive_curve = sce->toolsettings->gp_sculpt.cur_primitive;
+	curvemapping_initialize(gp_primitive_curve);
+	curvemap_reset(gp_primitive_curve->cm,
+		&gp_primitive_curve->clipr,
+		CURVE_PRESET_GAUSS,
+		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 10da6064f0b..e205789944f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6327,6 +6327,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
 		if (sce->toolsettings->gp_sculpt.cur_falloff) {
 			direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_falloff);
 		}
+		/* relink grease pencil primitive curve */
+		sce->toolsettings->gp_sculpt.cur_primitive = newdataadr(fd, sce->toolsettings->gp_sculpt.cur_primitive);
+		if (sce->toolsettings->gp_sculpt.cur_primitive) {
+			direct_link_curvemapping(fd, sce->toolsettings->gp_sculpt.cur_primitive);
+		}
 	}
 
 	if (sce->ed) {
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 25946a9fb31..ec956872599 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -174,7 +174,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 			}
 		}
 
-		/* Be sure curfalloff is initializated */
+		/* Be sure curfalloff and primitive are initializated */
 		for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
 			ToolSettings *ts = scene->toolsettings;
 			if (ts->gp_sculpt.cur_falloff == NULL) {
@@ -186,6 +186,15 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 				               CURVE_PRESET_GAUSS,
 				               CURVEMAP_SLOPE_POSITIVE);
 			}
+			if (ts->gp_sculpt.cur_primitive == NULL) {
+				ts->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+				CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive;
+				curvemapping_initialize(gp_primitive_curve);
+				curvemap_reset(gp_primitive_curve->cm,
+					&gp_primitive_curve->clipr,
+					CURVE_PRESET_GAUSS,
+					CURVEMAP_SLOPE_POSITIVE);
+			}
 		}
 	}
 
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index be708697ac6..e8eabebb479 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2555,6 +2555,10 @@ static void write_scene(WriteData *wd, Scene *sce)
 	if (tos->gp_sculpt.cur_falloff) {
 		write_curvemapping(wd, tos->gp_sculpt.cur_falloff);
 	}
+	/* write grease-pencil primitive curve to file */
+	if (tos->gp_sculpt.cur_primitive) {
+		write_curvemapping(wd, tos->gp_sculpt.cur_primitive);
+	}
 
 	write_paint(wd, &tos->imapaint.paint);
 
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index f7f336a8fef..bc55eb8310c 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -1252,7 +1252,7 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "use_thickness_curve", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE);
-	RNA_def_property_ui_text(prop, "Use Curve", "Use curvbe to define primitive stroke thickness");
+	RNA_def_property_ui_text(prop, "Use Curve", "Use curve to define primitive stroke thickness");
 	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
 	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);



More information about the Bf-blender-cvs mailing list