[Bf-blender-cvs] [c25e3a2] PSketch: PSculpt: Initial port of the old Pose Sculpting codebase from 2012 to modern Blender

Joshua Leung noreply at git.blender.org
Sun Jan 31 14:28:39 CET 2016


Commit: c25e3a27e7d4f6b7af32f83d92cfb94de8442090
Author: Joshua Leung
Date:   Sun Nov 22 19:21:58 2015 +1300
Branches: PSketch
https://developer.blender.org/rBc25e3a27e7d4f6b7af32f83d92cfb94de8442090

PSculpt: Initial port of the old Pose Sculpting codebase from 2012 to modern Blender

Pose Sculpting allows animators to pose rigs using a brush-based "sculpting"
paradigm. It has multiple similarities to the sculpting tools for meshes,
the particle editing tools, and the upcoming Grease Pencil stroke sculpting
features. In each of these cases, we are trying to make it easier and faster
to work, by allowing artists to seamlessly affect a whole bunch of points/items
at the same time by varying amounts.

Current Status:
* Use Q-LMB and Q-RMB to sculpt strokes. Unlike in the past, Pose Sculpting is
  not a separate mode, but instead works more like Grease Pencil drawing, which is
  non-modal.

* Settings for brushes can be found in the "Sculpt" tab of the toolbar

* All the brushes work as they did before. That includes the dodgy behaviour that
  the "Draw" brush had (fixing this is a top priority!), and/or any other random
  bugs that the others may have had. Also, all the brush strengths/etc. are left
  as-is so far (to be tweaked... they are still too strong)

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/armature/armature_intern.h
M	source/blender/editors/armature/armature_ops.c
A	source/blender/editors/armature/pose_sculpt.c
M	source/blender/makesdna/DNA_scene_types.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/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index a24dc49..3ca4759 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -786,6 +786,45 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
 
         self.layout.prop(arm, "use_auto_ik")
 
+
+class VIEW3D_PT_tools_poosemode_sculpt(View3DPanel, Panel):
+    bl_category = "Sculpt"
+    bl_context = "posemode"
+    bl_label = "Pose Sculpt"
+
+    def draw(self, context):
+        layout = self.layout
+
+        settings = context.tool_settings.pose_sculpt
+
+        tool = settings.tool
+        brush = settings.brush
+
+        layout.column().prop(settings, "tool", expand=True)
+
+        layout.separator()
+
+        if tool != 'NONE':
+            col = layout.column()
+            col.prop(brush, "size", slider=True)
+            col.prop(brush, "strength", slider=True)
+
+        if tool in ('CURL', 'STRETCH'):
+            col.prop(brush, "rate", slider=True)
+
+        if tool not in ('NONE', 'RESET'):
+            col.separator()
+            col.row().prop(brush, "direction", expand=True)
+
+        if tool == 'GRAB':
+            col.prop(brush, "use_initial_only")
+        if tool in ('CURL', 'STRETCH'):
+            col.row().prop(brush, "xz_mode", expand=True)
+
+        layout.separator()
+        layout.prop(settings, "use_select_mask")
+
+
 # ********** default tools for paint modes ****************
 
 
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 82a040f..e3fac21 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -465,6 +465,7 @@ void BKE_scene_free(Scene *sce)
 void BKE_scene_init(Scene *sce)
 {
 	ParticleEditSettings *pset;
+	PSculptSettings *psculpt;
 	int a;
 	const char *colorspace_name;
 	SceneRenderView *srv;
@@ -650,6 +651,17 @@ void BKE_scene_init(Scene *sce)
 		pset->brush[a].count = 10;
 	}
 	pset->brush[PE_BRUSH_CUT].strength = 100;
+	
+	psculpt = &sce->toolsettings->psculpt;
+	for (a = 0; a < PSCULPT_TOT_BRUSH; a++) {
+		psculpt->brush[a].strength = 0.5f;
+		psculpt->brush[a].size = 50;
+		psculpt->brush[a].rate = 0.1f;
+	}
+	psculpt->brush[PSCULPT_BRUSH_CURL].strength = 0.25f;
+	psculpt->brush[PSCULPT_BRUSH_TWIST].strength = 0.25f;
+	psculpt->brush[PSCULPT_BRUSH_CURL].xzMode = PSCULPT_BRUSH_DO_X;
+	psculpt->brush[PSCULPT_BRUSH_GRAB].flag |= PSCULPT_BRUSH_FLAG_GRAB_INITIAL;
 
 	sce->r.ffcodecdata.audio_mixrate = 44100;
 	sce->r.ffcodecdata.audio_volume = 1.0f;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index b5199e1..b294c06 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -935,5 +935,31 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 		}
 	}
 
-
+	/* Pose Sculpt... */
+	if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "PSculptSettings", "psculpt")) {
+		Scene *scene;
+		
+		/* init defaults for pose sculpt settings 
+		 * ! Keep in sync with blenkernel/scene.c - BKE_scene_init()
+		 *                and  blenloader/versioning_defaults.c
+		 */
+		for (scene = main->scene.first; scene; scene = scene->id.next) {
+			PSculptSettings *pset = &scene->toolsettings->psculpt;
+			
+			//if (pset->brush[0].size == 0) 
+			{
+				int i;
+				
+				for (i = 0; i < PSCULPT_TOT_BRUSH; i++) {
+					pset->brush[i].strength = 0.5f;
+					pset->brush[i].size = 50;
+					pset->brush[i].rate = 0.1f;
+				}
+				pset->brush[PSCULPT_BRUSH_CURL].strength = 0.25f;
+				pset->brush[PSCULPT_BRUSH_TWIST].strength = 0.25f;
+				pset->brush[PSCULPT_BRUSH_CURL].xzMode = PSCULPT_BRUSH_DO_X;
+				pset->brush[PSCULPT_BRUSH_GRAB].flag |= PSCULPT_BRUSH_FLAG_GRAB_INITIAL;
+			}
+		}
+	}
 }
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 01af11e..ab37fdf 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -180,5 +180,34 @@ void BLO_update_defaults_startup_blend(Main *bmain)
 			br->ob_mode &= ~OB_MODE_TEXTURE_PAINT;
 		}
 	}
+	
+	
+	/* Pose Sculpt... */
+	{
+		Scene *scene;
+		
+		/* init defaults for pose sculpt settings 
+		 * ! Keep in sync with blenkernel/scene.c - BKE_scene_init()
+		 */
+		for (scene = bmain->scene.first; scene; scene = scene->id.next) {
+			PSculptSettings *pset = &scene->toolsettings->psculpt;
+			
+			//if (pset->brush[0].size == 0) 
+			{
+				int i;
+				
+				for (i = 0; i < PSCULPT_TOT_BRUSH; i++) {
+					pset->brush[i].strength = 0.5f;
+					pset->brush[i].size = 50;
+					pset->brush[i].rate = 0.1f;
+				}
+				pset->brush[PSCULPT_BRUSH_CURL].strength = 0.25f;
+				pset->brush[PSCULPT_BRUSH_TWIST].strength = 0.25f;
+				pset->brush[PSCULPT_BRUSH_CURL].xzMode = PSCULPT_BRUSH_DO_X;
+				pset->brush[PSCULPT_BRUSH_GRAB].flag |= PSCULPT_BRUSH_FLAG_GRAB_INITIAL;
+			}
+		}
+	}
+
 }
 
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 3161af8..ea43cb9 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -215,6 +215,9 @@ void POSE_OT_propagate(struct wmOperatorType *ot);
 /* pose_sketch.c */
 void POSE_OT_sketch_direct(struct wmOperatorType *ot);
 
+/* pose_sculpt.c */
+void POSE_OT_brush_paint(struct wmOperatorType *ot);
+
 /* ******************************************************* */
 /* Various Armature Edit/Pose Editing API's */
 
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index c58486a..9b318ff 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -163,6 +163,9 @@ void ED_operatortypes_armature(void)
 	
 	/* POSE SKETCHING */
 	WM_operatortype_append(POSE_OT_sketch_direct);
+	
+	/* POSE SCULPTING */
+	WM_operatortype_append(POSE_OT_brush_paint);
 }
 
 void ED_operatormacros_armature(void)
@@ -426,15 +429,21 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
 	WM_keymap_add_item(keymap, "POSE_OT_relax", EKEY, KM_PRESS, KM_ALT, 0);
 	WM_keymap_add_item(keymap, "POSE_OT_breakdown", EKEY, KM_PRESS, KM_SHIFT, 0);
 	
+	/* Menus */
+	WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_specials", WKEY, KM_PRESS, 0, 0);
+	WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_propagate", PKEY, KM_PRESS, KM_ALT, 0);
 	
 	/* Pose -> Pose Sketching ----------- */
 	/* only set in posemode, by space_view3d listener */
 	
 	// XXX: temporary mappings
 	WM_keymap_add_item(keymap, "POSE_OT_sketch_direct_interactive", EKEY, KM_PRESS, 0, 0);
-
-	/* menus */
-	WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_specials", WKEY, KM_PRESS, 0, 0);
-	WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_propagate", PKEY, KM_PRESS, KM_ALT, 0);
+	
+	/* Pose -> Pose Sculpting ----------- */
+	kmi = WM_keymap_add_item(keymap, "POSE_OT_brush_paint", LEFTMOUSE, KM_PRESS, 0, QKEY);
+	RNA_boolean_set(kmi->ptr, "invert", false);
+	
+	kmi = WM_keymap_add_item(keymap, "POSE_OT_brush_paint", RIGHTMOUSE, KM_PRESS, 0, QKEY);
+	RNA_boolean_set(kmi->ptr, "invert", true);
 }
 
diff --git a/source/blender/editors/armature/pose_sculpt.c b/source/blender/editors/armature/pose_sculpt.c
new file mode 100644
index 0000000..2ad4513
--- /dev/null
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -0,0 +1,1278 @@
+/*
+ * ***** 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) 2012 Blender Foundation, Joshua Leung
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Original Author: Joshua Leung
+ * Contributor(s): Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ * Implements a brush-based "sculpting" tool for posing rigs
+ * in an easier and faster manner.
+ */
+
+/** \file blender/editors/armature/pose_sculpt.c
+ *  \ingroup edarmature
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_dynstr.h"
+#include "BLI_ghash.h"
+//#include "BLI_pbvh.h"
+#include "BLI_threads.h"
+#include "BLI_rand.h"
+
+#include "DNA_action_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_armature.h"
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_report.h"
+
+#include "BLT_translation.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "ED_armature.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "armature_intern.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+/* ******************************************************** */
+/* General settings */
+
+/* Get Pose Sculpt Settings */
+PSculptSettings *psculpt_settings(Scene *scene)
+{
+	return (scene->toolsettings) ? &scene->toolsettings->psculpt : NULL;
+}
+
+/* Get current brush */
+PSculptBrushData *psculpt_get_brush(Scene *scene)
+{
+	PSculptSettings *pset = psculpt_settings(scene);
+	
+	if ((pset) && (pset->brushtype >= 0) && (pset->brushtype < PSCULPT_TOT_BRUSH))
+		return &pset->brush[pset->brushtype];
+	else
+		return NULL;
+}
+
+void *psculpt_g

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list