diff options
Diffstat (limited to 'source')
54 files changed, 275 insertions, 377 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 9ed4da87395..536b21e83ce 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -85,7 +85,7 @@ void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target); bool BKE_object_exists_check(struct Object *obtest); bool BKE_object_is_in_editmode(const struct Object *ob); bool BKE_object_is_in_editmode_vgroup(struct Object *ob); -bool BKE_object_is_in_wpaint_select_vert(const struct EvaluationContext *eval_ctx, const struct Object *ob); +bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob, eObjectMode object_mode); typedef enum eObjectVisibilityCheck { OB_VISIBILITY_CHECK_FOR_VIEWPORT, diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 17f6438870c..2840971f157 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -147,12 +147,9 @@ bool BKE_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool /* testing face select mode * Texture paint could be removed since selected faces are not used * however hiding faces is useful */ -bool BKE_paint_select_face_test( - const struct EvaluationContext *eval_ctx, struct Object *ob); -bool BKE_paint_select_vert_test( - const struct EvaluationContext *eval_ctx, struct Object *ob); -bool BKE_paint_select_elem_test( - const struct EvaluationContext *eval_ctx, struct Object *ob); +bool BKE_paint_select_face_test(struct Object *ob, eObjectMode object_mode); +bool BKE_paint_select_vert_test(struct Object *ob, eObjectMode object_mode); +bool BKE_paint_select_elem_test(struct Object *ob, eObjectMode object_mode); /* partial visibility */ bool paint_is_face_hidden(const struct MLoopTri *lt, const struct MVert *mvert, const struct MLoop *mloop); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 5229cb35645..67463ffe915 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2721,7 +2721,7 @@ static CustomDataMask object_get_datamask( } if (ob == actob) { - bool editing = BKE_paint_select_face_test(eval_ctx, ob); + bool editing = BKE_paint_select_face_test(ob, eval_ctx->object_mode); /* weight paint and face select need original indices because of selection buffer drawing */ if (r_need_mapping) { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 8b7356eaa9e..2af3b6ce593 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -1035,11 +1035,10 @@ int CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectM int CTX_data_mode_enum(const bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *obedit = CTX_data_edit_object(C); Object *obact = obedit ? NULL : CTX_data_active_object(C); - return CTX_data_mode_enum_ex(obedit, obact, eval_ctx.object_mode); + return CTX_data_mode_enum_ex(obedit, obact, workspace->object_mode); } /* would prefer if we can use the enum version below over this one - Campbell */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 127830c0cf7..a0d2e7d76c8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -538,11 +538,11 @@ bool BKE_object_is_in_editmode_vgroup(Object *ob) BKE_object_is_in_editmode(ob)); } -bool BKE_object_is_in_wpaint_select_vert(const EvaluationContext *eval_ctx, const Object *ob) +bool BKE_object_is_in_wpaint_select_vert(const Object *ob, eObjectMode object_mode) { if (ob->type == OB_MESH) { const Mesh *me = ob->data; - return ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) && + return ((object_mode & OB_MODE_WEIGHT_PAINT) && (me->edit_btmesh == NULL) && (ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX)); } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 5a267f97d03..81943d470dc 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -41,6 +41,7 @@ #include "DNA_scene_types.h" #include "DNA_brush_types.h" #include "DNA_space_types.h" +#include "DNA_workspace_types.h" #include "BLI_bitmap.h" #include "BLI_utildefines.h" @@ -235,9 +236,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C) SpaceImage *sima; if (sce && view_layer) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); ToolSettings *ts = sce->toolsettings; Object *obact = NULL; @@ -245,7 +244,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C) obact = view_layer->basact->object; if ((sima = CTX_wm_space_image(C)) != NULL) { - if (obact && eval_ctx.object_mode == OB_MODE_EDIT) { + if (obact && workspace->object_mode == OB_MODE_EDIT) { if (sima->mode == SI_MODE_PAINT) return &ts->imapaint.paint; else if (ts->use_uv_sculpt) @@ -256,7 +255,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C) } } else if (obact) { - switch (eval_ctx.object_mode) { + switch (workspace->object_mode) { case OB_MODE_SCULPT: return &ts->sculpt->paint; case OB_MODE_VERTEX_PAINT: @@ -289,9 +288,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C) SpaceImage *sima; if (sce && view_layer) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); ToolSettings *ts = sce->toolsettings; Object *obact = NULL; @@ -299,7 +296,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C) obact = view_layer->basact->object; if ((sima = CTX_wm_space_image(C)) != NULL) { - if (obact && eval_ctx.object_mode == OB_MODE_EDIT) { + if (obact && workspace->object_mode == OB_MODE_EDIT) { if (sima->mode == SI_MODE_PAINT) return ePaintTexture2D; else if (ts->use_uv_sculpt) @@ -310,7 +307,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C) } } else if (obact) { - switch (eval_ctx.object_mode) { + switch (workspace->object_mode) { case OB_MODE_SCULPT: return ePaintSculpt; case OB_MODE_VERTEX_PAINT: @@ -501,24 +498,24 @@ bool BKE_palette_is_empty(const struct Palette *palette) /* are we in vertex paint or weight pain face select mode? */ -bool BKE_paint_select_face_test(const EvaluationContext *eval_ctx, Object *ob) +bool BKE_paint_select_face_test(Object *ob, eObjectMode object_mode) { return ( (ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) && - (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) + (object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) ); } /* are we in weight paint vertex select mode? */ -bool BKE_paint_select_vert_test(const EvaluationContext *eval_ctx, Object *ob) +bool BKE_paint_select_vert_test(Object *ob, eObjectMode object_mode) { return ( (ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) && - (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT || eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) + (object_mode & OB_MODE_WEIGHT_PAINT || object_mode & OB_MODE_VERTEX_PAINT) ); } @@ -526,10 +523,10 @@ bool BKE_paint_select_vert_test(const EvaluationContext *eval_ctx, Object *ob) * used to check if selection is possible * (when we don't care if its face or vert) */ -bool BKE_paint_select_elem_test(const EvaluationContext *eval_ctx, Object *ob) +bool BKE_paint_select_elem_test(Object *ob, eObjectMode object_mode) { - return (BKE_paint_select_vert_test(eval_ctx, ob) || - BKE_paint_select_face_test(eval_ctx, ob)); + return (BKE_paint_select_vert_test(ob, object_mode) || + BKE_paint_select_face_test(ob, object_mode)); } void BKE_paint_cavity_curve_preset(Paint *p, int preset) diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 14baa1fb179..a43f3ff4acc 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -874,9 +874,7 @@ void POSE_OT_select_grouped(wmOperatorType *ot) */ static int pose_select_mirror_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob_act = CTX_data_active_object(C); Object *ob = BKE_object_pose_armature_get(ob_act); bArmature *arm; @@ -920,7 +918,7 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op) arm->act_bone = pchan_mirror_act->bone; /* in weightpaint we select the associated vertex group too */ - if (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) { + if (workspace->object_mode & OB_MODE_WEIGHT_PAINT) { ED_vgroup_select_by_name(ob_act, pchan_mirror_act->name); DEG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 2941b08b7ad..f2798cedae1 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -46,6 +46,7 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_workspace_types.h" #include "RNA_access.h" #include "RNA_enum_types.h" @@ -1195,8 +1196,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) ui_id_icon_render(C, id, true); } else { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); SpaceImage *sima; const EnumPropertyItem *items = NULL; @@ -1207,11 +1207,11 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) * checking various context stuff here */ if (CTX_wm_view3d(C) && ob) { - if (eval_ctx.object_mode & OB_MODE_SCULPT) + if (workspace->object_mode & OB_MODE_SCULPT) mode = OB_MODE_SCULPT; - else if (eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) + else if (workspace->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) mode = OB_MODE_VERTEX_PAINT; - else if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) + else if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) mode = OB_MODE_TEXTURE_PAINT; } else if ((sima = CTX_wm_space_image(C)) && diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index c607707729d..7b88b091672 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -280,7 +280,7 @@ bool EDBM_backbuf_border_mask_init(const struct EvaluationContext *eval_ctx, Vie /* method in use for face selecting too */ if (vc->obedit == NULL) { - if (!BKE_paint_select_elem_test(eval_ctx, vc->obact)) { + if (!BKE_paint_select_elem_test(vc->obact, eval_ctx->object_mode)) { return false; } } @@ -332,7 +332,7 @@ bool EDBM_backbuf_circle_init( /* method in use for face selecting too */ if (vc->obedit == NULL) { - if (!BKE_paint_select_elem_test(eval_ctx, vc->obact)) { + if (!BKE_paint_select_elem_test(vc->obact, eval_ctx->object_mode)) { return false; } } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index efaf9a69e9c..bd3d2f652c0 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -506,16 +506,14 @@ static int layers_poll(bContext *C) static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); Mesh *me = ob->data; if (ED_mesh_uv_texture_add(me, NULL, true) == -1) return OPERATOR_CANCELLED; - if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); @@ -625,16 +623,14 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); Mesh *me = ob->data; if (!ED_mesh_uv_texture_remove_active(me)) return OPERATOR_CANCELLED; - if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); @@ -748,12 +744,10 @@ static int mesh_customdata_mask_clear_poll(bContext *C) { Object *ob = ED_object_context(C); if (ob && ob->type == OB_MESH) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); /* special case - can't run this if we're in sculpt mode */ - if (eval_ctx.object_mode & OB_MODE_SCULPT) { + if (workspace->object_mode & OB_MODE_SCULPT) { return false; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index cf00e657fbf..3c0c083dbd7 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -320,15 +320,13 @@ static void clear_images_poly(Image **ob_image_array, int ob_image_array_len, Cl static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) { Object *ob; + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); int objects_baked = 0; if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (scene->r.bake_flag & R_BAKE_CLEAR) { /* clear images */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { @@ -377,8 +375,8 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) bkr.ob_image.array = BKE_object_material_edit_image_get_array(ob); bkr.ob_image.len = ob->totcol; - bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, eval_ctx.object_mode, &bkr.tot_lvl, &bkr.simple); - bkr.lores_dm = multiresbake_create_loresdm(scene, ob, eval_ctx.object_mode, &bkr.lvl); + bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, workspace->object_mode, &bkr.tot_lvl, &bkr.simple); + bkr.lores_dm = multiresbake_create_loresdm(scene, ob, workspace->object_mode, &bkr.lvl); RE_multires_bake_images(&bkr); @@ -402,12 +400,10 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) /* Multiresbake adopted for job-system executing */ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) { + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); Object *ob; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - /* backup scene settings, so their changing in UI would take no effect on baker */ bkj->bake_filter = scene->r.bake_filter; bkj->mode = scene->r.bake_mode; @@ -436,8 +432,8 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) data->ob_image.len = ob->totcol; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ - data->hires_dm = multiresbake_create_hiresdm(scene, ob, eval_ctx.object_mode, &data->tot_lvl, &data->simple); - data->lores_dm = multiresbake_create_loresdm(scene, ob, eval_ctx.object_mode, &lvl); + data->hires_dm = multiresbake_create_hiresdm(scene, ob, workspace->object_mode, &data->tot_lvl, &data->simple); + data->lores_dm = multiresbake_create_loresdm(scene, ob, workspace->object_mode, &lvl); data->lvl = lvl; BLI_addtail(&bkj->data, data); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index b9956876cb3..ca96e1c6798 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -471,11 +471,10 @@ static int editmode_toggle_poll(bContext *C) if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data)) return 0; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); /* if hidden but in edit mode, we still display */ - if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(eval_ctx.object_mode & OB_MODE_EDIT)) { + if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(workspace->object_mode & OB_MODE_EDIT)) { return 0; } @@ -1024,8 +1023,6 @@ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object, static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); if (ob->pd == NULL) @@ -1034,8 +1031,9 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ob->pd->forcefield = PFIELD_FORCE; else ob->pd->forcefield = 0; - - ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob, eval_ctx.object_mode); + + const WorkSpace *workspace = CTX_wm_workspace(C); + ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob, workspace->object_mode); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c index 87c1f5a10c2..c865b45889a 100644 --- a/source/blender/editors/object/object_facemap_ops.c +++ b/source/blender/editors/object/object_facemap_ops.c @@ -35,6 +35,7 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_workspace_types.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -174,9 +175,8 @@ static int face_map_supported_edit_mode_poll(bContext *C) Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; if (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (eval_ctx.object_mode == OB_MODE_EDIT) { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode == OB_MODE_EDIT) { return true; } } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 6411676420a..78554713f4d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -690,8 +690,7 @@ static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene * int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md, int mode) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); int prev_mode; if (scene->obedit) { @@ -702,7 +701,7 @@ int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scen BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); return 0; } - else if ((eval_ctx.object_mode & OB_MODE_SCULPT) && + else if ((workspace->object_mode & OB_MODE_SCULPT) && (find_multires_modifier_before(scene, md)) && (modifier_isSameTopology(md) == false)) { @@ -754,14 +753,13 @@ int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierDat static int modifier_add_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); - if (!ED_object_modifier_add(op->reports, bmain, scene, ob, eval_ctx.object_mode, NULL, type)) + if (!ED_object_modifier_add(op->reports, bmain, scene, ob, workspace->object_mode, NULL, type)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -898,13 +896,12 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) static int modifier_remove_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - int mode_orig = eval_ctx.object_mode; + int mode_orig = workspace->object_mode; if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) return OPERATOR_CANCELLED; @@ -913,7 +910,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) /* if cloth/softbody was removed, particle mode could be cleared */ if (mode_orig & OB_MODE_PARTICLE_EDIT) { - if ((eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) == 0) { + if ((workspace->object_mode & OB_MODE_PARTICLE_EDIT) == 0) { if (view_layer->basact && view_layer->basact->object == ob) { WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); } @@ -1077,15 +1074,14 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, eval_ctx.object_mode, md)) { + if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, workspace->object_mode, md)) { return OPERATOR_CANCELLED; } @@ -1446,10 +1442,8 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - - multiresModifier_base_apply(mmd, ob, eval_ctx.object_mode); + const WorkSpace *workspace = CTX_wm_workspace(C); + multiresModifier_base_apply(mmd, ob, workspace->object_mode); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 2aa2451b834..ba3541b428a 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -292,11 +292,9 @@ void ED_operatormacros_object(void) static int object_mode_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); - return (!ob || eval_ctx.object_mode == OB_MODE_OBJECT); + return (!ob || workspace->object_mode == OB_MODE_OBJECT); } void ED_keymap_object(wmKeyConfig *keyconf) diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index d76019e9172..f2111adc09a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1428,9 +1428,7 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst static int make_links_data_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); const int type = RNA_enum_get(op->ptr, "type"); Object *ob_src; @@ -1515,7 +1513,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - BKE_object_link_modifiers(ob_dst, ob_src, eval_ctx.object_mode); + BKE_object_link_modifiers(ob_dst, ob_src, workspace->object_mode); DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; case MAKE_LINKS_FONTS: diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 8c9281e3e61..69e0fd20b86 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -166,9 +166,9 @@ static int objects_selectable_poll(bContext *C) if (CTX_data_edit_object(C)) { return 0; } - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (eval_ctx.object_mode) { + + const WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode != OB_MODE_OBJECT) { return 0; } return 1; diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 005ae64e413..bd3bd8fd0a5 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -49,6 +49,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_workspace_types.h" #include "BKE_context.h" #include "BKE_key.h" @@ -225,22 +226,20 @@ static bool object_shape_key_mirror(bContext *C, Object *ob, static int shape_key_mode_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (eval_ctx.object_mode != OB_MODE_EDIT)); + return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (workspace->object_mode != OB_MODE_EDIT)); } static int shape_key_mode_exists_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; /* same as shape_key_mode_poll */ - return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (eval_ctx.object_mode != OB_MODE_EDIT)) && + return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && (workspace->object_mode != OB_MODE_EDIT)) && /* check a keyblock exists */ (BKE_keyblock_from_object(ob) != NULL); } @@ -248,14 +247,13 @@ static int shape_key_mode_exists_poll(bContext *C) static int shape_key_move_poll(bContext *C) { /* Same as shape_key_mode_exists_poll above, but ensure we have at least two shapes! */ - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; Key *key = BKE_key_from_object(ob); return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data) && - (eval_ctx.object_mode != OB_MODE_EDIT) && key && key->totkey > 1); + (workspace->object_mode != OB_MODE_EDIT) && key && key->totkey > 1); } static int shape_key_poll(bContext *C) diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 55c5a9b18e6..d69d8f8b26e 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -245,9 +245,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, void (*clear_func)(Object *, const bool), const char default_ksName[]) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks; const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta"); @@ -266,7 +264,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - if (!(eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) { + if (!(workspace->object_mode & OB_MODE_WEIGHT_PAINT)) { /* run provided clearing function */ clear_func(ob, clear_delta); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 035d3d38436..8c6ccb7e8f0 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -43,6 +43,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_workspace_types.h" #include "BLI_alloca.h" #include "BLI_array.h" @@ -2539,8 +2540,6 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C) /* editmode _or_ weight paint vertex sel */ static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const short ob_type_flag) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; @@ -2551,12 +2550,13 @@ static int vertex_group_vert_poll_ex(bContext *C, const bool needs_select, const return false; } + const WorkSpace *workspace = CTX_wm_workspace(C); if (BKE_object_is_in_editmode_vgroup(ob)) { return true; } - else if (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) { + else if (workspace->object_mode & OB_MODE_WEIGHT_PAINT) { if (needs_select) { - if (BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)) { + if (BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode)) { return true; } else { @@ -2608,10 +2608,9 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C) if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) return 0; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); if (!(BKE_object_is_in_editmode_vgroup(ob) || - BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob))) + BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode))) { return 0; } @@ -2637,11 +2636,9 @@ static int vertex_group_vert_select_mesh_poll(bContext *C) if (ob->type != OB_MESH) return 0; - - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); return (BKE_object_is_in_editmode_vgroup(ob) || - BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob)); + BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode)); } static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 63eee657c3a..c78f1eaebd0 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -114,13 +114,12 @@ void update_world_cos(Object *ob, PTCacheEdit *edit); int PE_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene= CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob= CTX_data_active_object(C); - if (!scene || !view_layer || !ob || !(eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) { + if (!scene || !view_layer || !ob || !(workspace->object_mode & OB_MODE_PARTICLE_EDIT)) { return 0; } return (PE_get_current(scene, view_layer, ob) != NULL); @@ -128,14 +127,13 @@ int PE_poll(bContext *C) int PE_hair_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene= CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob= CTX_data_active_object(C); PTCacheEdit *edit; - if (!scene || !ob || !(eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) { + if (!scene || !ob || !(workspace->object_mode & OB_MODE_PARTICLE_EDIT)) { return 0; } edit= PE_get_current(scene, view_layer, ob); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 6d6f5185af7..222e0e20dff 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -99,8 +99,7 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); if (!ob) @@ -108,7 +107,7 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) BKE_object_material_slot_add(ob); - if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); @@ -138,8 +137,7 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot) static int material_slot_remove_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_context(C); if (!ob) @@ -153,7 +151,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op) BKE_object_material_slot_remove(ob); - if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index e4c3a051a13..bb92ea35ad0 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -86,8 +86,6 @@ const char *screen_context_dir[] = { int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); @@ -375,31 +373,31 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "sculpt_object")) { - if (obact && (eval_ctx.object_mode & OB_MODE_SCULPT)) { + if (obact && (workspace->object_mode & OB_MODE_SCULPT)) { CTX_data_id_pointer_set(result, &obact->id); } return 1; } else if (CTX_data_equals(member, "vertex_paint_object")) { - if (obact && (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT)) + if (obact && (workspace->object_mode & OB_MODE_VERTEX_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if (CTX_data_equals(member, "weight_paint_object")) { - if (obact && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) + if (obact && (workspace->object_mode & OB_MODE_WEIGHT_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if (CTX_data_equals(member, "image_paint_object")) { - if (obact && (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT)) + if (obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if (CTX_data_equals(member, "particle_edit_object")) { - if (obact && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) + if (obact && (workspace->object_mode & OB_MODE_PARTICLE_EDIT)) CTX_data_id_pointer_set(result, &obact->id); return 1; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 3c089483054..bc266180e09 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -152,8 +152,7 @@ int ED_operator_scene_editable(bContext *C) int ED_operator_objectmode(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); @@ -163,7 +162,7 @@ int ED_operator_objectmode(bContext *C) return 0; /* add a check for ob->mode too? */ - if (obact && (eval_ctx.object_mode != OB_MODE_OBJECT)) + if (obact && (workspace->object_mode != OB_MODE_OBJECT)) return 0; return 1; @@ -305,43 +304,39 @@ int ED_operator_console_active(bContext *C) return ed_spacetype_test(C, SPACE_CONSOLE); } -static int ed_object_hidden(const EvaluationContext *eval_ctx, Object *ob) +static int ed_object_hidden(Object *ob, eObjectMode object_mode) { /* if hidden but in edit mode, we still display, can happen with animation */ - return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(eval_ctx->object_mode & OB_MODE_EDIT)); + return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(object_mode & OB_MODE_EDIT)); } int ED_operator_object_active(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !ed_object_hidden(&eval_ctx, ob)); + return ((ob != NULL) && !ed_object_hidden(ob, workspace->object_mode)); } int ED_operator_object_active_editable(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(&eval_ctx, ob)); + return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob, workspace->object_mode)); } int ED_operator_object_active_editable_mesh(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(&eval_ctx, ob) && + return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob, workspace->object_mode) && (ob->type == OB_MESH) && !ID_IS_LINKED(ob->data)); } int ED_operator_object_active_editable_font(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = ED_object_active_context(C); - return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(&eval_ctx, ob) && + return ((ob != NULL) && !ID_IS_LINKED(ob) && !ed_object_hidden(ob, workspace->object_mode) && (ob->type == OB_FONT)); } @@ -387,9 +382,8 @@ int ED_operator_posemode_exclusive(bContext *C) Object *obact = CTX_data_active_object(C); if (obact) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if ((eval_ctx.object_mode & OB_MODE_EDIT) == 0) { + const WorkSpace *workspace = CTX_wm_workspace(C); + if ((workspace->object_mode & OB_MODE_EDIT) == 0) { Object *obpose; if ((obpose = BKE_object_pose_armature_get(obact))) { if (obact == obpose) { @@ -557,8 +551,6 @@ int ED_operator_editmball(bContext *C) int ED_operator_mask(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 9170c8b361a..c9ad4a46a13 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -32,6 +32,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "DNA_workspace_types.h" #include "BLI_math_vector.h" #include "BLI_string.h" @@ -61,14 +62,13 @@ int paint_curve_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); Paint *p; RegionView3D *rv3d = CTX_wm_region_view3d(C); SpaceImage *sima; - if (rv3d && !(ob && ((eval_ctx.object_mode & OB_MODE_ALL_PAINT) != 0))) + if (rv3d && !(ob && ((workspace->object_mode & OB_MODE_ALL_PAINT) != 0))) return false; sima = CTX_wm_space_image(C); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 662485bf4f7..d42bbfdc43a 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -588,15 +588,15 @@ static Brush *image_paint_brush(bContext *C) static int image_paint_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); Object *obact; if (!image_paint_brush(C)) { return 0; } + + const WorkSpace *workspace = CTX_wm_workspace(C); obact = CTX_data_active_object(C); - if ((obact && eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { + if ((obact && workspace->object_mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { return 1; } else { @@ -1472,13 +1472,12 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; - Brush *br; + WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); - if (!(ob && (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT))) { + Brush *br; + if (!(ob && (workspace->object_mode & OB_MODE_VERTEX_PAINT))) { br = image_paint_brush(C); } else { @@ -1510,9 +1509,8 @@ static int brush_colors_flip_poll(bContext *C) else { Object *ob = CTX_data_active_object(C); if (ob) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT) { + WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode & OB_MODE_VERTEX_PAINT) { return 1; } } @@ -1555,9 +1553,8 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op) static int texture_paint_poll(bContext *C) { if (texture_paint_toggle_poll(C)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) { return 1; } } @@ -1571,22 +1568,19 @@ int image_texture_paint_poll(bContext *C) int facemask_paint_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - return BKE_paint_select_face_test(&eval_ctx, CTX_data_active_object(C)); + const WorkSpace *workspace = CTX_wm_workspace(C); + return BKE_paint_select_face_test(CTX_data_active_object(C), workspace->object_mode); } int vert_paint_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - return BKE_paint_select_vert_test(&eval_ctx, CTX_data_active_object(C)); + const WorkSpace *workspace = CTX_wm_workspace(C); + return BKE_paint_select_vert_test(CTX_data_active_object(C), workspace->object_mode); } int mask_paint_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - return BKE_paint_select_elem_test(&eval_ctx, CTX_data_active_object(C)); + const WorkSpace *workspace = CTX_wm_workspace(C); + return BKE_paint_select_elem_test(CTX_data_active_object(C), workspace->object_mode); } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 1343ab13999..e339a4c13b6 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5941,10 +5941,9 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) static int add_simple_uvs_poll(bContext *C) { + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (!ob || (ob->type != OB_MESH) || (eval_ctx.object_mode != OB_MODE_TEXTURE_PAINT)) { + if (!ob || (ob->type != OB_MESH) || (workspace->object_mode != OB_MODE_TEXTURE_PAINT)) { return false; } return true; diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 214b260250d..c031a733630 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -262,9 +262,9 @@ static void PALETTE_OT_color_delete(wmOperatorType *ot) } static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) + { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); Object *ob = CTX_data_active_object(C); @@ -272,7 +272,7 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) if (!ob || !brush) return OPERATOR_CANCELLED; /* TODO: other modes */ - if (eval_ctx.object_mode & OB_MODE_SCULPT) { + if (workspace->object_mode & OB_MODE_SCULPT) { BKE_brush_sculpt_reset(brush); } else { @@ -405,8 +405,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, static int brush_select_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); ToolSettings *toolsettings = CTX_data_tool_settings(C); Paint *paint = NULL; @@ -420,7 +419,7 @@ static int brush_select_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); if (ob) { /* select current paint mode */ - paint_mode = eval_ctx.object_mode & OB_MODE_ALL_PAINT; + paint_mode = workspace->object_mode & OB_MODE_ALL_PAINT; } else { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 3a20973c465..4fc6ba40fdc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -199,13 +199,12 @@ static void paint_last_stroke_update(Scene *scene, ARegion *ar, const float mval /* Returns true if vertex paint mode is active */ int vertex_paint_mode_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); return (ob && (ob->type == OB_MESH) && ((Mesh *)ob->data)->totpoly && - (eval_ctx.object_mode & OB_MODE_VERTEX_PAINT)); + (workspace->object_mode & OB_MODE_VERTEX_PAINT)); } int vertex_paint_poll(bContext *C) @@ -225,24 +224,22 @@ int vertex_paint_poll(bContext *C) int weight_paint_mode_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); return (ob && (ob->type == OB_MESH) && ((Mesh *)ob->data)->totpoly && - (eval_ctx.object_mode == OB_MODE_WEIGHT_PAINT)); + (workspace->object_mode == OB_MODE_WEIGHT_PAINT)); } int weight_paint_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); ScrArea *sa; if ((ob != NULL) && - (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && + (workspace->object_mode & OB_MODE_WEIGHT_PAINT) && (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && (sa = CTX_wm_area(C)) && (sa->spacetype == SPACE_VIEW3D)) diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index 83407ba6765..f442c12cbe9 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -28,6 +28,7 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_workspace_types.h" #include "BLI_math_base.h" #include "BLI_math_color.h" @@ -51,11 +52,10 @@ static int vertex_weight_paint_mode_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); Mesh *me = BKE_mesh_from_object(ob); - return (ob && ELEM(eval_ctx.object_mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT)) && + return (ob && ELEM(workspace->object_mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT)) && (me && me->totpoly && me->dvert); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index b5d3a452d83..72e2e7b323d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -118,11 +118,10 @@ static void wpaint_prev_destroy(struct WPaintPrev *wpp) static int weight_from_bones_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); - return (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); + return (ob && (workspace->object_mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); } static int weight_from_bones_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 06705f6715d..02404ef2d8e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4082,10 +4082,9 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) int sculpt_mode_poll(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = CTX_data_active_object(C); - return ob && eval_ctx.object_mode & OB_MODE_SCULPT; + return ob && workspace->object_mode & OB_MODE_SCULPT; } int sculpt_mode_poll_view3d(bContext *C) diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 42ff57472e7..ebb14d3caeb 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -425,10 +425,9 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) scene = path->ptr[path->len - 1].data; if (scene) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); - br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, eval_ctx.object_mode)); + br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, workspace->object_mode)); } if (br) { diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 68bef3fd142..95ed8967380 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -323,15 +323,14 @@ bool ED_image_slot_cycle(struct Image *image, int direction) void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - + /* scope update can be expensive, don't update during paint modes */ if (sima->mode == SI_MODE_PAINT) return; - if (ob && ((eval_ctx.object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) { + if (ob && ((workspace->object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) { return; } /* We also don't update scopes of render result during render. */ diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 25808df807d..6bbec6a1a48 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -978,8 +978,7 @@ static int outliner_open_back(TreeElement *te) static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); SpaceOops *so = CTX_wm_space_outliner(C); ViewLayer *view_layer = CTX_data_view_layer(C); ARegion *ar = CTX_wm_region(C); @@ -1000,13 +999,13 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) /* traverse down the bone hierarchy in case of armature */ TreeElement *te_obact = te; - if (eval_ctx.object_mode & OB_MODE_POSE) { + if (workspace->object_mode & OB_MODE_POSE) { bPoseChannel *pchan = CTX_data_active_pose_bone(C); if (pchan) { te = outliner_find_posechannel(&te_obact->subtree, pchan); } } - else if (eval_ctx.object_mode & OB_MODE_EDIT) { + else if (workspace->object_mode & OB_MODE_EDIT) { EditBone *ebone = CTX_data_active_bone(C); if (ebone) { te = outliner_find_editbone(&te_obact->subtree, ebone); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 9f66e6a0105..df5f43978e6 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -658,8 +658,7 @@ static eOLDrawState tree_element_active_text( static eOLDrawState tree_element_active_pose( bContext *C, Scene *scene, ViewLayer *view_layer, TreeElement *UNUSED(te), TreeStoreElem *tselem, const eOLSetState set) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = (Object *)tselem->id; Base *base = BKE_view_layer_base_find(view_layer, ob); @@ -672,7 +671,7 @@ static eOLDrawState tree_element_active_pose( if (scene->obedit) { ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); } - if (eval_ctx.object_mode & OB_MODE_POSE) { + if (workspace->object_mode & OB_MODE_POSE) { ED_armature_exit_posemode(C, base); } else { @@ -680,7 +679,7 @@ static eOLDrawState tree_element_active_pose( } } else { - if (eval_ctx.object_mode & OB_MODE_POSE) { + if (workspace->object_mode & OB_MODE_POSE) { return OL_DRAWSEL_NORMAL; } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 8bbbc4ac489..7ad5f733f02 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -4321,7 +4321,7 @@ static void draw_mesh_fancy( bool /* no_verts,*/ no_edges, no_faces; DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask); const bool is_obact = (ob == OBACT(view_layer)); - int draw_flags = (is_obact && BKE_paint_select_face_test(eval_ctx, ob)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(ob, eval_ctx->object_mode)) ? DRAW_FACE_SELECT : 0; if (!dm) return; @@ -4560,7 +4560,7 @@ static void draw_mesh_fancy( } } - if (is_obact && BKE_paint_select_vert_test(eval_ctx, ob)) { + if (is_obact && BKE_paint_select_vert_test(ob, eval_ctx->object_mode)) { const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); @@ -4742,7 +4742,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL bool no_edges, no_faces; DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, scene->customdata_mask); const bool is_obact = (ob == OBACT(view_layer)); - int draw_flags = (is_obact && BKE_paint_select_face_test(eval_ctx, ob)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(ob, eval_ctx->object_mode)) ? DRAW_FACE_SELECT : 0; if (!dm) return; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index e5259a2c583..2f2e0db8c7a 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1386,10 +1386,9 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); if (view_layer->basact) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); /* if hidden but in edit mode, we still display, can happen with animation */ - if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (eval_ctx.object_mode & OB_MODE_EDIT)) { + if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (workspace->object_mode & OB_MODE_EDIT)) { CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact); } } @@ -1399,11 +1398,10 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes else if (CTX_data_equals(member, "active_object")) { ViewLayer *view_layer = CTX_data_view_layer(C); if (view_layer->basact) { + const WorkSpace *workspace = CTX_wm_workspace(C); Object *ob = view_layer->basact->object; - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); /* if hidden but in edit mode, we still display, can happen with animation */ - if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (eval_ctx.object_mode & OB_MODE_EDIT) != 0) { + if ((view_layer->basact->flag & BASE_VISIBLED) != 0 || (workspace->object_mode & OB_MODE_EDIT) != 0) { CTX_data_id_pointer_set(result, &ob->id); } } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index b87637ef081..bd62a4fc3bf 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -787,13 +787,12 @@ static void do_view3d_vgroup_buttons(bContext *C, void *UNUSED(arg), int event) static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt)) { + const WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); if (ob && (BKE_object_is_in_editmode_vgroup(ob) || - BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob))) + BKE_object_is_in_wpaint_select_vert(ob, workspace->object_mode))) { MDeformVert *dvert_act = ED_mesh_active_dvert_get_only(ob); if (dvert_act) { @@ -1130,9 +1129,8 @@ static int view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt)) static void view3d_panel_transform(const bContext *C, Panel *pa) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); uiBlock *block; + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); @@ -1157,7 +1155,7 @@ static void view3d_panel_transform(const bContext *C, Panel *pa) v3d_editvertex_buts(col, v3d, ob, lim); } } - else if (eval_ctx.object_mode & OB_MODE_POSE) { + else if (workspace->object_mode & OB_MODE_POSE) { v3d_posearmature_buts(col, ob); } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3ffbb67a492..7ce1978dca2 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1422,7 +1422,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) } } -static void draw_view_axis(RegionView3D *rv3d, rcti *rect) +static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) { const float k = U.rvisize * U.pixelsize; /* axis size */ const int bright = - 20 * (10 - U.rvibright); /* axis alpha offset (rvibright has range 0-10) */ @@ -1689,7 +1689,7 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) return name; } -static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) +static void draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect) { RegionView3D *rv3d = ar->regiondata; const char *name = view3d_get_name(v3d, rv3d); @@ -1719,7 +1719,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) */ static void draw_selected_name( - const EvaluationContext *eval_ctx, Scene *scene, Object *ob, rcti *rect) + Scene *scene, Object *ob, const eObjectMode object_mode, const rcti *rect) { const int cfra = CFRA; const char *msg_pin = " (Pinned)"; @@ -1761,7 +1761,7 @@ static void draw_selected_name( s += BLI_strcpy_rlen(s, arm->act_edbone->name); } } - else if (eval_ctx->object_mode & OB_MODE_POSE) { + else if (object_mode & OB_MODE_POSE) { if (arm->act_bone) { if (arm->act_bone->layer & arm->layer) { @@ -1774,7 +1774,7 @@ static void draw_selected_name( else if (ELEM(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) { /* try to display active bone and active shapekey too (if they exist) */ - if (ob->type == OB_MESH && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { + if (ob->type == OB_MESH && object_mode & OB_MODE_WEIGHT_PAINT) { Object *armobj = BKE_object_pose_armature_get(ob); if (armobj) { bArmature *arm = armobj->data; @@ -1833,8 +1833,6 @@ static void draw_selected_name( */ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); @@ -1865,9 +1863,10 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) } if (U.uiflag & USER_DRAWVIEWINFO) { + const WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - draw_selected_name(&eval_ctx, scene, ob, &rect); + draw_selected_name(scene, ob, workspace->object_mode, &rect); } #if 0 /* TODO */ if (grid_unit) { /* draw below the viewport name */ @@ -2365,19 +2364,19 @@ void VP_legacy_drawcursor( } } -void VP_legacy_draw_view_axis(RegionView3D *rv3d, rcti *rect) +void VP_legacy_draw_view_axis(RegionView3D *rv3d, const rcti *rect) { draw_view_axis(rv3d, rect); } -void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) +void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect) { draw_viewport_name(ar, v3d, rect); } -void VP_legacy_draw_selected_name(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, rcti *rect) +void VP_legacy_draw_selected_name(Scene *scene, Object *ob, eObjectMode object_mode, const rcti *rect) { - draw_selected_name(eval_ctx, scene, ob, rect); + draw_selected_name(scene, ob, object_mode, rect); } void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit) diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 5b7f7e78310..0b85ac47781 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -222,7 +222,7 @@ static void backdrawview3d( BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); if (base && (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || - BKE_paint_select_face_test(eval_ctx, base->object))) + BKE_paint_select_face_test(base->object, eval_ctx->object_mode))) { /* do nothing */ } @@ -2074,7 +2074,7 @@ static void view3d_main_region_draw_info( if (U.uiflag & USER_DRAWVIEWINFO) { Object *ob = OBACT(view_layer); - VP_legacy_draw_selected_name(&eval_ctx, scene, ob, &rect); + VP_legacy_draw_selected_name(scene, ob, eval_ctx.object_mode, &rect); } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 20eb65197e5..47778623561 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -244,24 +244,22 @@ void view3d_orbit_apply_dyn_ofs( static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) { static float lastofs[3] = {0, 0, 0}; - - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); bool is_set = false; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob_act = OBACT(view_layer); - if (ob_act && (eval_ctx.object_mode & OB_MODE_ALL_PAINT) && + if (ob_act && (workspace->object_mode & OB_MODE_ALL_PAINT) && /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ - ((eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) + ((workspace->object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) { /* in case of sculpting use last average stroke position as a rotation * center, in other cases it's not clear what rotation center shall be * so just rotate around object origin */ - if (eval_ctx.object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { + if (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { float stroke[3]; BKE_paint_stroke_get_average(scene, ob_act, stroke); copy_v3_v3(lastofs, stroke); @@ -271,7 +269,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) } is_set = true; } - else if (ob_act && (eval_ctx.object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { + else if (ob_act && (workspace->object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { Curve *cu = ob_act->data; EditFont *ef = cu->editfont; int i; @@ -286,7 +284,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) is_set = true; } - else if (ob_act == NULL || eval_ctx.object_mode == OB_MODE_OBJECT) { + else if (ob_act == NULL || workspace->object_mode == OB_MODE_OBJECT) { /* object mode use boundbox centers */ Base *base; unsigned int tot = 0; @@ -2795,8 +2793,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) /* like a localview without local!, was centerview() in 2.4x */ static int viewselected_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); @@ -2820,7 +2817,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) ob = NULL; } - if (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) { + if (ob && (workspace->object_mode & OB_MODE_WEIGHT_PAINT)) { Object *ob_armature = BKE_object_pose_armature_get_visible(ob, view_layer); if (ob_armature) { ob = ob_armature; @@ -2845,17 +2842,17 @@ static int viewselected_exec(bContext *C, wmOperator *op) else if (obedit) { ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */ } - else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) { + else if (ob && (workspace->object_mode & OB_MODE_POSE)) { ok = BKE_pose_minmax(ob, min, max, true, true); } - else if (BKE_paint_select_face_test(&eval_ctx, ob)) { + else if (BKE_paint_select_face_test(ob, workspace->object_mode)) { ok = paintface_minmax(ob, min, max); } - else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) { + else if (ob && (workspace->object_mode & OB_MODE_PARTICLE_EDIT)) { ok = PE_minmax(scene, view_layer, min, max); } else if (ob && - (eval_ctx.object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) + (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { BKE_paint_stroke_get_average(scene, ob, min); copy_v3_v3(max, min); @@ -2962,15 +2959,13 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) Object *obact = CTX_data_active_object(C); if (v3d) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - ED_view3d_lock_clear(v3d); v3d->ob_centre = obact; /* can be NULL */ if (obact && obact->type == OB_ARMATURE) { - if (eval_ctx.object_mode & OB_MODE_POSE) { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode & OB_MODE_POSE) { bPoseChannel *pcham_act = BKE_pose_channel_active(obact); if (pcham_act) { BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index b5de08c3d11..5f38cbddce0 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -276,8 +276,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; @@ -292,7 +291,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiLayout *row; bool is_paint = ( ob && !(gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) && - ELEM(eval_ctx.object_mode, + ELEM(workspace->object_mode, OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT)); RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr); @@ -307,18 +306,18 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) row = uiLayoutRow(layout, true); uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - if (!ob || ELEM(eval_ctx.object_mode, OB_MODE_OBJECT, OB_MODE_POSE, OB_MODE_WEIGHT_PAINT)) { + if (!ob || ELEM(workspace->object_mode, OB_MODE_OBJECT, OB_MODE_POSE, OB_MODE_WEIGHT_PAINT)) { uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } if (obedit == NULL && is_paint) { /* Manipulators aren't used in paint modes */ - if (!ELEM(eval_ctx.object_mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) { + if (!ELEM(workspace->object_mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) { /* masks aren't used for sculpt and particle painting */ PointerRNA meshptr; RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr); - if (eval_ctx.object_mode & (OB_MODE_TEXTURE_PAINT)) { + if (workspace->object_mode & (OB_MODE_TEXTURE_PAINT)) { uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } else { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 16731336d00..0b913ad179d 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -379,10 +379,9 @@ extern bool view3d_camera_border_hack_test; void VP_legacy_drawcursor( const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, ARegion *ar, View3D *v3d); -void VP_legacy_draw_view_axis(RegionView3D *rv3d, rcti *rect); -void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect); -void VP_legacy_draw_selected_name( - const struct EvaluationContext *eval_ctx, Scene *scene, struct Object *ob, rcti *rect); +void VP_legacy_draw_view_axis(RegionView3D *rv3d, const rcti *rect); +void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect); +void VP_legacy_draw_selected_name(Scene *scene, struct Object *ob, eObjectMode object_mode, const rcti *rect); void VP_legacy_drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit); void VP_legacy_drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool write_depth); void VP_legacy_view3d_main_region_setup_view(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4]); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index ce3c30d50e0..89a033236f1 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -252,16 +252,15 @@ static int view3d_selectable_data(bContext *C) return 0; if (ob) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (eval_ctx.object_mode & OB_MODE_EDIT) { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode & OB_MODE_EDIT) { if (ob->type == OB_FONT) { return 0; } } else { - if ((eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && - !BKE_paint_select_elem_test(&eval_ctx, ob)) + if ((workspace->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && + !BKE_paint_select_elem_test(ob, workspace->object_mode)) { return 0; } @@ -815,10 +814,10 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc, CTX_data_eval_ctx(C, &eval_ctx); if (vc->obedit == NULL) { /* Object Mode */ - if (BKE_paint_select_face_test(&eval_ctx, ob)) { + if (BKE_paint_select_face_test(ob, eval_ctx.object_mode)) { do_lasso_select_paintface(&eval_ctx, vc, mcords, moves, extend, select); } - else if (BKE_paint_select_vert_test(&eval_ctx, ob)) { + else if (BKE_paint_select_vert_test(ob, eval_ctx.object_mode)) { do_lasso_select_paintvert(&eval_ctx, vc, mcords, moves, extend, select); } else if (ob && (eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { @@ -2216,10 +2215,10 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) if (vc.obact && eval_ctx.object_mode & OB_MODE_SCULPT) { ret = ED_sculpt_mask_box_select(C, &vc, &rect, select, extend); } - else if (vc.obact && BKE_paint_select_face_test(&eval_ctx, vc.obact)) { + else if (vc.obact && BKE_paint_select_face_test(vc.obact, eval_ctx.object_mode)) { ret = do_paintface_box_select(&eval_ctx, &vc, &rect, select, extend); } - else if (vc.obact && BKE_paint_select_vert_test(&eval_ctx, vc.obact)) { + else if (vc.obact && BKE_paint_select_vert_test(vc.obact, eval_ctx.object_mode)) { ret = do_paintvert_box_select(&eval_ctx, &vc, &rect, select, extend); } else if (vc.obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) { @@ -2308,8 +2307,7 @@ static bool ed_wpaint_vertex_select_pick( static int view3d_select_exec(bContext *C, wmOperator *op) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); bool extend = RNA_boolean_get(op->ptr, "extend"); @@ -2321,9 +2319,9 @@ static int view3d_select_exec(bContext *C, wmOperator *op) * or paint-select to allow pose bone select with vert/face select */ bool object = (RNA_boolean_get(op->ptr, "object") && (obedit || - BKE_paint_select_elem_test(&eval_ctx, obact) || + BKE_paint_select_elem_test(obact, workspace->object_mode) || /* so its possible to select bones in weightpaint mode (LMB select) */ - (obact && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact)))); + (obact && (workspace->object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact)))); bool retval = false; int location[2]; @@ -2357,11 +2355,11 @@ static int view3d_select_exec(bContext *C, wmOperator *op) retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle); } - else if (obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) + else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) return PE_mouse_particles(C, location, extend, deselect, toggle); - else if (obact && BKE_paint_select_face_test(&eval_ctx, obact)) + else if (obact && BKE_paint_select_face_test(obact, workspace->object_mode)) retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle); - else if (BKE_paint_select_vert_test(&eval_ctx, obact)) + else if (BKE_paint_select_vert_test(obact, workspace->object_mode)) retval = ed_wpaint_vertex_select_pick(C, location, extend, deselect, toggle, obact); else retval = ed_object_select_pick(C, location, extend, deselect, toggle, center, enumerate, object); @@ -2875,7 +2873,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; - if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(&eval_ctx, obact) || + if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(obact, eval_ctx.object_mode) || (obact && (eval_ctx.object_mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) { ViewContext vc; @@ -2888,11 +2886,11 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) obedit_circle_select(&eval_ctx, &vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } - else if (BKE_paint_select_face_test(&eval_ctx, obact)) { + else if (BKE_paint_select_face_test(obact, eval_ctx.object_mode)) { paint_facesel_circle_select(&eval_ctx, &vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } - else if (BKE_paint_select_vert_test(&eval_ctx, obact)) { + else if (BKE_paint_select_vert_test(obact, eval_ctx.object_mode)) { paint_vertsel_circle_select(&eval_ctx, &vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index cee76925040..40dd2f0f428 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -700,12 +700,11 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r } } else { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); Object *ob = CTX_data_active_object(C); if (ob) { - if (eval_ctx.object_mode & OB_MODE_POSE) { + const WorkSpace *workspace = CTX_wm_workspace(C); + if (workspace->object_mode & OB_MODE_POSE) { bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) { if (!select_only || (pchan->bone->flag & BONE_SELECTED)) { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9f7b438e338..67e912ad15b 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2624,10 +2624,7 @@ static void constraintTransLim(TransInfo *t, TransData *td) if (td->con) { const bConstraintTypeInfo *ctiLoc = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_LOCLIMIT); const bConstraintTypeInfo *ctiDist = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_DISTLIMIT); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(t->context, &eval_ctx); - bConstraintOb cob = {NULL}; bConstraint *con; float ctime = (float)(t->scene->r.cfra); @@ -2676,7 +2673,7 @@ static void constraintTransLim(TransInfo *t, TransData *td) } /* get constraint targets if needed */ - BKE_constraint_targets_for_solving_get(&eval_ctx, con, &cob, &targets, ctime); + BKE_constraint_targets_for_solving_get(&t->eval_ctx, con, &cob, &targets, ctime); /* do constraint */ cti->evaluate_constraint(con, &cob, &targets); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index d77a2d87680..fdf5665b6d4 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -715,9 +715,6 @@ static void recalcData_spaceclip(TransInfo *t) static void recalcData_objects(TransInfo *t) { Base *base = t->view_layer->basact; - EvaluationContext eval_ctx; - - CTX_data_eval_ctx(t->context, &eval_ctx); if (t->obedit) { if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) { @@ -902,9 +899,9 @@ static void recalcData_objects(TransInfo *t) BIK_clear_data(ob->pose); } else - BKE_pose_where_is(&eval_ctx, t->scene, ob); + BKE_pose_where_is(&t->eval_ctx, t->scene, ob); } - else if (base && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) && + else if (base && (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, t->view_layer, base->object)) { if (t->state != TRANS_CANCEL) { diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 77ad70bf146..459727ad531 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -591,8 +591,7 @@ static int calc_manipulator_stats( const bContext *C, bool use_only_center, struct TransformBounds *tbounds) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -630,7 +629,7 @@ static int calc_manipulator_stats( case V3D_MANIP_GIMBAL: { float mat[3][3]; - if (gimbal_axis(ob, mat, eval_ctx.object_mode)) { + if (gimbal_axis(ob, mat, workspace->object_mode)) { copy_m4_m3(rv3d->twmat, mat); break; } @@ -639,7 +638,7 @@ static int calc_manipulator_stats( } case V3D_MANIP_NORMAL: { - if (obedit || eval_ctx.object_mode & OB_MODE_POSE) { + if (obedit || workspace->object_mode & OB_MODE_POSE) { float mat[3][3]; ED_getTransformOrientationMatrix(C, mat, v3d->around); copy_m4_m3(rv3d->twmat, mat); @@ -650,7 +649,7 @@ static int calc_manipulator_stats( } case V3D_MANIP_LOCAL: { - if (eval_ctx.object_mode & OB_MODE_POSE) { + if (workspace->object_mode & OB_MODE_POSE) { /* each bone moves on its own local axis, but to avoid confusion, * use the active pones axis for display [#33575], this works as expected on a single bone * and users who select many bones will understand whats going on and what local means @@ -692,7 +691,7 @@ static int calc_manipulator_stats( #ifdef USE_AXIS_BOUNDS copy_m3_m4(tbounds->axis, rv3d->twmat); - if (ob && eval_ctx.object_mode & OB_MODE_EDIT) { + if (ob && workspace->object_mode & OB_MODE_EDIT) { float diff_mat[3][3]; copy_m3_m4(diff_mat, ob->obmat); normalize_m3(diff_mat); @@ -935,7 +934,7 @@ static int calc_manipulator_stats( mul_m4_v3(obedit->obmat, tbounds->max); } } - else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) { + else if (ob && (workspace->object_mode & OB_MODE_POSE)) { bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed bool ok = false; @@ -973,10 +972,10 @@ static int calc_manipulator_stats( mul_m4_v3(ob->obmat, tbounds->max); } } - else if (ob && (eval_ctx.object_mode & OB_MODE_ALL_PAINT)) { + else if (ob && (workspace->object_mode & OB_MODE_ALL_PAINT)) { /* pass */ } - else if (ob && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) { + else if (ob && workspace->object_mode & OB_MODE_PARTICLE_EDIT) { PTCacheEdit *edit = PE_get_current(scene, view_layer, ob); PTCacheEditPoint *point; PTCacheEditKey *ek; @@ -1066,14 +1065,13 @@ static void manipulator_prepare_mat( case V3D_AROUND_CENTER_BOUNDS: case V3D_AROUND_ACTIVE: { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); bGPdata *gpd = CTX_data_gpencil_data(C); Object *ob = OBACT(view_layer); if (((v3d->around == V3D_AROUND_ACTIVE) && (scene->obedit == NULL)) && ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) && - (!(eval_ctx.object_mode & OB_MODE_POSE))) + (!(workspace->object_mode & OB_MODE_POSE))) { copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); } @@ -1662,12 +1660,10 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulator { struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; wmManipulator *mpr = xmgroup->manipulator; - - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - if (ob && eval_ctx.object_mode & OB_MODE_EDIT) { + if (ob && workspace->object_mode & OB_MODE_EDIT) { copy_m4_m4(mpr->matrix_space, ob->obmat); } else { diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index dc5218746c6..63eea11212c 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -298,8 +298,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, ts = createViewSpace(C, reports, name, overwrite); } else { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *obedit = CTX_data_edit_object(C); Object *ob = CTX_data_active_object(C); if (obedit) { @@ -310,7 +309,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, else if (obedit->type == OB_CURVE) ts = createCurveSpace(C, reports, name, overwrite); } - else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) { + else if (ob && (workspace->object_mode & OB_MODE_POSE)) { ts = createBoneSpace(C, reports, name, overwrite); } else { @@ -582,8 +581,7 @@ static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3], const short around) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); Base *base; @@ -1014,7 +1012,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 mul_m3_v3(mat, plane); } } - else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) { + else if (ob && (workspace->object_mode & OB_MODE_POSE)) { bArmature *arm = ob->data; bPoseChannel *pchan; float imat[3][3], mat[3][3]; @@ -1054,7 +1052,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 result = ORIENTATION_EDGE; } } - else if (ob && (eval_ctx.object_mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) { + else if (ob && (workspace->object_mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) { /* pass */ } else { diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index b58cb9cfabe..64055b46431 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -79,8 +79,7 @@ void ED_undo_push(bContext *C, const char *str) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); @@ -106,12 +105,12 @@ void ED_undo_push(bContext *C, const char *str) else if (obedit->type == OB_ARMATURE) undo_push_armature(C, str); } - else if (obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) { + else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) { if (U.undosteps == 0) return; PE_undo_push(CTX_data_scene(C), CTX_data_view_layer(C), str); } - else if (obact && eval_ctx.object_mode & OB_MODE_SCULPT) { + else if (obact && workspace->object_mode & OB_MODE_SCULPT) { /* do nothing for now */ } else { @@ -124,8 +123,7 @@ void ED_undo_push(bContext *C, const char *str) /* note: also check undo_history_exec() in bottom if you change notifiers */ static int ed_undo_step(bContext *C, int step, const char *undoname) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); Main *bmain = CTX_data_main(C); @@ -149,7 +147,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) if (sa && (sa->spacetype == SPACE_IMAGE)) { SpaceImage *sima = (SpaceImage *)sa->spacedata.first; - if ((obact && (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { + if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) { if (U.uiflag & USER_GLOBALUNDO) { ED_viewport_render_kill_jobs(wm, bmain, true); @@ -183,13 +181,13 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) * That was inconsistent with editmode, and also makes for * unecessarily tricky interaction with the other undo * systems. */ - if (obact && eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + if (obact && workspace->object_mode & OB_MODE_TEXTURE_PAINT) { ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname); } - else if (obact && eval_ctx.object_mode & OB_MODE_SCULPT) { + else if (obact && workspace->object_mode & OB_MODE_SCULPT) { ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname); } - else if (obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) { + else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) { if (step == 1) PE_undo(scene, view_layer); else @@ -275,9 +273,7 @@ void ED_undo_pop_op(bContext *C, wmOperator *op) /* name optionally, function used to check for operator redo panel */ bool ED_undo_is_valid(const bContext *C, const char *undoname) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - + const WorkSpace *workspace = CTX_wm_workspace(C); Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); ScrArea *sa = CTX_wm_area(C); @@ -285,7 +281,7 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname) if (sa && sa->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sa->spacedata.first; - if ((obact && (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { + if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { return 1; } } @@ -302,15 +298,15 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname) /* if below tests fail, global undo gets executed */ - if (obact && eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + if (obact && workspace->object_mode & OB_MODE_TEXTURE_PAINT) { if (ED_undo_paint_is_valid(UNDO_PAINT_IMAGE, undoname)) return 1; } - else if (obact && eval_ctx.object_mode & OB_MODE_SCULPT) { + else if (obact && workspace->object_mode & OB_MODE_SCULPT) { if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname)) return 1; } - else if (obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) { + else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) { return PE_undo_is_valid(CTX_data_scene(C), CTX_data_view_layer(C)); } @@ -506,8 +502,7 @@ enum { static int get_undo_system(bContext *C) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); ScrArea *sa = CTX_wm_area(C); @@ -516,7 +511,7 @@ static int get_undo_system(bContext *C) if (sa && (sa->spacetype == SPACE_IMAGE)) { SpaceImage *sima = (SpaceImage *)sa->spacedata.first; - if ((obact && (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { + if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE)) return UNDOSYSTEM_IMAPAINT; } @@ -529,13 +524,13 @@ static int get_undo_system(bContext *C) } else { if (obact) { - if (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) + if (workspace->object_mode & OB_MODE_PARTICLE_EDIT) return UNDOSYSTEM_PARTICLE; - else if (eval_ctx.object_mode & OB_MODE_TEXTURE_PAINT) { + else if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) { if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE)) return UNDOSYSTEM_IMAPAINT; } - else if (eval_ctx.object_mode & OB_MODE_SCULPT) { + else if (workspace->object_mode & OB_MODE_SCULPT) { if (!ED_undo_paint_empty(UNDO_PAINT_MESH)) return UNDOSYSTEM_SCULPT; } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 195db6ec429..270d9fe14ca 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -38,6 +38,7 @@ #include "DNA_property_types.h" #include "DNA_scene_types.h" #include "DNA_meta_types.h" +#include "DNA_workspace_types.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" @@ -1395,9 +1396,8 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report const char *name, int type) { Main *bmain = CTX_data_main(C); - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - return ED_object_modifier_add(reports, bmain, CTX_data_scene(C), object, eval_ctx.object_mode, name, type); + const WorkSpace *workspace = CTX_wm_workspace(C); + return ED_object_modifier_add(reports, bmain, CTX_data_scene(C), object, workspace->object_mode, name, type); } static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 90c653fdf2a..2c3f90d718b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1703,11 +1703,10 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons static void rna_UnifiedPaintSettings_update(bContext *C, PointerRNA *UNUSED(ptr)) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, eval_ctx.object_mode)); + Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer, workspace->object_mode)); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index 5eb6fcdba22..24e79b71c0a 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -35,6 +35,7 @@ #include "DNA_texture_types.h" #include "DNA_node_types.h" #include "DNA_space_types.h" +#include "DNA_workspace_types.h" #include "BLI_listbase.h" #include "BLI_threads.h" @@ -62,8 +63,7 @@ static void texture_get_from_context( const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); + const WorkSpace *workspace = CTX_wm_workspace(C); SpaceNode *snode = CTX_wm_space_node(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -98,7 +98,7 @@ static void texture_get_from_context( else if (snode->texfrom == SNODE_TEX_BRUSH) { struct Brush *brush = NULL; - if (ob && (eval_ctx.object_mode & OB_MODE_SCULPT)) + if (ob && (workspace->object_mode & OB_MODE_SCULPT)) brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint); else brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint); |