[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13801] trunk/blender/source/blender:
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu Feb 21 17:57:59 CET 2008
Revision: 13801
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13801
Author: blendix
Date: 2008-02-21 17:57:58 +0100 (Thu, 21 Feb 2008)
Log Message:
-----------
Fix for bug #6769: lattice editmode undo gave corrupt data
if the lattice resolution changed.
Modified Paths:
--------------
trunk/blender/source/blender/include/BIF_editmode_undo.h
trunk/blender/source/blender/src/editarmature.c
trunk/blender/source/blender/src/editcurve.c
trunk/blender/source/blender/src/editfont.c
trunk/blender/source/blender/src/editlattice.c
trunk/blender/source/blender/src/editmball.c
trunk/blender/source/blender/src/editmesh.c
trunk/blender/source/blender/src/editmode_undo.c
Modified: trunk/blender/source/blender/include/BIF_editmode_undo.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editmode_undo.h 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/include/BIF_editmode_undo.h 2008-02-21 16:57:58 UTC (rev 13801)
@@ -39,7 +39,8 @@
extern void undo_editmode_push(char *name,
void (*freedata)(void *), // pointer to function freeing data
void (*to_editmode)(void *), // data to editmode conversion
- void *(*from_editmode)(void)); // editmode to data conversion
+ void *(*from_editmode)(void), // editmode to data conversion
+ int (*validate_undo)(void *)); // check if undo data is still valid
// Further exported for UI is:
Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editarmature.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -1565,7 +1565,7 @@
/* and this is all the undo system needs to know */
void undo_push_armature(char *name)
{
- undo_editmode_push(name, free_undoBones, undoBones_to_editBones, editBones_to_undoBones);
+ undo_editmode_push(name, free_undoBones, undoBones_to_editBones, editBones_to_undoBones, NULL);
}
Modified: trunk/blender/source/blender/src/editcurve.c
===================================================================
--- trunk/blender/source/blender/src/editcurve.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editcurve.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -4624,7 +4624,7 @@
/* and this is all the undo system needs to know */
void undo_push_curve(char *name)
{
- undo_editmode_push(name, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve);
+ undo_editmode_push(name, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve, NULL);
}
Modified: trunk/blender/source/blender/src/editfont.c
===================================================================
--- trunk/blender/source/blender/src/editfont.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editfont.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -1283,7 +1283,7 @@
/* and this is all the undo system needs to know */
void undo_push_font(char *name)
{
- undo_editmode_push(name, free_undoFont, undoFont_to_editFont, editFont_to_undoFont);
+ undo_editmode_push(name, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL);
}
Modified: trunk/blender/source/blender/src/editlattice.c
===================================================================
--- trunk/blender/source/blender/src/editlattice.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editlattice.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -294,28 +294,51 @@
/* **************** 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 *defv)
+static void free_undoLatt(void *data)
{
- MEM_freeN(defv);
+ UndoLattice *ult= (UndoLattice*)data;
+
+ if(ult->def) MEM_freeN(ult->def);
+ MEM_freeN(ult);
}
+static int validate_undoLatt(void *data)
+{
+ 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);
}
Modified: trunk/blender/source/blender/src/editmball.c
===================================================================
--- trunk/blender/source/blender/src/editmball.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editmball.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -494,7 +494,7 @@
/* this is undo system for MetaBalls */
void undo_push_mball(char *name)
{
- undo_editmode_push(name, free_undoMball, undoMball_to_editMball, editMball_to_undoMball);
+ undo_editmode_push(name, free_undoMball, undoMball_to_editMball, editMball_to_undoMball, NULL);
}
/* Hide selected/unselected MetaElems */
Modified: trunk/blender/source/blender/src/editmesh.c
===================================================================
--- trunk/blender/source/blender/src/editmesh.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editmesh.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -2235,7 +2235,7 @@
/* and this is all the undo system needs to know */
void undo_push_mesh(char *name)
{
- undo_editmode_push(name, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh);
+ undo_editmode_push(name, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh, NULL);
}
Modified: trunk/blender/source/blender/src/editmode_undo.c
===================================================================
--- trunk/blender/source/blender/src/editmode_undo.c 2008-02-21 15:24:15 UTC (rev 13800)
+++ trunk/blender/source/blender/src/editmode_undo.c 2008-02-21 16:57:58 UTC (rev 13801)
@@ -79,6 +79,7 @@
void (*freedata)(void *), // pointer to function freeing data
void (*to_editmode)(void *), // data to editmode conversion
void * (*from_editmode)(void)) // editmode to data conversion
+ int (*validate_undo)(void *)) // check if undo data is still valid
Further exported for UI is:
@@ -96,7 +97,8 @@
void undo_editmode_clear(void); // free & clear all data
void undo_editmode_menu(void); // history menu
void undo_editmode_push(char *name, void (*freedata)(void *),
- void (*to_editmode)(void *), void *(*from_editmode)(void));
+ void (*to_editmode)(void *), void *(*from_editmode)(void),
+ int (*validate_undo)(void *));
struct uiBlock *editmode_undohistorymenu(void *arg_unused);
@@ -112,6 +114,7 @@
void (*freedata)(void *);
void (*to_editmode)(void *);
void * (*from_editmode)(void);
+ int (*validate_undo)(void *);
} UndoElem;
static ListBase undobase={NULL, NULL};
@@ -133,7 +136,8 @@
/* name can be a dynamic string */
void undo_editmode_push(char *name, void (*freedata)(void *),
- void (*to_editmode)(void *), void *(*from_editmode)(void))
+ void (*to_editmode)(void *), void *(*from_editmode)(void),
+ int (*validate_undo)(void *))
{
UndoElem *uel;
int nr;
@@ -157,6 +161,7 @@
uel->freedata= freedata;
uel->to_editmode= to_editmode;
uel->from_editmode= from_editmode;
+ uel->validate_undo= validate_undo;
/* and limit amount to the maximum */
nr= 0;
@@ -197,7 +202,8 @@
next= uel->next;
/* for when objects are converted, renamed, or global undo changes pointers... */
- if(uel->type==G.obedit->type && strcmp(uel->id.name, G.obedit->id.name)==0) {
+ if(uel->type==G.obedit->type && strcmp(uel->id.name, G.obedit->id.name)==0 &&
+ (!uel->validate_undo || uel->validate_undo(uel->undodata))) {
uel->ob= G.obedit;
}
else {
More information about the Bf-blender-cvs
mailing list