From 55c1d9d4bc0d6662cbe2d4baa3e9a48e255d51e6 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Mon, 2 Nov 2009 16:01:24 +0000 Subject: shapekey bugfixes --- source/blender/bmesh/operators/mesh_conv.c | 4 ++++ source/blender/editors/armature/editarmature.c | 4 ++-- source/blender/editors/curve/editcurve.c | 4 ++-- source/blender/editors/curve/editfont.c | 4 ++-- source/blender/editors/mesh/bmeshutils.c | 14 ++++++++++---- source/blender/editors/metaball/mball_edit.c | 4 ++-- source/blender/editors/object/object_lattice.c | 4 ++-- source/blender/editors/util/editmode_undo.c | 23 ++++++++++++----------- 8 files changed, 36 insertions(+), 25 deletions(-) (limited to 'source') diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 53a358a824c..4020356834a 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -77,6 +77,10 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, NULL, 0); + if (me->key && ob->shapenr > me->key->totkey) { + ob->shapenr = me->key->totkey-1; + } + actkey = ob_get_keyblock(ob); if(actkey && actkey->totelem == me->totvert) { /*check if we need to generate unique ids for the shapekeys. diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f379ff6c395..acbf62f0363 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2086,7 +2086,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot) /* **************** undo for armatures ************** */ -static void undoBones_to_editBones(void *lbuv, void *lbev) +static void undoBones_to_editBones(void *lbuv, void *lbev, void *data) { ListBase *lbu= lbuv; ListBase *edbo= lbev; @@ -2111,7 +2111,7 @@ static void undoBones_to_editBones(void *lbuv, void *lbev) } } -static void *editBones_to_undoBones(void *lbev) +static void *editBones_to_undoBones(void *lbev, void *obdata) { ListBase *edbo= lbev; ListBase *lb; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 45820869b48..1ad3e1a42ec 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5158,7 +5158,7 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) /****************** undo for curves ****************/ -static void undoCurve_to_editCurve(void *lbu, void *lbe) +static void undoCurve_to_editCurve(void *lbu, void *lbe, void *obdata) { ListBase *lb= lbu; ListBase *editnurb= lbe; @@ -5173,7 +5173,7 @@ static void undoCurve_to_editCurve(void *lbu, void *lbe) } } -static void *editCurve_to_undoCurve(void *lbe) +static void *editCurve_to_undoCurve(void *lbe, void *obdata) { ListBase *editnurb= lbe; ListBase *lb; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 2be567e1921..978edda27ca 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1538,7 +1538,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) /* **************** undo for font object ************** */ -static void undoFont_to_editFont(void *strv, void *ecu) +static void undoFont_to_editFont(void *strv, void *ecu, void *obdata) { Curve *cu= (Curve *)ecu; EditFont *ef= cu->editfont; @@ -1555,7 +1555,7 @@ static void undoFont_to_editFont(void *strv, void *ecu) update_string(cu); } -static void *editFont_to_undoFont(void *ecu) +static void *editFont_to_undoFont(void *ecu, void *obdata) { Curve *cu= (Curve *)ecu; EditFont *ef= cu->editfont; diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c index e5cda669438..e5048c538bb 100644 --- a/source/blender/editors/mesh/bmeshutils.c +++ b/source/blender/editors/mesh/bmeshutils.c @@ -555,13 +555,14 @@ typedef struct undomesh { } undomesh; /*undo simply makes copies of a bmesh*/ -static void *editbtMesh_to_undoMesh(void *emv) +static void *editbtMesh_to_undoMesh(void *emv, void *obdata) { BMEditMesh *em = emv; + Mesh *obme = obdata; undomesh *me = MEM_callocN(sizeof(undomesh), "undo Mesh"); /*make sure shape keys work*/ - me->me.key = copy_key_nolib(em->me->key); + me->me.key = obme->key ? copy_key_nolib(obme->key) : NULL; /*we recalc the tesselation here, to avoid seeding calls to BMEdit_RecalcTesselation throughout the code.*/ @@ -573,17 +574,22 @@ static void *editbtMesh_to_undoMesh(void *emv) return me; } -static void undoMesh_to_editbtMesh(void *umv, void *emv) +static void undoMesh_to_editbtMesh(void *umv, void *emv, void *obdata) { BMEditMesh *em = emv, *em2; + Object ob = {0,}; undomesh *me = umv; BMesh *bm; int allocsize[4] = {512, 512, 2048, 512}; + ob.data = me; + ob.type = OB_MESH; + ob.shapenr = em->bm->shapenr; + BMEdit_Free(em); bm = BM_Make_Mesh(allocsize); - BMO_CallOpf(bm, "mesh_to_bmesh mesh=%p object=%p", me, em->ob); + BMO_CallOpf(bm, "mesh_to_bmesh mesh=%p object=%p", me, &ob); em2 = BMEdit_Create(bm); *em = *em2; diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 6ad7fbabfcb..889aeee8180 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -614,7 +614,7 @@ static void freeMetaElemlist(ListBase *lb) } -static void undoMball_to_editMball(void *lbu, void *lbe) +static void undoMball_to_editMball(void *lbu, void *lbe, void *obdata) { ListBase *lb= lbu; ListBase *editelems= lbe; @@ -632,7 +632,7 @@ static void undoMball_to_editMball(void *lbu, void *lbe) } -static void *editMball_to_undoMball(void *lbe) +static void *editMball_to_undoMball(void *lbe, void *obdata) { ListBase *editelems= lbe; ListBase *lb; diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index b49c1eb5902..41005904494 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -325,7 +325,7 @@ typedef struct UndoLattice { int pntsu, pntsv, pntsw; } UndoLattice; -static void undoLatt_to_editLatt(void *data, void *edata) +static void undoLatt_to_editLatt(void *data, void *edata, void *obdata) { UndoLattice *ult= (UndoLattice*)data; Lattice *editlatt= (Lattice *)edata; @@ -334,7 +334,7 @@ static void undoLatt_to_editLatt(void *data, void *edata) memcpy(editlatt->def, ult->def, a*sizeof(BPoint)); } -static void *editLatt_to_undoLatt(void *edata) +static void *editLatt_to_undoLatt(void *edata, void *obdata) { UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice"); Lattice *editlatt= (Lattice *)edata; diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 2d73a9f1d25..93d36805f0c 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -95,8 +95,8 @@ typedef struct UndoElem { char name[MAXUNDONAME]; void * (*getdata)(bContext *C); void (*freedata)(void *); - void (*to_editmode)(void *, void *); - void * (*from_editmode)(void *); + void (*to_editmode)(void *, void *, void *); + void * (*from_editmode)(void *, void *); int (*validate_undo)(void *, void *); } UndoElem; @@ -106,10 +106,10 @@ static UndoElem *curundo= NULL; /* ********************* xtern api calls ************* */ -static void undo_restore(UndoElem *undo, void *editdata) +static void undo_restore(UndoElem *undo, void *editdata, void *obdata) { if(undo) { - undo->to_editmode(undo->undodata, editdata); + undo->to_editmode(undo->undodata, editdata, obdata); } } @@ -117,8 +117,8 @@ static void undo_restore(UndoElem *undo, void *editdata) void undo_editmode_push(bContext *C, char *name, void * (*getdata)(bContext *C), void (*freedata)(void *), - void (*to_editmode)(void *, void *), - void *(*from_editmode)(void *), + void (*to_editmode)(void *, void *, void *), + void *(*from_editmode)(void *, void *), int (*validate_undo)(void *, void *)) { UndoElem *uel; @@ -167,7 +167,7 @@ void undo_editmode_push(bContext *C, char *name, /* copy */ memused= MEM_get_memory_in_use(); editdata= getdata(C); - curundo->undodata= curundo->from_editmode(editdata); + curundo->undodata= curundo->from_editmode(editdata, obedit->data); curundo->undosize= MEM_get_memory_in_use() - memused; curundo->ob= obedit; curundo->id= obedit->id; @@ -240,12 +240,13 @@ static void undo_clean_stack(bContext *C) /* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ void undo_editmode_step(bContext *C, int step) { - + Object *ob = CTX_data_edit_object(C); + /* prevent undo to happen on wrong object, stack can be a mix */ undo_clean_stack(C); if(step==0) { - undo_restore(curundo, curundo->getdata(C)); + undo_restore(curundo, curundo->getdata(C), ob->data); } else if(step==1) { @@ -253,7 +254,7 @@ void undo_editmode_step(bContext *C, int step) else { if(G.f & G_DEBUG) printf("undo %s\n", curundo->name); curundo= curundo->prev; - undo_restore(curundo, curundo->getdata(C)); + undo_restore(curundo, curundo->getdata(C), ob->data); } } else { @@ -261,7 +262,7 @@ void undo_editmode_step(bContext *C, int step) if(curundo==NULL || curundo->next==NULL) error("No more steps to redo"); else { - undo_restore(curundo->next, curundo->getdata(C)); + undo_restore(curundo->next, curundo->getdata(C), ob->data); curundo= curundo->next; if(G.f & G_DEBUG) printf("redo %s\n", curundo->name); } -- cgit v1.2.3