[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30254] branches/soc-2010-jwilkins: == Front Faces Only ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Tue Jul 13 10:31:32 CEST 2010


Revision: 30254
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30254
Author:   jwilkins
Date:     2010-07-13 10:31:28 +0200 (Tue, 13 Jul 2010)

Log Message:
-----------
== Front Faces Only ==
Turning on 'front faces only' causes the brush to only effect vertexes that have normals facing the viewer.  This is useful for sculpting thin objects where you do not want the other side of the object effected by the brush

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_intern.h
    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/makesdna/DNA_windowmanager_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-07-13 08:20:34 UTC (rev 30253)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-07-13 08:31:28 UTC (rev 30254)
@@ -525,7 +525,7 @@
 
                 row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaultbrushes)
 
-            col.operator("brush.copy")
+            col.operator("brush.copy", text="Duplicate Brush")
 
         # Particle Mode #
 
@@ -656,7 +656,10 @@
                 row.active=brush.use_plane_trim
                 row.prop(brush, "plane_trim", slider=True, text="Distance")
 
+            col.separator()
 
+            row= col.row()
+            row.prop(brush, "use_frontface", text="Front Faces Only")
 
             if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY', 'CLAY_TUBES', 'WAX'):
                 col.separator()

Modified: branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-07-13 08:20:34 UTC (rev 30253)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c	2010-07-13 08:31:28 UTC (rev 30254)
@@ -10985,6 +10985,9 @@
 
 			if (brush->crease_pinch_factor == 0)
 				brush->crease_pinch_factor = 2.0f/3.0f;
+
+			if (brush->plane_trim == 0)
+				brush->plane_trim = 0.5f;
 		}
 	}
 

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_intern.h	2010-07-13 08:20:34 UTC (rev 30253)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_intern.h	2010-07-13 08:31:28 UTC (rev 30254)
@@ -110,6 +110,13 @@
 
 int facemask_paint_poll(struct bContext *C);
 
+/* stroke operator */
+typedef enum wmBrushStrokeMode {
+	WM_BRUSHSTROKE_NORMAL,
+	WM_BRUSHSTROKE_INVERT,
+	WM_BRUSHSTROKE_SMOOTH,
+} wmBrushStrokeMode;
+
 /* paint_undo.c */
 typedef void (*UndoRestoreCb)(struct bContext *C, struct ListBase *lb);
 typedef void (*UndoFreeCb)(struct ListBase *lb);

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-13 08:20:34 UTC (rev 30253)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-07-13 08:31:28 UTC (rev 30254)
@@ -339,116 +339,49 @@
 typedef struct SculptBrushTest {
 	float radius_squared;
 	float location[3];
-
 	float dist;
-
-	//float true_location[3];
-	//int symmetry;
-	//int mirror_symmetry_pass;
 } SculptBrushTest;
 
 static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
 {
 	test->radius_squared= ss->cache->radius_squared;
 	copy_v3_v3(test->location, ss->cache->location);
-
-	//copy_v3_v3(test->true_location, ss->cache->true_location);
-	//test->symmetry = ss->cache->symmetry;
-	//test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass;
 }
 
-#if 0
-
-static int sculpt_brush_test_clip(SculptBrushTest* test, float co[3])
+static int sculpt_brush_test(SculptBrushTest *test, float co[3])
 {
-	if (test->symmetry) {
-		int i;
+	float distsq = len_squared_v3v3(co, test->location);
 
-		for (i = 0; i < 3; i++) {
-			if (test->mirror_symmetry_pass & (1<<i)) {
-				if (test->true_location[i] >= 0) {
-					if (co[i] >= 0) return 0;
-				}
-				else if (test->true_location[i] < 0) {
-					if (co[i] < 0) return 0;
-				}
-			}
-			else {
-				if (test->true_location[i] >= 0) {
-					if (co[i] < 0) return 0;
-				}
-				else if (test->true_location[i] < 0) {
-					if (co[i] >= 0) return 0;
-				}
-			}
-		}
+	if(distsq <= test->radius_squared) {
+		test->dist = sqrt(distsq);
+		return 1;
 	}
-
-	return 1;
+	else {
+		return 0;
+	}
 }
 
-static int sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float location[3], float an[3])
+static int sculpt_brush_test_sq(SculptBrushTest *test, float co[3])
 {
-	if (sculpt_brush_test_fast(test, co)) {
-		float t1[3], t2[3], t3[3], dist;
+	float distsq = len_squared_v3v3(co, test->location);
 
-		sub_v3_v3v3(t1, location, co);
-		sub_v3_v3v3(t2, x2, location);
-
-		cross_v3_v3v3(t3, an, t1);
-
-		dist = len_v3(t3)/len_v3(t2);
-
-		test->dist = dist;
-
+	if(distsq <= test->radius_squared) {
+		test->dist = distsq;
 		return 1;
 	}
-
-	return 0;
+	else {
+		return 0;
+	}
 }
 
-#endif
-
-static int sculpt_brush_test(SculptBrushTest *test, float co[3])
+static int sculpt_brush_test_fast(SculptBrushTest *test, float co[3])
 {
-	//if (sculpt_brush_test_clip(test, co)) {
-		float distsq = len_squared_v3v3(co, test->location);
-
-		if(distsq <= test->radius_squared) {
-			test->dist = sqrt(distsq);
-			return 1;
-		}
-		else {
-			return 0;
-		}
-	//}
-	//else {
-	//	return 0;
-	//}
+	return len_squared_v3v3(co, test->location) <= test->radius_squared;
 }
 
-static int sculpt_brush_test_sq(SculptBrushTest *test, float co[3])
-{
-	//if (sculpt_brush_test_clip(test, co)) {
-		float distsq = len_squared_v3v3(co, test->location);
-
-		if(distsq <= test->radius_squared) {
-			test->dist = distsq;
-			return 1;
-		}
-		else {
-			return 0;
-		}
-	//}
-	//else {
-	//	return 0;
-	//}
-}
-
 static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float local[4][4])
 {
 	const static float side = 0.70710678118654752440084436210485; // sqrt(.5);
-	//float corner = 0.80*side;
 
 	float local_co[3];
 
@@ -468,38 +401,57 @@
 	}
 }
 
-static int sculpt_brush_test_fast(SculptBrushTest *test, float co[3])
+static float frontface(SculptSession *ss, Brush *brush, short no[3], float fno[3])
 {
-	//if (sculpt_brush_test_clip(test, co)) {
-		return len_squared_v3v3(co, test->location) <= test->radius_squared;
-	//}
-	//else {
-	//	return 0;
-	//}
-}
+	if (brush->flag & BRUSH_FRONTFACE) {
+		float dot;
 
+		if (no) {
+			float tmp[3];
 
-/* ===== Sculpting =====
- *
- */
-  
+			normal_short_to_float_v3(tmp, no);
+			dot= dot_v3v3(tmp, ss->cache->view_normal);
+		}
+		else {
+			dot= dot_v3v3(fno, ss->cache->view_normal);
+		}
 
+		return dot > 0 ? dot : 0;
+	}
+	else {
+		return 1;
+	}
+}
+
 #if 0
 
-/* area of overlap of two circles of radius 1 seperated by d units from their centers */
-static float circle_overlap(float d)
+static int sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float location[3], float an[3])
 {
-	return (2*acos(d/2)-(1/2)*d*sqrt(4-d*d));
-}
+	if (sculpt_brush_test_fast(test, co)) {
+		float t1[3], t2[3], t3[3], dist;
 
-/* percentage of overlap of two circles of radius 1 seperated by d units from their centers */
-static float circle_overlap_percent(float d)
-{
-	return circle_overlap(d) / M_PI;
+		sub_v3_v3v3(t1, location, co);
+		sub_v3_v3v3(t2, x2, location);
+
+		cross_v3_v3v3(t3, an, t1);
+
+		dist = len_v3(t3)/len_v3(t2);
+
+		test->dist = dist;
+
+		return 1;
+	}
+
+	return 0;
 }
 
 #endif
 
+/* ===== Sculpting =====
+ *
+ */
+  
+
 static float overlapped_curve(Brush* br, float x)
 {
 	int i;
@@ -635,9 +587,6 @@
 	float invert       = cache->invert ? -1 : 1;
 	float accum        = integrate_overlap(brush);
 	float overlap      = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
-	//float overlap      = (brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100.0f) ? 1 - circle_overlap_percent(brush->spacing/50.0f) : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
-	//float overlap      = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? (float)brush->spacing/100.0f : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
-	//float overlap      = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 50) ? (float)brush->spacing/50.0f : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
 	float flip         = dir * invert * pen_flip;
 	float feather      = calc_symmetry_feather(sd, cache);
 
@@ -692,7 +641,7 @@
 			return alpha * pressure * overlap * feather;
 
 		case SCULPT_TOOL_THUMB:
-			return alpha*pressure*feather / 4;
+			return alpha*pressure*feather;
 
 		case SCULPT_TOOL_SNAKE_HOOK:
 			return feather;
@@ -1086,7 +1035,7 @@
 
 	BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
 		if(sculpt_brush_test(&test, vd.co)) {
-			const float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength;
+			const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(ss, brush, vd.no, vd.fno);
 			float avg[3], val[3];
 
 			neighbor_average(ss, avg, vd.vert_indices[vd.i]);
@@ -1159,6 +1108,8 @@
 		for(y = 0; y < gridsize; ++y)  {
 			for(x = 0; x < gridsize; ++x)  {
 				float *co;
+				float *fno;
+				int index;
 
 				if(x == 0 && adj->index[0] == -1)
 					continue;
@@ -1172,10 +1123,12 @@
 				if(y == gridsize - 1 && adj->index[1] == -1)
 					continue;
 
-				co = data[x + y*gridsize].co;
+				index = x + y*gridsize;
+				co=  data[index].co;
+				fno= data[index].no;
 
 				if(sculpt_brush_test(&test, co)) {
-					const float fade = tex_strength(ss, brush, co, test.dist)*bstrength;
+					const float fade = bstrength*tex_strength(ss, brush, co, test.dist)*frontface(ss, brush, NULL, fno);
 					float *avg, val[3];
 					float n;
 
@@ -1267,12 +1220,11 @@
 		sculpt_brush_test_init(ss, &test);
 
 		BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
-			if(sculpt_brush_test(&test, vd.co)) {
+			if (sculpt_brush_test(&test, vd.co)) {
 			//if(sculpt_brush_test_cyl(&test, vd.co, ss->cache->location, area_normal)) {
 				/* offset vertex */
-				float fade = tex_strength(ss, brush, vd.co, test.dist);
+				float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(ss, brush, vd.no, vd.fno);
 
-				//fade *= symmetry_feather(sd, ss->cache, vd.co);
 				mul_v3_v3fl(proxy[vd.i], offset, fade);
 
 				if(vd.mvert)
@@ -1324,7 +1276,7 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list