[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29591] branches/soc-2010-jwilkins: == Wax & Clay Brushes ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Jun 21 13:39:11 CEST 2010


Revision: 29591
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29591
Author:   jwilkins
Date:     2010-06-21 13:39:11 +0200 (Mon, 21 Jun 2010)

Log Message:
-----------
== Wax & Clay Brushes ==
The old clay brush has been renamed 'Wax', this brush fills in crevices below the offset plane and does not effect brushes above it.

A new Clay brush has been created that is like 'Flatten' with a high plane offset.  It brings things up to the offset plane while lowering things above it.

On top of that, the default offset for clay and wax has been lowered to half the brush radius and the plane offset slider now only goes from -0.5 to 0.5.  This has the effect of flattening clay and wax and makes them less like draw

(so please, no more "clay is just like draw" comments :P)

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    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-21 11:04:19 UTC (rev 29590)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-06-21 11:39:11 UTC (rev 29591)
@@ -583,7 +583,7 @@
                 row = col.row(align=True)
                 row.prop(brush, "normal_weight", slider=True)
 
-            if brush.sculpt_tool in ('CLAY', 'FLATTEN', 'FILL', 'SCRAPE'):
+            if brush.sculpt_tool in ('CLAY', 'WAX', 'FLATTEN', 'FILL', 'SCRAPE'):
                 row = col.row(align=True)
                 row.prop(brush, "plane_offset", slider=True)
                 row.prop(brush, "use_offset_pressure", text="")

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-21 11:04:19 UTC (rev 29590)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-06-21 11:39:11 UTC (rev 29591)
@@ -545,6 +545,7 @@
 		case SCULPT_TOOL_FILL:
 		case SCULPT_TOOL_SCRAPE:
 		case SCULPT_TOOL_FLATTEN:
+		case SCULPT_TOOL_WAX:
 			return alpha * dir * flip * pressure * overlap;
 
 		case SCULPT_TOOL_SMOOTH:
@@ -1817,14 +1818,15 @@
 				point_plane_project(intr, vd.co, an, fc);
 				sub_v3_v3v3(val, intr, vd.co);
 				mul_v3_fl(val, fade);
-				symmetry_feather(sd, ss, vd.co, val);
 				add_v3_v3(val, vd.co);
 
 				sculpt_clip(sd, ss, vd.co, val);
 
 				if(vd.mvert) {
 					vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
-					if(brush->flag & BRUSH_SUBDIV) vd.mvert->flag = 1; 
+
+					if(brush->flag & BRUSH_SUBDIV)
+						vd.mvert->flag = 1; 
 				}
 			}
 		}
@@ -1860,7 +1862,7 @@
 		radius    = -radius;
 	}
 
-	displace = radius * (1+offset);
+	displace = radius * (0.5f+offset);
 
 	mul_v3_v3v3(temp, an, ss->cache->scale);
 	mul_v3_fl(temp, displace);
@@ -1875,6 +1877,73 @@
 
 		BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
 			if (sculpt_brush_test_sq(&test, vd.co)) {
+				float intr[3];
+				float val[3];
+
+				const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist));
+
+				point_plane_project(intr, vd.co, an, fc);
+				sub_v3_v3v3(val, intr, vd.co);
+				mul_v3_fl(val, fade);
+				add_v3_v3(val, vd.co);
+
+				sculpt_clip(sd, ss, vd.co, val);
+
+				if(vd.mvert) {
+					vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+
+					if(brush->flag & BRUSH_SUBDIV)
+						vd.mvert->flag = 1; 
+				}
+			}
+		}
+		BLI_pbvh_vertex_iter_end;
+	}
+}
+
+static void do_wax_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
+{
+	Brush *brush = paint_brush(&sd->paint);
+
+	float bstrength = ss->cache->bstrength;
+	float radius    = ss->cache->radius;
+	float offset    = get_offset(sd, ss);
+	
+	float displace;
+
+	float an[3]; // area normal
+	float fc[3]; // flatten center
+
+	int n;
+
+	float temp[3];
+
+	int flip;
+
+	calc_area_normal_and_flatten_center(sd, ss, nodes, totnode, an, fc);
+
+	flip = bstrength < 0;
+
+	if (flip) {
+		bstrength = -bstrength;
+		radius    = -radius;
+	}
+
+	displace = radius * (0.5+offset);
+
+	mul_v3_v3v3(temp, an, ss->cache->scale);
+	mul_v3_fl(temp, displace);
+	add_v3_v3(fc, temp);
+
+	#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+	for (n = 0; n < totnode; n++) {
+		PBVHVertexIter vd;
+		SculptBrushTest test;
+
+		sculpt_brush_test_init(ss, &test);
+
+		BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+			if (sculpt_brush_test_sq(&test, vd.co)) {
 				if (plane_point_side_flip(vd.co, an, fc, flip)) {
 					float intr[3];
 					float val[3];
@@ -2084,6 +2153,9 @@
 		case SCULPT_TOOL_SCRAPE:
 			do_scrape_brush(sd, ss, nodes, totnode);
 			break;
+		case SCULPT_TOOL_WAX:
+			do_wax_brush(sd, ss, nodes, totnode);
+			break;
 		}
 
 		if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0)
@@ -2421,7 +2493,7 @@
 		cache->original = 1;
 	}
 
-	if(ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY))
+	if(ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_WAX))
 		if(!(brush->flag & BRUSH_ACCUMULATE))
 			cache->original = 1;
 
@@ -2609,7 +2681,6 @@
 	else if(brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK) {
 		float grab_location[3], imat[4][4];
 
-
 		if(cache->first_time)
 			copy_v3_v3(cache->orig_grab_location, cache->true_location);
 		else

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-21 11:04:19 UTC (rev 29590)
+++ branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h	2010-06-21 11:39:11 UTC (rev 29591)
@@ -162,6 +162,7 @@
 #define SCULPT_TOOL_THUMB      12
 #define SCULPT_TOOL_SNAKE_HOOK 13
 #define SCULPT_TOOL_ROTATE     14
+#define SCULPT_TOOL_WAX        15
 
 /* ImagePaintSettings.tool */
 #define PAINT_TOOL_DRAW		0

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-21 11:04:19 UTC (rev 29590)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c	2010-06-21 11:39:11 UTC (rev 29591)
@@ -110,6 +110,7 @@
 		{SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""},
 		{SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""},
 		{SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""},
+		{SCULPT_TOOL_WAX, "WAX", 0, "Wax", ""},
 		{SCULPT_TOOL_FILL, "FILL", 0, "Fill", ""},
 		{SCULPT_TOOL_SCRAPE, "SCRAPE", 0, "Scrape", ""},
 		{0, NULL, 0, NULL, NULL}};
@@ -268,7 +269,7 @@
 
 	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, -1.0f, 1.0f);
+	RNA_def_property_range(prop, -0.5f, 0.5f);
 	RNA_def_property_ui_text(prop, "Plane Offset", "Adjusts the plane on which the brush acts");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 





More information about the Bf-blender-cvs mailing list