2.5/Multires:
authorNicholas Bishop <nicholasbishop@gmail.com>
Fri, 14 Aug 2009 01:48:05 +0000 (01:48 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Fri, 14 Aug 2009 01:48:05 +0000 (01:48 +0000)
Bugfixes

* Don't allow multires subdivision in editmode, this leads to corruption as noted by nudelZ. Reason is that editmode has its own copy of the MDisps customdata layer, gets written back out on exiting editmode, but the layer that was subdivided was the non-editmode original.
* Missed clearing a couple variables, caught with valgrind.

source/blender/blenkernel/intern/multires.c
source/blender/editors/object/object_modifier.c

index 22a471f65219c49481fcd792962b167925966e81..e91f318adadb60afa04b0fc5b8e57d5600695579 100644 (file)
@@ -220,6 +220,7 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in
        int skip = multires_side_tot[totlvl - lvl] - 1;
        int i, j, k;
 
+       memset(&mmd_sub, 0, sizeof(MultiresModifierData));
        mmd_sub.lvl = mmd_sub.totlvl = totlvl;
        mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0);
                
@@ -465,6 +466,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista
                MultiresModifierData mmd_sub;
 
                orig = CDDM_from_mesh(me, NULL);
+               memset(&mmd_sub, 0, sizeof(MultiresModifierData));
                mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl;
                mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0);
                totsubvert = mrdm->getNumVerts(mrdm);
index 6b9f2db0d961fdde4594f7a4feb281512183d334..1742e1d127981c5ee833f06fe08bc93d90c7f7e6 100644 (file)
@@ -640,14 +640,19 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
+static int multires_subdivide_poll(bContext *C)
+{
+       return NULL != CTX_data_active_object(C) && NULL == CTX_data_edit_object(C);
+}
+
 void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
 {
        ot->name= "Multires Subdivide";
        ot->description= "Add a new level of subdivision.";
        ot->idname= "OBJECT_OT_multires_subdivide";
-       ot->poll= ED_operator_object_active;
 
        ot->exec= multires_subdivide_exec;
+       ot->poll= multires_subdivide_poll;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;