diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-13 12:35:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-13 12:55:12 +0300 |
commit | c8597a465f22e020b1c0ce6fcfbb7b7308efdad1 (patch) | |
tree | bdff87671b2f24ce7f393534e4325fb9e66eeda8 /source/blender/blenkernel | |
parent | 754d3a2fe626fbe57bb6ef47581368e3859f6390 (diff) |
Object Mode: remove Scene.obedit
Add ED_screen_window_find, BKE_workspace_edit_object
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_workspace.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/workspace.c | 19 |
5 files changed, 30 insertions, 9 deletions
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; +} + |