- Enable shape key switching in edit mode for curves, surfaces and latticies
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 10 Aug 2010 06:36:42 +0000 (06:36 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 10 Aug 2010 06:36:42 +0000 (06:36 +0000)
- Disable changing of lattice size if there are shape keys

22 files changed:
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/object.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/ED_lattice.h [new file with mode: 0644]
source/blender/editors/interface/interface_templates.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_lattice.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/space_info/info_stats.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_lattice_types.h
source/blender/makesrna/intern/rna_lattice.c
source/blender/makesrna/intern/rna_object.c

index 1eb7b5d20215d427b3b7be795784316272130aa4..1390f0dbd56fa70505ea57305b22d6caced7e690 100644 (file)
@@ -225,8 +225,12 @@ void free_lattice(Lattice *lt)
        if(lt->def) MEM_freeN(lt->def);
        if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
        if(lt->editlatt) {
-               if(lt->editlatt->def) MEM_freeN(lt->editlatt->def);
-               if(lt->editlatt->dvert) free_dverts(lt->editlatt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
+               Lattice *editlt= lt->editlatt->latt;
+
+               if(editlt->def) MEM_freeN(editlt->def);
+               if(editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
+
+               MEM_freeN(editlt);
                MEM_freeN(lt->editlatt);
        }
 }
@@ -295,7 +299,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
        float fu, fv, fw;
        int u, v, w;
 
-       if(lt->editlatt) lt= lt->editlatt;
+       if(lt->editlatt) lt= lt->editlatt->latt;
        bp = lt->def;
        
        fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata");
@@ -350,7 +354,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
        MDeformVert *dvert= lattice_get_deform_verts(ob);
 
 
-       if(lt->editlatt) lt= lt->editlatt;
+       if(lt->editlatt) lt= lt->editlatt->latt;
        if(lt->latticedata==NULL) return;
 
        if(lt->vgroup[0] && dvert) {
@@ -446,7 +450,7 @@ void end_latt_deform(Object *ob)
 {
        Lattice *lt= ob->data;
        
-       if(lt->editlatt) lt= lt->editlatt;
+       if(lt->editlatt) lt= lt->editlatt->latt;
        
        if(lt->latticedata)
                MEM_freeN(lt->latticedata);
@@ -1002,7 +1006,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]
        int i, numVerts;
        float (*vertexCos)[3];
 
-       if(lt->editlatt) lt= lt->editlatt;
+       if(lt->editlatt) lt= lt->editlatt->latt;
        numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw;
        
        vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos");
@@ -1066,7 +1070,7 @@ struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt)
        if(oblatt->type == OB_LATTICE)
        {
                Lattice *lt = (Lattice*)oblatt->data;
-               if(lt->editlatt) lt= lt->editlatt;
+               if(lt->editlatt) lt= lt->editlatt->latt;
                return lt->dvert;
        }
 
index c08a3408505f57b3d06e105aa04805f0573b97d5..18eedd63906ae3ae27d28cedb92bf0d3ba9ed32a 100644 (file)
@@ -1917,7 +1917,7 @@ static void give_parvert(Object *par, int nr, float *vec)
                DispList *dl = find_displist(&par->disp, DL_VERTS);
                float *co = dl?dl->verts:NULL;
                
-               if(latt->editlatt) latt= latt->editlatt;
+               if(latt->editlatt) latt= latt->editlatt->latt;
                
                a= latt->pntsu*latt->pntsv*latt->pntsw;
                count= 0;
index 7150070dd6554f9ad10adc41978fc5e58fbd4375..b85429e36a9731069b99db41dfba0a70f763a30b 100644 (file)
@@ -724,7 +724,7 @@ static void calc_shapeKeys(Object *obedit)
                int a, i, j;
                EditNurb *editnurb= cu->editnurb;
                KeyBlock *currkey;
-               KeyBlock *actkey= ob_get_keyblock(obedit);
+               KeyBlock *actkey= BLI_findlink(&cu->key->block, editnurb->shapenr-1);
                BezTriple *bezt, *oldbezt;
                BPoint *bp, *oldbp;
                Nurb *nu;
@@ -738,7 +738,7 @@ static void calc_shapeKeys(Object *obedit)
                        int act_is_basis = 0;
                        /* find if this key is a basis for any others */
                        for(currkey = cu->key->block.first; currkey; currkey= currkey->next) {
-                               if(obedit->shapenr-1 == currkey->relative) {
+                               if(editnurb->shapenr-1 == currkey->relative) {
                                        act_is_basis = 1;
                                        break;
                                }
@@ -806,7 +806,7 @@ static void calc_shapeKeys(Object *obedit)
 
                currkey = cu->key->block.first;
                while(currkey) {
-                       int apply_offset = (ofs && (currkey != actkey) && (obedit->shapenr-1 == currkey->relative));
+                       int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr-1 == currkey->relative));
 
                        fp= newkey= MEM_callocN(cu->key->elemsize * totvert,  "currkey->data");
                        ofp= oldkey = currkey->data;
@@ -1035,6 +1035,7 @@ void make_editNurb(Object *obedit)
                }
 
                if(actkey) {
+                       editnurb->shapenr= obedit->shapenr;
                        init_editNurb_keyIndex(editnurb, &cu->nurb);
                }
        }
diff --git a/source/blender/editors/include/ED_lattice.h b/source/blender/editors/include/ED_lattice.h
new file mode 100644 (file)
index 0000000..bebd6c5
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+struct Object;
+
+void free_editLatt(struct Object *ob);
+void make_editLatt(struct Object *obedit);
+void load_editLatt(struct Object *obedit);
index bebec77ce1a4125b62f11577e574aabb2d48e164..eb99a45d62da3676a7df44135dc928b65344e473 100644 (file)
@@ -2097,12 +2097,6 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
        /* list item behind label & other buttons */
        sub= uiLayoutRow(overlap, 0);
 
-       if(itemptr->type == &RNA_ShapeKey) {
-               ob= (Object*)activeptr->data;
-               if(ob->mode == OB_MODE_EDIT && !(ob->type == OB_MESH))
-                       uiLayoutSetEnabled(sub, 0);
-       }
-
        but= uiDefButR(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
        uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
 
index f7bde0777404b91814253596cb54a0f26115df63..36879e43fe2ee0df579630dc1a734699e8816104 100644 (file)
@@ -78,6 +78,7 @@
 #include "ED_curve.h"
 #include "ED_mesh.h"
 #include "ED_mball.h"
+#include "ED_lattice.h"
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_util.h"
@@ -938,14 +939,15 @@ void special_editmenu(Scene *scene, View3D *v3d)
                static float weight= 1.0f;
                { // XXX
 // XXX         if(fbutton(&weight, 0.0f, 1.0f, 10, 10, "Set Weight")) {
-                       int a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-                       BPoint *bp= lt->editlatt->def;
+                       Lattice *editlt= lt->editlatt->latt;
+                       int a= editlt->pntsu*editlt->pntsv*editlt->pntsw;
+                       BPoint *bp= editlt->def;
                        
                        while(a--) {
                                if(bp->f1 & SELECT)
                                        bp->weight= weight;
                                bp++;
-                       }       
+                       }
                }
        }
 
index 2ee82a194cc24fc07bd23326a486bbcda62b30ad..75e22d5356fa2f5c412d74e6e30e7daca9b6ccbe 100644 (file)
@@ -191,13 +191,14 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar
 
 static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
 {
-       Lattice *lt= obedit->data;
+       Lattice *lt= obedit->data, *editlt;
        BPoint *bp;
        int index=0, nr=0, a;
-       
+
+       editlt= lt->editlatt->latt;
        /* count */
-       a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-       bp= lt->editlatt->def;
+       a= editlt->pntsu*editlt->pntsv*editlt->pntsw;
+       bp= editlt->def;
        while(a--) {
                if(hmd->indexar[index]==nr) {
                        bp->f1 |= SELECT;
@@ -313,7 +314,7 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char
                case OB_LATTICE:
                {
                        Lattice *lt= obedit->data;
-                       return return_editlattice_indexar(lt->editlatt, tot, indexar, cent_r);
+                       return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r);
                }
                default:
                        return 0;
index bd48db2f78080abbc8103e26ff55500bbc00ccaa..ed75c4060a20342e52fdbb6fdb062e5389b35625 100644 (file)
@@ -131,11 +131,6 @@ void OBJECT_OT_hook_reset(struct wmOperatorType *ot);
 void OBJECT_OT_hook_recenter(struct wmOperatorType *ot);
 
 /* object_lattice.c */
-void free_editLatt(struct Object *ob);
-void make_editLatt(struct Object *obedit);
-void load_editLatt(struct Object *obedit);
-void remake_editLatt(struct Object *obedit);
-
 void LATTICE_OT_select_all(struct wmOperatorType *ot);
 void LATTICE_OT_make_regular(struct wmOperatorType *ot);
 
index a1fb10e350eb718556216d13b80f5aa09d25d369..9f82a1209cf9814901ff05f92ce9deab73975fd9 100644 (file)
@@ -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(&lt->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)
index 23bcf5309c5489f9d3faa92a23f5120d2243e14b..6e9244e39cab69f652e9a5056c5a7e59e4899dde 100644 (file)
@@ -172,8 +172,8 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
        else if(obedit->type==OB_LATTICE) {
                Lattice *lt= obedit->data;
                
-               a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-               bp= lt->editlatt->def;
+               a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
+               bp= lt->editlatt->latt->def;
                while(a--) {
                        if(bp->f1 & SELECT) {
                                if(v1==0) v1= nr;
index 86f0c5fa874915cdebf97fb8c96ca36a027e3d65..5cdabcab41ab4dd338450645ee37bf2af367d2eb 100644 (file)
@@ -73,7 +73,7 @@ static Lattice *vgroup_edit_lattice(Object *ob)
 {
        if(ob->type==OB_LATTICE) {
                Lattice *lt= ob->data;
-               return (lt->editlatt)? lt->editlatt: lt;
+               return (lt->editlatt)? lt->editlatt->latt: lt;
        }
 
        return NULL;
@@ -169,7 +169,7 @@ int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot)
                                int i=0;
 
                                Lattice *lt= (Lattice *)id;
-                               lt= (lt->editlatt)? lt->editlatt: lt;
+                               lt= (lt->editlatt)? lt->editlatt->latt: lt;
 
                                *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
                                *dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me");
@@ -203,7 +203,7 @@ int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot)
                        case ID_LT:
                        {
                                Lattice *lt= (Lattice *)id;
-                               lt= (lt->editlatt)? lt->editlatt: lt;
+                               lt= (lt->editlatt)? lt->editlatt->latt: lt;
                                *dvert_arr= lt->dvert;
                                *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
                                return TRUE;
index 693cac01f07dfcb674c3db2987156d3868489e75..0789114c054023e0774f5e74344a663cf96551e6 100644 (file)
@@ -225,7 +225,7 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
        else if(obedit->type==OB_LATTICE) {
                /* Lattice Edit */
                Lattice *lt= obedit->data;
-               Lattice *editlatt= lt->editlatt;
+               Lattice *editlatt= lt->editlatt->latt;
                BPoint *bp;
                int a;
 
index d8c4a38e2aae50100e7c42a9801cb8426e3f4c3a..e23276cecad80a18d941d36163b799fc0c7768bc 100644 (file)
@@ -1357,10 +1357,10 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo
 {
        Object *obedit= vc->obedit;
        Lattice *lt= obedit->data;
-       BPoint *bp = lt->editlatt->def;
+       BPoint *bp = lt->editlatt->latt->def;
        DispList *dl = find_displist(&obedit->disp, DL_VERTS);
        float *co = dl?dl->verts:NULL;
-       int i, N = lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
+       int i, N = lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
        short s[2] = {IS_CLIPPED, 0};
 
        ED_view3d_local_clipping(vc->rv3d, obedit->obmat); /* for local clipping lookups */
@@ -1408,7 +1408,7 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
        dl= find_displist(&ob->disp, DL_VERTS);
        
        if(is_edit) {
-               lt= lt->editlatt;
+               lt= lt->editlatt->latt;
 
                cpack(0x004000);
                
index 5f3565c10885274a6367bc7285185be0805d4c13..e6c8ff2c2687f9bcfeb2ef32e2f9d493a4a479c8 100644 (file)
@@ -255,8 +255,8 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
                BPoint *bp;
                int a;
                
-               a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-               bp= lt->editlatt->def;
+               a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
+               bp= lt->editlatt->latt->def;
                while(a--) {
                        if(bp->f1 & SELECT) {
                                add_v3_v3(median, bp->vec);
@@ -457,8 +457,8 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
                        BPoint *bp;
                        int a;
                        
-                       a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-                       bp= lt->editlatt->def;
+                       a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
+                       bp= lt->editlatt->latt->def;
                        while(a--) {
                                if(bp->f1 & SELECT) {
                                        add_v3_v3(bp->vec, median);
index 35c4d10cb94c5f68a88ade65f6e7f709596819a5..a4e893a61813e056fafdd5d69d7c834caed29338 100644 (file)
@@ -145,8 +145,8 @@ static void special_transvert_update(Scene *scene, Object *obedit)
                else if(obedit->type==OB_LATTICE) {
                        Lattice *lt= obedit->data;
                        
-                       if(lt->editlatt->flag & LT_OUTSIDE) 
-                               outside_lattice(lt->editlatt);
+                       if(lt->editlatt->latt->flag & LT_OUTSIDE)
+                               outside_lattice(lt->editlatt->latt);
                }
        }
 }
@@ -372,9 +372,9 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
        else if(obedit->type==OB_LATTICE) {
                Lattice *lt= obedit->data;
                
-               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;
                
                tv=transvmain= MEM_callocN(a*sizeof(TransVert), "maketransverts curve");
                
index e40c15de25df6ddf413478b4930b8aaf31b36ab5..a82037ead114f19b1079c41edee0aafa97485199 100644 (file)
@@ -1532,7 +1532,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
 
 static void createTransLatticeVerts(bContext *C, TransInfo *t)
 {
-       Lattice *latt = ((Lattice*)t->obedit->data)->editlatt;
+       Lattice *latt = ((Lattice*)t->obedit->data)->editlatt->latt;
        TransData *td = NULL;
        BPoint *bp;
        float mtx[3][3], smtx[3][3];
index 74f4b5cb52f1de62bc857ab4f7fdde5f8c7a7758..56a4eb846c00e8b6f33ebdbb51c18ed943e5f025 100644 (file)
@@ -659,7 +659,7 @@ void recalcData(TransInfo *t)
                                Lattice *la= t->obedit->data;
                                DAG_id_flush_update(t->obedit->data, OB_RECALC_DATA);  /* sets recalc flags */
        
-                               if(la->editlatt->flag & LT_OUTSIDE) outside_lattice(la->editlatt);
+                               if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt);
                        }
                        else if (t->obedit->type == OB_MESH) {
                                EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
index e6def04130ca522d0c0f3981816f3aa9bab52beb..27c3f056b9b06fa66ae5c3dfef27f9f3e8916e6b 100644 (file)
@@ -379,9 +379,9 @@ int calc_manipulator_stats(const bContext *C)
                        BPoint *bp;
                        Lattice *lt= obedit->data;
 
-                       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->f1 & SELECT) {
                                        calc_tw_center(scene, bp->vec);
index a013177e1b88759cf0780e0be2b870f420afb2ea..973ba896100c501fbc0bfa0ea48368b736e08396 100644 (file)
@@ -157,6 +157,11 @@ typedef struct EditNurb {
 
        /* index data for shape keys */
        struct GHash *keyindex;
+
+       /* shape key being edited */
+       int shapenr;
+
+       char pad[4];
 } EditNurb;
 
 typedef struct Curve {
index 3a0fcb3c38ce7228602858479e37e83c95578d1d..94fc9fefb66ed4fb1711de1459bd474f4363cf6e 100644 (file)
@@ -36,6 +36,14 @@ struct Ipo;
 struct Key;
 struct MDeformVert;
 
+typedef struct EditLatt {
+       struct Lattice *latt;
+
+       int shapenr;
+
+       char pad[4];
+} EditLatt;
+
 typedef struct Lattice {
        ID id;
        
@@ -58,7 +66,7 @@ typedef struct Lattice {
        float *latticedata;
        float latmat[4][4];
        
-       struct Lattice *editlatt;
+       struct EditLatt *editlatt;
 } Lattice;
 
 /* ***************** LATTICE ********************* */
index c513284401679d1b7f6c6a42621ef60468bbf4bb..9f979582165a569f621d76aec2ba8ec69f509f09 100644 (file)
@@ -79,8 +79,8 @@ static void rna_Lattice_points_begin(CollectionPropertyIterator *iter, PointerRN
        Lattice *lt= (Lattice*)ptr->data;
        int tot= lt->pntsu*lt->pntsv*lt->pntsw;
 
-       if(lt->editlatt && lt->editlatt->def)
-               rna_iterator_array_begin(iter, (void*)lt->editlatt->def, sizeof(BPoint), tot, 0, NULL);
+       if(lt->editlatt && lt->editlatt->latt->def)
+               rna_iterator_array_begin(iter, (void*)lt->editlatt->latt->def, sizeof(BPoint), tot, 0, NULL);
        else if(lt->def)
                rna_iterator_array_begin(iter, (void*)lt->def, sizeof(BPoint), tot, 0, NULL);
        else
@@ -111,7 +111,7 @@ static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr)
                if(ob->data == lt) {
                        resizelattice(lt, newu, newv, neww, ob);
                        if(lt->editlatt)
-                               resizelattice(lt->editlatt, newu, newv, neww, ob);
+                               resizelattice(lt->editlatt->latt, newu, newv, neww, ob);
                        break;
                }
        }
@@ -120,7 +120,7 @@ static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr)
        if(!ob) {
                resizelattice(lt, newu, newv, neww, NULL);
                if(lt->editlatt)
-                       resizelattice(lt->editlatt, newu, newv, neww, NULL);
+                       resizelattice(lt->editlatt->latt, newu, newv, neww, NULL);
        }
 
        rna_Lattice_update_data(bmain, scene, ptr);
@@ -136,26 +136,39 @@ static void rna_Lattice_outside_set(PointerRNA *ptr, int value)
        outside_lattice(lt);
 
        if(lt->editlatt) {
-               if(value) lt->editlatt->flag |= LT_OUTSIDE;
-               else lt->editlatt->flag &= ~LT_OUTSIDE;
+               if(value) lt->editlatt->latt->flag |= LT_OUTSIDE;
+               else lt->editlatt->latt->flag &= ~LT_OUTSIDE;
 
-               outside_lattice(lt->editlatt);
+               outside_lattice(lt->editlatt->latt);
        }
 }
 
+static int rna_Lattice_size_editable(PointerRNA *ptr)
+{
+       Lattice *lt= (Lattice*)ptr->data;
+
+       return lt->key == NULL;
+}
+
 static void rna_Lattice_points_u_set(PointerRNA *ptr, int value)
 {
-       ((Lattice*)ptr->data)->opntsu= CLAMPIS(value, 1, 64);
+       Lattice *lt= (Lattice*)ptr->data;
+
+       lt->opntsu= CLAMPIS(value, 1, 64);
 }
 
 static void rna_Lattice_points_v_set(PointerRNA *ptr, int value)
 {
-       ((Lattice*)ptr->data)->opntsv= CLAMPIS(value, 1, 64);
+       Lattice *lt= (Lattice*)ptr->data;
+
+       lt->opntsv= CLAMPIS(value, 1, 64);
 }
 
 static void rna_Lattice_points_w_set(PointerRNA *ptr, int value)
 {
-       ((Lattice*)ptr->data)->opntsw= CLAMPIS(value, 1, 64);
+       Lattice *lt= (Lattice*)ptr->data;
+
+       lt->opntsw= CLAMPIS(value, 1, 64);
 }
 
 static void rna_Lattice_vg_name_set(PointerRNA *ptr, const char *value)
@@ -164,7 +177,7 @@ static void rna_Lattice_vg_name_set(PointerRNA *ptr, const char *value)
        strcpy(lt->vgroup, value);
 
        if(lt->editlatt)
-               strcpy(lt->editlatt->vgroup, value);
+               strcpy(lt->editlatt->latt->vgroup, value);
 }
 
 
@@ -216,22 +229,25 @@ static void rna_def_lattice(BlenderRNA *brna)
        RNA_def_property_int_sdna(prop, NULL, "pntsu");
        RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_u_set", NULL);
        RNA_def_property_range(prop, 1, 64);
-       RNA_def_property_ui_text(prop, "U", "Points in U direction");
+       RNA_def_property_ui_text(prop, "U", "Points in U direction (can't be changed when there are shape keys)");
        RNA_def_property_update(prop, 0, "rna_Lattice_update_size");
+       RNA_def_property_editable_func(prop, "rna_Lattice_size_editable");
 
        prop= RNA_def_property(srna, "points_v", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "pntsv");
        RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_v_set", NULL);
        RNA_def_property_range(prop, 1, 64);
-       RNA_def_property_ui_text(prop, "V", "Points in V direction");
+       RNA_def_property_ui_text(prop, "V", "Points in V direction (can't be changed when there are shape keys)");
        RNA_def_property_update(prop, 0, "rna_Lattice_update_size");
+       RNA_def_property_editable_func(prop, "rna_Lattice_size_editable");
 
        prop= RNA_def_property(srna, "points_w", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "pntsw");
        RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_w_set", NULL);
        RNA_def_property_range(prop, 1, 64);
-       RNA_def_property_ui_text(prop, "W", "Points in W direction");
+       RNA_def_property_ui_text(prop, "W", "Points in W direction (can't be changed when there are shape keys)");
        RNA_def_property_update(prop, 0, "rna_Lattice_update_size");
+       RNA_def_property_editable_func(prop, "rna_Lattice_size_editable");
 
        prop= RNA_def_property(srna, "interpolation_type_u", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "typeu");
index 51e2fc380141c95f4036fcb73a8e903e9afe5d4c..ee38505d792395f12f15cd2eb03bca63dbf980fe 100644 (file)
@@ -128,6 +128,8 @@ EnumPropertyItem object_type_curve_items[] = {
 #include "ED_mesh.h"
 #include "ED_object.h"
 #include "ED_particle.h"
+#include "ED_curve.h"
+#include "ED_lattice.h"
 
 static void rna_Object_internal_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
@@ -182,12 +184,24 @@ void rna_Object_internal_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
 void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        Object *ob= ptr->id.data;
-       int editmode= (scene->obedit == ob && ob->type == OB_MESH);
 
-       if(editmode) {
+       if(scene->obedit == ob) {
                /* exit/enter editmode to get new shape */
-               load_editMesh(scene, ob);
-               make_editMesh(scene, ob);
+               switch(ob->type) {
+                       case OB_MESH:
+                               load_editMesh(scene, ob);
+                               make_editMesh(scene, ob);
+                               break;
+                       case OB_CURVE:
+                       case OB_SURF:
+                               load_editNurb(ob);
+                               make_editNurb(ob);
+                               break;
+                       case OB_LATTICE:
+                               load_editLatt(ob);
+                               make_editLatt(ob);
+                               break;
+               }
        }
 
        rna_Object_internal_update_data(bmain, scene, ptr);