Commit: e77b4a30c05a95781deade1163b5c2f37643a920
Author: Campbell Barton
Date:   Tue Feb 13 17:23:07 2018 +1100
Branches: temp-scene-obedit-remove
https://developer.blender.org/rBe77b4a30c05a95781deade1163b5c2f37643a920

Initial removal of Scene.obedit

First pass, some issues remain

===================================================================

M       source/blender/blenkernel/BKE_workspace.h
M       source/blender/blenkernel/intern/library_query.c
M       source/blender/blenkernel/intern/object_dupli.c
M       source/blender/blenkernel/intern/object_update.c
M       source/blender/blenkernel/intern/scene.c
M       source/blender/blenkernel/intern/workspace.c
M       source/blender/blenloader/intern/readfile.c
M       source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M       source/blender/draw/engines/clay/clay_engine.c
M       source/blender/draw/engines/eevee/eevee_materials.c
M       source/blender/draw/intern/DRW_render.h
M       source/blender/draw/intern/draw_manager.c
M       source/blender/draw/modes/edit_curve_mode.c
M       source/blender/draw/modes/edit_lattice_mode.c
M       source/blender/draw/modes/edit_mesh_mode.c
M       source/blender/draw/modes/edit_metaball_mode.c
M       source/blender/draw/modes/edit_text_mode.c
M       source/blender/draw/modes/object_mode.c
M       source/blender/editors/animation/anim_channels_edit.c
M       source/blender/editors/armature/armature_edit.c
M       source/blender/editors/armature/armature_intern.h
M       source/blender/editors/armature/armature_select.c
M       source/blender/editors/armature/pose_select.c
M       source/blender/editors/curve/editcurve.c
M       source/blender/editors/curve/editcurve_paint.c
M       source/blender/editors/gpencil/gpencil_convert.c
M       source/blender/editors/include/ED_armature.h
M       source/blender/editors/include/ED_screen.h
M       source/blender/editors/include/ED_uvedit.h
M       source/blender/editors/mesh/editmesh_path.c
M       source/blender/editors/mesh/meshtools.c
M       source/blender/editors/object/object_add.c
M       source/blender/editors/object/object_edit.c
M       source/blender/editors/object/object_modifier.c
M       source/blender/editors/object/object_transform.c
M       source/blender/editors/render/render_internal.c
M       source/blender/editors/screen/screen_context.c
M       source/blender/editors/screen/screen_edit.c
M       source/blender/editors/sculpt_paint/paint_image.c
M       source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
M       source/blender/editors/sculpt_paint/sculpt_uv.c
M       source/blender/editors/space_image/image_ops.c
M       source/blender/editors/space_info/info_stats.c
M       source/blender/editors/space_outliner/outliner_draw.c
M       source/blender/editors/space_outliner/outliner_select.c
M       source/blender/editors/space_outliner/outliner_tools.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/editors/space_view3d/view3d_draw_legacy.c
M       source/blender/editors/space_view3d/view3d_header.c
M       source/blender/editors/space_view3d/view3d_intern.h
M       source/blender/editors/space_view3d/view3d_select.c
M       source/blender/editors/space_view3d/view3d_view.c
M       source/blender/editors/transform/transform_conversions.c
M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/transform/transform_manipulator2d.c
M       source/blender/editors/transform/transform_ops.c
M       source/blender/editors/transform/transform_snap_object.c
M       source/blender/editors/util/ed_util.c
M       source/blender/editors/uvedit/uvedit_buttons.c
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/editors/uvedit/uvedit_intern.h
M       source/blender/editors/uvedit/uvedit_ops.c
M       source/blender/editors/uvedit/uvedit_smart_stitch.c
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_layer.c
M       source/blender/makesrna/intern/rna_material.c
M       source/blender/makesrna/intern/rna_object.c
M       source/blender/makesrna/intern/rna_sculpt_paint.c
M       source/blender/makesrna/intern/rna_space.c
M       source/blender/makesrna/intern/rna_wm.c
M       source/blender/modifiers/intern/MOD_meshdeform.c
M       source/blender/modifiers/intern/MOD_surfacedeform.c
M       source/gameengine/Converter/BL_BlenderDataConversion.cpp

===================================================================

diff --git a/source/blender/blenkernel/BKE_workspace.h 
b/source/blender/blenkernel/BKE_workspace.h
index f839d4cdf76..6ed1369c155 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -33,6 +33,7 @@ struct Main;
 struct Scene;
 struct TransformOrientation;
 struct ViewLayer;
+struct wmWindow;
 
 /* -------------------------------------------------------------------- */
 /* Create, delete, init */
@@ -133,6 +134,9 @@ void BKE_workspace_update_object_mode(
         struct EvaluationContext *eval_ctx,
         struct WorkSpace *workspace);
 
+struct Object *BKE_workspace_edit_object(
+        struct WorkSpace *workspace, struct Scene *scene);
+
 #undef GETTER_ATTRS
 #undef SETTER_ATTRS
 
diff --git a/source/blender/blenkernel/intern/library_query.c 
b/source/blender/blenkernel/intern/library_query.c
index 0f83dfe7ecf..419ed8246db 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -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);
                                }
-                               /* 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)
diff --git a/source/blender/blenkernel/intern/object_dupli.c 
b/source/blender/blenkernel/intern/object_dupli.c
index f9f6b0aab40..2d82d5a1e0a 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -74,6 +74,7 @@ typedef struct DupliContext {
        bool do_update;
        bool animated;
        Group *group; /* XXX child objects are selected from this group if set, 
could be nicer */
+       Object *obedit; /* Only to check if the object is in edit-mode. */
 
        Scene *scene;
        ViewLayer *view_layer;
@@ -107,6 +108,7 @@ static void init_context(DupliContext *r_ctx, const 
EvaluationContext *eval_ctx,
        r_ctx->animated = false;
        r_ctx->group = NULL;
 
+       r_ctx->obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
        r_ctx->object = ob;
        if (space_mat)
                copy_m4_m4(r_ctx->space_mat, space_mat);
@@ -241,14 +243,13 @@ static bool is_child(const Object *ob, const Object 
*parent)
 static void make_child_duplis(const DupliContext *ctx, void *userdata, 
MakeChildDuplisFunc make_child_duplis_cb)
 {
        Object *parent = ctx->object;
-       Object *obedit = ctx->scene->obedit;
 
        if (ctx->group) {
                int groupid = 0;
                FOREACH_GROUP_BASE(ctx->group, base)
                {
                        Object *ob = base->object;
-                       if ((base->flag & BASE_VISIBLED) && ob != obedit && 
is_child(ob, parent)) {
+                       if ((base->flag & BASE_VISIBLED) && ob != ctx->obedit 
&& is_child(ob, parent)) {
                                DupliContext pctx;
                                copy_dupli_context(&pctx, ctx, ctx->object, 
NULL, groupid, false);
 
@@ -267,7 +268,7 @@ static void make_child_duplis(const DupliContext *ctx, void 
*userdata, MakeChild
                ViewLayer *view_layer = ctx->view_layer;
                for (Base *base = view_layer->object_bases.first; base; base = 
base->next, baseid++) {
                        Object *ob = base->object;
-                       if (ob != obedit && is_child(ob, parent)) {
+                       if (ob != ctx->obedit && is_child(ob, parent)) {
                                DupliContext pctx;
                                copy_dupli_context(&pctx, ctx, ctx->object, 
NULL, baseid, false);
 
diff --git a/source/blender/blenkernel/intern/object_update.c 
b/source/blender/blenkernel/intern/object_update.c
index bc183ba95a6..845afb8af3c 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -173,7 +173,7 @@ void BKE_object_handle_data_update(
        switch (ob->type) {
                case OB_MESH:
                {
-                       BMEditMesh *em = (ob == scene->obedit) ? 
BKE_editmesh_from_object(ob) : NULL;
+                       BMEditMesh *em = (eval_ctx->object_mode & OB_MODE_EDIT) 
? BKE_editmesh_from_object(ob) : NULL;
                        uint64_t data_mask = scene->customdata_mask | 
CD_MASK_BAREMESH;
 #ifdef WITH_FREESTYLE
                        /* make sure Freestyle edge/face marks appear in DM for 
render (see T40315) */
@@ -223,7 +223,7 @@ void BKE_object_handle_data_update(
        }
 
        /* particles */
-       if (ob != scene->obedit && ob->particlesystem.first) {
+       if (ob != OBEDIT_FROM_EVAL_CTX(eval_ctx) && ob->particlesystem.first) {
                ParticleSystem *tpsys, *psys;
                DerivedMesh *dm;
                ob->transflag &= ~OB_DUPLIPARTS;
diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index a4ccf3b9bba..932f80c35d5 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -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->obedit = NULL;
        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);
        
-       /* 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);
@@ -1380,7 +1376,7 @@ static bool check_rendered_viewport_visible(Main *bmain)
        return false;
 }
 
-static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene)
+static void prepare_mesh_for_viewport_render(Main *bmain, const 
EvaluationContext *eval_ctx)
 {
        /* This is needed to prepare mesh to be used by the render
         * engine from the viewport rendering. We do loading here
@@ -1391,7 +1387,7 @@ static void prepare_mesh_for_viewport_render(Main *bmain, 
Scene *scene)
         * call loading of the edit data for the mesh objects.
         */
 
-       Object *obedit = scene->obedit;
+       Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx);
        if (obedit) {
                Mesh *mesh = obedit->data;
                if ((obedit->type == OB_MESH) &&
@@ -1429,7 +1425,7 @@ void BKE_scene_graph_update_tagged(EvaluationContext 
*eval_ctx,
        /* Uncomment this to check if graph was properly tagged for update. */
        // DEG_debug_graph_relations_validate(depsgraph, bmain, scene);
        /* Flush editing data if needed. */
-       prepare_mesh_for_viewport_render(bmain, scene);
+       prepare_mesh_for_viewport_render(bmain, eval_ctx);
        /* Flush recalc flags to dependencies. */
        DEG_graph_flush_update(bmain, depsgraph);
        /* Update all objects: drivers, matrices, displists, etc. flags set
diff --git a/source/blender/blenkernel/intern/workspace.c 
b/source/blender/blenkernel/intern/workspace.c
index dcd4183210d..bc5731b9574 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -38,6 +38,7 @@
 #include "BKE_main.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h"
+#include "BKE_object.h"
 #include "BKE_workspace.h"
 
 #include "DNA_object_types.h"
@@ -517,4 +518,20 @@ void BKE_workspace_update_object_mode(
         * for now without this 'bmain->eval_ctx' is never set. */
 
        eval_ctx->object_mode = workspace->object_mode;
-}
\ No newline at end of file
+}
+
+Object *BKE_workspace_edit_object(WorkSpace *workspace, Scene *scene)
+{
+       if (workspace->object_mode & OB_MODE_EDIT) {
+               ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, 
scene);
+               if (view_layer) {
+                       Object *obedit = OBACT(view_layer);
+                       if (obedit) {
+                               BLI_assert(BKE_object_is_in_editmode(obedit));
+                               return obedit;
+                       }
+               }
+       }
+       return NULL;
+}
+
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index a91aeee52df..a5370313a93 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6216,7 +6216,6 @@ static void direct_link_scene(FileData *fd, Scene *sce, 
Main *bmain)
        SceneRenderLayer *srl;
        
        sce->depsgraph_hash = NULL;
-       sce->obedit = NULL;
        sce->fps_info = NULL;
        sce->customdata_mask_modal = 0;
        sce->lay_updated = 0;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc 
b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 5daf4629708..8bdc68d9351 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -461,18 +461,6 @@ void update_special_pointers(const Depsgraph *depsgraph,
                        }
                        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;
        }
@@ -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 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,
diff --git a/source/blender/draw/engines/clay/clay_engine.c 
b/source/blender/draw/engines/clay/clay_engine.c
index 50c6790f817..4b554f776a6 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -770,11 +770,7 @@ static void clay_cache_populate_particles(void *vedata, 
Object *ob)
        CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
        const DRWContextState *draw_ctx = DRW_context_state_get();
 
-
-       Scene *scene = draw_ctx->scene;
-       Object *obedit = scene->obedit;
-
-       if (ob != obedit) {
+       if (ob != draw_ctx->object_edit) {
                for (ParticleSystem *psys = ob->particlesystem.first; psys; psys

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to