Object Mode: Add to EvaluationContext & DRWContextState
authorCampbell Barton <ideasman42@gmail.com>
Tue, 6 Feb 2018 05:10:03 +0000 (16:10 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 6 Feb 2018 07:03:28 +0000 (18:03 +1100)
19 files changed:
source/blender/blenkernel/intern/context.c
source/blender/depsgraph/DEG_depsgraph.h
source/blender/depsgraph/intern/depsgraph_eval.cc
source/blender/draw/DRW_engine.h
source/blender/draw/engines/clay/clay_engine.c
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/eevee/eevee_motion_blur.c
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_armature.c
source/blender/draw/intern/draw_common.c
source/blender/draw/intern/draw_common.h
source/blender/draw/intern/draw_manager.c
source/blender/draw/intern/draw_view.c
source/blender/draw/modes/object_mode.c
source/blender/draw/modes/pose_mode.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_snap_object.c

index 7d4cbd163318add83b748ea352abc920f2ea3e96..ba69ecfb7f1529c8f9ffed9e899e79bed69e59f6 100644 (file)
@@ -1273,8 +1273,10 @@ void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
 
        Scene *scene = CTX_data_scene(C);
        ViewLayer *view_layer = CTX_data_view_layer(C);
+       Object *obact = OBACT(view_layer);
        RenderEngineType *engine_type = CTX_data_engine_type(C);
-       DEG_evaluation_context_init_from_scene(eval_ctx,
-                                              scene, view_layer, engine_type,
-                                              DAG_EVAL_VIEWPORT);
+       DEG_evaluation_context_init_from_scene(
+               eval_ctx,
+               scene, view_layer, engine_type,
+               obact ? obact->mode : OB_MODE_OBJECT, DAG_EVAL_VIEWPORT);
 }
index 4d3f36b5fba3fe7bc30dadf40092e2921428ee1a..e3d379666a07b7a024d771a53c279d5844f22084 100644 (file)
@@ -83,6 +83,7 @@ typedef enum eEvaluationMode {
 typedef struct EvaluationContext {
        eEvaluationMode mode;
        float ctime;
+       short object_mode;
 
        struct Depsgraph *depsgraph;
        struct ViewLayer *view_layer;
@@ -213,11 +214,13 @@ struct EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode);
  */
 void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
                                  eEvaluationMode mode);
-void DEG_evaluation_context_init_from_scene(struct EvaluationContext *eval_ctx,
-                                            struct Scene *scene,
-                                            struct ViewLayer *view_layer,
-                                            struct RenderEngineType *engine_type,
-                                            eEvaluationMode mode);
+void DEG_evaluation_context_init_from_scene(
+        struct EvaluationContext *eval_ctx,
+        struct Scene *scene,
+        struct ViewLayer *view_layer,
+        struct RenderEngineType *engine_type,
+        const short object_mode,
+        eEvaluationMode mode);
 
 /* Free evaluation context. */
 void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
index ad1a850a8073dbb323da836eacc1bbf75e223135..d7d12bc6968fdaae02ec847efe069768c58f9b79 100644 (file)
@@ -76,17 +76,20 @@ void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
        eval_ctx->mode = mode;
 }
 
-void DEG_evaluation_context_init_from_scene(EvaluationContext *eval_ctx,
-                                            Scene *scene,
-                                            ViewLayer *view_layer,
-                                            RenderEngineType *engine_type,
-                                            eEvaluationMode mode)
+void DEG_evaluation_context_init_from_scene(
+        EvaluationContext *eval_ctx,
+        Scene *scene,
+        ViewLayer *view_layer,
+        RenderEngineType *engine_type,
+        short object_mode,
+        eEvaluationMode mode)
 {
        DEG_evaluation_context_init(eval_ctx, mode);
        eval_ctx->depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
        eval_ctx->view_layer = view_layer;
        eval_ctx->engine_type = engine_type;
        eval_ctx->ctime = BKE_scene_frame_get(scene);
+       eval_ctx->object_mode = object_mode;
 }
 
 /* Free evaluation context. */
index c4946e2a4b8117d19f46935c9483dace1d85550f..30470b227b44ed769d2b9a23657b6affdb80421a 100644 (file)
@@ -91,25 +91,25 @@ void DRW_draw_view(const struct bContext *C);
 void DRW_draw_render_loop_ex(
         struct Depsgraph *depsgraph,
         struct RenderEngineType *engine_type,
-        struct ARegion *ar, struct View3D *v3d,
+        struct ARegion *ar, struct View3D *v3d, const short object_mode,
         const struct bContext *evil_C);
 void DRW_draw_render_loop(
         struct Depsgraph *depsgraph,
-        struct ARegion *ar, struct View3D *v3d);
+        struct ARegion *ar, struct View3D *v3d, const short object_mode);
 void DRW_draw_render_loop_offscreen(
         struct Depsgraph *depsgraph,
         struct RenderEngineType *engine_type,
-        struct ARegion *ar, struct View3D *v3d,
+        struct ARegion *ar, struct View3D *v3d, const short object_mode,
         const bool draw_background,
         struct GPUOffScreen *ofs,
         struct GPUViewport *viewport);
 void DRW_draw_select_loop(
         struct Depsgraph *depsgraph,
-        struct ARegion *ar, struct View3D *v3d,
+        struct ARegion *ar, struct View3D *v3d, const short object_mode,
         bool use_obedit_skip, bool use_nearest, const struct rcti *rect);
 void DRW_draw_depth_loop(
         struct Depsgraph *depsgraph,
-        struct ARegion *ar, struct View3D *v3d);
+        struct ARegion *ar, struct View3D *v3d, const short object_mode);
 
 /* This is here because GPUViewport needs it */
 void DRW_pass_free(struct DRWPass *pass);
index d2bf164efdc6bb6261aab456766c8f2c4c39a602..b9a372f802d193fd7c618eb741e392a532f8c8c0 100644 (file)
@@ -820,7 +820,7 @@ static void clay_cache_populate(void *vedata, Object *ob)
        if (geom) {
                IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
                const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
-               const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
+               const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
                const bool is_default_mode_shader = is_sculpt_mode;
 
                /* Depth Prepass */
index 88caaf2a75cc6f2b41dcf7cba3c2ac45c4d78d25..9754bfbd78bf691388e8037623a3098cc85f3bda 100644 (file)
@@ -1241,7 +1241,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
        IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
        const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
        const bool is_active = (ob == draw_ctx->obact);
-       const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
+       const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
 #if 0
        const bool is_sculpt_mode_draw = is_sculpt_mode && (draw_ctx->v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0;
 #else
index 037bbe3b6c97d87f3498935f0fc978914fe13172..53fff5de50e1043d1e537a9b28687d266d628961 100644 (file)
@@ -79,6 +79,7 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
                scene,
                draw_ctx->view_layer,
                draw_ctx->engine_type,
+               draw_ctx->object_mode,
                DAG_EVAL_VIEWPORT);
        eval_ctx.ctime = time;
 
index 528495b8710177743a94084ca5f9331e293a35f1..cad99d5e7ab9d3f871dee4932bcc9a7bb05d0a75 100644 (file)
@@ -455,6 +455,7 @@ struct DRWTextStore *DRW_state_text_cache_get(void);
 
 /* Avoid too many lookups while drawing */
 typedef struct DRWContextState {
+
        struct ARegion *ar;         /* 'CTX_wm_region(C)' */
        struct RegionView3D *rv3d;  /* 'CTX_wm_region_view3d(C)' */
        struct View3D *v3d;     /* 'CTX_wm_view3d(C)' */
@@ -469,9 +470,12 @@ typedef struct DRWContextState {
 
        struct Depsgraph *depsgraph;
 
+       short object_mode;
+
        /* Last resort (some functions take this as an arg so we can't easily avoid).
         * May be NULL when used for selection or depth buffer. */
        const struct bContext *evil_C;
+
 } DRWContextState;
 
 const DRWContextState *DRW_context_state_get(void);
index 09fe3d686514a008e69118592314588d729d6917..5daafadada61299a5b464a659efc8d3dd0bf419a 100644 (file)
@@ -1308,7 +1308,9 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
 
        // if (!(base->flag & OB_FROMDUPLI)) // TODO
        {
-               if (ob->mode & OB_MODE_POSE) {
+               const DRWContextState *draw_ctx = DRW_context_state_get();
+
+               if (draw_ctx->object_mode & OB_MODE_POSE) {
                        arm->flag |= ARM_POSEMODE;
                }
 
index 0eb97a54ba593787be2ba1152b7a93fd40d1682f..4bd138e80f54a8b0e8fd542fe39bca82da4a16df 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "draw_common.h"
 
-
 #if 0
 #define UI_COLOR_RGB_FROM_U8(r, g, b, v4) \
        ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0)
@@ -386,7 +385,8 @@ DRWShadingGroup *shgroup_instance_mball_helpers(DRWPass *pass, struct Gwn_Batch
  */
 int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color)
 {
-       const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
+       const DRWContextState *draw_ctx = DRW_context_state_get();
+       const bool is_edit = (draw_ctx->object_mode & OB_MODE_EDIT) != 0;
        const bool active = (view_layer->basact && view_layer->basact->object == ob);
        /* confusing logic here, there are 2 methods of setting the color
         * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
index cfd88effd1587d67c0916f9dd1012c61c9e249b5..7ff11f5f069bb6a15c1b66a2aa310085a40fc871 100644 (file)
@@ -120,7 +120,8 @@ struct DRWShadingGroup *shgroup_instance_bone_envelope_wire(struct DRWPass *pass
 struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, struct Gwn_Batch *geom);
 struct DRWShadingGroup *shgroup_instance_mball_helpers(struct DRWPass *pass, struct Gwn_Batch *geom);
 
-int DRW_object_wire_theme_get(struct Object *ob, struct ViewLayer *view_layer, float **r_color);
+int DRW_object_wire_theme_get(
+        struct Object *ob, struct ViewLayer *view_layer, float **r_color);
 float *DRW_color_background_blend_get(int theme_id);
 
 /* draw_armature.c */
index e6064c202ae2690d02c21b3c398ac7f084a117e5..af42aacbc50533700ed833025120432c75eda7db 100644 (file)
@@ -2257,8 +2257,8 @@ bool DRW_object_is_flat_normal(const Object *ob)
 int DRW_object_is_mode_shade(const Object *ob)
 {
        BLI_assert(ob == DST.draw_ctx.obact);
-       if ((ob->mode & OB_MODE_EDIT) == 0) {
-               if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+       if ((DST.draw_ctx.object_mode & OB_MODE_EDIT) == 0) {
+               if (DST.draw_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
                        if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) {
                                return true;
                        }
@@ -3329,7 +3329,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
 
        DST.viewport = rv3d->viewport;
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph,
+               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, OB_MODE_OBJECT,
                NULL,
        };
 
@@ -3376,7 +3376,7 @@ void DRW_notify_id_update(const DRWUpdateContext *update_ctx, ID *id)
        memset(&DST, 0x0, sizeof(DST));
        DST.viewport = rv3d->viewport;
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, NULL,
+               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, OB_MODE_OBJECT, NULL,
        };
        drw_engines_enable(scene, view_layer, engine_type);
        for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
@@ -3402,14 +3402,15 @@ void DRW_notify_id_update(const DRWUpdateContext *update_ctx, ID *id)
  * for each relevant engine / mode engine. */
 void DRW_draw_view(const bContext *C)
 {
-       struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+       EvaluationContext eval_ctx;
+       CTX_data_eval_ctx(C, &eval_ctx);
        RenderEngineType *engine_type = CTX_data_engine_type(C);
        ARegion *ar = CTX_wm_region(C);
        View3D *v3d = CTX_wm_view3d(C);
 
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
-       DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, C);
+       DRW_draw_render_loop_ex(eval_ctx.depsgraph, engine_type, ar, v3d, eval_ctx.object_mode, C);
 }
 
 /**
@@ -3419,7 +3420,7 @@ void DRW_draw_view(const bContext *C)
 void DRW_draw_render_loop_ex(
         struct Depsgraph *depsgraph,
         RenderEngineType *engine_type,
-        ARegion *ar, View3D *v3d,
+        ARegion *ar, View3D *v3d, const short object_mode,
         const bContext *evil_C)
 {
        Scene *scene = DEG_get_evaluated_scene(depsgraph);
@@ -3435,7 +3436,7 @@ void DRW_draw_render_loop_ex(
        GPU_viewport_engines_data_validate(DST.viewport, DRW_engines_get_hash());
 
        DST.draw_ctx = (DRWContextState){
-           ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph,
+           ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, object_mode,
 
            /* reuse if caller sets */
            DST.draw_ctx.evil_C,
@@ -3544,7 +3545,7 @@ void DRW_draw_render_loop_ex(
 
 void DRW_draw_render_loop(
         struct Depsgraph *depsgraph,
-        ARegion *ar, View3D *v3d)
+        ARegion *ar, View3D *v3d, const short object_mode)
 {
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
@@ -3552,13 +3553,14 @@ void DRW_draw_render_loop(
        Scene *scene = DEG_get_evaluated_scene(depsgraph);
        RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
 
-       DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
+       DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, object_mode, NULL);
 }
 
 /* @viewport CAN be NULL, in this case we create one. */
 void DRW_draw_render_loop_offscreen(
         struct Depsgraph *depsgraph, RenderEngineType *engine_type,
-        ARegion *ar, View3D *v3d, const bool draw_background, GPUOffScreen *ofs,
+        ARegion *ar, View3D *v3d, const short object_mode,
+        const bool draw_background, GPUOffScreen *ofs,
         GPUViewport *viewport)
 {
        RegionView3D *rv3d = ar->regiondata;
@@ -3579,7 +3581,7 @@ void DRW_draw_render_loop_offscreen(
        memset(&DST, 0x0, sizeof(DST));
        DST.options.is_image_render = true;
        DST.options.draw_background = draw_background;
-       DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
+       DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, object_mode, NULL);
 
        /* restore */
        {
@@ -3605,6 +3607,7 @@ void DRW_render_to_image(RenderEngine *re, struct Depsgraph *depsgraph)
        DrawEngineType *draw_engine_type = engine_type->draw_engine;
        RenderData *r = &scene->r;
        Render *render = re->re;
+       const EvaluationContext *eval_ctx = RE_GetEvalCtx(render);
 
        /* Reset before using it. */
        memset(&DST, 0x0, sizeof(DST));
@@ -3613,7 +3616,7 @@ void DRW_render_to_image(RenderEngine *re, struct Depsgraph *depsgraph)
        DST.options.draw_background = scene->r.alphamode == R_ADDSKY;
 
        DST.draw_ctx = (DRWContextState){
-           NULL, NULL, NULL, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, NULL
+           NULL, NULL, NULL, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, eval_ctx->object_mode, NULL,
        };
 
        DST.viewport = GPU_viewport_create();
@@ -3681,7 +3684,7 @@ void DRW_render_object_iter(
  */
 void DRW_draw_select_loop(
         struct Depsgraph *depsgraph,
-        ARegion *ar, View3D *v3d,
+        ARegion *ar, View3D *v3d, const short object_mode,
         bool UNUSED(use_obedit_skip), bool UNUSED(use_nearest), const rcti *rect)
 {
        Scene *scene = DEG_get_evaluated_scene(depsgraph);
@@ -3737,7 +3740,8 @@ void DRW_draw_select_loop(
 
        /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, (bContext *)NULL,
+               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, object_mode,
+               (bContext *)NULL,
        };
 
        drw_viewport_var_init();
@@ -3802,7 +3806,7 @@ void DRW_draw_select_loop(
  */
 void DRW_draw_depth_loop(
         Depsgraph *depsgraph,
-        ARegion *ar, View3D *v3d)
+        ARegion *ar, View3D *v3d, const short object_mode)
 {
        Scene *scene = DEG_get_evaluated_scene(depsgraph);
        RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
@@ -3836,7 +3840,8 @@ void DRW_draw_depth_loop(
 
        /* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
        DST.draw_ctx = (DRWContextState){
-               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, (bContext *)NULL,
+               ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, object_mode,
+               (bContext *)NULL,
        };
 
        drw_viewport_var_init();
index 391c29e511f24b31f0ceb67ecacd0a4d8299e67f..1e1f9da3c97b114fe2dda57592d841fcbcc66c11 100644 (file)
@@ -611,20 +611,20 @@ void DRW_draw_background(void)
 
 /* **************************** 3D Cursor ******************************** */
 
-static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer)
+static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, ViewLayer *view_layer)
 {
        Object *ob = OBACT(view_layer);
 
        /* don't draw cursor in paint modes, but with a few exceptions */
-       if (ob && ob->mode & OB_MODE_ALL_PAINT) {
+       if (ob && draw_ctx->object_mode & OB_MODE_ALL_PAINT) {
                /* exception: object is in weight paint and has deforming armature in pose mode */
-               if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+               if (draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
                        if (BKE_object_pose_armature_get(ob) != NULL) {
                                return true;
                        }
                }
                /* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
-               else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+               else if (draw_ctx->object_mode & OB_MODE_TEXTURE_PAINT) {
                        const Paint *p = BKE_paint_get_active(scene, view_layer);
 
                        if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
@@ -654,7 +654,7 @@ void DRW_draw_cursor(void)
        glDisable(GL_DEPTH_TEST);
        glLineWidth(1.0f);
 
-       if (is_cursor_visible(scene, view_layer)) {
+       if (is_cursor_visible(draw_ctx, scene, view_layer)) {
                float *co = ED_view3d_cursor3d_get(scene, v3d);
                unsigned char crosshair_color[3];
 
index d7778a0aba94be68505d851bf363b85b69fe0298..b1e0eddfc467b0fae7a80d7abc20fc13913e0d97 100644 (file)
@@ -1811,7 +1811,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
 
        if (do_outlines) {
                Object *obedit = scene->obedit;
-               if (ob != obedit && !((ob == draw_ctx->obact) && (ob->mode & OB_MODE_ALL_PAINT))) {
+               if (ob != obedit && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) {
                        struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
                        if (geom) {
                                theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
index 560773f2d0581ee419fa651d56e5dc65e8028bc8..1589ff39bdfcc54c40b1b63911ebcace2598f723 100644 (file)
@@ -136,13 +136,15 @@ static void POSE_cache_populate(void *vedata, Object *ob)
  */
 bool DRW_pose_mode_armature(Object *ob, Object *active_ob)
 {
+       const DRWContextState *draw_ctx = DRW_context_state_get();
+
        /* Pode armature is handled by pose mode engine. */
-       if ((ob == active_ob) && ((ob->mode & OB_MODE_POSE) != 0)) {
+       if ((ob == active_ob) && ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) {
                return true;
        }
 
        /* Armature parent is also handled by pose mode engine. */
-       if ((active_ob != NULL) && ((active_ob->mode & OB_MODE_WEIGHT_PAINT) != 0)) {
+       if ((active_ob != NULL) && ((draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) != 0)) {
                if (active_ob->parent == ob) {
                        return true;
                }
index f734bb085d035dabbcae3f89e4e5347139198067..3c4cc4d11b965a4d3d1b2329e61941e7e80e682e 100644 (file)
@@ -752,7 +752,7 @@ void ED_view3d_draw_depth(
        else
 #endif /* WITH_OPENGL_LEGACY */
        {
-               DRW_draw_depth_loop(graph, ar, v3d);
+               DRW_draw_depth_loop(graph, ar, v3d, eval_ctx->object_mode);
        }
 
        if (rv3d->rflag & RV3D_CLIPPING) {
@@ -2076,7 +2076,9 @@ void ED_view3d_draw_offscreen(
                }
        }
        else {
-               DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine_type, ar, v3d, do_sky, ofs, viewport);
+               DRW_draw_render_loop_offscreen(
+                       depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode,
+                       do_sky, ofs, viewport);
        }
 
        /* restore size */
index 0597f2806b38150d1dbd98ac62db7895893ccdc7..779c2cc53d428b15b38103f99bfe5c84a3693685 100644 (file)
@@ -954,7 +954,9 @@ int view3d_opengl_select(
        else
 #else
        {
-               DRW_draw_select_loop(graph, ar, v3d, use_obedit_skip, use_nearest, &rect);
+               DRW_draw_select_loop(
+                       graph, ar, v3d, eval_ctx->object_mode,
+                       use_obedit_skip, use_nearest, &rect);
        }
 #endif /* WITH_OPENGL_LEGACY */
 
@@ -971,7 +973,9 @@ int view3d_opengl_select(
                else
 #else
                {
-                       DRW_draw_select_loop(graph, ar, v3d, use_obedit_skip, use_nearest, &rect);
+                       DRW_draw_select_loop(
+                               graph, ar, v3d, eval_ctx->object_mode,
+                               use_obedit_skip, use_nearest, &rect);
                }
 #endif /* WITH_OPENGL_LEGACY */
 
index 730ca70547bf811dea12b6467944090e3513413f..6c55967fc8f98724991f21776b3e3a87c4776734 100644 (file)
@@ -2482,9 +2482,10 @@ static void createTransEditVerts(TransInfo *t)
        int island_info_tot;
        int *island_vert_map = NULL;
 
-       DEG_evaluation_context_init_from_scene(&eval_ctx,
-                                              t->scene, t->view_layer, t->engine_type,
-                                              DAG_EVAL_VIEWPORT);
+       DEG_evaluation_context_init_from_scene(
+               &eval_ctx,
+               t->scene, t->view_layer, t->engine_type, t->obedit->mode,
+               DAG_EVAL_VIEWPORT);
 
        /* Even for translation this is needed because of island-orientation, see: T51651. */
        const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
index 8f0590eb5b9e1566d60d42cdd004b9091a3ce3f9..07b45d58f377e21df23f470563ca6f06b3dd40dd 100644 (file)
@@ -2096,7 +2096,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
        sctx->bmain = bmain;
        sctx->scene = scene;
 
-       DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, view_layer, engine_type, DAG_EVAL_VIEWPORT);
+       Object *obact = OBACT(view_layer);
+
+       DEG_evaluation_context_init_from_scene(
+               &sctx->eval_ctx, scene, view_layer, engine_type,
+               obact ? obact->mode : OB_MODE_OBJECT, DAG_EVAL_VIEWPORT);
 
        sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
        sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);