[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25180] branches/sculpt25: Sculpt Branch:

Brecht Van Lommel brecht at blender.org
Mon Dec 7 20:11:37 CET 2009


Revision: 25180
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25180
Author:   blendix
Date:     2009-12-07 20:11:37 +0100 (Mon, 07 Dec 2009)

Log Message:
-----------
Sculpt Branch:

* Don't allow adding/removing multires levels in editmode.
* Customdata code for swapping mdisps restored.
* Fix inflate brush crashing with multires.
* Smooth and layer brush don't work yet with multires, but at
  least avoids crashing now.
* Fix threading issue with flatten brush.

Modified Paths:
--------------
    branches/sculpt25/release/scripts/ui/properties_data_modifier.py
    branches/sculpt25/source/blender/blenkernel/intern/customdata.c
    branches/sculpt25/source/blender/blenlib/intern/pbvh.c
    branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c

Modified: branches/sculpt25/release/scripts/ui/properties_data_modifier.py
===================================================================
--- branches/sculpt25/release/scripts/ui/properties_data_modifier.py	2009-12-07 18:17:39 UTC (rev 25179)
+++ branches/sculpt25/release/scripts/ui/properties_data_modifier.py	2009-12-07 19:11:37 UTC (rev 25180)
@@ -440,6 +440,7 @@
         if wide_ui:
             col = split.column()
 
+        col.enabled = ob.mode != 'EDIT'
         col.operator("object.multires_subdivide", text="Subdivide")
         col.operator("object.multires_higher_levels_delete", text="Delete Higher")
         row = col.row()

Modified: branches/sculpt25/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/customdata.c	2009-12-07 18:17:39 UTC (rev 25179)
+++ branches/sculpt25/source/blender/blenkernel/intern/customdata.c	2009-12-07 19:11:37 UTC (rev 25180)
@@ -440,29 +440,30 @@
 }
 #endif
 
+static int mdisp_corners(MDisps *s)
+{
+	/* silly trick because we don't get it from callback */
+	return (s->totdisp % (3*3) == 0)? 3: 4;
+}
+
 static void layerSwap_mdisps(void *data, int *ci)
 {
-	// XXX
-#if 0
 	MDisps *s = data;
 	float (*d)[3] = NULL;
-	int x, y, st;
+	int corners, cornersize, S;
 
-	if(!(ci[0] == 2 && ci[1] == 3 && ci[2] == 0 && ci[3] == 1)) return;
+	/* this function is untested .. */
+	corners = mdisp_corners(s);
+	cornersize = s->totdisp/corners;
 
 	d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
-	st = sqrt(s->totdisp);
 
-	for(y = 0; y < st; ++y) {
-		for(x = 0; x < st; ++x) {
-			copy_v3_v3(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]);
-		}
-	}
+	for(S = 0; S < corners; S++)
+		memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float));
 	
 	if(s->disps)
 		MEM_freeN(s->disps);
 	s->disps = d;
-#endif
 }
 
 static void layerInterp_mdisps(void **sources, float *weights, float *sub_weights,

Modified: branches/sculpt25/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/sculpt25/source/blender/blenlib/intern/pbvh.c	2009-12-07 18:17:39 UTC (rev 25179)
+++ branches/sculpt25/source/blender/blenlib/intern/pbvh.c	2009-12-07 19:11:37 UTC (rev 25180)
@@ -1012,12 +1012,12 @@
 void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *totvert)
 {
 	if(bvh->grids) {
-		*totvert= node->totprim*bvh->gridsize*bvh->gridsize;
-		*uniquevert= *totvert;
+		if(totvert) *totvert= node->totprim*bvh->gridsize*bvh->gridsize;
+		if(uniquevert) *uniquevert= *totvert;
 	}
 	else {
-		*uniquevert= node->uniq_verts;
-		*totvert= node->uniq_verts + node->face_verts;
+		if(totvert) *totvert= node->uniq_verts + node->face_verts;
+		if(uniquevert) *uniquevert= node->uniq_verts;
 	}
 }
 
@@ -1030,10 +1030,10 @@
 		if(gridsize) *gridsize= bvh->gridsize;
 	}
 	else {
-		*grid_indices= NULL;
-		*totgrid= 0;
-		*maxgrid= 0;
-		*gridsize= 0;
+		if(grid_indices) *grid_indices= NULL;
+		if(totgrid) *totgrid= 0;
+		if(maxgrid) *maxgrid= 0;
+		if(gridsize) *gridsize= 0;
 	}
 }
 

Modified: branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c	2009-12-07 18:17:39 UTC (rev 25179)
+++ branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c	2009-12-07 19:11:37 UTC (rev 25180)
@@ -905,6 +905,10 @@
 	float bstrength= ss->cache->bstrength;
 	int iteration, n;
 
+	/* XXX not working for multires yet */
+	if(!ss->fmap)
+		return;
+
 	for(iteration = 0; iteration < 2; ++iteration) {
 		#pragma omp parallel for private(n) schedule(static)
 		for(n=0; n<totnode; n++) {
@@ -999,7 +1003,6 @@
 
 		BLI_pbvh_node_mark_update(nodes[n]);
 	}
-
 }
 
 static void do_layer_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
@@ -1010,6 +1013,10 @@
 	float lim= ss->cache->radius / 4;
 	int n;
 
+	/* XXX not working yet for multires */
+	if(!ss->mvert)
+		return;
+
 	if(ss->cache->flip)
 		lim = -lim;
 
@@ -1081,10 +1088,10 @@
 			if(sculpt_brush_test(&test, vd.co)) {
 				float fade = tex_strength(ss, brush, vd.co, test.dist)*bstrength;
 				float add[3];
+
+				if(vd.fno) copy_v3_v3(add, vd.fno);
+				else normal_short_to_float_v3(add, vd.no);
 				
-				add[0]= vd.no[0]/32767.0f;
-				add[1]= vd.no[1]/32767.0f;
-				add[2]= vd.no[2]/32767.0f;
 				mul_v3_fl(add, fade * ss->cache->radius);
 				add[0]*= ss->cache->scale[0];
 				add[1]*= ss->cache->scale[1];
@@ -1116,16 +1123,17 @@
 	for(n=0; n<totnode; n++) {
 		PBVHVertexIter vd;
 		SculptBrushTest test;
+		int j;
 		
 		sculpt_undo_push_node(ss, nodes[n]);
 		sculpt_brush_test_init(ss, &test);
 
 		BLI_pbvh_vertex_iter_begin(ss->tree, nodes[n], vd, PBVH_ITER_UNIQUE) {
 			if(sculpt_brush_test(&test, vd.co)) {
-				for(i = 0; i < FLATTEN_SAMPLE_SIZE; ++i) {
-					if(test.dist > outer_dist[i]) {
-						copy_v3_v3(outer_co[i], vd.co);
-						outer_dist[i] = test.dist;
+				for(j = 0; j < FLATTEN_SAMPLE_SIZE; ++j) {
+					if(test.dist > outer_dist[j]) {
+						copy_v3_v3(outer_co[j], vd.co);
+						outer_dist[j] = test.dist;
 						break;
 					}
 				}
@@ -1424,9 +1432,9 @@
 	if((ss->multires = sculpt_multires_active(ob))) {
 		ss->totvert = dm->getNumVerts(dm);
 		ss->totface = dm->getNumFaces(dm);
-		ss->mvert = dm->getVertDataArray(dm, CD_MVERT);
-		ss->mface = dm->getFaceDataArray(dm, CD_MFACE);
-		ss->face_normals = dm->getFaceDataArray(dm, CD_NORMAL);
+		ss->mvert= NULL;
+		ss->mface= NULL;
+		ss->face_normals= NULL;
 	}
 	else {
 		Mesh *me = get_mesh(ob);
@@ -1439,7 +1447,7 @@
 
 	ss->ob = ob;
 	ss->tree = dm->getPBVH(ob, dm);
-	ss->fmap = (need_fmap)? dm->getFaceMap(dm): NULL;
+	ss->fmap = (need_fmap && dm->getFaceMap)? dm->getFaceMap(dm): NULL;
 
 	if((ob->shapeflag & OB_SHAPE_LOCK) && !sculpt_multires_active(ob)) {
 		ss->kb= ob_get_keyblock(ob);





More information about the Bf-blender-cvs mailing list