[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29821] branches/soc-2010-jwilkins: == Inverse Autosmooth Pressure ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Wed Jun 30 12:36:27 CEST 2010


Revision: 29821
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29821
Author:   jwilkins
Date:     2010-06-30 12:36:26 +0200 (Wed, 30 Jun 2010)

Log Message:
-----------
== Inverse Autosmooth Pressure ==
* Autosmooth can be enabled to work at low pressure, this can be used to make a "Polish" brush that flattens at high pressure and smooths at low pressure.

* Slider to control how much pinch is applied to crease brush.

* fixed texture angle, it was 90 degrees offsetof

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
    branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-06-30 10:36:26 UTC (rev 29821)
@@ -617,6 +617,7 @@
 
                 row = col.row(align=True)
                 row.prop(brush, "autosmooth_factor", slider=True)
+                row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
 
 
 
@@ -628,6 +629,14 @@
 
 
 
+            if brush.sculpt_tool in ('CREASE'):
+                col.separator()
+
+                row = col.row(align=True)
+                row.prop(brush, "crease_pinch_factor", slider=True)
+
+
+
             if brush.sculpt_tool in ('CLAY', 'WAX', 'FLATTEN', 'FILL', 'SCRAPE'):
                 col.separator()
 

Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c	2010-06-30 10:36:26 UTC (rev 29821)
@@ -109,8 +109,11 @@
 	brush->texture_offset = 0;
 	
 	brush->overlay_texture = 0; /* toggles whether the texture is shown as an overlay when not sculpting 0 is off */
+
 	brush->autosmooth_factor = 0;
 
+	brush->crease_pinch_factor = 2.0f/3.0f;
+
 	/* color of the 'on surface' brush */
 	brush->add_col[0] = 1.00; /* add mode color is red */
 	brush->add_col[1] = 0.39;

Modified: branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-06-30 10:36:26 UTC (rev 29821)
@@ -10927,10 +10927,12 @@
 		for (brush= main->brush.first; brush; brush= brush->id.next) {
 			if (brush->detail == 0.0f)                brush->detail = 0.25f;
 			if (brush->smoothness == 0.0f)            brush->smoothness = 0.25f;
+
 			if (brush->texture_scale_x == 0)          brush->texture_scale_x = 100;
 			if (brush->texture_scale_y == 0)          brush->texture_scale_y = 100;
 			if (brush->texture_scale_percentage == 0) brush->texture_scale_percentage = 100;
 			if (brush->texture_overlay_alpha == 0)    brush->texture_overlay_alpha = 33;
+
 			if (brush->unprojected_radius == 0)       brush->unprojected_radius = 0.125;
 
 			if (brush->add_col[0] == 0 &&
@@ -10950,6 +10952,9 @@
 				brush->sub_col[1] = 0.39;
 				brush->sub_col[2] = 1.00;
 			}
+
+			if (brush->crease_pinch_factor == 0)
+				brush->crease_pinch_factor = 2.0f/3.0f;
 		}
 	}
 

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-06-30 10:36:26 UTC (rev 29821)
@@ -250,7 +250,7 @@
 				   atan2, sqrtf, sin, and cos. */
 				/* epsilon good as long as precision of angle control is 0.001 */
 				if (rotation > 0.001 || rotation < -0.001) {
-					const float angle    = M_PI_2 + atan2(x, y) - rotation;
+					const float angle    = atan2(x, y) - rotation;
 					const float flen     = sqrtf(x*x + y*y);
 
 					x = flen * cos(angle);

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-06-30 10:36:26 UTC (rev 29821)
@@ -612,10 +612,12 @@
 		case SCULPT_TOOL_CLAY:
 		case SCULPT_TOOL_DRAW:
 		case SCULPT_TOOL_WAX:
-		case SCULPT_TOOL_CREASE:
 		case SCULPT_TOOL_LAYER:
 			return alpha * flip * pressure * overlap;
 
+		case SCULPT_TOOL_CREASE:
+			return alpha * flip * pressure * overlap;
+
 		case SCULPT_TOOL_INFLATE:
 			if (dir*invert*pen_flip > 0) {
 				return 0.250f * alpha * flip * pressure * overlap;
@@ -805,7 +807,7 @@
 		   atan2, sqrtf, sin, and cos. */
 		/* epsilon good as long as precision of angle control is 0.001 */
 		if (rotation > 0.001 || rotation < -0.001) {
-			const float angle    = M_PI_2 + atan2(x, y) - rotation;
+			const float angle    = atan2(x, y) - rotation;
 			const float flen     = sqrtf(x*x + y*y);
 
 			x = flen * cos(angle);
@@ -1287,13 +1289,13 @@
 	/* offset with as much as possible factored in already */
 	mul_v3_v3fl(offset, area_normal, ss->cache->radius);
 	mul_v3_v3(offset, ss->cache->scale);
-	mul_v3_fl(offset, bstrength);
+	mul_v3_fl(offset, bstrength*(1-brush->crease_pinch_factor));
 
 	/* we always want crease to pinch even when draw is negative also crease we want stronger than the draw effect*/
-	flippedbstrength = (bstrength < 0) ? -(2.0f/3.0f)*bstrength : (2.0f/3.0f)*bstrength;
+	flippedbstrength = (bstrength < 0) ? -brush->crease_pinch_factor*bstrength : brush->crease_pinch_factor*bstrength;
 
 	/* threaded loop over nodes */
-#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+	#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
 		SculptBrushTest test;
@@ -1315,10 +1317,10 @@
 				sculpt_clip(sd, ss, vd.co, val);
 
 				/* then we draw */
-				mul_v3_v3fl(val, offset, fade*(1.0f/3.0f));
+				mul_v3_v3fl(val, offset, fade);
 				symmetry_feather(sd, ss, vd.co, val);
 				add_v3_v3(val, vd.co);
-				
+
 				sculpt_clip(sd, ss, vd.co, val);
 
 				if(vd.mvert) {
@@ -2346,7 +2348,10 @@
 		}
 
 		if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0)
-			smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*brush->autosmooth_overlap);
+			if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE)
+				smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*(1-ss->cache->pressure)*brush->autosmooth_overlap);
+			else
+				smooth(sd, ss, nodes, totnode, brush->autosmooth_factor*brush->autosmooth_overlap);
 
 		/* copy the modified vertices from mesh to the active key */
 		if(ss->kb)

Modified: branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h	2010-06-30 10:36:26 UTC (rev 29821)
@@ -84,8 +84,11 @@
 	char stroke_tool;
 
 	float autosmooth_factor;
-	float autosmooth_overlap;
+	float autosmooth_overlap; // XXX: move this to strokecache
 
+	float crease_pinch_factor;
+	int pad2;
+
 	// all this below is used to communicate with the cursor drawing routine
 
 	float texture_offset;
@@ -141,6 +144,7 @@
 #define BRUSH_TEXTURE_OVERLAY	(1<<21)
 #define BRUSH_EDGE_TO_EDGE	(1<<22)
 #define BRUSH_RESTORE_MESH	(1<<23)
+#define BRUSH_INVERSE_SMOOTH_PRESSURE (1<<24)
 
 /* Brush stroke_style */
 //#define STROKE_TOOL_DOTS	1

Modified: branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c	2010-06-30 10:22:37 UTC (rev 29820)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c	2010-06-30 10:36:26 UTC (rev 29821)
@@ -336,6 +336,7 @@
 	
 	prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_float_sdna(prop, NULL, "alpha");
+	RNA_def_property_float_default(prop, 0.5f);
 	RNA_def_property_range(prop, 0.0f, 10.0f);
 	RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001);
 	RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied");
@@ -343,30 +344,43 @@
 
 	prop= RNA_def_property(srna, "strength_multiplier", PROP_INT, PROP_FACTOR);
 	RNA_def_property_int_sdna(prop, NULL, "strength_multiplier");
+	RNA_def_property_int_default(prop, 1);
 	RNA_def_property_range(prop, 1, 10);
 	RNA_def_property_ui_text(prop, "Strength Multiplier", "Multiplier factor for the strength setting");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
 	prop= RNA_def_property(srna, "plane_offset", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_float_sdna(prop, NULL, "plane_offset");
-	RNA_def_property_range(prop, -0.5f, 0.5f);
+	RNA_def_property_float_default(prop, 0);
+	RNA_def_property_range(prop, -2.0f, 2.0f);
+	RNA_def_property_ui_range(prop, -0.5f, 0.5f, 0.001, 0.001);
 	RNA_def_property_ui_text(prop, "Plane Offset", "Adjusts plane on which the brush acts towards or away from the object surface");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
 	prop= RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_float_sdna(prop, NULL, "texture_offset");
-	RNA_def_property_range(prop, -1.0f, 0.0f);
+	RNA_def_property_float_default(prop, 0);
+	RNA_def_property_range(prop, -1, 1);
 	RNA_def_property_ui_text(prop, "Tex Offset", "Allows base level of texture to be biased so that samples can have both positive and negative values");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
 	prop= RNA_def_property(srna, "normal_weight", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_float_sdna(prop, NULL, "normal_weight");
+	RNA_def_property_float_default(prop, 0);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
-	RNA_def_property_ui_text(prop, "Normal Weight", "Controls how much grab will pull vertexes out of the surface during a grab");
+	RNA_def_property_ui_text(prop, "Normal Weight", "How much grab will pull vertexes out of surface during a grab");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+	prop= RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor");
+	RNA_def_property_float_default(prop, 2.0f/3.0f);
+	RNA_def_property_range(prop, 0.0f, 2.0f);
+	RNA_def_property_ui_text(prop, "Pinch", "How much the crease brush pinches");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list