remove vertex groups from a mesh or lattice when this there are no remaining vertex...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 3 Sep 2012 00:02:13 +0000 (00:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 3 Sep 2012 00:02:13 +0000 (00:02 +0000)
source/blender/editors/object/object_vgroup.c

index d08237ed09a46e51178a74515e2ead4c23c2e016..b13a299c4c79a2dfbcbb4fd13d2587cf4155d3b5 100644 (file)
@@ -1786,6 +1786,21 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg)
        if (ob->actdef < 1 && ob->defbase.first)
                ob->actdef = 1;
 
+       /* remove all dverts */
+       if (ob->defbase.first == NULL) {
+               if (ob->type == OB_MESH) {
+                       Mesh *me = ob->data;
+                       CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
+                       me->dvert = NULL;
+               }
+               else if (ob->type == OB_LATTICE) {
+                       Lattice *lt = ob->data;
+                       if (lt->dvert) {
+                               MEM_freeN(lt->dvert);
+                               lt->dvert = NULL;
+                       }
+               }
+       }
 }
 
 /* only in editmode */