[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22438] branches/blender2.5/blender: 2.5/ Sculpt:

Nicholas Bishop nicholasbishop at gmail.com
Thu Aug 13 22:05:36 CEST 2009


Revision: 22438
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22438
Author:   nicholasbishop
Date:     2009-08-13 22:05:36 +0200 (Thu, 13 Aug 2009)

Log Message:
-----------
2.5/Sculpt:

* Moved the brush texture settings to MTex/TextureSlot. The mapping settings now show up in the texture panel, pretty much like they do for textures used with materials.

TODO:
* Tiled mode should not show Z size setting
* Add a locked mode so that texture size can be changed uniformly like in 2.4x

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_texture.py
    branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_brush_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_texture_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_brush.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c

Modified: branches/blender2.5/blender/release/ui/buttons_texture.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_texture.py	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/release/ui/buttons_texture.py	2009-08-13 20:05:36 UTC (rev 22438)
@@ -137,10 +137,21 @@
 			row.itemR(tex, "y_mapping", text="")
 			row.itemR(tex, "z_mapping", text="")
 
-		row = layout.row()
-		row.column().itemR(tex, "offset")
-		row.column().itemR(tex, "size")
+		if br:
+			layout.itemR(tex, "brush_map_mode", expand=True)
+			
+			row = layout.row()
+			row.active = tex.brush_map_mode in ('FIXED', 'TILED')
+			row.itemR(tex, "angle")
 
+			row = layout.row()
+			row.active = tex.brush_map_mode in ('TILED', '3D')
+			row.column().itemR(tex, "size")
+		else:
+			row = layout.row()
+			row.column().itemR(tex, "offset")
+			row.column().itemR(tex, "size")
+
 class TEXTURE_PT_influence(TextureButtonsPanel):
 	__label__ = "Influence"
 	

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c	2009-08-13 20:05:36 UTC (rev 22438)
@@ -300,6 +300,13 @@
 	curvemapping_changed(b->curve, 0);
 }
 
+static MTex *brush_active_texture(Brush *brush)
+{
+	if(brush && brush->texact >= 0)
+		return brush->mtex[brush->texact];
+	return NULL;
+}
+
 int brush_texture_set_nr(Brush *brush, int nr)
 {
 	ID *idtest, *id=NULL;
@@ -1077,8 +1084,11 @@
 		original_value = br->size * size_weight;
 	else if(mode == WM_RADIALCONTROL_STRENGTH)
 		original_value = br->alpha;
-	else if(mode == WM_RADIALCONTROL_ANGLE)
-		original_value = br->rot;
+	else if(mode == WM_RADIALCONTROL_ANGLE) {
+		MTex *mtex = brush_active_texture(br);
+		if(mtex)
+			original_value = mtex->rot;
+	}
 
 	RNA_float_set(op->ptr, "initial_value", original_value);
 	op->customdata = brush_gen_radial_control_imbuf(br);
@@ -1094,8 +1104,11 @@
 		br->size = new_value * size_weight;
 	else if(mode == WM_RADIALCONTROL_STRENGTH)
 		br->alpha = new_value;
-	else if(mode == WM_RADIALCONTROL_ANGLE)
-		br->rot = new_value * conv;
+	else if(mode == WM_RADIALCONTROL_ANGLE) {
+		MTex *mtex = brush_active_texture(br);
+		if(mtex)
+			mtex->rot = new_value * conv;
+	}
 
 	return OPERATOR_FINISHED;
 }

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-08-13 20:05:36 UTC (rev 22438)
@@ -655,31 +655,26 @@
 {
 	SculptSession *ss= sd->session;
 	Brush *br = sd->brush;
+	MTex *tex = NULL;
 	float avg= 1;
 
-	if(br->texact==-1 || !br->mtex[br->texact])
+	if(br->texact >= 0)
+		tex = br->mtex[br->texact];
+
+	if(!tex) {
 		avg= 1;
-	else if(br->tex_mode==BRUSH_TEX_3D) {
-		/* Get strength by feeding the vertex location directly
-		   into a texture */
+	}
+	else if(tex->brush_map_mode == MTEX_MAP_MODE_3D) {
 		float jnk;
-		const float factor= 0.01;
-		MTex mtex;
-		memset(&mtex,0,sizeof(MTex));
-		mtex.tex= br->mtex[br->texact]->tex;
-		mtex.projx= 1;
-		mtex.projy= 2;
-		mtex.projz= 3;
-		VecCopyf(mtex.size, br->mtex[br->texact]->size);
-		VecMulf(mtex.size, factor);
-		if(!sd->texsep)
-			mtex.size[1]= mtex.size[2]= mtex.size[0];
-		
-		externtex(&mtex,point,&avg,&jnk,&jnk,&jnk,&jnk);
+
+		/* Get strength by feeding the vertex 
+		   location directly into a texture */
+		externtex(tex, point, &avg,
+			  &jnk, &jnk, &jnk, &jnk);
 	}
 	else if(ss->texcache) {
 		const float bsize= ss->cache->pixel_radius * 2;
-		const float rot= sd->brush->rot + ss->cache->rotation;
+		const float rot= tex->rot + ss->cache->rotation;
 		int px, py;
 		float flip[3], point_2d[2];
 
@@ -692,9 +687,9 @@
 
 		/* For Tile and Drag modes, get the 2D screen coordinates of the
 		   and scale them up or down to the texture size. */
-		if(br->tex_mode==BRUSH_TEX_TILE) {
-			const int sx= (const int)br->mtex[br->texact]->size[0];
-			const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx;
+		if(tex->brush_map_mode == MTEX_MAP_MODE_TILED) {
+			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];
@@ -714,7 +709,8 @@
 			if(sy != 1)
 				py %= sy-1;
 			avg= get_texcache_pixel_bilinear(ss, ss->texcache_side*px/sx, ss->texcache_side*py/sy);
-		} else {
+		}
+		else if(tex->brush_map_mode == MTEX_MAP_MODE_FIXED) {
 			float fx= (point_2d[0] - ss->cache->mouse[0]) / bsize;
 			float fy= (point_2d[1] - ss->cache->mouse[1]) / bsize;
 

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_brush_types.h	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_brush_types.h	2009-08-13 20:05:36 UTC (rev 22438)
@@ -63,13 +63,10 @@
 	float rgb[3];				/* color */
 	float alpha;				/* opacity */
 
-	float rot;					/* rotation in radians */
-
 	short texact;				/* active texture */
 	char sculpt_tool;			/* active tool */
-	char tex_mode;
 	
-	char pad[4];
+	char pad;
 } Brush;
 
 /* Brush.flag */
@@ -97,11 +94,6 @@
 #define BRUSH_BLEND_ERASE_ALPHA	6
 #define BRUSH_BLEND_ADD_ALPHA	7
 
-/* Brush.tex_mode */
-#define BRUSH_TEX_DRAG 0
-#define BRUSH_TEX_TILE 1
-#define BRUSH_TEX_3D   2
-
 /* Brush.sculpt_tool */
 #define SCULPT_TOOL_DRAW    1
 #define SCULPT_TOOL_SMOOTH  2

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h	2009-08-13 20:05:36 UTC (rev 22438)
@@ -476,11 +476,10 @@
 	/* For rotating around a pivot point */
 	float pivot[3];
 	int flags;
-	/* For the Brush Shape */
-	char texsep;
+
 	/* Control tablet input */
 	char tablet_size, tablet_strength;
-	char pad[5];
+	char pad[6];
 } Sculpt;
 
 typedef struct VPaint {

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_texture_types.h	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_texture_types.h	2009-08-13 20:05:36 UTC (rev 22438)
@@ -53,17 +53,17 @@
 	char uvname[32];
 	
 	char projx, projy, projz, mapping;
-	float ofs[3], size[3];
+	float ofs[3], size[3], rot;
 	
 	short texflag, colormodel, pmapto, pmaptoneg;
-	short normapspace, which_output, pad[2];
+	short normapspace, which_output;
+	char brush_map_mode, pad[7];
 	float r, g, b, k;
 	float def_var, rt;
 	
 	float colfac, norfac, varfac;
 	float dispfac; 
 	float warpfac;
-	
 } MTex;
 
 #ifndef DNA_USHORT_FIX
@@ -396,6 +396,11 @@
 #define MTEX_BLEND_COLOR	13
 #define MTEX_NUM_BLENDTYPES	14
 
+/* brush_map_mode */
+#define MTEX_MAP_MODE_FIXED    0
+#define MTEX_MAP_MODE_TILED    1
+#define MTEX_MAP_MODE_3D       2
+
 /* **************** EnvMap ********************* */
 
 /* type */

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_brush.c	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_brush.c	2009-08-13 20:05:36 UTC (rev 22438)
@@ -74,20 +74,6 @@
 	}
 }
 
-static float rna_Brush_rotation_get(PointerRNA *ptr)
-{
-	Brush *brush= (Brush*)ptr->data;
-	const float conv = 57.295779506;
-	return brush->rot * conv;
-}
-
-static void rna_Brush_rotation_set(PointerRNA *ptr, float v)
-{
-	Brush *brush= (Brush*)ptr->data;
-	const float conv = 0.017453293;
-	brush->rot = v * conv;
-}
-
 #else
 
 void rna_def_brush(BlenderRNA *brna)
@@ -106,12 +92,6 @@
 		{BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."},
 		{0, NULL, 0, NULL, NULL}};
 		
-	static EnumPropertyItem prop_texture_mode_items[] = {
-		{BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""},
-		{BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""},
-		{BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""},
-		{0, NULL, 0, NULL, NULL}};
-		
 	static EnumPropertyItem prop_sculpt_tool_items[] = {
 		{SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""},
 		{SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""},
@@ -132,11 +112,6 @@
 	RNA_def_property_enum_items(prop, prop_blend_items);
 	RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode.");
 
-	prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_sdna(prop, NULL, "tex_mode");
-	RNA_def_property_enum_items(prop, prop_texture_mode_items);
-	RNA_def_property_ui_text(prop, "Texture Mode", "");
-
 	prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_items(prop, prop_sculpt_tool_items);
 	RNA_def_property_ui_text(prop, "Sculpt Tool", "");
@@ -170,12 +145,6 @@
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush.");
 
-	prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE);
-	RNA_def_property_float_sdna(prop, NULL, "rot");
-	RNA_def_property_range(prop, 0, 360);
-	RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL);
-	RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture.");
-	
 	/* flag */
 	prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c	2009-08-13 19:30:31 UTC (rev 22437)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c	2009-08-13 20:05:36 UTC (rev 22438)
@@ -147,6 +147,20 @@
 	return item;
 }
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list