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.
This commit is contained in:
Sergey Sharybin 2011-11-24 13:39:43 +00:00
parent 7187fd46c6
commit 51014d8e4f

@ -656,12 +656,17 @@ void BLI_pbvh_free(PBVH *bvh)
/* 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 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3])
PBVHNode **nodes;
int totnode;
if(!bvh->nodes)
return;
BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag),
&nodes, &totnode);