[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26509] trunk/blender/source/blender: Fix #20420: grab brush + subsurf modifier crash.

Brecht Van Lommel brecht at blender.org
Mon Feb 1 12:36:22 CET 2010


Revision: 26509
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26509
Author:   blendix
Date:     2010-02-01 12:36:22 +0100 (Mon, 01 Feb 2010)

Log Message:
-----------
Fix #20420: grab brush + subsurf modifier crash. Previously the PBVH nodes
were cached once at the start, but these can change when modifiers are
executed, now it simply doesn't cache them anymore, that was only really
a performance bottleneck when it was caching individual vertices.

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

Modified: trunk/blender/source/blender/blenlib/intern/pbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/pbvh.c	2010-02-01 11:20:01 UTC (rev 26508)
+++ trunk/blender/source/blender/blenlib/intern/pbvh.c	2010-02-01 11:36:22 UTC (rev 26509)
@@ -346,6 +346,8 @@
 			GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(iter));
 	}
 
+	BLI_ghashIterator_free(iter);
+
 	for(i = 0; i < totface*4; ++i)
 		if(node->face_vert_indices[i] < 0)
 			node->face_vert_indices[i]= -node->face_vert_indices[i] + node->uniq_verts - 1;
@@ -1006,6 +1008,8 @@
 	    BLI_ghashIterator_step(hiter), ++i)
 		faces[i]= BLI_ghashIterator_getKey(hiter);
 
+	BLI_ghashIterator_free(hiter);
+
 	BLI_ghash_free(map, NULL, NULL);
 
 	*totface= tot;

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2010-02-01 11:20:01 UTC (rev 26508)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2010-02-01 11:36:22 UTC (rev 26509)
@@ -152,8 +152,6 @@
 	float (*face_norms)[3]; /* Copy of the mesh faces' normals */
 	float rotation; /* Texture rotation (radians) for anchored and rake modes */
 	int pixel_radius, previous_pixel_radius;
-	PBVHNode **grab_active_nodes[8]; /* The same list of nodes is used throught grab stroke */
-	int grab_active_totnode[8];
 	float grab_active_location[8][3];
 	float grab_delta[3], grab_delta_symmetry[3];
 	float old_grab_location[3], orig_grab_location[3];
@@ -689,8 +687,7 @@
 	Sculpt *sd;
 	SculptSession *ss;
 	float radius_squared;
-	ListBase *active_verts;
-	float area_normal[3];
+	int original;
 } SculptSearchSphereData;
 
 /* Test AABB against sphere */
@@ -701,7 +698,10 @@
 	float t[3], bb_min[3], bb_max[3];
 	int i;
 
-	BLI_pbvh_node_get_BB(node, bb_min, bb_max);
+	if(data->original)
+		BLI_pbvh_node_get_original_BB(node, bb_min, bb_max);
+	else
+		BLI_pbvh_node_get_BB(node, bb_min, bb_max);
 
 	for(i = 0; i < 3; ++i) {
 		if(bb_min[i] > center[i])
@@ -1351,21 +1351,14 @@
 	/* Build a list of all nodes that are potentially within the brush's
 	   area of influence */
 	if(brush->sculpt_tool == SCULPT_TOOL_GRAB) {
-		if(cache->first_time) {
-			/* For the grab tool we store these nodes once in the beginning
-			   and then reuse them. */
-			BLI_pbvh_search_gather(ss->tree, sculpt_search_sphere_cb, &data,
+		data.original= 1;
+		BLI_pbvh_search_gather(ss->tree, sculpt_search_sphere_cb, &data,
 				&nodes, &totnode);
-			
-			ss->cache->grab_active_nodes[ss->cache->symmetry]= nodes;
-			ss->cache->grab_active_totnode[ss->cache->symmetry]= totnode;
+
+		if(cache->first_time)
 			copy_v3_v3(ss->cache->grab_active_location[ss->cache->symmetry], ss->cache->location);
-		}
-		else {
-			nodes= ss->cache->grab_active_nodes[ss->cache->symmetry];
-			totnode= ss->cache->grab_active_totnode[ss->cache->symmetry];
+		else
 			copy_v3_v3(ss->cache->location, ss->cache->grab_active_location[ss->cache->symmetry]);
-		}
 	}
 	else {
 		BLI_pbvh_search_gather(ss->tree, sculpt_search_sphere_cb, &data,
@@ -1405,7 +1398,7 @@
 		/* copy the modified vertices from mesh to the active key */
 		if(ss->kb) mesh_to_key(ss->ob->data, ss->kb);
 		
-		if((brush->sculpt_tool != SCULPT_TOOL_GRAB) && nodes)
+		if(nodes)
 			MEM_freeN(nodes);
 	}	
 }
@@ -1651,15 +1644,10 @@
 
 static void sculpt_cache_free(StrokeCache *cache)
 {
-	int i;
 	if(cache->face_norms)
 		MEM_freeN(cache->face_norms);
 	if(cache->mats)
 		MEM_freeN(cache->mats);
-	for(i = 0; i < 8; ++i) {
-		if(cache->grab_active_nodes[i])
-			MEM_freeN(cache->grab_active_nodes[i]);
-	}
 	MEM_freeN(cache);
 }
 





More information about the Bf-blender-cvs mailing list