[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60122] trunk/blender: Sculpting:

Antony Riakiotakis kalast at gmail.com
Sat Sep 14 01:58:01 CEST 2013


Revision: 60122
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60122
Author:   psy-fi
Date:     2013-09-13 23:58:00 +0000 (Fri, 13 Sep 2013)
Log Message:
-----------
Sculpting:

* Cleanup for previous commit and reduce some local variable referencing
* Add support for brushes that operate on frontfaces only and do not
show the option for those brushes. Currently only clay strips is in the
list but this may change according to artist feedback. This should take
care of the "sticky" surface problem completely.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    trunk/blender/source/blender/blenkernel/BKE_brush.h
    trunk/blender/source/blender/blenkernel/BKE_paint.h
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/makesrna/intern/rna_brush.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-09-13 23:21:35 UTC (rev 60121)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-09-13 23:58:00 UTC (rev 60122)
@@ -642,9 +642,10 @@
                 row.prop(brush, "height", slider=True, text="Height")
 
             # use_frontface
-            col.separator()
-            row = col.row()
-            row.prop(brush, "use_frontface", text="Front Faces Only")
+            if capabilities.has_frontface:
+                col.separator()
+                row = col.row()
+                row.prop(brush, "use_frontface", text="Front Faces Only")
 
             # direction
             col.separator()

Modified: trunk/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_brush.h	2013-09-13 23:21:35 UTC (rev 60121)
+++ trunk/blender/source/blender/blenkernel/BKE_brush.h	2013-09-13 23:58:00 UTC (rev 60122)
@@ -111,5 +111,8 @@
 /* debugging only */
 void BKE_brush_debug_print_state(struct Brush *br);
 
+/* sculpt */
+bool BKE_sculpt_brush_frontface_only(struct Brush *);
+
 #endif
 

Modified: trunk/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_paint.h	2013-09-13 23:21:35 UTC (rev 60121)
+++ trunk/blender/source/blender/blenkernel/BKE_paint.h	2013-09-13 23:58:00 UTC (rev 60122)
@@ -173,5 +173,4 @@
 void free_sculptsession_deformMats(struct SculptSession *ss);
 void sculptsession_bm_to_me(struct Object *ob, int reorder);
 void sculptsession_bm_to_me_for_render(struct Object *object);
-
 #endif

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c	2013-09-13 23:21:35 UTC (rev 60121)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c	2013-09-13 23:58:00 UTC (rev 60122)
@@ -1048,3 +1048,8 @@
 
 	return im;
 }
+
+bool BKE_sculpt_brush_frontface_only(struct Brush *br)
+{
+	return br->sculpt_tool != SCULPT_TOOL_CLAY_STRIPS;
+}

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-09-13 23:21:35 UTC (rev 60121)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-09-13 23:58:00 UTC (rev 60122)
@@ -318,6 +318,8 @@
 	float plane_trim_squared;
 
 	rcti previous_r; /* previous redraw rectangle */
+
+	bool frontface; /* use front face */
 } StrokeCache;
 
 /************** Access to original unmodified vertex data *************/
@@ -669,10 +671,10 @@
 	}
 }
 
-static float frontface(Brush *brush, const float sculpt_normal[3],
+static float frontface(bool ff, const float sculpt_normal[3],
                        const short no[3], const float fno[3])
 {
-	if (brush->flag & BRUSH_FRONTFACE) {
+	if (ff) {
 		float dot;
 
 		if (no) {
@@ -949,7 +951,8 @@
                           const float fno[3],
                           const float mask)
 {
-	const Scene *scene = ss->cache->vc->scene;
+	const StrokeCache *cache = ss->cache;
+	const Scene *scene = cache->vc->scene;
 	MTex *mtex = &br->mtex;
 	float avg = 1;
 	float rgba[4];
@@ -971,12 +974,12 @@
 		 * position in order to project it. This insures that the 
 		 * brush texture will be oriented correctly. */
 
-		flip_v3_v3(symm_point, point, ss->cache->mirror_symmetry_pass);
+		flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass);
 
-		if (ss->cache->radial_symmetry_pass)
-			mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point);
+		if (cache->radial_symmetry_pass)
+			mul_m4_v3(cache->symm_rot_mat_inv, symm_point);
 
-		ED_view3d_project_float_v2_m4(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
+		ED_view3d_project_float_v2_m4(cache->vc->ar, symm_point, point_2d, cache->projection_mat);
 
 		/* still no symmetry supported for other paint modes.
 		 * Sculpt does it DIY */
@@ -984,7 +987,7 @@
 			/* Similar to fixed mode, but projects from brush angle
 			 * rather than view direction */
 
-			mul_m4_v3(ss->cache->brush_local_mat, symm_point);
+			mul_m4_v3(cache->brush_local_mat, symm_point);
 
 			x = symm_point[0];
 			y = symm_point[1];
@@ -1006,9 +1009,9 @@
 	}
 
 	/* Falloff curve */
-	avg *= BKE_brush_curve_strength(br, len, ss->cache->radius);
+	avg *= BKE_brush_curve_strength(br, len, cache->radius);
 
-	avg *= frontface(br, sculpt_normal, vno, fno);
+	avg *= frontface(cache->frontface, sculpt_normal, vno, fno);
 
 	/* Paint mask */
 	avg *= 1.0f - mask;
@@ -2307,11 +2310,9 @@
 			{
 				if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
 					float fno[3];
-					float dot_result;
 
 					normal_short_to_float_v3(fno, unode->no[vd.i]);
-					dot_result = dot_v3v3(ss->cache->view_normal, fno);
-					if (dot_result > 0) {
+					if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
 						add_v3_v3(private_fc, unode->co[vd.i]);
 						private_count++;
 					}
@@ -2327,16 +2328,13 @@
 			BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
 			{
 				if (sculpt_brush_test_fast(&test, vd.co)) {
-					float dot_result;
-
 					/* for area normal */
 					if (vd.no) {
 						float fno[3];
 
 						normal_short_to_float_v3(fno, vd.no);
-						dot_result = dot_v3v3(ss->cache->view_normal, fno);
 
-						if (dot_result > 0) {
+						if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
 							add_v3_v3(private_fc, vd.co);
 							private_count++;
 						}
@@ -2346,8 +2344,7 @@
 						}
 					}
 					else {
-						dot_result = dot_v3v3(ss->cache->view_normal, vd.fno);
-						if (dot_result > 0) {
+						if (dot_v3v3(ss->cache->view_normal, vd.fno) > 0) {
 							add_v3_v3(private_fc, vd.co);
 							private_count++;
 						}
@@ -2423,11 +2420,10 @@
 				if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
 					/* for area normal */
 					float fno[3];
-					float dot_result;
 
 					normal_short_to_float_v3(fno, unode->no[vd.i]);
-					dot_result = dot_v3v3(ss->cache->view_normal, fno);
-					if (dot_result > 0) {
+
+					if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
 						add_v3_v3(private_an, fno);
 						add_v3_v3(private_fc, unode->co[vd.i]);
 						private_count++;
@@ -2445,16 +2441,13 @@
 			BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
 			{
 				if (sculpt_brush_test_fast(&test, vd.co)) {
-					float dot_result;
-
 					/* for area normal */
 					if (vd.no) {
 						float fno[3];
 
 						normal_short_to_float_v3(fno, vd.no);
-						dot_result = dot_v3v3(ss->cache->view_normal, fno);
 
-						if (dot_result > 0) {
+						if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
 							add_v3_v3(private_an, fno);
 							add_v3_v3(private_fc, vd.co);
 							private_count++;
@@ -2466,8 +2459,7 @@
 						}
 					}
 					else {
-						dot_result = dot_v3v3(ss->cache->view_normal, vd.fno);
-						if (dot_result > 0) {
+						if (dot_v3v3(ss->cache->view_normal, vd.fno) > 0) {
 							add_v3_v3(private_an, vd.fno);
 							add_v3_v3(private_fc, vd.co);
 							private_count++;
@@ -3930,6 +3922,9 @@
 	cache->previous_vertex_rotation = 0;
 	cache->init_dir_set = false;
 
+	cache->frontface = ((brush->flag & BRUSH_FRONTFACE) != 0) ||
+	                     BKE_sculpt_brush_frontface_only(brush);
+
 	sculpt_omp_start(sd, ss);
 }
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_brush.c	2013-09-13 23:21:35 UTC (rev 60121)
+++ trunk/blender/source/blender/makesrna/intern/rna_brush.c	2013-09-13 23:58:00 UTC (rev 60122)
@@ -237,6 +237,12 @@
 	return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
 }
 
+static int rna_SculptToolCapabilities_has_frontface_get(PointerRNA *ptr)
+{
+	Brush *br = (Brush *)ptr->data;
+	return BKE_sculpt_brush_frontface_only(br);
+}
+
 static int rna_BrushCapabilities_has_texture_angle_get(PointerRNA *ptr)
 {
 	Brush *br = (Brush *)ptr->data;
@@ -556,6 +562,7 @@
 	SCULPT_TOOL_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke");
 	SCULPT_TOOL_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
 	SCULPT_TOOL_CAPABILITY(has_strength, "Has Strength");
+	SCULPT_TOOL_CAPABILITY(has_frontface, "Has Strength");
 
 #undef SCULPT_CAPABILITY
 }




More information about the Bf-blender-cvs mailing list