[Bf-blender-cvs] [98d42b7] GPencil_Editing_Stage3: GPencil: Minimum-working-version of new Stroke Sculpting functionality

Joshua Leung noreply at git.blender.org
Sat Jun 13 02:45:03 CEST 2015


Commit: 98d42b72361d17edea2c378ffe9c0f0014bd9d2f
Author: Joshua Leung
Date:   Mon Jun 8 13:15:32 2015 +1200
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rB98d42b72361d17edea2c378ffe9c0f0014bd9d2f

GPencil: Minimum-working-version of new Stroke Sculpting functionality

Usage:
* In Stroke Edit Mode, EKEY will start the modal brush operator, using the active
  brush (set via the Toolbar)
* LMB-click-drag to sculpt, release to stop.
* RMB/ESC to stop editing
* Scrollwheel to increase/decrease brush radius
* Shift-Scrollwheel to increase/decrease strength
* Hold Ctrl to invert the brush action

Notes:
* Currently only "Thickness" brush is implemented. This adjusts the stroke thickness
  as you "paint" the effect onto the stroke. (Recommended Strength: 0.093)
* Strength and radius are not correctly initialised yet (to be fixed soon)

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_clip.py
M	release/scripts/startup/bl_ui/space_image.py
M	release/scripts/startup/bl_ui/space_node.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenloader/intern/readfile.c
A	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_ops.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_scene.c
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 4860f3b..6519fac 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -154,6 +154,41 @@ class GreasePencilStrokeEditPanel:
         col.operator("transform.tosphere", text="To Sphere").gpencil_strokes = True
 
 
+class GreasePencilStrokeSculptPanel:
+    # subclass must set
+    # bl_space_type = 'IMAGE_EDITOR'
+    bl_label = "Sculpt Strokes"
+    bl_category = "Grease Pencil"
+    bl_region_type = 'TOOLS'
+
+    @classmethod
+    def poll(cls, context):
+        if context.gpencil_data is None:
+            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_sculpt
+        tool = settings.tool
+        brush = settings.brush
+        
+        layout.column().prop(settings, "tool", expand=True)
+
+        col = layout.column()
+        col.prop(brush, "size", slider=True)
+        row = col.row(align=True)
+        row.prop(brush, "strength", slider=True)
+        row.prop(brush, "use_pressure_strength", text="")
+        col.prop(brush, "use_falloff")
+
+        layout.prop(settings, "use_select_mask")
+
+
 ###############################
 
 class GPENCIL_PIE_tool_palette(Menu):
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 33943af..8f2fd30 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -24,6 +24,7 @@ from bpy.app.translations import pgettext_iface as iface_
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDrawingToolsPanel,
         GreasePencilStrokeEditPanel,
+        GreasePencilStrokeSculptPanel,
         GreasePencilDataPanel
         )
 
@@ -1133,6 +1134,10 @@ class CLIP_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
 class CLIP_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
     bl_space_type = 'CLIP_EDITOR'
 
+# Grease Pencil stroke sculpting tools
+class CLIP_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+
 
 class CLIP_MT_view(Menu):
     bl_label = "View"
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 4c6966b..e9859a7 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -28,6 +28,7 @@ from bl_ui.properties_paint_common import (
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDrawingToolsPanel,
         GreasePencilStrokeEditPanel,
+        GreasePencilStrokeSculptPanel,
         GreasePencilDataPanel,
         )
 from bpy.app.translations import pgettext_iface as iface_
@@ -1173,5 +1174,10 @@ class IMAGE_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
 
 
+# Grease Pencil stroke sculpting tools
+class IMAGE_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+
+
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index d0d1376..b466522 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -23,6 +23,7 @@ from bpy.app.translations import pgettext_iface as iface_
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDrawingToolsPanel,
         GreasePencilStrokeEditPanel,
+        GreasePencilStrokeSculptPanel,
         GreasePencilDataPanel,
         GreasePencilToolsPanel,
         )
@@ -483,6 +484,11 @@ class NODE_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
     bl_space_type = 'NODE_EDITOR'
     bl_region_type = 'TOOLS'
 
+# Grease Pencil stroke sculpting tools
+class NODE_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
+    bl_space_type = 'NODE_EDITOR'
+    bl_region_type = 'TOOLS'
+
 # -----------------------------
 
 
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 362b7b0..268fa22 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -21,7 +21,8 @@ import bpy
 from bpy.types import Menu, Panel, UIList
 from bl_ui.properties_grease_pencil_common import (
         GreasePencilDrawingToolsPanel,
-        GreasePencilStrokeEditPanel
+        GreasePencilStrokeEditPanel,
+        GreasePencilStrokeSculptPanel
         )
 from bl_ui.properties_paint_common import (
         UnifiedPaintPanel,
@@ -1865,6 +1866,11 @@ class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
     bl_space_type = 'VIEW_3D'
 
 
+# Grease Pencil stroke sculpting tools
+class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
+    bl_space_type = 'VIEW_3D'
+
+
 # Note: moved here so that it's always in last position in 'Tools' panels!
 class VIEW3D_PT_tools_history(View3DPanel, Panel):
     bl_category = "Tools"
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a22e882..f89b7fb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5598,6 +5598,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
 		sce->toolsettings->particle.paintcursor = NULL;
 		sce->toolsettings->particle.scene = NULL;
 		sce->toolsettings->particle.object = NULL;
+		sce->toolsettings->gp_sculpt.paintcursor = NULL;
 
 		/* in rare cases this is needed, see [#33806] */
 		if (sce->toolsettings->vpaint) {
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
new file mode 100644
index 0000000..50a8532
--- /dev/null
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -0,0 +1,775 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2015, Blender Foundation
+ * This is a new part of Blender
+ *
+ * Contributor(s): Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ * Brush based operators for editing Grease Pencil strokes
+ */
+
+/** \file blender/editors/gpencil/gpencil_edit.c
+ *  \ingroup edgpencil
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+
+#include "BLF_translation.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_gpencil_types.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_gpencil.h"
+#include "BKE_library.h"
+#include "BKE_report.h"
+#include "BKE_screen.h"
+
+#include "UI_interface.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "UI_view2d.h"
+
+#include "ED_gpencil.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "gpencil_intern.h"
+
+/* ************************************************ */
+/* General Brush Editing Context */
+
+/* Context for brush operators */
+typedef struct tGP_BrushEditData {
+	/* Brush Settings */
+	GP_BrushEdit_Settings *settings;
+	GP_EditBrush_Data *brush;
+	
+	eGP_EditBrush_Types brush_type;
+	eGP_EditBrush_Flag  flag;
+	
+	/* Space Conversion Data */
+	GP_SpaceConversion gsc;
+	
+	
+	/* Is the brush currently painting? */
+	bool is_painting;
+	
+	/* Start of new sculpt stroke */
+	bool first;
+	
+	
+	/* Brush Runtime Data: */
+	/* - position and pressure
+	 * - the *_prev variants are the previous values
+	 */
+	int   mval[2], mval_prev[2];
+	float pressure, pressure_prev;
+	
+	/* brush geometry (bounding box) */
+	rcti brush_rect;
+	
+	/* Custom data for certain brushes */
+	void *customdata;
+} tGP_BrushEditData;
+
+
+/* Callback for performing some brush operation on a single point */
+typedef bool (*GP_BrushApplyCb)(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
+                                const int mx, const int my, const int radius,
+                                const int x0, const int y0);
+
+/* ************************************************ */
+/* Utility Functions */
+
+/* Context ---------------------------------------- */
+
+/* Get the sculpting settings */
+static GP_BrushEdit_Settings *gpsculpt_get_settings(Scene *scene)
+{
+	return &scene->toolsettings->gp_sculpt;
+}
+
+/* Get the active brush */
+static GP_EditBrush_Data *gpsculpt_get_brush(Scene *scene)
+{
+	GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
+	return &gset->brush[gset->brushtype];
+}
+
+/* Brush Operations ------------------------------- */
+
+/* Invert behaviour of brush? */
+// XXX: Maybe this should work the way that pose sculpt did it instead?
+static bool gp_brush_invert_check(tGP_BrushEditData *gso)
+{
+	/* The basic setting is the brush's setting (from the pa

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list