diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-08-10 10:36:42 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-08-10 10:36:42 +0400 |
commit | c0e39df6ac42d137fd51eeea463aace856bf97d4 (patch) | |
tree | 86be54ecb6f01b8192905a05707b12402970d5a4 /source/blender/editors/object/object_lattice.c | |
parent | 41531e4fb6547df543a80d62b473c250d5b78753 (diff) |
- Enable shape key switching in edit mode for curves, surfaces and latticies
- Disable changing of lattice size if there are shape keys
Diffstat (limited to 'source/blender/editors/object/object_lattice.c')
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 116 |
1 files changed, 63 insertions, 53 deletions
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index a1fb10e350e..9f82a1209cf 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -46,6 +46,8 @@ #include "BKE_lattice.h" #include "BKE_mesh.h" +#include "BLI_listbase.h" + #include "ED_screen.h" #include "ED_view3d.h" #include "ED_util.h" @@ -62,12 +64,16 @@ void free_editLatt(Object *ob) Lattice *lt= ob->data; if(lt->editlatt) { - if(lt->editlatt->def) - MEM_freeN(lt->editlatt->def); - if(lt->editlatt->dvert) - free_dverts(lt->editlatt->dvert, lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw); - + Lattice *editlt= lt->editlatt->latt; + + if(editlt->def) + MEM_freeN(editlt->def); + if(editlt->dvert) + free_dverts(editlt->dvert, editlt->pntsu*editlt->pntsv*editlt->pntsw); + + MEM_freeN(editlt); MEM_freeN(lt->editlatt); + lt->editlatt= NULL; } } @@ -76,47 +82,51 @@ void make_editLatt(Object *obedit) { Lattice *lt= obedit->data; KeyBlock *actkey; - + free_editLatt(obedit); - + lt= obedit->data; actkey= ob_get_keyblock(obedit); if(actkey) key_to_latt(actkey, lt); - lt->editlatt= MEM_dupallocN(lt); - lt->editlatt->def= MEM_dupallocN(lt->def); - + lt->editlatt= MEM_callocN(sizeof(EditLatt), "editlatt"); + lt->editlatt->latt= MEM_dupallocN(lt); + lt->editlatt->latt->def= MEM_dupallocN(lt->def); + if(lt->dvert) { int tot= lt->pntsu*lt->pntsv*lt->pntsw; - lt->editlatt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); - copy_dverts(lt->editlatt->dvert, lt->dvert, tot); + lt->editlatt->latt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); } + + if(lt->key) lt->editlatt->shapenr= obedit->shapenr; } void load_editLatt(Object *obedit) { - Lattice *lt; + Lattice *lt, *editlt; KeyBlock *actkey; BPoint *bp; float *fp; int tot; - + lt= obedit->data; - - actkey= ob_get_keyblock(obedit); + editlt= lt->editlatt->latt; + + if(lt->editlatt->shapenr) { + actkey= BLI_findlink(<->key->block, lt->editlatt->shapenr-1); - if(actkey) { /* active key: vertices */ - tot= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw; + tot= editlt->pntsu*editlt->pntsv*editlt->pntsw; if(actkey->data) MEM_freeN(actkey->data); fp=actkey->data= MEM_callocN(lt->key->elemsize*tot, "actkey->data"); actkey->totelem= tot; - - bp= lt->editlatt->def; + + bp= editlt->def; while(tot--) { VECCOPY(fp, bp->vec); fp+= 3; @@ -125,30 +135,30 @@ void load_editLatt(Object *obedit) } else { MEM_freeN(lt->def); - - lt->def= MEM_dupallocN(lt->editlatt->def); - lt->flag= lt->editlatt->flag; + lt->def= MEM_dupallocN(editlt->def); - lt->pntsu= lt->editlatt->pntsu; - lt->pntsv= lt->editlatt->pntsv; - lt->pntsw= lt->editlatt->pntsw; + lt->flag= editlt->flag; + + lt->pntsu= editlt->pntsu; + lt->pntsv= editlt->pntsv; + lt->pntsw= editlt->pntsw; - lt->typeu= lt->editlatt->typeu; - lt->typev= lt->editlatt->typev; - lt->typew= lt->editlatt->typew; + lt->typeu= editlt->typeu; + lt->typev= editlt->typev; + lt->typew= editlt->typew; } - + if(lt->dvert) { free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); lt->dvert= NULL; } - - if(lt->editlatt->dvert) { + + if(editlt->dvert) { int tot= lt->pntsu*lt->pntsv*lt->pntsw; - + lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); - copy_dverts(lt->dvert, lt->editlatt->dvert, tot); + copy_dverts(lt->dvert, editlt->dvert, tot); } } @@ -160,9 +170,9 @@ void ED_setflagsLatt(Object *obedit, int flag) BPoint *bp; int a; - bp= lt->editlatt->def; + bp= lt->editlatt->latt->def; - a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; while(a--) { if(bp->hide==0) { @@ -183,8 +193,8 @@ int select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = SEL_SELECT; - bp= lt->editlatt->def; - a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw; + bp= lt->editlatt->latt->def; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; while(a--) { if(bp->hide==0) { @@ -205,8 +215,8 @@ int select_all_exec(bContext *C, wmOperator *op) ED_setflagsLatt(obedit, 0); break; case SEL_INVERT: - bp= lt->editlatt->def; - a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw; + bp= lt->editlatt->latt->def; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; while(a--) { if(bp->hide==0) { @@ -256,7 +266,7 @@ int make_regular_exec(bContext *C, wmOperator *op) if(ob) { lt= ob->data; - resizelattice(lt->editlatt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } else { ob= CTX_data_active_object(C); @@ -354,21 +364,21 @@ typedef struct UndoLattice { static void undoLatt_to_editLatt(void *data, void *edata) { UndoLattice *ult= (UndoLattice*)data; - Lattice *editlatt= (Lattice *)edata; - int a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; + EditLatt *editlatt= (EditLatt *)edata; + int a= editlatt->latt->pntsu*editlatt->latt->pntsv*editlatt->latt->pntsw; - memcpy(editlatt->def, ult->def, a*sizeof(BPoint)); + memcpy(editlatt->latt->def, ult->def, a*sizeof(BPoint)); } static void *editLatt_to_undoLatt(void *edata) { UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice"); - Lattice *editlatt= (Lattice *)edata; + EditLatt *editlatt= (EditLatt *)edata; - ult->def= MEM_dupallocN(editlatt->def); - ult->pntsu= editlatt->pntsu; - ult->pntsv= editlatt->pntsv; - ult->pntsw= editlatt->pntsw; + ult->def= MEM_dupallocN(editlatt->latt->def); + ult->pntsu= editlatt->latt->pntsu; + ult->pntsv= editlatt->latt->pntsv; + ult->pntsw= editlatt->latt->pntsw; return ult; } @@ -384,11 +394,11 @@ static void free_undoLatt(void *data) static int validate_undoLatt(void *data, void *edata) { UndoLattice *ult= (UndoLattice*)data; - Lattice *editlatt= (Lattice *)edata; + EditLatt *editlatt= (EditLatt *)edata; - return (ult->pntsu == editlatt->pntsu && - ult->pntsv == editlatt->pntsv && - ult->pntsw == editlatt->pntsw); + return (ult->pntsu == editlatt->latt->pntsu && + ult->pntsv == editlatt->latt->pntsv && + ult->pntsw == editlatt->latt->pntsw); } static void *get_editlatt(bContext *C) |