[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29154] branches/soc-2010-jwilkins: * no longer uses fixed size texcache for textures.

Jason Wilkins Jason.A.Wilkins at gmail.com
Wed Jun 2 13:06:07 CEST 2010


Revision: 29154
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29154
Author:   jwilkins
Date:     2010-06-02 13:06:07 +0200 (Wed, 02 Jun 2010)

Log Message:
-----------
* no longer uses fixed size texcache for textures.
	- this means textures aren't cached which will effect performance.
	- we'll get it back later without losing any quality
* unprojecting object coordinates for the tiled texture mode should be floating point, not integers
* Both of these previous changes "fix" the anchor brush and tiled texture modes
* Changed tiled mode to not scale the texture according to the brush size.  Later will add controls to transform this into a mudbox like stencil mode.
* Added a slider to bias the value of the texture so it can have negative values (sinks texture into the model)
* Corrected spacing distance slider to be percentage of diameter, not radius.  Changed tooltip to be more clear.
* Changed tooltip for brush size to indicate that it is the radius, not the diameter
* increased max spacing back up to 500%, I'll be refactoring this control later
* fixed problem with anchor brush updating the screen properly when you made it large and then shrink it down again.

Modified Paths:
--------------
    branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
    branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    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-02 07:59:15 UTC (rev 29153)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py	2010-06-02 11:06:07 UTC (rev 29154)
@@ -547,7 +547,7 @@
             col.separator()
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)           	    
+            row.prop(brush, "size", slider=True)
 
             if brush.sculpt_tool != 'GRAB':
                 row.prop(brush, "use_size_pressure", toggle=True, text="")
@@ -559,20 +559,19 @@
                 # XXX - TODO
                 #row = col.row(align=True)
                 #row.prop(brush, "jitter", slider=True)
-                #row.prop(brush, "use_jitter_pressure", toggle=True, text="")                
-                col = layout.column()
+                #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
 
                 if brush.sculpt_tool in ('CLAY', 'FLATTEN', 'FILL', 'SCRAPE', 'CONTRAST'):
                     row = col.row(align=True)
-                    row.prop(brush, "offset", slider=True)
+                    row.prop(brush, "plane_offset", slider=True)
                     row.prop(brush, "use_offset_pressure", text="")
 
                 if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
                     col.row().prop(brush, "direction", expand=True)
 
                 if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER', 'CLAY'):
-                    col.prop(brush, "use_accumulate")                	    
-	
+                    col.prop(brush, "use_accumulate")
+
                 if brush.sculpt_tool == 'LAYER':
                     ob = context.sculpt_object
                     do_persistent = True
@@ -677,8 +676,13 @@
         col.template_ID_preview(brush, "texture", new="texture.new", rows=2, cols=4)
 
         if context.sculpt_object:
-            col.row().prop(tex_slot, "map_mode", expand=True)
+            row = col.row(align=True)
+            row.prop(tex_slot, "map_mode", expand=True)
+            row = col.row(align=True)
+            row.prop(brush, "texture_offset", slider=True)
 
+        row = col.row(align=True)
+        row.prop(tex_slot, "angle", slider=True)
 
 class VIEW3D_PT_tools_brush_tool(PaintPanel):
     bl_label = "Tool"

Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c	2010-06-02 07:59:15 UTC (rev 29153)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c	2010-06-02 11:06:07 UTC (rev 29154)
@@ -75,7 +75,8 @@
 	brush->rgb[2]= 1.0f;
 	brush->alpha= 0.2f;
 	brush->size= 25;
-	brush->offset= 0.0f;
+	brush->plane_offset= 0.0f;
+	brush->texture_offset = 0.0f;
 	brush->spacing= 15.0f;
 	brush->smooth_stroke_radius= 75;
 	brush->smooth_stroke_factor= 0.9;

Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-06-02 07:59:15 UTC (rev 29153)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c	2010-06-02 11:06:07 UTC (rev 29154)
@@ -200,7 +200,7 @@
             int steps;
             int i;
 
-            scale = (stroke->brush->size*stroke->brush->spacing/100.0f) / length;
+            scale = (stroke->brush->size*stroke->brush->spacing/50.0f) / length;
             mul_v2_fl(vec, scale);
 
             steps = (int)(1.0f / scale);

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-02 07:59:15 UTC (rev 29153)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c	2010-06-02 11:06:07 UTC (rev 29154)
@@ -83,6 +83,7 @@
 
 
 #include "RE_render_ext.h"
+#include "RE_shader_ext.h"
 
 #include "gpu_buffers.h"
 
@@ -715,6 +716,20 @@
 		out[2]= in[2];
 }
 
+static float get_tex_pixel(Brush* br, float u, float v)
+{
+	TexResult texres;
+	float co[3] = { u, v, 0 };
+	int hasrgb;
+	
+	memset(&texres, 0, sizeof(TexResult));
+	hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres);
+
+	if (hasrgb & TEX_RGB) texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb);
+
+	return texres.tin;
+}
+
 /* Get a pixel from the texcache at (px, py) */
 static unsigned char get_texcache_pixel(const SculptSession *ss, int px, int py)
 {
@@ -772,7 +787,7 @@
 	else if(ss->texcache) {
 		const float bsize= ss->cache->pixel_radius * 2;
 		const float rot= tex->rot + ss->cache->rotation;
-		int px, py;
+		float px, py;
 		float flip[3], point_2d[2];
 
 		/* If the active area is being applied for symmetry, flip it
@@ -788,24 +803,25 @@
 			const int sx= (const int)tex->size[0];
 			const int sy= (const int)tex->size[1];
 			
-			float fx= point_2d[0];
-			float fy= point_2d[1];
-			
-			float angle= atan2(fy, fx) - rot;
-			float flen= sqrtf(fx*fx + fy*fy);
-			
 			if(rot<0.001 && rot>-0.001) {
 				px= point_2d[0];
 				py= point_2d[1];
 			} else {
+				float fx= point_2d[0];
+				float fy= point_2d[1];
+				float angle= atan2(fy, fx) - rot;
+				float flen= sqrtf(fx*fx + fy*fy);
+				
 				px= flen * cos(angle) + 2000;
 				py= flen * sin(angle) + 2000;
 			}
-			if(sx != 1)
+			/*if(sx != 1)
 				px %= sx-1;
 			if(sy != 1)
 				py %= sy-1;
-			avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy);
+			*///get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy);
+			//avg= get_tex_pixel(br, ss->texcache_side*px/10000.0f/sx, ss->texcache_side*py/10000.0f/sy);
+			avg= get_tex_pixel(br, px/100.0f/sx, py/100.0f/sx);
 		}
 		else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) {
 			float fx= (point_2d[0] - ss->cache->tex_mouse[0]) / bsize;
@@ -817,12 +833,15 @@
 			fx = flen * cos(angle) + 0.5;
 			fy = flen * sin(angle) + 0.5;
 
-			avg= get_texcache_pixel_bilinear(ss, fx * ss->texcache_side, fy * ss->texcache_side);
+			//avg= get_texcache_pixel_bilinear(ss, fx * ss->texcache_side, fy * ss->texcache_side);
+			avg= get_tex_pixel(br, fx * ss->texcache_side/100.0f, fy * ss->texcache_side/100.0f);
 		}
 	}
 
 	avg*= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */
 
+	avg += br->texture_offset;
+
 	return avg;
 }
 
@@ -903,12 +922,10 @@
 		PBVHVertexIter vd;
 		SculptBrushTest test;
 
+		SculptUndoNode *unode = sculpt_undo_push_node(ss, nodes[n]);
 		sculpt_brush_test_init(ss, &test);
+
 		if(ss->cache->original) {
-			// XXX push instead of get for thread safety in draw
-			// brush .. lame, but also not harmful really
-			SculptUndoNode *unode = sculpt_undo_push_node(ss, nodes[n]);
-
 			BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
 				if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
 					float fno[3];
@@ -1418,16 +1435,14 @@
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
 		SculptBrushTest test;
+		SculptUndoNode *unode;
 
+		// an
+		unode = sculpt_undo_push_node(ss, nodes[n]);
 		sculpt_brush_test_init(ss, &test);
 
 		if(ss->cache->original) {
-			// an
 
-			// XXX push instead of get for thread safety in draw
-			// brush .. lame, but also not harmful really
-			SculptUndoNode *unode = sculpt_undo_push_node(ss, nodes[n]);
-
 			BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
 				if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
 					// an
@@ -1561,7 +1576,7 @@
 {
 	Brush* brush = paint_brush(&sd->paint);
 
-	float rv = brush->offset;
+	float rv = brush->plane_offset;
 
 	if (brush->flag & BRUSH_OFFSET_PRESSURE) {
 		rv *= ss->cache->pressure;
@@ -2516,8 +2531,12 @@
 					copy_v3_v3(vd.co, unode->co[vd.i]);
 					if(vd.no) VECCOPY(vd.no, unode->no[vd.i])
 					else normal_short_to_float_v3(vd.fno, unode->no[vd.i]);
+
+					if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
 				}
 				BLI_pbvh_vertex_iter_end;
+
+				BLI_pbvh_node_mark_update(nodes[n]);
 			}
 		}
 

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-02 07:59:15 UTC (rev 29153)
+++ branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h	2010-06-02 11:06:07 UTC (rev 29154)
@@ -69,12 +69,15 @@
 	
 	int sculpt_direction;		/* the direction of movement for sculpt vertices */
 
-	float offset; /* offset for plane brushes (clay, flatten, fill, scrape, contrast) */
+	float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape, contrast) */
+	float texture_offset;
 
 	char sculpt_tool;			/* active sculpt tool */
 	char vertexpaint_tool;		/* active vertex/weight paint tool/blend mode */
 	char imagepaint_tool;		/* active image paint tool */
 	char stroke_tool;
+
+	int pad2;
 } Brush;
 
 /* Brush.flag */

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-02 07:59:15 UTC (rev 29153)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c	2010-06-02 11:06:07 UTC (rev 29154)
@@ -194,7 +194,7 @@
 	/* number values */
 	prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
 	RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS);
-	RNA_def_property_ui_text(prop, "Size", "Diameter of the brush");
+	RNA_def_property_ui_text(prop, "Size", "Radius of the brush");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 	
 	prop= RNA_def_property(srna, "detail", PROP_FLOAT, PROP_NONE);
@@ -210,8 +210,8 @@
 
 	prop= RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "spacing");
-	RNA_def_property_range(prop, 1.0f, 300.0f);
-	RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush stamps as a percentage of brush size");
+	RNA_def_property_range(prop, 1.0f, 500.0f);
+	RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush stamps as a percentage of brush diameter");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list