[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18393] branches/blender2.5/blender/source /blender: Changes/cleanup for sculptdata and brushes.

Nicholas Bishop nicholasbishop at gmail.com
Wed Jan 7 05:38:34 CET 2009


Revision: 18393
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18393
Author:   nicholasbishop
Date:     2009-01-07 05:38:30 +0100 (Wed, 07 Jan 2009)

Log Message:
-----------
Changes/cleanup for sculptdata and brushes. Summary:
* Removed texfade, wasn't a very useful option (same result can be created with the falloff curve)
* Removed CurveMapping from sculptdata, moved instead to Brush
* Removed rake field from sculptdata, moved to Brush.flag
* Moved Anchored flag from sculpt to Brush, same for direction field
* Removed BrushData, replaced usages with the regular Brush type
* Removed hardcoded brushes and brush_type from sculptdata, replaced with a pointer to the current Brush
* Made sculpt tool type settable in Brush
* Changed symmetry and axis lock fields to flags

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
    branches/blender2.5/blender/source/blender/editors/sculpt/sculpt_intern.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_brush_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h	2009-01-07 04:06:52 UTC (rev 18392)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_brush.h	2009-01-07 04:38:30 UTC (rev 18393)
@@ -51,6 +51,14 @@
 int brush_clone_image_set_nr(struct Brush *brush, int nr);
 int brush_clone_image_delete(struct Brush *brush);
 
+/* brush curve */
+typedef enum {
+	BRUSH_PRESET_SHARP,
+	BRUSH_PRESET_SMOOTH,
+	BRUSH_PRESET_MAX
+} BrushCurvePreset;
+void brush_curve_preset(struct Brush *b, BrushCurvePreset preset);
+
 /* sampling */
 float brush_sample_falloff(struct Brush *brush, float dist);
 float brush_sample_falloff_noalpha(struct Brush *brush, float dist);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c	2009-01-07 04:06:52 UTC (rev 18392)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c	2009-01-07 04:38:30 UTC (rev 18393)
@@ -32,6 +32,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_brush_types.h"
+#include "DNA_color_types.h"
 #include "DNA_image_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
@@ -114,6 +115,8 @@
 			MEM_freeN(mtex);
 		}
 	}
+
+	curvemapping_free(brush->curve);
 }
 
 void make_local_brush(Brush *brush)
@@ -217,6 +220,40 @@
 	}
 }
 
+
+void sculpt_preset_curve(Brush *b, BrushCurvePreset preset)
+{
+	CurveMap *cm = NULL;
+
+	if(!b->curve)
+		b->curve = curvemapping_add(1, 0, 0, 1, 1);
+
+	cm = b->curve->cm;
+
+	if(cm->curve)
+		MEM_freeN(cm->curve);
+
+	if(preset == BRUSH_PRESET_SHARP) {
+		cm->curve= MEM_callocN(3*sizeof(CurveMapPoint), "curve points");
+		cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+		cm->totpoint= 3;
+		cm->curve[0].x= 0;
+		cm->curve[0].y= 1;
+		cm->curve[1].x= 0.33;
+		cm->curve[1].y= 0.33;
+		cm->curve[2].x= 1;
+		cm->curve[2].y= 0;
+	}
+	else if(preset == BRUSH_PRESET_SMOOTH) {
+		// XXX: todo
+	}
+	else if(preset == BRUSH_PRESET_MAX) {
+		// XXX: todo
+	}
+
+	curvemapping_changed(b->curve, 0);
+}
+
 int brush_texture_set_nr(Brush *brush, int nr)
 {
 	ID *idtest, *id=NULL;

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-01-07 04:06:52 UTC (rev 18392)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-01-07 04:38:30 UTC (rev 18393)
@@ -625,13 +625,9 @@
 
 	sd= &sce->sculptdata;
 
-	if(sd->cumap) {
-		curvemapping_free(sd->cumap);
-		sd->cumap = NULL;
-	}
-
 	memset(sd, 0, sizeof(SculptData));
 
+	/* XXX: create preset brushes here
 	sd->drawbrush.size = sd->smoothbrush.size = sd->pinchbrush.size =
 		sd->inflatebrush.size = sd->grabbrush.size =
 		sd->layerbrush.size = sd->flattenbrush.size = 50;
@@ -653,8 +649,7 @@
 	sd->flags= SCULPT_DRAW_BRUSH;
 	sd->tablet_size=3;
 	sd->tablet_strength=10;
-	sd->rake=0;
-	sculpt_reset_curve(sd);
+	sd->rake=0;*/
 }
 
 void sculptdata_free(Scene *sce)
@@ -671,9 +666,6 @@
 			MEM_freeN(mtex);
 		}
 	}
-
-	curvemapping_free(sd->cumap);
-	sd->cumap = NULL;
 }
 
 void sculpt_vertexusers_free(SculptSession *ss)
@@ -707,30 +699,6 @@
 	}
 }
 
-void sculpt_reset_curve(SculptData *sd)
-{
-	CurveMap *cm = NULL;
-
-	if(!sd->cumap)
-		sd->cumap = curvemapping_add(1, 0, 0, 1, 1);
-
-	cm = sd->cumap->cm;
-
-	if(cm->curve)
-		MEM_freeN(cm->curve);
-	cm->curve= MEM_callocN(3*sizeof(CurveMapPoint), "curve points");
-	cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
-	cm->totpoint= 3;
-	cm->curve[0].x= 0;
-	cm->curve[0].y= 1;
-	cm->curve[1].x= 0.33;
-	cm->curve[1].y= 0.33;
-	cm->curve[2].x= 1;
-	cm->curve[2].y= 0;
-
-	curvemapping_changed(sd->cumap, 0);
-}
-
 /* render simplification */
 
 int get_render_subsurf_level(RenderData *r, int lvl)

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-01-07 04:06:52 UTC (rev 18392)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-01-07 04:38:30 UTC (rev 18393)
@@ -1456,6 +1456,22 @@
 {
 }
 
+/* ************ READ CurveMapping *************** */
+
+/* cuma itself has been read! */
+static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
+{
+	int a;
+	
+	/* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
+	cumap->flag &= ~CUMA_PREMULLED;
+	
+	for(a=0; a<CM_TOT; a++) {
+		cumap->cm[a].curve= newdataadr(fd, cumap->cm[a].curve);
+		cumap->cm[a].table= NULL;
+	}
+}
+
 /* ************ READ Brush *************** */
 /* library brush linking after fileread */
 static void lib_link_brush(FileData *fd, Main *main)
@@ -1485,6 +1501,11 @@
 
 	for(a=0; a<MAX_MTEX; a++)
 		brush->mtex[a]= newdataadr(fd, brush->mtex[a]);
+
+	/* fallof curve */
+	brush->curve= newdataadr(fd, brush->curve);
+	if(brush->curve)
+		direct_link_curvemapping(fd, brush->curve);
 }
 
 static void direct_link_script(FileData *fd, Script *script)
@@ -1493,22 +1514,6 @@
 	SCRIPT_SET_NULL(script)
 }
 
-/* ************ READ CurveMapping *************** */
-
-/* cuma itself has been read! */
-static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
-{
-	int a;
-	
-	/* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
-	cumap->flag &= ~CUMA_PREMULLED;
-	
-	for(a=0; a<CM_TOT; a++) {
-		cumap->cm[a].curve= newdataadr(fd, cumap->cm[a].curve);
-		cumap->cm[a].table= NULL;
-	}
-}
-
 /* ************ READ NODE TREE *************** */
 
 /* singe node tree (also used for material/scene trees), ntree is not NULL */
@@ -3604,12 +3609,6 @@
 	/* SculptData textures */
 	for(a=0; a<MAX_MTEX; ++a)
 		sce->sculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]);
-	/* Sculpt intensity curve */
-	sce->sculptdata.cumap= newdataadr(fd, sce->sculptdata.cumap);
-	if(sce->sculptdata.cumap)
-		direct_link_curvemapping(fd, sce->sculptdata.cumap);
-	else
-		sculpt_reset_curve(&sce->sculptdata);
 
 	if(sce->ed) {
 		ListBase *old_seqbasep= &((Editing *)sce->ed)->seqbase;

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-01-07 04:06:52 UTC (rev 18392)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-01-07 04:38:30 UTC (rev 18393)
@@ -1475,8 +1475,6 @@
 
 		for(a=0; a<MAX_MTEX; ++a)
 			writestruct(wd, DATA, "MTex", 1, sce->sculptdata.mtex[a]);
-		if(sce->sculptdata.cumap)
-			write_curvemapping(wd, sce->sculptdata.cumap);
 
 		ed= sce->ed;
 		if(ed) {
@@ -2011,6 +2009,9 @@
 			for(a=0; a<MAX_MTEX; a++)
 				if(brush->mtex[a])
 					writestruct(wd, DATA, "MTex", 1, brush->mtex[a]);
+
+			if(brush->curve)
+				write_curvemapping(wd, brush->curve);
 		}
 	}
 }

Modified: branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c	2009-01-07 04:06:52 UTC (rev 18392)
+++ branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c	2009-01-07 04:38:30 UTC (rev 18393)
@@ -333,15 +333,14 @@
    shrink the brush. Skipped for grab brush because only the first mouse down
    size is used, which is small if the user has just touched the pen to the
    tablet */
-char brush_size()
+char brush_size(Brush *b)
 {
 	SculptData *sd = NULL; /* XXX */
-	const BrushData *b= sculptmode_brush();
 	float size= b->size;
 	float pressure= 0; /* XXX: get_pressure(); */
 	short activedevice= get_activedevice();
 	
-	if(sculpt_data()->brush_type!=GRAB_BRUSH) {
+	if(b->sculpt_tool!=SCULPT_TOOL_GRAB) {
 		const float size_factor= sd->tablet_size / 10.0f;
 		
 		/* XXX: tablet stuff
@@ -356,15 +355,14 @@
 /* Return modified brush strength. Includes the direction of the brush, positive
    values pull vertices, negative values push. Uses tablet pressure and a
    special multiplier found experimentally to scale the strength factor. */
-float brush_strength(BrushAction *a)
+float brush_strength(Brush *b, BrushAction *a)
 {
 	SculptData *sd = NULL; /* XXX */
-	const BrushData* b= sculptmode_brush();
-	float dir= b->dir==1 ? 1 : -1;
+	float dir= b->flag & BRUSH_DIR_IN ? -1 : 1;
 	float pressure= 1;
 	short activedevice= get_activedevice();
 	float flip= a->flip ? -1:1;
-	float anchored = b->flag & SCULPT_BRUSH_ANCHORED ? 25 : 1;
+	float anchored = b->flag & BRUSH_ANCHORED ? 25 : 1;
 
 	const float strength_factor= sd->tablet_strength / 10.0f;
 
@@ -379,20 +377,20 @@
 		dir= -dir;
 #endif
 
-	switch(sd->brush_type){
-	case DRAW_BRUSH:
-	case LAYER_BRUSH:
-		return b->strength / 5000.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */;
-	case SMOOTH_BRUSH:
-		return b->strength / 50.0f * pressure * anchored;
-	case PINCH_BRUSH:
-		return b->strength / 1000.0f * dir * pressure * flip * anchored;
-	case GRAB_BRUSH:
+	switch(b->sculpt_tool){
+	case SCULPT_TOOL_DRAW:
+	case SCULPT_TOOL_LAYER:
+		return b->alpha / 5000.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */;
+	case SCULPT_TOOL_SMOOTH:
+		return b->alpha / 50.0f * pressure * anchored;
+	case SCULPT_TOOL_PINCH:
+		return b->alpha / 1000.0f * dir * pressure * flip * anchored;
+	case SCULPT_TOOL_GRAB:
 		return 1;
-	case INFLATE_BRUSH:
-		return b->strength / 5000.0f * dir * pressure * flip * anchored;
-	case FLATTEN_BRUSH:
-		return b->strength / 500.0f * pressure * anchored;
+	case SCULPT_TOOL_INFLATE:
+		return b->alpha / 5000.0f * dir * pressure * flip * anchored;
+	case SCULPT_TOOL_FLATTEN:
+		return b->alpha / 500.0f * pressure * anchored;
 	default:
 		return 0;
 	}
@@ -413,21 +411,21 @@
 void sculpt_axislock(float *co)
 {
 	SculptData *sd = sculpt_data();
-	if (sd->axislock == AXISLOCK_X+AXISLOCK_Y+AXISLOCK_Z) return;
+	if (sd->flags & (SCULPT_LOCK_X|SCULPT_LOCK_Y|SCULPT_LOCK_Z)) return;
 	/* XXX: if(G.vd->twmode == V3D_MANIP_LOCAL) { */
 	if(0) {
 		float mat[3][3], imat[3][3];
 		/* XXX: Mat3CpyMat4(mat, OBACT->obmat); */
 		Mat3Inv(imat, mat);
 		Mat3MulVecfl(mat, co);
-		if (sd->axislock & AXISLOCK_X) co[0] = 0.0;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list