Revision: 42124
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42124
Author:   nazgul
Date:     2011-11-24 13:39:43 +0000 (Thu, 24 Nov 2011)
Log Message:
-----------
Fix #29384: Mesh without polygons + Modifier crashes when switching to sculpt 
mode

There were some issues with PBVH which prevented working it for meshes without 
faces.

Discussed with Brecht, for benefits of dynamic-topology-sculpting and so better 
to
make PBVH survive such things.

Added some extra NULL-pointer checks for this.

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

Modified: trunk/blender/source/blender/blenlib/intern/pbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/pbvh.c  2011-11-24 13:07:02 UTC 
(rev 42123)
+++ trunk/blender/source/blender/blenlib/intern/pbvh.c  2011-11-24 13:39:43 UTC 
(rev 42124)
@@ -656,12 +656,17 @@
                        /* if pbvh was deformed, new memory was allocated for 
verts/faces -- free it */
 
                        MEM_freeN(bvh->verts);
-                       MEM_freeN(bvh->faces);
+                       if(bvh->faces)
+                               MEM_freeN(bvh->faces);
                }
        }
 
-       MEM_freeN(bvh->nodes);
-       MEM_freeN(bvh->prim_indices);
+       if(bvh->nodes)
+               MEM_freeN(bvh->nodes);
+
+       if(bvh->prim_indices)
+               MEM_freeN(bvh->prim_indices);
+
        MEM_freeN(bvh);
 }
 
@@ -1127,6 +1132,9 @@
        PBVHNode **nodes;
        int totnode;
 
+       if(!bvh->nodes)
+               return;
+
        BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag),
                &nodes, &totnode);
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to