2.5
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 3 Jul 2009 15:23:33 +0000 (15:23 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 3 Jul 2009 15:23:33 +0000 (15:23 +0000)
* Lattices: properties editable, editmode operators, menus working
  again. As a bonus you can now edit u/v/w in editmode.
* Shape Keys: some code cleanup, and added more buttons. The
  value/min/max buttons don't work correct yet though.
* Fix issue with uv textures, vertex colors not being visible outside
  editmode, and a few other issue. Mesh.edit_mesh is now NULL when
  not in editmode.

17 files changed:
release/ui/buttons_data_lattice.py
release/ui/buttons_data_mesh.py
source/blender/blenkernel/intern/lattice.c
source/blender/editors/include/ED_screen.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/object/editkey.c
source/blender/editors/object/editlattice.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_ops.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_lattice.c
source/blender/makesrna/intern/rna_object.c

index bf2aaad5a97865e79177947a649c32df4bc86686..653a638c458db868e75dde58f313dcccfb044134 100644 (file)
@@ -48,7 +48,7 @@ class DATA_PT_lattice(DataButtonsPanel):
                        row.itemR(lat, "interpolation_type_w", expand=True)
                        
                        row = layout.row()
+                       row.itemO("LATTICE_OT_make_regular")
                        row.itemR(lat, "outside")
-                       row.itemR(lat, "shape_keys")
 
 bpy.types.register(DATA_PT_lattice)
index c7e253d5084e5a8174f26959fb0d6932bed46ec6..cb3041d505728f3f361418a20aa9fff89d386ebf 100644 (file)
@@ -131,16 +131,44 @@ class DATA_PT_shape_keys(DataButtonsPanel):
        def draw(self, context):
                layout = self.layout
                ob = context.object
-
-               row = layout.row()
-
                key = ob.data.shape_keys
+               kb = ob.active_shape_key
 
+               row = layout.row()
                row.template_list(key, "keys", ob, "active_shape_key_index")
 
-               col = row.column(align=True)
-               col.itemO("OBJECT_OT_shape_key_add", icon="ICON_ZOOMIN", text="")
-               col.itemO("OBJECT_OT_shape_key_remove", icon="ICON_ZOOMOUT", text="")
+               col = row.column()
+
+               subcol = col.column(align=True)
+               subcol.itemO("OBJECT_OT_shape_key_add", icon="ICON_ZOOMIN", text="")
+               subcol.itemO("OBJECT_OT_shape_key_remove", icon="ICON_ZOOMOUT", text="")
+
+               if kb:
+                       col.itemS()
+
+                       subcol = col.column(align=True)
+                       subcol.itemR(ob, "shape_key_lock", icon="ICON_PINNED", text="")
+                       subcol.itemR(kb, "mute", icon="ICON_MUTE_IPO_ON", text="")
+
+                       if key.relative:
+                               row = layout.row()
+                               row.itemR(key, "relative")
+                               row.itemL()
+
+                               if ob.active_shape_key_index != 0:
+                                       if not ob.shape_key_lock:
+                                               row = layout.row(align=True)
+                                               row.itemR(kb, "value", text="")
+                                               row.itemR(kb, "slider_min", text="Min")
+                                               row.itemR(kb, "slider_max", text="Max")
+
+                                       row = layout.row()
+                                       row.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
+                                       row.item_pointerR(kb, "relative_key", key, "keys", text="")
+                       else:
+                               row = layout.row()
+                               row.itemR(key, "relative")
+                               row.itemR(key, "slurph")
 
                if context.edit_object:
                        layout.enabled = False
index 5cf52d093147466df98793812958ff4cee993151..67d63d527cbc606eea12eb8b84386a9fed65e0ab 100644 (file)
@@ -232,8 +232,8 @@ 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->def) MEM_freeN(lt->def);
-               if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
+               if(lt->editlatt->def) MEM_freeN(lt->editlatt->def);
+               if(lt->editlatt->dvert) free_dverts(lt->editlatt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
                MEM_freeN(lt->editlatt);
        }
 }
@@ -817,59 +817,68 @@ void outside_lattice(Lattice *lt)
        int u, v, w;
        float fac1, du=0.0, dv=0.0, dw=0.0;
 
-       bp= lt->def;
+       if(lt->flag & LT_OUTSIDE) {
+               bp= lt->def;
 
-       if(lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
-       if(lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
-       if(lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
-               
-       for(w=0; w<lt->pntsw; w++) {
-               
-               for(v=0; v<lt->pntsv; v++) {
-               
-                       for(u=0; u<lt->pntsu; u++, bp++) {
-                               if(u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
-                               else {
-                               
-                                       bp->hide= 1;
-                                       bp->f1 &= ~SELECT;
-                                       
-                                       /* u extrema */
-                                       bp1= latt_bp(lt, 0, v, w);
-                                       bp2= latt_bp(lt, lt->pntsu-1, v, w);
-                                       
-                                       fac1= du*u;
-                                       bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
-                                       bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
-                                       bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
-                                       
-                                       /* v extrema */
-                                       bp1= latt_bp(lt, u, 0, w);
-                                       bp2= latt_bp(lt, u, lt->pntsv-1, w);
-                                       
-                                       fac1= dv*v;
-                                       bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
-                                       bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
-                                       bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
-                                       
-                                       /* w extrema */
-                                       bp1= latt_bp(lt, u, v, 0);
-                                       bp2= latt_bp(lt, u, v, lt->pntsw-1);
-                                       
-                                       fac1= dw*w;
-                                       bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
-                                       bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
-                                       bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
-                                       
-                                       VecMulf(bp->vec, 0.3333333f);
+               if(lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
+               if(lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
+               if(lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
+                       
+               for(w=0; w<lt->pntsw; w++) {
+                       
+                       for(v=0; v<lt->pntsv; v++) {
+                       
+                               for(u=0; u<lt->pntsu; u++, bp++) {
+                                       if(u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
+                                       else {
                                        
+                                               bp->hide= 1;
+                                               bp->f1 &= ~SELECT;
+                                               
+                                               /* u extrema */
+                                               bp1= latt_bp(lt, 0, v, w);
+                                               bp2= latt_bp(lt, lt->pntsu-1, v, w);
+                                               
+                                               fac1= du*u;
+                                               bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
+                                               bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
+                                               bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
+                                               
+                                               /* v extrema */
+                                               bp1= latt_bp(lt, u, 0, w);
+                                               bp2= latt_bp(lt, u, lt->pntsv-1, w);
+                                               
+                                               fac1= dv*v;
+                                               bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
+                                               bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
+                                               bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
+                                               
+                                               /* w extrema */
+                                               bp1= latt_bp(lt, u, v, 0);
+                                               bp2= latt_bp(lt, u, v, lt->pntsw-1);
+                                               
+                                               fac1= dw*w;
+                                               bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
+                                               bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
+                                               bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
+                                               
+                                               VecMulf(bp->vec, 0.3333333f);
+                                               
+                                       }
                                }
+                               
                        }
                        
                }
-               
        }
-       
+       else {
+               bp= lt->def;
+
+               for(w=0; w<lt->pntsw; w++)
+                       for(v=0; v<lt->pntsv; v++)
+                               for(u=0; u<lt->pntsu; u++, bp++)
+                                       bp->hide= 0;
+       }
 }
 
 float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]
index ef682c871bcc41e6ba7dde0a6c5a5dccfa33a93f..4bb1dd65f853d55229f7be0d2fb86ed44f058d9c 100644 (file)
@@ -127,6 +127,7 @@ int         ED_operator_editcurve(struct bContext *C);
 int            ED_operator_editsurf(struct bContext *C);
 int            ED_operator_editsurfcurve(struct bContext *C);
 int            ED_operator_editfont(struct bContext *C);
+int            ED_operator_editlattice(struct bContext *C);
 int            ED_operator_uvedit(struct bContext *C);
 int            ED_operator_uvmap(struct bContext *C);
 int            ED_operator_posemode(struct bContext *C);
index 2e30c5f1cb74dc0da25d65c211e595f0f1171609..59726c6d5fd26b7cccf8e949508c693f7e22ba60 100644 (file)
@@ -699,7 +699,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
        subtype= RNA_property_subtype(prop);
        len= RNA_property_array_length(prop);
 
-       if(type == PROP_STRING && strcmp(name, "") == 0)
+       if(ELEM(type, PROP_STRING, PROP_POINTER) && strcmp(name, "") == 0)
                name= "non-empty";
 
        w= ui_text_icon_width(layout, name, icon);
index 1c31c7c765356a134dd9f92cf4a089b37eeec5be..f38c03fb284873025266ef789afe997a3a11d195 100644 (file)
 
 #include "object_intern.h"
 
-/* XXX */
-static void BIF_undo_push() {}
-/* XXX */
-
 #if 0 // XXX old animation system
 static void default_key_ipo(Scene *scene, Key *key)
 {
@@ -117,7 +113,7 @@ static void default_key_ipo(Scene *scene, Key *key)
 #endif // XXX old animation system
        
 
-/* **************************************** */
+/************************* Mesh ************************/
 
 void mesh_to_key(Mesh *me, KeyBlock *kb)
 {
@@ -213,7 +209,7 @@ void insert_meshkey(Scene *scene, Mesh *me, short rel)
        mesh_to_key(me, kb);
 }
 
-/* ******************** */
+/************************* Lattice ************************/
 
 void latt_to_key(Lattice *lt, KeyBlock *kb)
 {
@@ -271,7 +267,7 @@ void insert_lattkey(Scene *scene, Lattice *lt, short rel)
        latt_to_key(lt, kb);
 }
 
-/* ******************************** */
+/************************* Curve ************************/
 
 void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
 {
@@ -383,7 +379,7 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel)
        if(cu->key==NULL) {
                cu->key= add_key( (ID *)cu);
 
-               if (rel)
+               if(rel)
                        cu->key->type = KEY_RELATIVE;
 //             else
 //                     default_key_ipo(scene, cu->key);        // XXX old animation system
@@ -396,17 +392,34 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel)
        else curve_to_key(cu, kb, &cu->nurb);
 }
 
+/*********************** add shape key ***********************/
+
+void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob)
+{
+       Key *key;
+
+       if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1);
+       else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1);
+       else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1);
 
-/* ******************** */
+       key= ob_get_key(ob);
+       ob->shapenr= BLI_countlist(&key->block);
 
-void delete_key(Scene *scene, Object *ob)
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+}
+
+/*********************** remove shape key ***********************/
+
+int ED_object_shape_key_remove(bContext *C, Scene *scene, Object *ob)
 {
+       Main *bmain= CTX_data_main(C);
        KeyBlock *kb, *rkb;
        Key *key;
        //IpoCurve *icu;
-       
+
        key= ob_get_key(ob);
-       if(key==NULL) return;
+       if(key==NULL)
+               return 0;
        
        kb= BLI_findlink(&key->block, ob->shapenr-1);
 
@@ -417,15 +430,15 @@ void delete_key(Scene *scene, Object *ob)
 
                BLI_remlink(&key->block, kb);
                key->totkey--;
-               if(key->refkey== kb) key->refkey= key->block.first;
+               if(key->refkey== kb)
+                       key->refkey= key->block.first;
                        
                if(kb->data) MEM_freeN(kb->data);
                MEM_freeN(kb);
                
-               for(kb= key->block.first; kb; kb= kb->next) {
+               for(kb= key->block.first; kb; kb= kb->next)
                        if(kb->adrcode>=ob->shapenr)
                                kb->adrcode--;
-               }
                
 #if 0 // XXX old animation system
                if(key->ipo) {
@@ -451,12 +464,13 @@ void delete_key(Scene *scene, Object *ob)
                else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
                else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
 
-               free_libblock_us(&(G.main->key), key);
+               free_libblock_us(&(bmain->key), key);
        }
        
        DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
-       
-       BIF_undo_push("Delete Shapekey");
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+
+       return 1;
 }
 
 /********************** shape key operators *********************/
@@ -465,19 +479,11 @@ static int shape_key_add_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
-       Key *key;
 
        if(!ob)
                return OPERATOR_CANCELLED;
 
-       if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1);
-       else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1);
-       else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1);
-
-       key= ob_get_key(ob);
-       ob->shapenr= BLI_countlist(&key->block);
-
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+       ED_object_shape_key_add(C, scene, ob);
        
        return OPERATOR_FINISHED;
 }
@@ -499,67 +505,13 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
        Scene *scene= CTX_data_scene(C);
-       Main *bmain= CTX_data_main(C);
-       KeyBlock *kb, *rkb;
-       Key *key;
-       //IpoCurve *icu;
 
        if(!ob)
                return OPERATOR_CANCELLED;
        
-       key= ob_get_key(ob);
-       if(key==NULL)
+       if(!ED_object_shape_key_remove(C, scene, ob))
                return OPERATOR_CANCELLED;
        
-       kb= BLI_findlink(&key->block, ob->shapenr-1);
-
-       if(kb) {
-               for(rkb= key->block.first; rkb; rkb= rkb->next)
-                       if(rkb->relative == ob->shapenr-1)
-                               rkb->relative= 0;
-
-               BLI_remlink(&key->block, kb);
-               key->totkey--;
-               if(key->refkey== kb)
-                       key->refkey= key->block.first;
-                       
-               if(kb->data) MEM_freeN(kb->data);
-               MEM_freeN(kb);
-               
-               for(kb= key->block.first; kb; kb= kb->next)
-                       if(kb->adrcode>=ob->shapenr)
-                               kb->adrcode--;
-               
-#if 0 // XXX old animation system
-               if(key->ipo) {
-                       
-                       for(icu= key->ipo->curve.first; icu; icu= icu->next) {
-                               if(icu->adrcode==ob->shapenr-1) {
-                                       BLI_remlink(&key->ipo->curve, icu);
-                                       free_ipo_curve(icu);
-                                       break;
-                               }
-                       }
-                       for(icu= key->ipo->curve.first; icu; icu= icu->next) 
-                               if(icu->adrcode>=ob->shapenr)
-                                       icu->adrcode--;
-               }
-#endif // XXX old animation system             
-               
-               if(ob->shapenr>1) ob->shapenr--;
-       }
-       
-       if(key->totkey==0) {
-               if(GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL;
-               else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
-               else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
-
-               free_libblock_us(&(bmain->key), key);
-       }
-       
-       DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-       
        return OPERATOR_FINISHED;
 }
 
index 523f38dd43246c0ae5a1f98d5920cb1932ffa182..3e30efd635aa063fc3cc1f3713f20a9034331fde 100644 (file)
@@ -52,6 +52,7 @@
 #include "BKE_utildefines.h"
 
 #include "ED_object.h"
+#include "ED_screen.h"
 #include "ED_view3d.h"
 #include "ED_util.h"
 
 
 #include "object_intern.h"
 
-/* ***************************** */
-
-static int okee() {return 0;}
+/********************** Load/Make/Free ********************/
 
 void free_editLatt(Object *ob)
 {
        Lattice *lt= ob->data;
        
        if(lt->editlatt) {
-               if(lt->editlatt->def) MEM_freeN(lt->editlatt->def);
+               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);
                
@@ -78,27 +78,6 @@ void free_editLatt(Object *ob)
        }
 }
 
-
-static void setflagsLatt(Object *obedit, int flag)
-{
-       Lattice *lt= obedit->data;
-       BPoint *bp;
-       int a;
-       
-       bp= lt->editlatt->def;
-       
-       a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-       
-       while(a--) {
-               if(bp->hide==0) {
-                       bp->f1= flag;
-               }
-               bp++;
-       }
-}
-
-
-
 void make_editLatt(Object *obedit)
 {
        Lattice *lt= obedit->data;
@@ -108,10 +87,9 @@ void make_editLatt(Object *obedit)
        
        lt= obedit->data;
 
-       actkey = ob_get_keyblock(obedit);
-       if(actkey) {
+       actkey= ob_get_keyblock(obedit);
+       if(actkey)
                key_to_latt(actkey, lt);
-       }
 
        lt->editlatt= MEM_dupallocN(lt);
        lt->editlatt->def= MEM_dupallocN(lt->def);
@@ -121,11 +99,8 @@ void make_editLatt(Object *obedit)
                lt->editlatt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
                copy_dverts(lt->editlatt->dvert, lt->dvert, tot);
        }
-       
-       //BIF_undo_push("Original");
 }
 
-
 void load_editLatt(Object *obedit)
 {
        Lattice *lt;
@@ -136,7 +111,8 @@ void load_editLatt(Object *obedit)
        
        lt= obedit->data;
        
-       actkey = ob_get_keyblock(obedit);
+       actkey= ob_get_keyblock(obedit);
+
        if(actkey) {
                /* active key: vertices */
                tot= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
@@ -154,7 +130,6 @@ void load_editLatt(Object *obedit)
                }
        }
        else {
-
                MEM_freeN(lt->def);
        
                lt->def= MEM_dupallocN(lt->editlatt->def);
@@ -181,55 +156,135 @@ void load_editLatt(Object *obedit)
                lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
                copy_dverts(lt->dvert, lt->editlatt->dvert, tot);
        }
-       
 }
 
-void remake_editLatt(Object *obedit)
+/************************** Operators *************************/
+
+static void setflagsLatt(Object *obedit, int flag)
 {
-       if(okee("Reload original data")==0) return;
+       Lattice *lt= obedit->data;
+       BPoint *bp;
+       int a;
        
-       make_editLatt(obedit);
-
-       //BIF_undo_push("Reload original");
+       bp= lt->editlatt->def;
+       
+       a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
+       
+       while(a--) {
+               if(bp->hide==0) {
+                       bp->f1= flag;
+               }
+               bp++;
+       }
 }
 
-
-void deselectall_Latt(Object *obedit)
+int de_select_all_exec(bContext *C, wmOperator *op)
 {
+       Object *obedit= CTX_data_edit_object(C);
        Lattice *lt= obedit->data;
        BPoint *bp;
-       int a;
+       int a, deselect= 0;
        
        bp= lt->editlatt->def;
-       
        a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
        
        while(a--) {
                if(bp->hide==0) {
                        if(bp->f1) {
-                               setflagsLatt(obedit, 0);
-                               //BIF_undo_push("(De)select all");
-                               return;
+                               deselect= 1;
+                               break;
                        }
                }
                bp++;
        }
-       setflagsLatt(obedit, 1);
-       //BIF_undo_push("(De)select all");
+
+       if(deselect)
+               setflagsLatt(obedit, 0);
+       else
+               setflagsLatt(obedit, 1);
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       return OPERATOR_FINISHED;
 }
 
+void LATTICE_OT_select_all_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select or Deselect All";
+       ot->idname= "LATTICE_OT_select_all_toggle";
+       
+       /* api callbacks */
+       ot->exec= de_select_all_exec;
+       ot->poll= ED_operator_editlattice;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+int make_regular_poll(bContext *C)
+{
+       Object *ob;
+
+       if(ED_operator_editlattice(C)) return 1;
+
+       ob= CTX_data_active_object(C);
+       return (ob && ob->type==OB_LATTICE);
+}
+
+int make_regular_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_edit_object(C);
+       Lattice *lt;
+       
+       if(ob) {
+               lt= ob->data;
+               resizelattice(lt->editlatt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+       }
+       else {
+               ob= CTX_data_active_object(C);
+               lt= ob->data;
+               resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+       }
+       
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void LATTICE_OT_make_regular(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Make Regular";
+       ot->idname= "LATTICE_OT_make_regular";
+       
+       /* api callbacks */
+       ot->exec= make_regular_exec;
+       ot->poll= make_regular_poll;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/****************************** Mouse Selection *************************/
+
 static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y)
 {
        struct { BPoint *bp; short dist, select, mval[2]; } *data = userData;
        float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y);
        
-       if ((bp->f1 & SELECT)==data->select) temp += 5;
-       if (temp<data->dist) {
+       if((bp->f1 & SELECT)==data->select)
+               temp += 5;
+
+       if(temp<data->dist) {
                data->dist = temp;
 
                data->bp = bp;
        }
 }
+
 static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel)
 {
                /* sel==1: selected gets a disadvantage */
@@ -247,34 +302,27 @@ static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel)
        return data.bp;
 }
 
-
 void mouse_lattice(bContext *C, short mval[2], int extend)
 {
        ViewContext vc;
-       BPoint *bp=0;
+       BPoint *bp= NULL;
 
        view3d_set_viewcontext(C, &vc);
-       
        bp= findnearestLattvert(&vc, mval, 1);
 
        if(bp) {
                if(extend==0) {
-               
                        setflagsLatt(vc.obedit, 0);
                        bp->f1 |= SELECT;
-
                }
-               else {
+               else
                        bp->f1 ^= SELECT; /* swap */
-               }
 
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit);
-               //BIF_undo_push("Select");
        }
 }
 
-
-/* **************** undo for lattice object ************** */
+/******************************** Undo *************************/
 
 typedef struct UndoLattice {
        BPoint *def;
@@ -324,20 +372,18 @@ static int validate_undoLatt(void *data, void *edata)
 static void *get_editlatt(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);
+
        if(obedit && obedit->type==OB_LATTICE) {
                Lattice *lt= obedit->data;
                return lt->editlatt;
        }
+
        return NULL;
 }
 
-
 /* and this is all the undo system needs to know */
 void undo_push_lattice(bContext *C, char *name)
 {
        undo_editmode_push(C, name, get_editlatt, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt, validate_undoLatt);
 }
 
-
-
-/***/
index c436ccdb328473c6a1f328d9b6ca80dd0b2b220d..c28200612ead37086cbaa6ded24700b6784bb434 100644 (file)
@@ -3208,7 +3208,11 @@ void ED_object_exit_editmode(bContext *C, int flag)
                }
                load_editMesh(scene, obedit);
                
-               if(freedata) free_editMesh(me->edit_mesh);
+               if(freedata) {
+                       free_editMesh(me->edit_mesh);
+                       MEM_freeN(me->edit_mesh);
+                       me->edit_mesh= NULL;
+               }
                
                if(G.f & G_WEIGHTPAINT)
                        mesh_octree_table(obedit, NULL, NULL, 'e');
index 6ec5f029148ce0437c319121deba03654dec30d7..f7bdf5da92401007cbcd168311a739b3f8bccc93 100644 (file)
@@ -78,6 +78,9 @@ void make_editLatt(Object *obedit);
 void load_editLatt(Object *obedit);
 void remake_editLatt(Object *obedit);
 
+void LATTICE_OT_select_all_toggle(struct wmOperatorType *ot);
+void LATTICE_OT_make_regular(struct wmOperatorType *ot);
+
 /* editgroup.c */
 void GROUP_OT_group_create(struct wmOperatorType *ot);
 void GROUP_OT_objects_remove(struct wmOperatorType *ot);
index bda3e4e8f79573f8e8d3860a23bc04d35b56e34b..a2ea02c24a4a866645bb4be3793406acef7cd6eb 100644 (file)
@@ -763,9 +763,7 @@ static uiBlock *modifiers_add_menu(void *ob_v)
                ModifierTypeInfo *mti = modifierType_getInfo(i);
 
                /* Only allow adding through appropriate other interfaces */
-               if(ELEM3(i, eModifierType_Softbody, eModifierType_Hook, eModifierType_ParticleSystem)) continue;
-               
-               if(ELEM4(i, eModifierType_Cloth, eModifierType_Collision, eModifierType_Surface, eModifierType_Fluidsim)) continue;
+               if(ELEM(i, eModifierType_ParticleSystem, eModifierType_Surface)) continue;
 
                if((mti->flags&eModifierTypeFlag_AcceptsCVs) ||
                   (ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) {
index 6248d826ad47a22f27e78e8ad215be3b8db0e7e4..37e9a2e75ffa0079922525f979c30dfe6af9f80f 100644 (file)
@@ -122,6 +122,9 @@ void ED_operatortypes_object(void)
 
        WM_operatortype_append(OBJECT_OT_shape_key_add);
        WM_operatortype_append(OBJECT_OT_shape_key_remove);
+
+       WM_operatortype_append(LATTICE_OT_select_all_toggle);
+       WM_operatortype_append(LATTICE_OT_make_regular);
 }
 
 void ED_keymap_object(wmWindowManager *wm)
@@ -168,5 +171,9 @@ void ED_keymap_object(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
 
+       /* Lattice */
+       keymap= WM_keymap_listbase(wm, "Lattice", 0, 0);
+
+       WM_keymap_add_item(keymap, "LATTICE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
 }
 
index dcfdfbf8285c0febdbf7816d1954dee80e4b7f14..631ab3cf8cb865cf0e2b67689333c48e7a4fe80e 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "DNA_armature_types.h"
 #include "DNA_image_types.h"
+#include "DNA_lattice_types.h"
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_curve_types.h"
@@ -287,6 +288,14 @@ int ED_operator_editfont(bContext *C)
        return 0;
 }
 
+int ED_operator_editlattice(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && obedit->type==OB_LATTICE)
+               return NULL != ((Lattice *)obedit->data)->editlatt;
+       return 0;
+}
+
 /* *************************** action zone operator ************************** */
 
 /* operator state vars used:  
index 1ea69d595d39406867c5452cdccbe92b1b771fdf..c93926c908e5a7604f0eb6cc87749b7b640ca241 100644 (file)
@@ -304,6 +304,12 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
        else
                WM_event_remove_keymap_handler(&ar->handlers, keymap);
 
+       keymap= WM_keymap_listbase(wm, "Lattice", 0, 0);
+       if(stype==NS_EDITMODE_LATTICE)
+               WM_event_add_keymap_handler(&ar->handlers, keymap);
+       else
+               WM_event_remove_keymap_handler(&ar->handlers, keymap);
+
        /* armature sketching needs to take over mouse */
        keymap= WM_keymap_listbase(wm, "Armature_Sketch", 0, 0);
        if(stype==NS_EDITMODE_TEXT)
@@ -323,7 +329,6 @@ static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
                WM_event_add_keymap_handler_priority(&ar->handlers, keymap, 10);
        else
                WM_event_remove_keymap_handler(&ar->handlers, keymap);
-       
 }
 
 /* add handlers, stuff you only do once or on area/region changes */
index 5edcd203e166452a590baf1e9cf5063a2d6ec094..6a44b0d4476a82bf768e680531b3cac7f5639c42 100644 (file)
@@ -1302,46 +1302,11 @@ static uiBlock *view3d_select_metaballmenu(bContext *C, ARegion *ar, void *arg_u
        return block;
 }
 
-static void do_view3d_select_latticemenu(bContext *C, void *arg, int event)
+static void view3d_select_latticemenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-#if 0
-/*     extern void borderselect(void);*/
-       
-       switch(event) {
-                       case 0: /* border select */
-                       borderselect();
-                       break;
-               case 2: /* Select/Deselect all */
-                       deselectall_Latt();
-                       break;
-       }
-#endif
-}
-
-static uiBlock *view3d_select_latticemenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, ar, "view3d_select_latticemenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_view3d_select_latticemenu, NULL);
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B",                                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
-       
-       uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
-
-       if(ar->alignment==RGN_ALIGN_TOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-
-       uiTextBoundsBlock(block, 50);
-       return block;
+       uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
+       uiItemS(layout);
+       uiItemO(layout, NULL, 0, "LATTICE_OT_select_all_toggle");
 }
 
 static void do_view3d_select_armaturemenu(bContext *C, void *arg, int event)
@@ -3327,10 +3292,11 @@ static void view3d_edit_curve_showhidemenu(bContext *C, uiLayout *layout, void *
 
 static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       PointerRNA sceneptr;
        Scene *scene= CTX_data_scene(C);
-
-       RNA_id_pointer_create(&scene->id, &sceneptr);
+       ToolSettings *ts= CTX_data_tool_settings(C);
+       PointerRNA tsptr;
+       
+       RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr);
 
 #if 0
        uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Transform Properties...|N",          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
@@ -3361,8 +3327,8 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse
 
        uiItemS(layout);
 
-       uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0, 0, 0); // |O
-       uiItemMenuEnumR(layout, NULL, 0, &sceneptr, "proportional_editing_falloff");
+       uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O
+       uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff");
 
        uiItemS(layout);
 
@@ -3516,47 +3482,15 @@ static void view3d_edit_textmenu(bContext *C, uiLayout *layout, void *arg_unused
        uiItemMenuF(layout, "Special Characters", 0, view3d_edit_text_charsmenu);
 }
 
-static void do_view3d_edit_latticemenu(bContext *C, void *arg, int event)
+static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-#if 0
        Scene *scene= CTX_data_scene(C);
-
-       switch(event) {
-                                                                       
-       case 0: /* Undo Editing */
-               remake_editLatt();
-               break;
-       case 2: /* insert keyframe */
-               common_insertkey();
-               break;
-       case 3: /* Shear */
-               initTransform(TFM_SHEAR, CTX_NONE);
-               Transform();
-               break;
-       case 4: /* Warp */
-               initTransform(TFM_WARP, CTX_NONE);
-               Transform();
-               break;
-       case 5: /* proportional edit (toggle) */
-               if(ts->proportional) ts->proportional= 0;
-               else ts->proportional= 1;
-               break;
-       case 7: /* delete keyframe */
-               common_deletekey();
-               break;
-       }
-#endif
-}
-
-static uiBlock *view3d_edit_latticemenu(bContext *C, ARegion *ar, void *arg_unused)
-{
        ToolSettings *ts= CTX_data_tool_settings(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-               
-       block= uiBeginBlock(C, ar, "view3d_edit_latticemenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_view3d_edit_latticemenu, NULL);
+       PointerRNA tsptr;
        
+       RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &tsptr);
+
+#if 0
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo Editing|U",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
        
        uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
@@ -3564,35 +3498,19 @@ static uiBlock *view3d_edit_latticemenu(bContext *C, ARegion *ar, void *arg_unus
        uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
        uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");              
        uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, "");
+#endif
+
+       // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I",                               0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
+       // common_insertkey();
+       // XXX uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I",                           0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
+       // common_deletekey();
        
-       uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Keyframe|Alt I",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
-       
-       uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UV Unwrap|U",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
-       
-       uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       if(ts->proportional) {
-               uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
-       } else {
-               uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
-       }
-       uiDefIconTextBlockBut(block, view3d_edit_propfalloffmenu, NULL, ICON_RIGHTARROW_THIN, "Proportional Falloff", 0, yco-=20, 120, 19, "");
+       uiItemO(layout, NULL, 0, "LATTICE_OT_make_regular");
 
-       if(ar->alignment==RGN_ALIGN_TOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemS(layout);
 
-       uiTextBoundsBlock(block, 50);
-       return block;
+       uiItemR(layout, NULL, 0, &tsptr, "proportional_editing", 0, 0, 0); // |O
+       uiItemMenuEnumR(layout, NULL, 0, &tsptr, "proportional_editing_falloff"); // |Shift O
 }
 
 void do_view3d_edit_armature_parentmenu(bContext *C, void *arg, int event)
@@ -5155,7 +5073,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
                } else if (ob && ob->type == OB_MBALL) {
                        uiDefPulldownBut(block, view3d_select_metaballmenu, NULL, "Select",     xco,yco, xmax-3, 24, "");
                } else if (ob && ob->type == OB_LATTICE) {
-                       uiDefPulldownBut(block, view3d_select_latticemenu, NULL, "Select", xco,yco, xmax-3, 20, "");
+                       uiDefMenuBut(block, view3d_select_latticemenu, NULL, "Select", xco, yco, xmax-3, 24, "");
                } else if (ob && ob->type == OB_ARMATURE) {
                        uiDefPulldownBut(block, view3d_select_armaturemenu, NULL, "Select",     xco,yco, xmax-3, 20, "");
                }
@@ -5199,7 +5117,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
                        xco+= xmax;
                } else if (ob && ob->type == OB_LATTICE) {
                        xmax= GetButStringLength("Lattice");
-                       uiDefPulldownBut(block, view3d_edit_latticemenu, NULL, "Lattice",       xco,yco, xmax-3, 20, "");
+                       uiDefMenuBut(block, view3d_edit_latticemenu, NULL, "Lattice", xco, yco, xmax-3, 20, "");
                        xco+= xmax;
                } else if (ob && ob->type == OB_ARMATURE) {
                        xmax= GetButStringLength("Armature");
index 71e424bbd6910e5e26273f28316a8c711794299b..0a7e989a93aaf278da665970d830bbcfe965f00e 100644 (file)
 
 #ifdef RNA_RUNTIME
 
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_depsgraph.h"
+#include "BKE_key.h"
+#include "BKE_main.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
 static Key *rna_ShapeKey_find_key(ID *id)
 {
        switch(GS(id->name)) {
@@ -62,6 +72,18 @@ static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, NULL, NULL);
 }
 
+static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
+{
+       Key *key= rna_ShapeKey_find_key(ptr->id.data);
+       KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
+       int a;
+
+       if(key)
+               for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
+                       if(kbrel == value.data)
+                               kb->relative= a;
+}
+
 static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)
 {
        float *vec= (float*)ptr->data;
@@ -220,6 +242,21 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter)
        return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter));
 }
 
+static void rna_Key_update_data(bContext *C, PointerRNA *ptr)
+{
+       Main *bmain= CTX_data_main(C);
+       Scene *scene= CTX_data_scene(C);
+       Key *key= ptr->id.data;
+       Object *ob;
+
+       for(ob=bmain->object.first; ob; ob= ob->id.next) {
+               if(ob_get_key(ob) == key) {
+                       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+               }
+       }
+}
+
 #else
 
 static void rna_def_keydata(BlenderRNA *brna)
@@ -234,6 +271,7 @@ static void rna_def_keydata(BlenderRNA *brna)
        RNA_def_property_array(prop, 3);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL);
        RNA_def_property_ui_text(prop, "Location", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        srna= RNA_def_struct(brna, "ShapeKeyCurvePoint", NULL);
        RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves.");
@@ -242,10 +280,12 @@ static void rna_def_keydata(BlenderRNA *brna)
        RNA_def_property_array(prop, 3);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL);
        RNA_def_property_ui_text(prop, "Location", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyCurvePoint_tilt_get", "rna_ShapeKeyCurvePoint_tilt_set", NULL);
        RNA_def_property_ui_text(prop, "Tilt", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        srna= RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL);
        RNA_def_struct_ui_text(srna, "Shape Key Bezier Point", "Point in a shape key for bezier curves.");
@@ -254,21 +294,25 @@ static void rna_def_keydata(BlenderRNA *brna)
        RNA_def_property_array(prop, 3);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", NULL);
        RNA_def_property_ui_text(prop, "Location", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "handle_1_co", PROP_FLOAT, PROP_VECTOR);
        RNA_def_property_array(prop, 3);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_1_co_get", "rna_ShapeKeyBezierPoint_handle_1_co_set", NULL);
        RNA_def_property_ui_text(prop, "Handle 1 Location", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "handle_2_co", PROP_FLOAT, PROP_VECTOR);
        RNA_def_property_array(prop, 3);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_2_co_get", "rna_ShapeKeyBezierPoint_handle_2_co_set", NULL);
        RNA_def_property_ui_text(prop, "Handle 2 Location", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        /* appears to be unused currently
        prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_tilt_get", "rna_ShapeKeyBezierPoint_tilt_set", NULL);
-       RNA_def_property_ui_text(prop, "Tilt", "");*/
+       RNA_def_property_ui_text(prop, "Tilt", "");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data"); */
 }
 
 static void rna_def_keyblock(BlenderRNA *brna)
@@ -296,30 +340,37 @@ static void rna_def_keyblock(BlenderRNA *brna)
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_float_sdna(prop, NULL, "pos");
        RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys.");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
        
        /* for now, this is editable directly, as users can set this even if they're not animating them (to test results) */
        prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "curval");
        RNA_def_property_ui_text(prop, "Value", "Value of shape key at the current frame.");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_keyblock_type_items);
        RNA_def_property_ui_text(prop, "Interpolation", "Interpolation type.");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "vgroup");
        RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape.");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_struct_type(prop, "ShapeKey");
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", "rna_ShapeKey_relative_key_set", NULL);
        RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key.");
-       RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL, NULL);
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE);
        RNA_def_property_ui_text(prop, "Mute", "Mute this shape key.");
+       RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "slidermin");
@@ -366,11 +417,13 @@ static void rna_def_key(BlenderRNA *brna)
        prop= RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE);
        RNA_def_property_ui_text(prop, "Relative", "Makes shape keys relative.");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
        prop= RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_int_sdna(prop, NULL, "slurph");
        RNA_def_property_range(prop, -500, 500);
        RNA_def_property_ui_text(prop, "Slurph", "Creates a delay in amount of frames in applying keypositions, first vertex goes first.");
+       RNA_def_property_update(prop, 0, "rna_Key_update_data");
 }
 
 void RNA_def_key(BlenderRNA *brna)
index f67267ce0d0bcda8d26600a47a3e018d41bfd359..c685e5b691292b2d950b62fb741c9c55f3f26138 100644 (file)
 
 #ifdef RNA_RUNTIME
 
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_depsgraph.h"
+#include "BKE_lattice.h"
+#include "BKE_main.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
 static void rna_LatticePoint_co_get(PointerRNA *ptr, float *values)
 {
        Lattice *lt= (Lattice*)ptr->id.data;
@@ -67,15 +77,96 @@ static void rna_LatticePoint_groups_begin(CollectionPropertyIterator *iter, Poin
 static void rna_Lattice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Lattice *lt= (Lattice*)ptr->data;
+       int tot= lt->pntsu*lt->pntsv*lt->pntsw;
 
-       if(lt->def) {
-               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, NULL);
+       else if(lt->def)
                rna_iterator_array_begin(iter, (void*)lt->def, sizeof(BPoint), tot, NULL);
-       }
        else
                rna_iterator_array_begin(iter, NULL, 0, 0, NULL);
 }
 
+static void rna_Lattice_update_data(bContext *C, PointerRNA *ptr)
+{
+       Main *bmain= CTX_data_main(C);
+       Scene *scene= CTX_data_scene(C);
+       Lattice *lt= ptr->id.data;
+       Object *ob;
+
+       for(ob=bmain->object.first; ob; ob= ob->id.next) {
+               if(ob->data == lt) {
+                       /* XXX this will loop over all objects again (slow) */
+                       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+               }
+       }
+}
+
+static void rna_Lattice_update_size(bContext *C, PointerRNA *ptr)
+{
+       Main *bmain= CTX_data_main(C);
+       Lattice *lt= ptr->id.data;
+       Object *ob;
+       int newu, newv, neww;
+
+       /* we don't modify the actual pnts, but go through opnts instead */
+       newu= (lt->opntsu > 0)? lt->opntsu: lt->pntsu;
+       newv= (lt->opntsv > 0)? lt->opntsv: lt->pntsv;
+       neww= (lt->opntsw > 0)? lt->opntsw: lt->pntsw;
+
+       /* resizelattice needs an object, any object will have the same result */
+       for(ob=bmain->object.first; ob; ob= ob->id.next) {
+               if(ob->data == lt) {
+                       resizelattice(lt, newu, newv, neww, ob);
+                       if(lt->editlatt)
+                               resizelattice(lt->editlatt, newu, newv, neww, ob);
+                       break;
+               }
+       }
+
+       /* otherwise without, means old points are not repositioned */
+       if(!ob) {
+               resizelattice(lt, newu, newv, neww, NULL);
+               if(lt->editlatt)
+                       resizelattice(lt->editlatt, newu, newv, neww, NULL);
+       }
+
+       rna_Lattice_update_data(C, ptr);
+}
+
+static void rna_Lattice_outside_set(PointerRNA *ptr, int value)
+{
+       Lattice *lt= ptr->data;
+
+       if(value) lt->flag |= LT_OUTSIDE;
+       else lt->flag &= ~LT_OUTSIDE;
+
+       outside_lattice(lt);
+
+       if(lt->editlatt) {
+               if(value) lt->editlatt->flag |= LT_OUTSIDE;
+               else lt->editlatt->flag &= ~LT_OUTSIDE;
+
+               outside_lattice(lt->editlatt);
+       }
+}
+
+static void rna_Lattice_points_u_set(PointerRNA *ptr, int value)
+{
+       ((Lattice*)ptr->data)->opntsu= CLAMPIS(value, 1, 64);
+}
+
+static void rna_Lattice_points_v_set(PointerRNA *ptr, int value)
+{
+       ((Lattice*)ptr->data)->opntsv= CLAMPIS(value, 1, 64);
+}
+
+static void rna_Lattice_points_w_set(PointerRNA *ptr, int value)
+{
+       ((Lattice*)ptr->data)->opntsw= CLAMPIS(value, 1, 64);
+}
+
 #else
 
 static void rna_def_latticepoint(BlenderRNA *brna)
@@ -97,6 +188,7 @@ static void rna_def_latticepoint(BlenderRNA *brna)
        RNA_def_property_float_sdna(prop, NULL, "vec");
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Deformed Location", "");
+       RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
 
        prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0);
@@ -121,37 +213,48 @@ static void rna_def_lattice(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "points_u", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "pntsu");
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       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_update(prop, 0, "rna_Lattice_update_size");
 
        prop= RNA_def_property(srna, "points_v", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "pntsv");
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       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_update(prop, 0, "rna_Lattice_update_size");
 
        prop= RNA_def_property(srna, "points_w", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "pntsw");
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       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_update(prop, 0, "rna_Lattice_update_size");
 
        prop= RNA_def_property(srna, "interpolation_type_u", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "typeu");
        RNA_def_property_enum_items(prop, prop_keyblock_type_items);
        RNA_def_property_ui_text(prop, "Interpolation Type U", "");
+       RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
 
        prop= RNA_def_property(srna, "interpolation_type_v", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "typev");
        RNA_def_property_enum_items(prop, prop_keyblock_type_items);
        RNA_def_property_ui_text(prop, "Interpolation Type V", "");
+       RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
 
        prop= RNA_def_property(srna, "interpolation_type_w", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "typew");
        RNA_def_property_enum_items(prop, prop_keyblock_type_items);
        RNA_def_property_ui_text(prop, "Interpolation Type W", "");
+       RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
 
        prop= RNA_def_property(srna, "outside", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", LT_OUTSIDE);
+       RNA_def_property_boolean_funcs(prop, NULL, "rna_Lattice_outside_set");
        RNA_def_property_ui_text(prop, "Outside", "Only draw, and take into account, the outer vertices.");
+       RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
 
        prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "key");
index bf2a2c0ba404b83d3e67ceecee0e0d0d8cd29d19..f814980f3678e0896f2f480a3cf9065a032e715d 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_types.h"
 
@@ -447,6 +448,21 @@ static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
        ob->shapeflag |= OB_SHAPE_TEMPLOCK;
 }
 
+static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
+{
+       Object *ob= (Object*)ptr->id.data;
+       Key *key= ob_get_key(ob);
+       KeyBlock *kb;
+       PointerRNA keyptr;
+
+       if(key==NULL)
+               return PointerRNA_NULL;
+       
+       kb= BLI_findlink(&key->block, ob->shapenr-1);
+       RNA_pointer_create(&key->id, &RNA_ShapeKey, kb, &keyptr);
+       return keyptr;
+}
+
 static void rna_Object_shape_key_lock_set(PointerRNA *ptr, int value)
 {
        Object *ob= (Object*)ptr->id.data;
@@ -1277,8 +1293,14 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
        RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_shape_key_lock_set");
        RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object.");
+       RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
        RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
 
+       prop= RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
+       RNA_def_property_struct_type(prop, "ShapeKey");
+       RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key.");
+
        prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "shapenr");
        RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range");