diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-02-21 19:57:58 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-02-21 19:57:58 +0300 |
commit | 0d9c6ea649e6e6118afba29e536152f160bf8217 (patch) | |
tree | 4427d0b28ff536ca4f971fe5680f8f437564e389 /source/blender/src/editlattice.c | |
parent | 835624fa050362728f4b8dc6a17a25ca89984be3 (diff) |
Fix for bug #6769: lattice editmode undo gave corrupt data
if the lattice resolution changed.
Diffstat (limited to 'source/blender/src/editlattice.c')
-rw-r--r-- | source/blender/src/editlattice.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/source/blender/src/editlattice.c b/source/blender/src/editlattice.c index f3073cf886a..e80e87b6976 100644 --- a/source/blender/src/editlattice.c +++ b/source/blender/src/editlattice.c @@ -294,28 +294,51 @@ void mouse_lattice(void) /* **************** undo for lattice object ************** */ -static void undoLatt_to_editLatt(void *defv) +typedef struct UndoLattice { + BPoint *def; + int pntsu, pntsv, pntsw; +} UndoLattice; + +static void undoLatt_to_editLatt(void *data) { + UndoLattice *ult= (UndoLattice*)data; int a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw; - memcpy(editLatt->def, defv, a*sizeof(BPoint)); + memcpy(editLatt->def, ult->def, a*sizeof(BPoint)); } static void *editLatt_to_undoLatt(void) { + UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice"); + ult->def= MEM_dupallocN(editLatt->def); + ult->pntsu= editLatt->pntsu; + ult->pntsv= editLatt->pntsv; + ult->pntsw= editLatt->pntsw; - return MEM_dupallocN(editLatt->def); + return ult; +} + +static void free_undoLatt(void *data) +{ + UndoLattice *ult= (UndoLattice*)data; + + if(ult->def) MEM_freeN(ult->def); + MEM_freeN(ult); } -static void free_undoLatt(void *defv) +static int validate_undoLatt(void *data) { - MEM_freeN(defv); + UndoLattice *ult= (UndoLattice*)data; + + return (ult->pntsu == editLatt->pntsu && + ult->pntsv == editLatt->pntsv && + ult->pntsw == editLatt->pntsw); } /* and this is all the undo system needs to know */ void undo_push_lattice(char *name) { - undo_editmode_push(name, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt); + undo_editmode_push(name, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt, validate_undoLatt); } |