Commit: c8597a465f22e020b1c0ce6fcfbb7b7308efdad1
Author: Campbell Barton
Date:   Tue Feb 13 20:35:29 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBc8597a465f22e020b1c0ce6fcfbb7b7308efdad1

Object Mode: remove Scene.obedit

Add ED_screen_window_find, BKE_workspace_edit_object

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

M       source/blender/blenkernel/BKE_workspace.h
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/editors/animation/anim_channels_edit.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_screen.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/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_vertex_weight_utils.c
M       source/blender/editors/space_info/info_stats.c
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/editors/space_view3d/view3d_draw_legacy.c
M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/transform/transform_snap_object.c
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/modifiers/intern/MOD_meshdeform.c
M       source/blender/modifiers/intern/MOD_surfacedeform.c

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

diff --git a/source/blender/blenkernel/BKE_workspace.h 
b/source/blender/blenkernel/BKE_workspace.h
index f839d4cdf76..b309ae838d6 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -133,6 +133,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/object_dupli.c 
b/source/blender/blenkernel/intern/object_dupli.c
index f9f6b0aab40..2d655913b3e 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..52c85011b6a 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..074d7b9c90d 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1380,7 +1380,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 +1391,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 +1429,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/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 5d5990b9a0a..d137e5f1c74 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2683,8 +2683,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext 
*ac, int channel_index,
                }
                case ANIMTYPE_OBJECT:
                {
+#if 0
                        bDopeSheet *ads = (bDopeSheet *)ac->data;
                        Scene *sce = (Scene *)ads->source;
+#endif
                        ViewLayer *view_layer = ac->view_layer;
                        Base *base = (Base *)ale->data;
                        Object *ob = base->object;
@@ -2723,7 +2725,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext 
*ac, int channel_index,
                                        adt->flag |= ADT_UI_ACTIVE;
 
                                /* ensure we exit editmode on whatever object 
was active before to avoid getting stuck there - T48747 */
-                               if (ob != sce->obedit)
+                               if (ob != CTX_data_edit_object(C))
                                        ED_object_editmode_exit(C, EM_FREEDATA 
| EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
 
                                notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
diff --git a/source/blender/editors/curve/editcurve.c 
b/source/blender/editors/curve/editcurve.c
index 4b578ba389e..c3e92589791 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5027,7 +5027,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, 
const wmEvent *event)
                                snap_context,
                                SCE_SELECT_FACE,
                                &(const struct SnapObjectParams){
-                                   .snap_select = (vc.scene->obedit != NULL) ? 
SNAP_NOT_ACTIVE : SNAP_ALL,
+                                   .snap_select = (vc.obedit != NULL) ? 
SNAP_NOT_ACTIVE : SNAP_ALL,
                                    .use_object_edit_cage = false,
                                },
                                mval, NULL, true,
diff --git a/source/blender/editors/curve/editcurve_paint.c 
b/source/blender/editors/curve/editcurve_paint.c
index 062b9c94a1b..0d2514ec27e 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -788,7 +788,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op)
        struct CurveDrawData *cdd = op->customdata;
 
        const CurvePaintSettings *cps = 
&cdd->vc.scene->toolsettings->curve_paint_settings;
-       Object *obedit = cdd->vc.scene->obedit;
+       Object *obedit = cdd->vc.obedit;
        Curve *cu = obedit->data;
        ListBase *nurblist = object_editcurve_get(obedit);
 
diff --git a/source/blender/editors/gpencil/gpencil_convert.c 
b/source/blender/editors/gpencil/gpencil_convert.c
index d2ae8bc3ce7..8d45c6af686 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -55,6 +55,7 @@
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_gpencil_types.h"
+#include "DNA_workspace_types.h"
 
 #include "BKE_collection.h"
 #include "BKE_context.h"
@@ -1293,6 +1294,7 @@ static int gp_convert_poll(bContext *C)
        bGPDframe *gpf = NULL;
        ScrArea *sa = CTX_wm_area(C);
        Scene *scene = CTX_data_scene(C);
+       const WorkSpace *workspace = CTX_wm_workspace(C);
        
        /* only if the current view is 3D View, if there's valid data (i.e. at 
least one stroke!),
         * and if we are not in edit mode!
@@ -1301,7 +1303,7 @@ static int gp_convert_poll(bContext *C)
                (gpl = BKE_gpencil_layer_getactive(gpd)) &&
                (gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0)) &&
                (gpf->strokes.first) &&
-               (scene->obedit == NULL));
+               ((workspace->object_mode & OB_MODE_EDIT) == 0));
 }
 
 static int gp_convert_layer_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/include/ED_screen.h 
b/source/blender/editors/include/ED_screen.h
index 18480d01ed7..8fa043499f8 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -148,6 +148,7 @@ void    ED_screens_header_tools_menu_create(struct bContext 
*C, struct uiLayout
 bool    ED_screen_stereo3d_required(const struct bScreen *screen, const struct 
Scene *scene);
 Scene   *ED_screen_scene_find(const struct bScreen *screen, const struct 
wmWindowManager *wm);
 Scene   *ED_screen_scene_find_with_window(const struct bScreen *screen, const 
struct wmWindowManager *wm, struct wmWindow **r_window);
+struct wmWindow

@@ 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