[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24244] branches/bmesh/blender/source/ blender: shapekey bugfixes

Joseph Eagar joeedh at gmail.com
Mon Nov 2 17:01:25 CET 2009


Revision: 24244
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24244
Author:   joeedh
Date:     2009-11-02 17:01:24 +0100 (Mon, 02 Nov 2009)

Log Message:
-----------
shapekey bugfixes

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
    branches/bmesh/blender/source/blender/editors/armature/editarmature.c
    branches/bmesh/blender/source/blender/editors/curve/editcurve.c
    branches/bmesh/blender/source/blender/editors/curve/editfont.c
    branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
    branches/bmesh/blender/source/blender/editors/metaball/mball_edit.c
    branches/bmesh/blender/source/blender/editors/object/object_lattice.c
    branches/bmesh/blender/source/blender/editors/util/editmode_undo.c

Modified: branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -77,6 +77,10 @@
 
 	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.

Modified: branches/bmesh/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/armature/editarmature.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/armature/editarmature.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -2086,7 +2086,7 @@
 
 /* **************** 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 *editBones_to_undoBones(void *lbev)
+static void *editBones_to_undoBones(void *lbev, void *obdata)
 {
 	ListBase *edbo= lbev;
 	ListBase *lb;

Modified: branches/bmesh/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/curve/editcurve.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/curve/editcurve.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -5158,7 +5158,7 @@
 
 /****************** 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 *editCurve_to_undoCurve(void *lbe)
+static void *editCurve_to_undoCurve(void *lbe, void *obdata)
 {
 	ListBase *editnurb= lbe;
 	ListBase *lb;

Modified: branches/bmesh/blender/source/blender/editors/curve/editfont.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/curve/editfont.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/curve/editfont.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -1538,7 +1538,7 @@
 
 /* **************** 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 @@
 	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;

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -555,13 +555,14 @@
 } 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 @@
 	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;

Modified: branches/bmesh/blender/source/blender/editors/metaball/mball_edit.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/metaball/mball_edit.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/metaball/mball_edit.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -614,7 +614,7 @@
 }
 
 
-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 *editMball_to_undoMball(void *lbe)
+static void *editMball_to_undoMball(void *lbe, void *obdata)
 {
 	ListBase *editelems= lbe;
 	ListBase *lb;

Modified: branches/bmesh/blender/source/blender/editors/object/object_lattice.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/object/object_lattice.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/object/object_lattice.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -325,7 +325,7 @@
 	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 @@
 	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;

Modified: branches/bmesh/blender/source/blender/editors/util/editmode_undo.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/util/editmode_undo.c	2009-11-02 14:49:22 UTC (rev 24243)
+++ branches/bmesh/blender/source/blender/editors/util/editmode_undo.c	2009-11-02 16:01:24 UTC (rev 24244)
@@ -95,8 +95,8 @@
 	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 @@
 
 /* ********************* 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 @@
 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 @@
 	/* 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 @@
 /* 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 @@
 		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 @@
 		
 		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);
 		}





More information about the Bf-blender-cvs mailing list