[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36109] trunk/blender/source/blender/ editors/sculpt_paint/sculpt.c: Fix #26879: Some sculpt brushes does not work when sculpting corrective shapekeys

Sergey Sharybin g.ulairi at gmail.com
Tue Apr 12 12:16:01 CEST 2011


Revision: 36109
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36109
Author:   nazgul
Date:     2011-04-12 10:16:00 +0000 (Tue, 12 Apr 2011)
Log Message:
-----------
Fix #26879: Some sculpt brushes does not work when sculpting corrective shapekeys

It was simply missed crazyspace correction for shape keys when mesh is
deformed by modifiers and current tool is smooth/layer (they need special
approach due to they don't use proxies)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-04-12 10:13:09 UTC (rev 36108)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-04-12 10:16:00 UTC (rev 36109)
@@ -2492,38 +2492,50 @@
 static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
 {
 	SculptSession *ss = ob->sculpt;
-	
-	if(!ss->kb) {
+	Brush *brush= paint_brush(&sd->paint);
+
+	if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) {
+		/* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't
+		   propagate needed deformation to original base */
+
+		int n, totnode;
 		Mesh *me= (Mesh*)ob->data;
-		Brush *brush= paint_brush(&sd->paint);
+		PBVHNode** nodes;
+		float (*vertCos)[3]= NULL;
 
-		if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) {
-			/* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't
-			   propagate needed deformation to original base */
+		if(ss->kb)
+			vertCos= MEM_callocN(sizeof(*vertCos)*me->totvert, "flushStrokeDeofrm keyVerts");
 
-			int n, totnode;
-			PBVHNode** nodes;
+		BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
 
-			BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
+		#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+		for (n= 0; n < totnode; n++) {
+			PBVHVertexIter vd;
 
-			#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
-			for (n= 0; n < totnode; n++) {
-				PBVHVertexIter vd;
+			BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+				sculpt_flush_pbvhvert_deform(ob, &vd);
 
-				BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
-					sculpt_flush_pbvhvert_deform(ob, &vd);
+				if(vertCos) {
+					int index= vd.vert_indices[vd.i];
+					copy_v3_v3(vertCos[index], ss->orig_cos[index]);
 				}
-				BLI_pbvh_vertex_iter_end;
 			}
+			BLI_pbvh_vertex_iter_end;
+		}
 
-			MEM_freeN(nodes);
+		if(vertCos) {
+			sculpt_vertcos_to_key(ob, ss->kb, vertCos);
+			MEM_freeN(vertCos);
 		}
 
+		MEM_freeN(nodes);
+
 		/* Modifiers could depend on mesh normals, so we should update them/
 		   Note, then if sculpting happens on locked key, normals should be re-calculated
 		   after applying coords from keyblock on base mesh */
 		mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
-	} else sculpt_update_keyblock(ob);
+	} else if (ss->kb)
+		sculpt_update_keyblock(ob);
 }
 
 //static int max_overlap_count(Sculpt *sd)




More information about the Bf-blender-cvs mailing list