[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30849] branches/soc-2010-nicolasbishop/ source/blender: == Paint ==

Nicholas Bishop nicholasbishop at gmail.com
Wed Jul 28 21:43:48 CEST 2010


Revision: 30849
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30849
Author:   nicholasbishop
Date:     2010-07-28 21:43:48 +0200 (Wed, 28 Jul 2010)

Log 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 Paths:
--------------
    branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c

Modified: branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c	2010-07-28 19:43:05 UTC (rev 30848)
+++ branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c	2010-07-28 19:43:48 UTC (rev 30849)
@@ -1492,6 +1492,9 @@
 	writestruct(wd, DATA, "CustomDataMultires", count, grids);
 
 	for(i = 0; i < count; ++i) {
+		writestruct(wd, DATA, "CustomDataMultiresLayer",
+			    grids[i].totlayer, grids[i].layers);
+
 		for(j = 0; j < grids[i].totlayer; ++j) {
 			CustomDataMultiresLayer *l = &grids[i].layers[j];
 

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h	2010-07-28 19:43:05 UTC (rev 30848)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h	2010-07-28 19:43:48 UTC (rev 30849)
@@ -72,6 +72,11 @@
 
 int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
 void paint_stroke_apply_brush(struct bContext *C, struct PaintStroke *stroke, struct Paint *paint);
+float paint_stroke_combined_strength(struct PaintStroke *stroke,
+				     struct Brush *brush, float dist,
+				     float co[3], float mask,
+				     float special_rotation,
+				     float tex_mouse[2]);
 int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
 void *paint_stroke_mode_data(struct PaintStroke *stroke);
 void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c	2010-07-28 19:43:05 UTC (rev 30848)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c	2010-07-28 19:43:48 UTC (rev 30849)
@@ -67,6 +67,8 @@
 	float project_mat[4][4];
 	bglMats mats;
 	Brush *brush;
+	/* not always the same as brush_size() */
+	int pixel_radius;
 	/* projected brush radius */
 	float radius, radius_squared;
 	/* brush location (object space) */
@@ -77,6 +79,7 @@
 	int mirror_symmetry_pass;
 	int radial_symmetry_pass;
 	float symm_rot_mat[4][4];
+	float symm_rot_mat_inv[4][4];
 	/* decrease brush strength if symmetry overlaps */
 	float feather;
 
@@ -875,6 +878,9 @@
 	unit_m4(stroke->symm_rot_mat);
 	rotate_m4(stroke->symm_rot_mat, axis, angle);
 
+	unit_m4(stroke->symm_rot_mat_inv);
+	rotate_m4(stroke->symm_rot_mat_inv, axis, -angle);
+
 	/* symmetry_location */
 	paint_flip_coord(location, location, symm);
 	mul_m4_v3(stroke->symm_rot_mat, location);
@@ -910,9 +916,9 @@
 {
 	ViewContext *vc = &stroke->vc;
 
-	/* TODO: radius */
+	stroke->pixel_radius = brush_size(paint_brush(paint));
 	stroke->radius = paint_calc_object_space_radius(vc->obact, vc, stroke->location,
-							brush_size(paint_brush(paint)));
+							stroke->pixel_radius);
 	stroke->radius_squared = stroke->radius*stroke->radius;
 	stroke->feather = calc_symmetry_feather(stroke, paint, stroke->location, paint->flags & 7);
 }
@@ -1047,7 +1053,7 @@
 					pressure = brush_use_size_pressure(stroke->brush) ? wmtab->Pressure : 1;
 			}
 
-			scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
+			scale = (stroke->pixel_radius * pressure * stroke->brush->spacing/50.0f) / length;
 			mul_v2_fl(vec, scale);
 
 			steps = (int)(1.0f / scale);
@@ -1184,6 +1190,31 @@
 	}
 }
 
+/* combines mask, curve, and texture strengths */
+float paint_stroke_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);
+}
+
 int paint_stroke_exec(bContext *C, wmOperator *op)
 {
 	Paint *paint = paint_get_active(CTX_data_scene(C));

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c	2010-07-28 19:43:05 UTC (rev 30848)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c	2010-07-28 19:43:48 UTC (rev 30849)
@@ -1652,18 +1652,13 @@
 }
 
 static float tex_strength(Brush *brush, PaintStroke *stroke,
-			  float co[3], float mask, float len,
+			  float co[3], float mask, float dist,
 			  float radius3d)
 {
-	ViewContext *vc = paint_stroke_view_context(stroke);
-	float (*pmat)[4];
 	float tex_mouse[2] = {0,0}; /* TODO */
 
-	paint_stroke_projection_mat(stroke, &pmat);
-
-	return brush_tex_strength(vc, pmat, brush, co, mask, len,
-				  brush_size(brush), radius3d, 0,
-				  tex_mouse);
+	return paint_stroke_combined_strength(stroke, brush, dist, co, mask,
+					      0, tex_mouse);
 }
 
 /* apply paint at specified coordinate

Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c	2010-07-28 19:43:05 UTC (rev 30848)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c	2010-07-28 19:43:48 UTC (rev 30849)
@@ -187,6 +187,7 @@
 	float project_mat[4][4];
 
 	/* Clean this up! */
+	PaintStroke *stroke;
 	ViewContext *vc;
 	Brush *brush;
 
@@ -203,7 +204,6 @@
 	float last_center[3];
 	int radial_symmetry_pass;
 	float symm_rot_mat[4][4];
-	float symm_rot_mat_inv[4][4];
 	float last_rake[2]; /* Last location of updating rake rotation */
 	int original;
 
@@ -404,29 +404,12 @@
 
 #endif
 
-static float tex_strength(SculptSession *ss, Brush *br, float *co, float mask, const float len)
+static float tex_strength(SculptSession *ss, Brush *br, float *co,
+			  float mask, float dist)
 {
-	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(br->mtex.tex &&
-	   br->mtex.brush_map_mode != MTEX_MAP_MODE_3D) {
-		/* XXX, move to paint stroke: flip_coord(mco, co, ss->cache->mirror_symmetry_pass);
-		
-		if(ss->cache->radial_symmetry_pass)
-		mul_m4_v3(ss->cache->symm_rot_mat_inv, mco); */
-
-		co = mco;
-	}
-	
-	return brush_tex_strength(ss->cache->vc,
-				  ss->cache->project_mat, br, co, mask, len,
-				  ss->cache->pixel_radius, ss->cache->radius,
-				  ss->cache->special_rotation,
-				  ss->cache->tex_mouse);
+	return paint_stroke_combined_strength(ss->cache->stroke, br, dist, co, mask,
+					      ss->cache->special_rotation,
+					      ss->cache->tex_mouse);
 }
 
 
@@ -2332,6 +2315,7 @@
 	int mode;
 
 	ss->cache = cache;
+	ss->cache->stroke = op->customdata;
 
 	/* Set scaling adjustment */
 	ss->cache->scale[0] = 1.0f / ob->size[0];
@@ -2870,9 +2854,6 @@
 
 	copy_m4_m4(cache->symm_rot_mat, symmetry_rot_mat);
 
-	unit_m4(cache->symm_rot_mat_inv);
-	rotate_m4(cache->symm_rot_mat_inv, axis, -angle);
-
 	mul_m4_v3(symmetry_rot_mat, cache->grab_delta_symmetry);
 }
 





More information about the Bf-blender-cvs mailing list