[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39141] branches/soc-2011-onion/source/ blender/editors/sculpt_paint: Revision: 30849

Jason Wilkins Jason.A.Wilkins at gmail.com
Sun Aug 7 15:01:25 CEST 2011


Revision: 39141
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39141
Author:   jwilkins
Date:     2011-08-07 13:01:25 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
Revision: 30849
Author: nicholasbishop
Date: 2:43:48 PM, Wednesday, July 28, 2010
Message:
== Paint ==

* More texture refactoring; brush texture symmetry now works properly in sculpt mode again, also works in vpaint now.

TODO:
* Fixed texture mode doesn't work in vpaint
* Anchored brush needs updating

----
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c

--
jwilkins:
Not really is left from Nick's work to apply here, even though texturing is not functional yet in Onion branch.  I moved paint_stroke_combined_strength to paint_dab.c and renamed it paint_combined_strength.  I had a function called paint_strength, but I liked the word 'combined' better because it describes what is happening more clearly.  Also, where a local static tex_strength function was used as a thin wrapper I just directly call paint_combined_strength as I do not think there will be any difference between modes that requires a wrapper.  

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_texcache.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c	2011-08-07 13:01:25 UTC (rev 39141)
@@ -499,7 +499,7 @@
 //			  float radius3d)
 //static float frontface(Brush *brush, float start, float range, float sculpt_normal[3], short no[3])
 //
-//float paint_strength(const Brush *brush, const BrushSpace *bspace, float co[3], short no[3], float mask, float dist)
+//float paint_combined_strength(const Brush *brush, const BrushSpace *bspace, float co[3], short no[3], float mask, float dist)
 //{
 //	return tex_strength(brush, bspace, co, mask, dist) * frontface(brush, bspace, no);
 //}

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c	2011-08-07 13:01:25 UTC (rev 39141)
@@ -301,7 +301,34 @@
 	}
 }
 
-float paint_strength(const Brush *brush, const BrushSpace *bspace, float co[3], short no[3], float mask, float dist)
+float paint_combined_strength(const Brush *brush, const BrushSpace *bspace, float co[3], short no[3], float mask, float dist)
 {
 	return (1.0f-mask)*brush_curve_strength(brush, dist, bspace->radius3d);
 }
+
+#if 0 // SNIP, taken from Nick's work, I'm pasting it here for reference
+/* combines mask, curve, and texture strengths */
+float paint_combined_strength(PaintStroke *stroke, Brush *brush, float dist, float co[3], float mask, float special_rotation, float tex_mouse[2])
+{
+	float mco[3];
+
+	/* if the active area is being applied for symmetry, flip it
+	   across the symmetry axis and rotate it back to the orignal
+	   position in order to project it. This insures that the 
+	   brush texture will be oriented correctly. */
+	if(brush->mtex.tex) {
+		paint_flip_coord(mco, co, stroke->mirror_symmetry_pass);
+		
+		if(stroke->radial_symmetry_pass)
+			mul_m4_v3(stroke->symm_rot_mat_inv, mco);
+
+		co = mco;
+	}
+	
+	return brush_tex_strength(&stroke->vc,
+				  stroke->project_mat, brush, co, mask, dist,
+				  stroke->pixel_radius, stroke->radius,
+				  special_rotation,
+				  tex_mouse);
+}
+#endif

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-08-07 13:01:25 UTC (rev 39141)
@@ -287,11 +287,13 @@
 
 struct MultiresModifierData *paint_mesh_get_active_multires(const struct bContext *C);
 
+#if 0 // SNIP
 float brush_tex_strength(const struct ViewContext *vc,
 			 float pmat[4][4], float symm_brush_local_mat[4][4], int mirror_pass, struct Brush *br,
 			 float co[3], float mask, const float len,
 			 float pixel_radius, float radius3d,
 			 float special_rotation, float tex_mouse[2], struct bglMats* mats);
+#endif
 
 void paint_cache_init(
 	struct wmWindowManager *wm,
@@ -383,7 +385,6 @@
 void PAINT_OT_set_persistent_base(struct wmOperatorType *ot);
 
 /* paint_bspace.c*/
-float paint_strength(const struct Brush *brush, const struct BrushSpace *bspace, float co[3], short no[3], float mask, float dist);
 
 /* paint_texcache.c */
 void paint_tex_init(const struct bContext *C);
@@ -404,6 +405,14 @@
 	const struct PaintStroke *stroke,
 	const struct BrushSpace *bspace);
 
+float paint_combined_strength(
+	const struct Brush *brush,
+	const struct BrushSpace *bspace,
+	float co[3],
+	short no[3],
+	float mask,
+	float dist);
+
 int paint_tool_can_space_stroke(const struct Brush *brush);
 int paint_tool_can_smooth_stroke(const struct Brush *brush);
 

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c	2011-08-07 13:01:25 UTC (rev 39141)
@@ -145,9 +145,16 @@
 			/* TODO: should add a mask layer if needed */
 			if(vd.mask_active) {
 				if(paint_stroke_test(&test, vd.co)) {
-					float fade;
+					float fade=
+						bstrength *
+						paint_combined_strength(
+							brush,
+							paint->cache->bspace_symm_curr,
+							vd.co,
+							NULL,
+							0,
+							test.dist);
 
-					fade= bstrength*paint_strength(brush, paint->cache->bspace_symm_curr, vd.co, NULL, 0, test.dist);
 						/* SNIP bstrength *
 						brush_tex_strength(
 							vc,

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_texcache.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_texcache.c	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_texcache.c	2011-08-07 13:01:25 UTC (rev 39141)
@@ -350,9 +350,9 @@
 	return avg;
 }
 #else
+#if 0 // SNIP
 static float tex_strength(const struct PaintStroke *stroke, struct Brush *br, float *co, float mask, const float len)
 {
-#if 0 // SNIP
 	const struct BrushSpace *bspace= ob->paint->bspace;
 	float mco[3];
 
@@ -387,13 +387,11 @@
 			bspace->tex_angle,
 			bspace->tex_center2d,
 			&(bspace->mats));
-#else
-	return 1;
-#endif
 }
 #endif
+#endif
 
-
+#if 0 // SNIP
 /* return a multiplier for brush strength at a coordinate,
    incorporating texture, curve control, and masking
 
@@ -532,3 +530,4 @@
 	return avg;
 }
 
+#endif

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-07 13:01:25 UTC (rev 39141)
@@ -1608,6 +1608,7 @@
 	}
 }
 
+#if 0 // SNIP
 static float tex_strength(
 	struct Brush *brush,
 	struct BrushSpace *bspace,
@@ -1617,7 +1618,6 @@
 	float len,
 	float radius3d)
 {
-#if 0 // SNIP
 	struct Object *ob= CTX_data_active_object(C);
 	const ViewContext *vc = paint_stroke_view_context(stroke);
 	/*float (*pmat)[4]; XXX: doesn't work */
@@ -1645,10 +1645,8 @@
 			special_rotation,
 			tex_mouse,
 			mats);
-#else
-	return paint_strength(brush, bspace, co, NULL, mask, len);
-#endif
 }
+#endif
 
 /* apply paint at specified coordinate
    returns 1 if paint was applied, 0 otherwise */
@@ -1672,7 +1670,7 @@
 		dist = sqrtf(dist_squared);
 
 		fac= vpd->fac *
-			tex_strength(brush, bspace, stroke, co, mask, dist, radius);
+			paint_combined_strength(brush, bspace, co, NULL, mask, dist);
 
 		vpaint_blend(brush, col, col, vpd->color, fac);
 
@@ -1863,14 +1861,13 @@
 
 				strength=
 					brush->alpha *
-					tex_strength(
+					paint_combined_strength(
 						brush,
 						bspace,
-						stroke,
 						co,
+						NULL,
 						mask,
-						dist,
-						radius);
+						dist);
 
 				act_col= GRIDELEM_COLOR(act_elem, gridkey)[active];
 
@@ -1948,14 +1945,13 @@
 
 					strength =
 						brush->alpha *
-						tex_strength(
+						paint_combined_strength(
 							brush,
 							bspace,
-							stroke,
 							vd.co,
+							NULL,
 							vd.mask_combined,
-							test.dist,
-							radius);
+							test.dist);
 
 					for(j = 0; j < 4; ++j) {
 						unsigned char *c;

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c	2011-08-07 12:45:55 UTC (rev 39140)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c	2011-08-07 13:01:25 UTC (rev 39141)
@@ -197,7 +197,7 @@
 
 		if(paint_stroke_test(&test, vd.co)) {
 			//const float fade = bstrength*tex_strength(stroke, brush, vd.co, vd.mask_combined, test.dist)*frontface(brush, bspace->frontface_start, bspace->frontface_range, bspace->symm_view_vector, orig_no[vd.i]);
-			const float fade= bstrength*paint_strength(brush, bspace, vd.co, orig_no[vd.i], vd.mask_combined, test.dist);
+			const float fade= bstrength*paint_combined_strength(brush, bspace, vd.co, orig_no[vd.i], vd.mask_combined, test.dist);
 			float avg[3], val[3];
 
 			paint_mesh_neighbor_average(ob->paint->meshcache, avg, vd.vert_indices[vd.i]);
@@ -302,7 +302,7 @@
 					float mask = (gridkey->mask ?
 						      *GRIDELEM_MASK_AT(data, x + y*gridsize, gridkey) : 0);
 					//float fade = bstrength*tex_strength(stroke, brush, co, mask, test.dist)*frontface(brush, bspace->frontface_start, bspace->frontface_range, bspace->symm_view_vector, orig_no[k]);
-					const float fade= bstrength*paint_strength(brush, bspace, co, orig_no[k], mask, test.dist);
+					const float fade= bstrength*paint_combined_strength(brush, bspace, co, orig_no[k], mask, test.dist);
 					float *avg, val[3];
 					float n;
 
@@ -410,7 +410,7 @@
 		BLI_pbvh_vertex_iter_begin(pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
 			if (paint_stroke_test(&test, vd.co)) {
 				const float fade=
-					paint_strength(
+					paint_combined_strength(
 						brush,
 						bspace,
 						vd.co,
@@ -472,7 +472,7 @@
 			//if(paint_stroke_test_cyl(&test, vd.co, bspace->location, an)) {
 				/* offset vertex */
 				//float fade = tex_strength(stroke, brush, vd.co, vd.mask_combined, test.dist)*frontface(brush, bspace->frontface_start, bspace->frontface_range, an, orig_no[vd.i]);
-				const float fade= paint_strength(brush, bspace, vd.co, orig_no[vd.i], vd.mask_combined, test.dist);
+				const float fade= paint_combined_strength(brush, bspace, vd.co, orig_no[vd.i], vd.mask_combined, test.dist);
 
 				mul_v3_v3fl(proxy[vd.i], offset, fade);
 
@@ -543,7 +543,7 @@
 			if(paint_stroke_test(&test, vd.co)) {
 				/* offset vertex */
 				//const float fade = tex_strength(stroke, brush, vd.co, vd.mask_combined, test.dist)*frontface(brush, bspace->frontface_start, bspace->frontface_start, an, orig_no[vd.i]);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list