[Bf-blender-cvs] [cb95149] PSketch: PSculpt: Make pressure and falloff configurable options, as in other sculpt brush systems

Joshua Leung noreply at git.blender.org
Sun Jan 31 14:29:37 CET 2016


Commit: cb95149d737a4b74828718d4abb5796f3ed00f82
Author: Joshua Leung
Date:   Sun Jan 31 19:31:13 2016 +1300
Branches: PSketch
https://developer.blender.org/rBcb95149d737a4b74828718d4abb5796f3ed00f82

PSculpt: Make pressure and falloff configurable options, as in other sculpt brush systems

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

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/pose_sculpt.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/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index e202177..df3281d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -808,11 +808,16 @@ class VIEW3D_PT_tools_posemode_sculpt(View3DPanel, Panel):
         if tool != 'NONE':
             col = layout.column()
             col.prop(brush, "size", slider=True)
-            col.prop(brush, "strength", slider=True)
+            subcol = col.row(align=True)
+            subcol.prop(brush, "strength", slider=True)
+            subcol.prop(brush, "use_pressure_strength", text="")
+            col.prop(brush, "use_falloff") # XXX: should be with rate?
 
-        if tool in ('CURL', 'STRETCH'):
+        if tool in ('CURL', 'STRETCH', 'TWIST', 'RESET'):
+            col.separator()
             col.prop(brush, "rate", slider=True)
 
+
         if tool not in ('NONE', 'RESET'):
             col.separator()
             col.row().prop(brush, "direction", expand=True)
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 2502742..a91533c 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -657,6 +657,7 @@ void BKE_scene_init(Scene *sce)
 		psculpt->brush[a].strength = 0.5f;
 		psculpt->brush[a].size = 50;
 		psculpt->brush[a].rate = 0.1f;
+		psculpt->brush[a].flag = PSCULPT_BRUSH_FLAG_USE_PRESSURE | PSCULPT_BRUSH_FLAG_USE_FALLOFF;
 	}
 	psculpt->brush[PSCULPT_BRUSH_CURL].strength = 0.25f;
 	psculpt->brush[PSCULPT_BRUSH_TWIST].strength = 0.25f;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 79e7351..7c12b8b 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1071,6 +1071,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 					pset->brush[i].strength = 0.5f;
 					pset->brush[i].size = 50;
 					pset->brush[i].rate = 0.1f;
+					pset->brush[i].flag = PSCULPT_BRUSH_FLAG_USE_PRESSURE | PSCULPT_BRUSH_FLAG_USE_FALLOFF;
 				}
 				pset->brush[PSCULPT_BRUSH_CURL].strength = 0.25f;
 				pset->brush[PSCULPT_BRUSH_TWIST].strength = 0.25f;
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index d03b6ae..cdd82eb 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -256,6 +256,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
 					pset->brush[i].strength = 0.5f;
 					pset->brush[i].size = 50;
 					pset->brush[i].rate = 0.1f;
+					pset->brush[i].flag = PSCULPT_BRUSH_FLAG_USE_PRESSURE | PSCULPT_BRUSH_FLAG_USE_FALLOFF;
 				}
 				pset->brush[PSCULPT_BRUSH_CURL].strength = 0.25f;
 				pset->brush[PSCULPT_BRUSH_TWIST].strength = 0.25f;
diff --git a/source/blender/editors/armature/pose_sculpt.c b/source/blender/editors/armature/pose_sculpt.c
index 31d36ab..3ca427b 100644
--- a/source/blender/editors/armature/pose_sculpt.c
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -314,21 +314,20 @@ static void psculpt_init_view3d_data(bContext *C, tPSculptContext *data)
 
 /* Brush Utilities ---------------------------------------- */
 
-static float psculpt_brush_calc_influence(tPoseSculptingOp *pso, bool use_falloff)
+static float psculpt_brush_calc_influence(tPoseSculptingOp *pso)
 {
 	tPSculptContext *data = &pso->data;
 	PSculptBrushData *brush = data->brush;
 	float fac = brush->strength;
 	
 	/* use pressure to modulate strength */
-	//if (brush->flag & PSCULPT_BRUSH_FLAG_USE_PRESSURE) 
+	if (brush->flag & PSCULPT_BRUSH_FLAG_USE_PRESSURE) 
 	{
 		fac *= pso->pressure;
 	}
 	
 	/* use distance falloff */
-	// XXX: make this another brush setting?
-	if (use_falloff) {
+	if (brush->flag & PSCULPT_BRUSH_FLAG_USE_FALLOFF) {
 		fac *= fabsf(1.0f - data->dist / data->rad);
 	}
 	
@@ -812,7 +811,7 @@ static void psculpt_brush_grab_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
 	float fac;
 	
 	/* strength of push */
-	fac = psculpt_brush_calc_influence(pso, true);
+	fac = psculpt_brush_calc_influence(pso);
 	if (data->invert) fac = -fac;
 	
 	if (brush->flag & PSCULPT_BRUSH_FLAG_GRAB_INITIAL) {
@@ -926,8 +925,8 @@ static void psculpt_brush_curl_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
 	 *   however is much too strong for controllability. So, leaving it as-is.
 	 * - Rotations are internally represented using radians, which are very sensitive
 	 */
-	angle = psculpt_brush_calc_influence(pso, true);      //printf("%f ", angle);
-	angle = DEG2RAD(angle);                               //printf("%f \n", angle);
+	angle = psculpt_brush_calc_influence(pso);      //printf("%f ", angle);
+	angle = DEG2RAD(angle);                         //printf("%f \n", angle);
 	
 	if (data->invert) angle = -angle;
 	
@@ -969,8 +968,8 @@ static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, bPoseChannel *pchan
 	 *   however is much too strong for controllability. So, leaving it as-is.
 	 * - Rotations are internally represented using radians, which are very sensitive
 	 */
-	angle = psculpt_brush_calc_influence(pso, true);      //printf("%f ", angle);
-	angle = DEG2RAD(angle);                               //printf("%f \n", angle);
+	angle = psculpt_brush_calc_influence(pso);  //printf("%f ", angle);
+	angle = DEG2RAD(angle);                     //printf("%f \n", angle);
 	
 	if (data->invert) angle = -angle;
 	
@@ -994,7 +993,7 @@ static void psculpt_brush_stretch_apply(tPoseSculptingOp *pso, bPoseChannel *pch
 	float fac;
 	
 	/* scale factor must be greater than 1 for add, and less for subtract */
-	fac = psculpt_brush_calc_influence(pso, true) * DAMP_FAC;
+	fac = psculpt_brush_calc_influence(pso) * DAMP_FAC;
 	
 	if (data->invert)
 		fac = 1.0f - fac;
@@ -1031,7 +1030,7 @@ static void psculpt_brush_stretch_apply(tPoseSculptingOp *pso, bPoseChannel *pch
  */
 static void psculpt_brush_reset_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
 {
-	const float fac = psculpt_brush_calc_influence(pso, true);
+	const float fac = psculpt_brush_calc_influence(pso);
 	const short locks = pchan->protectflag;
 	float eul[3] = {0.0f};
 	
@@ -1078,7 +1077,7 @@ static void psculpt_brush_reset_apply(tPoseSculptingOp *pso, bPoseChannel *pchan
  */
 static void psculpt_brush_restore_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
 {
-	const float fac = psculpt_brush_calc_influence(pso, true);
+	const float fac = psculpt_brush_calc_influence(pso);
 	const short locks = pchan->protectflag;
 	
 	/* We need to use the old (pre-sculpt) values.
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 3fb00fe..a726d3d 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -2113,6 +2113,10 @@ typedef enum ePSculptBrush_Flag {
 	PSCULPT_BRUSH_FLAG_INV			= (1 << 0),
 	/* only initially affected bones should be considered */
 	PSCULPT_BRUSH_FLAG_GRAB_INITIAL = (1 << 1),
+	/* tablet pressure influences strength */
+	PSCULPT_BRUSH_FLAG_USE_PRESSURE = (1 << 2),
+	/* use brush falloff */
+	PSCULPT_BRUSH_FLAG_USE_FALLOFF  = (1 << 3),
 } ePSculptBrush_Flag;
 
 /* PSculptBrushData.xzMode - how to handle x and z axes (when scaling or rotating) */
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index ddb59a3..f496881 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -1157,6 +1157,17 @@ static void rna_def_pose_sculpt(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Strength", "Brush strength");
 	RNA_def_property_update(prop, 0, "rna_PSculptBrush_update");
 	
+	prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", PSCULPT_BRUSH_FLAG_USE_PRESSURE);
+	RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
+	RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
+	RNA_def_property_update(prop, 0, "rna_PSculptBrush_update");
+	
+	prop = RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", PSCULPT_BRUSH_FLAG_USE_FALLOFF);
+	RNA_def_property_ui_text(prop, "Use Falloff", "Strength of brush decays with distance from cursor");
+	RNA_def_property_update(prop, 0, "rna_PSculptBrush_update");
+	
 	prop = RNA_def_property(srna, "rate", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_range(prop, 0.001f, 1.0f);
 	RNA_def_property_ui_text(prop, "Rate", "Rate of brush application in seconds");




More information about the Bf-blender-cvs mailing list