Object Mode: remove Scene.obedit
authorCampbell Barton <ideasman42@gmail.com>
Tue, 13 Feb 2018 21:39:10 +0000 (08:39 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 13 Feb 2018 21:49:20 +0000 (08:49 +1100)
This means we can support having the same scene in different windows
with different edit-objects.

source/blender/blenkernel/intern/library_query.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
source/blender/editors/object/object_edit.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_layer.c

index 0f83dfe7ecfc9989e5679eb89148fa191e071620..419ed8246db75ec35fa003cd73044fe8de45a079 100644 (file)
@@ -421,10 +421,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
                                        /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
                                        library_foreach_ID_as_subdata_link((ID **)&scene->nodetree, callback, user_data, flag, &data);
                                }
                                        /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
                                        library_foreach_ID_as_subdata_link((ID **)&scene->nodetree, callback, user_data, flag, &data);
                                }
-                               /* DO NOT handle scene->basact here, it's doubling with the loop over whole scene->base later,
-                                * since basact is just a pointer to one of those items. */
-                               CALLBACK_INVOKE(scene->obedit, IDWALK_CB_NOP);
-
                                if (scene->ed) {
                                        Sequence *seq;
                                        SEQP_BEGIN(scene->ed, seq)
                                if (scene->ed) {
                                        Sequence *seq;
                                        SEQP_BEGIN(scene->ed, seq)
index 074d7b9c90dd286bd5e35cf5b79ffff4a5ecb0bf..932f80c35d523c1858461cb32693626fb24f589f 100644 (file)
@@ -166,7 +166,6 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
 
        sce_dst->ed = NULL;
        sce_dst->depsgraph_hash = NULL;
 
        sce_dst->ed = NULL;
        sce_dst->depsgraph_hash = NULL;
-       sce_dst->obedit = NULL;
        sce_dst->fps_info = NULL;
 
        /* layers and collections */
        sce_dst->fps_info = NULL;
 
        /* layers and collections */
@@ -982,9 +981,6 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
        /* check for cyclic sets, for reading old files but also for definite security (py?) */
        BKE_scene_validate_setscene(bmain, scene);
        
        /* check for cyclic sets, for reading old files but also for definite security (py?) */
        BKE_scene_validate_setscene(bmain, scene);
        
-       /* can happen when switching modes in other scenes */
-       scene->obedit = NULL;
-
        /* deselect objects (for dataselect) */
        for (ob = bmain->object.first; ob; ob = ob->id.next)
                ob->flag &= ~(SELECT | OB_FROMGROUP);
        /* deselect objects (for dataselect) */
        for (ob = bmain->object.first; ob; ob = ob->id.next)
                ob->flag &= ~(SELECT | OB_FROMGROUP);
index a91aeee52dfbb35b5b31b0ca76fb50fe12d5820b..a5370313a93558264efcd47cf2487731980de7ea 100644 (file)
@@ -6216,7 +6216,6 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain)
        SceneRenderLayer *srl;
        
        sce->depsgraph_hash = NULL;
        SceneRenderLayer *srl;
        
        sce->depsgraph_hash = NULL;
-       sce->obedit = NULL;
        sce->fps_info = NULL;
        sce->customdata_mask_modal = 0;
        sce->lay_updated = 0;
        sce->fps_info = NULL;
        sce->customdata_mask_modal = 0;
        sce->lay_updated = 0;
index 5daf462970854c7582f41d45bc1eb2e3994e134b..8bdc68d935191bbc78388eb9342a0996aebc3a68 100644 (file)
@@ -461,18 +461,6 @@ void update_special_pointers(const Depsgraph *depsgraph,
                        }
                        break;
                }
                        }
                        break;
                }
-               case ID_SCE:
-               {
-                       const Scene *scene_orig = (const Scene *)id_orig;
-                       Scene *scene_cow = (Scene *)id_cow;
-                       if (scene_orig->obedit != NULL) {
-                               scene_cow->obedit = (Object *)depsgraph->get_cow_id(&scene_orig->obedit->id);
-                       }
-                       else {
-                               scene_cow->obedit = NULL;
-                       }
-                       break;
-               }
                default:
                        break;
        }
                default:
                        break;
        }
@@ -622,13 +610,6 @@ void update_copy_on_write_scene(const Depsgraph *depsgraph,
        update_copy_on_write_view_layers(depsgraph, scene_cow, scene_orig);
        update_copy_on_write_scene_collection(scene_cow->collection,
                                              scene_orig->collection);
        update_copy_on_write_view_layers(depsgraph, scene_cow, scene_orig);
        update_copy_on_write_scene_collection(scene_cow->collection,
                                              scene_orig->collection);
-       // Update edit object pointer.
-       if (scene_orig->obedit != NULL) {
-               scene_cow->obedit = (Object *)depsgraph->get_cow_id(&scene_orig->obedit->id);
-       }
-       else {
-               scene_cow->obedit = NULL;
-       }
        /* Synchronize active render engine. */
        BLI_strncpy(scene_cow->view_render.engine_id,
                    scene_orig->view_render.engine_id,
        /* Synchronize active render engine. */
        BLI_strncpy(scene_cow->view_render.engine_id,
                    scene_orig->view_render.engine_id,
index 03c497bcef08f4f389056795ca4239598d664f56..c6f9ced51a317a2830a35dfdab9c648e58019a0a 100644 (file)
@@ -286,9 +286,6 @@ void ED_object_editmode_exit_ex(bContext *C, WorkSpace *workspace, Scene *scene,
                ListBase pidlist;
                PTCacheID *pid;
 
                ListBase pidlist;
                PTCacheID *pid;
 
-               /* for example; displist make is different in editmode */
-               scene->obedit = NULL; // XXX for context
-
                /* flag object caches as outdated */
                BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0);
                for (pid = pidlist.first; pid; pid = pid->next) {
                /* flag object caches as outdated */
                BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0);
                for (pid = pidlist.first; pid; pid = pid->next) {
@@ -373,8 +370,6 @@ void ED_object_editmode_enter(bContext *C, int flag)
        if (ob->type == OB_MESH) {
                BMEditMesh *em;
                ok = 1;
        if (ob->type == OB_MESH) {
                BMEditMesh *em;
                ok = 1;
-               scene->obedit = ob;  /* context sees this */
-
                const bool use_key_index = mesh_needs_keyindex(ob->data);
 
                EDBM_mesh_make(scene->toolsettings, ob, use_key_index);
                const bool use_key_index = mesh_needs_keyindex(ob->data);
 
                EDBM_mesh_make(scene->toolsettings, ob, use_key_index);
@@ -404,7 +399,6 @@ void ED_object_editmode_enter(bContext *C, int flag)
                        return;
                }
                ok = 1;
                        return;
                }
                ok = 1;
-               scene->obedit = ob;
                ED_armature_to_edit(arm);
                /* to ensure all goes in restposition and without striding */
                DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */
                ED_armature_to_edit(arm);
                /* to ensure all goes in restposition and without striding */
                DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */
@@ -412,21 +406,18 @@ void ED_object_editmode_enter(bContext *C, int flag)
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
        }
        else if (ob->type == OB_FONT) {
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
        }
        else if (ob->type == OB_FONT) {
-               scene->obedit = ob; /* XXX for context */
                ok = 1;
                ED_curve_editfont_make(ob);
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
        }
        else if (ob->type == OB_MBALL) {
                ok = 1;
                ED_curve_editfont_make(ob);
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
        }
        else if (ob->type == OB_MBALL) {
-               scene->obedit = ob; /* XXX for context */
                ok = 1;
                ED_mball_editmball_make(ob);
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene);
        }
        else if (ob->type == OB_LATTICE) {
                ok = 1;
                ED_mball_editmball_make(ob);
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene);
        }
        else if (ob->type == OB_LATTICE) {
-               scene->obedit = ob; /* XXX for context */
                ok = 1;
                ED_lattice_editlatt_make(ob);
 
                ok = 1;
                ED_lattice_editlatt_make(ob);
 
@@ -434,7 +425,6 @@ void ED_object_editmode_enter(bContext *C, int flag)
        }
        else if (ob->type == OB_SURF || ob->type == OB_CURVE) {
                ok = 1;
        }
        else if (ob->type == OB_SURF || ob->type == OB_CURVE) {
                ok = 1;
-               scene->obedit = ob; /* XXX for context */
                ED_curve_editnurb_make(ob);
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene);
                ED_curve_editnurb_make(ob);
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene);
@@ -446,7 +436,6 @@ void ED_object_editmode_enter(bContext *C, int flag)
                DEG_id_tag_update(&scene->id, 0);
        }
        else {
                DEG_id_tag_update(&scene->id, 0);
        }
        else {
-               scene->obedit = NULL; /* XXX for context */
                workspace->object_mode &= ~OB_MODE_EDIT;
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
        }
                workspace->object_mode &= ~OB_MODE_EDIT;
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
        }
index bf5f7c1d0dacf206a6d9104b74e43751df93d6fb..1642da25481a88ae0765486c161f2c4c9645a926 100644 (file)
@@ -1623,7 +1623,7 @@ typedef struct Scene {
        
        ListBase base DNA_DEPRECATED;
        struct Base  *basact DNA_DEPRECATED; /* active base */
        
        ListBase base DNA_DEPRECATED;
        struct Base  *basact DNA_DEPRECATED; /* active base */
-       struct Object *obedit;          /* name replaces old G.obedit */
+       void *_pad1;
        
        float cursor[3];                        /* 3d cursor location */
        char _pad[4];
        
        float cursor[3];                        /* 3d cursor location */
        char _pad[4];
index efa05ed5b92b63dcb43ef51500356980d78b4d11..9489fa243dc4d51271657e67d8ca017ae81ac846 100644 (file)
@@ -73,6 +73,7 @@ const EnumPropertyItem rna_enum_collection_type_items[] = {
 #include "BKE_node.h"
 #include "BKE_scene.h"
 #include "BKE_mesh.h"
 #include "BKE_node.h"
 #include "BKE_scene.h"
 #include "BKE_mesh.h"
+#include "BKE_object.h"
 #include "BKE_workspace.h"
 
 #include "DEG_depsgraph_build.h"
 #include "BKE_workspace.h"
 
 #include "DEG_depsgraph_build.h"
@@ -845,11 +846,25 @@ static void rna_LayerObjects_active_object_update(struct bContext *C, PointerRNA
        if (scene != ptr->id.data) {
                return;
        }
        if (scene != ptr->id.data) {
                return;
        }
-
        ViewLayer *view_layer = (ViewLayer *)ptr->data;
        ViewLayer *view_layer = (ViewLayer *)ptr->data;
-       if (scene->obedit) {
-               ED_object_editmode_exit(C, EM_FREEDATA);
+
+       /* We don't know the previous active object in update.
+        *
+        * Not correct because it's possible other work-spaces use these.
+        * although that's a corner case. */
+       WorkSpace *workspace = CTX_wm_workspace(C);
+       if (workspace->object_mode & OB_MODE_EDIT) {
+               Object *obact = OBACT(view_layer);
+               FOREACH_OBJECT(view_layer, ob) {
+                       if (ob != obact) {
+                               if (BKE_object_is_in_editmode(ob)) {
+                                       ED_object_editmode_exit_ex(NULL, workspace, scene, ob, EM_FREEDATA);
+                               }
+                       }
+               }
+               FOREACH_OBJECT_END;
        }
        }
+
        ED_object_base_activate(C, view_layer->basact);
 }
 
        ED_object_base_activate(C, view_layer->basact);
 }