[Bf-blender-cvs] [351f537fa83] blender2.8: GP: New Curve primitive and other primitive improvements

Antonioya noreply at git.blender.org
Sat Dec 15 17:22:13 CET 2018


Commit: 351f537fa832c50971454af304a071c096427e71
Author: Antonioya
Date:   Sat Dec 15 17:21:47 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB351f537fa832c50971454af304a071c096427e71

GP: New Curve primitive and other primitive improvements

This commit adds support for new curve tool and adds more functionalities to the existing primitives, including new handles, editing, stroke thickness curve, noise, preview of the real stroke, etc.

Thanks to @charlie for his great contribution to this improvement.

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/blenkernel/intern/colortools.c
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/versioning_defaults.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/makesdna/DNA_color_types.h
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 72b3e166cc1..8c386af57be 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5709,6 +5709,15 @@ def km_3d_view_tool_paint_gpencil_arc(params):
         ]},
     )
 
+def km_3d_view_tool_paint_gpencil_curve(params):
+    return (
+        "3D View Tool: Paint Gpencil, Curve",
+        {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
+        {"items": [
+            ("gpencil.primitive", {"type": params.tool_tweak, "value": 'ANY'},
+             {"properties": [("type", 'CURVE'), ("wait_for_input", False)]}),
+        ]},
+    )	
 
 def km_3d_view_tool_edit_gpencil_select(params):
     return (
@@ -6019,6 +6028,7 @@ def generate_keymaps(params=None):
         km_3d_view_tool_paint_gpencil_box(params),
         km_3d_view_tool_paint_gpencil_circle(params),
         km_3d_view_tool_paint_gpencil_arc(params),
+        km_3d_view_tool_paint_gpencil_curve(params),
         km_3d_view_tool_edit_gpencil_select(params),
         km_3d_view_tool_edit_gpencil_select_box(params),
         km_3d_view_tool_edit_gpencil_select_circle(params),
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 09e81115d6a..32c0aa6ab0b 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -645,6 +645,7 @@ class GPENCIL_MT_gpencil_draw_specials(Menu):
         layout.operator("gpencil.primitive", text="Rectangle", icon='UV_FACESEL').type = 'BOX'
         layout.operator("gpencil.primitive", text="Circle", icon='ANTIALIASED').type = 'CIRCLE'
         layout.operator("gpencil.primitive", text="Arc", icon='SPHERECURVE').type = 'ARC'
+        layout.operator("gpencil.primitive", text="Curve", icon='CURVE_BEZCURVE').type = 'CURVE'
 
 
 class GPENCIL_MT_gpencil_draw_delete(Menu):
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 4da5455298f..aa6adee0d19 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1076,6 +1076,17 @@ class _defs_gpencil_paint:
             widget=None,
             keymap=(),
         )
+		
+
+    @ToolDef.from_fn
+    def curve():
+        return dict(
+            text="Curve",
+            icon="ops.gpencil.primitive_curve",
+            cursor='CROSSHAIR',
+            widget=None,
+            keymap=(),
+        )		
 
 class _defs_gpencil_edit:
     @ToolDef.from_fn
@@ -1583,6 +1594,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             _defs_gpencil_paint.box,
             _defs_gpencil_paint.circle,
             _defs_gpencil_paint.arc,
+            _defs_gpencil_paint.curve,
         ],
         'EDIT_GPENCIL': [
             *_tools_gpencil_select,
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index f73d21dcfb8..a94ebea4561 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -301,7 +301,7 @@ class _draw_left_context_mode:
                 return
 
             is_paint = True
-            if (tool.name in {"Line", "Box", "Circle", "Arc"}):
+            if (tool.name in {"Line", "Box", "Circle", "Arc", "Curve"}):
                 is_paint = False
             elif (not tool.has_datablock):
                 return
@@ -375,6 +375,17 @@ class _draw_left_context_mode:
 
                 draw_color_selector()
 
+                if tool.name in {"Arc", "Curve", "Line", "Box", "Circle"}:
+                    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="Thickness Profile"
+                    )
+
         @staticmethod
         def SCULPT_GPENCIL(context, layout, tool):
             if (tool is None) or (not tool.has_datablock):
@@ -1039,6 +1050,21 @@ 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
+        # Curve
+        layout.template_curve_mapping(settings, "thickness_primitive_curve", brush=True)
+
+
 classes = (
     TOPBAR_HT_upper_bar,
     TOPBAR_HT_lower_bar,
@@ -1059,6 +1085,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/colortools.c b/source/blender/blenkernel/intern/colortools.c
index aad59e32187..bc34b24c8f2 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -283,6 +283,7 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
 		case CURVE_PRESET_ROUND: cuma->totpoint = 4; break;
 		case CURVE_PRESET_ROOT: cuma->totpoint = 4; break;
 		case CURVE_PRESET_GAUSS: cuma->totpoint = 7; break;
+		case CURVE_PRESET_BELL: cuma->totpoint = 3; break;
 	}
 
 	cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), "curve points");
@@ -371,6 +372,16 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
 			cuma->curve[6].x = 1.0f;
 			cuma->curve[6].y = 0.025f;
 			break;
+		case CURVE_PRESET_BELL:
+			cuma->curve[0].x = 0;
+			cuma->curve[0].y = 0.025f;
+
+			cuma->curve[1].x = 0.50f;
+			cuma->curve[1].y = 1.0f;
+
+			cuma->curve[2].x = 1.0f;
+			cuma->curve[2].y = 0.025f;
+			break;
 	}
 
 	/* mirror curve in x direction to have positive slope
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index a070bf97317..3894d83c169 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_BELL,
+		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 6aff6f6506f..6dd9c80b5d9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6275,6 +6275,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_280.c b/source/blender/blenloader/intern/versioning_280.c
index 56ca663e3f0..5a1002702b3 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2516,6 +2516,21 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 				}
 			}
 		}
+
+		/* Grease pencil primitive curve */
+		if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive")) {
+			for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+				GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt;
+				if ((gset) && (gset->cur_primitive == NULL)) {
+					gset->cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+					curvemapping_initialize(gset->cur_primitive);
+					curvemap_reset(gset->cur_primitive->cm,
+						&gset->cur_primitive->clipr,
+						CURVE_PRESET_BELL,
+						CURVEMAP_SLOPE_POSITIVE);
+				}
+			}
+		}
 	}
 
 	{
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 4dd046d9a73..f3ae1426fa8 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -187,7 +187,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 			}
 		}
 
-		/* Be sure curfalloff is initiali

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list