svn merge -r39384:39433 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / editors / object / object_edit.c
index 61734bc51a2ae23f47c23e317b83ebe7a4c9695e..7f1355af801a408f42724ac20f3d8510b80c3b44 100644 (file)
@@ -81,6 +81,7 @@
 #include "BKE_sca.h"
 #include "BKE_softbody.h"
 #include "BKE_modifier.h"
+#include "BKE_tessmesh.h"
 
 #include "ED_armature.h"
 #include "ED_curve.h"
@@ -321,22 +322,24 @@ void ED_object_exit_editmode(bContext *C, int flag)
 //             if(retopo_mesh_paint_check())
 //                     retopo_end_okee();
                
-               if(me->edit_mesh->totvert>MESH_MAX_VERTS) {
+               if(me->edit_btmesh->bm->totvert>MESH_MAX_VERTS) {
                        error("Too many vertices");
                        return;
                }
-               load_editMesh(scene, obedit);
+               
+               EDBM_LoadEditBMesh(scene, obedit);
                
                if(freedata) {
-                       free_editMesh(me->edit_mesh);
-                       MEM_freeN(me->edit_mesh);
-                       me->edit_mesh= NULL;
+                       EDBM_FreeEditBMesh(me->edit_btmesh);
+                       MEM_freeN(me->edit_btmesh);
+                       me->edit_btmesh= NULL;
                }
-               
+#if 0 //BMESH_TODO             
                if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT) {
                        mesh_octree_table(NULL, NULL, NULL, 'e');
                        mesh_mirrtopo_table(NULL, 'e');
                }
+#endif
        }
        else if (obedit->type==OB_ARMATURE) {   
                ED_armature_from_edit(obedit);
@@ -376,7 +379,7 @@ void ED_object_exit_editmode(bContext *C, int flag)
                }
                BLI_freelistN(&pidlist);
                
-               BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED);
+               BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_DEPSGRAPH);
 
                /* also flush ob recalc, doesn't take much overhead, but used for particles */
                DAG_id_tag_update(&obedit->id, OB_RECALC_OB|OB_RECALC_DATA);
@@ -445,7 +448,7 @@ void ED_object_enter_editmode(bContext *C, int flag)
                ok= 1;
                scene->obedit= ob;      // context sees this
                
-               make_editMesh(scene, ob);
+               EDBM_MakeEditBMesh(CTX_data_tool_settings(C), scene, ob);
 
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, scene);
        }
@@ -1828,11 +1831,16 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o
 {
        ObjectMode mode = RNA_enum_get(op->ptr, "mode");
 
-       if(ob) {
-               if(mode == OB_MODE_OBJECT)
-                       return 1;
+       if(mode == OB_MODE_OBJECT)
+               return 1;
 
+       if(ob) {
                switch(ob->type) {
+               case OB_EMPTY:
+               case OB_LAMP:
+               case OB_CAMERA:
+                       return 0;
+
                case OB_MESH:
                        if(mode & (OB_MODE_EDIT|OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))
                                return 1;
@@ -1841,14 +1849,14 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o
                case OB_SURF:
                case OB_FONT:
                case OB_MBALL:
-                       if(mode & (OB_MODE_EDIT))
+                       if(mode & (OB_MODE_OBJECT|OB_MODE_EDIT))
                                return 1;
                        return 0;
                case OB_LATTICE:
-                       if(mode & (OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT))
+                       if(mode & (OB_MODE_OBJECT|OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT))
                                return 1;
                case OB_ARMATURE:
-                       if(mode & (OB_MODE_EDIT|OB_MODE_POSE))
+                       if(mode & (OB_MODE_OBJECT|OB_MODE_EDIT|OB_MODE_POSE))
                                return 1;
                }
        }
@@ -1864,7 +1872,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
        int toggle = RNA_boolean_get(op->ptr, "toggle");
 
        if(!ob || !object_mode_set_compat(C, op, ob))
-               return OPERATOR_PASS_THROUGH;
+               return OPERATOR_CANCELLED;
 
        /* Exit current mode if it's not the mode we're setting */
        if(ob->mode != OB_MODE_OBJECT && ob->mode != mode)
@@ -1905,7 +1913,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
        /* flags */
        ot->flag= 0; /* no register/undo here, leave it to operators being called */
        
-       prop= RNA_def_enum(ot->srna, "mode", object_mode_items, OB_MODE_OBJECT, "Mode", "");
+       prop= RNA_def_enum(ot->srna, "mode", object_mode_items, 0, "Mode", "");
        RNA_def_enum_funcs(prop, object_mode_set_itemsf);
 
        RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "");