diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-06 09:06:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-06 10:03:28 +0300 |
commit | c7fecab2efd3b28a18b56dbd321616728d8b7cce (patch) | |
tree | 0169ab63925ce3d6730f519a4a54822e7f77c652 /source/blender/editors/space_view3d | |
parent | ef11113399e3273ee647b3710b346356a2b5f8f0 (diff) |
Object Mode: Use eval_ctx mode for drawing, paint & modifiers
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 209 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw_legacy.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 26 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 76 |
8 files changed, 266 insertions, 186 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index f8f2d5598de..ce36d9b58c4 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -59,6 +59,8 @@ #include "UI_resources.h" +#include "DEG_depsgraph.h" + #include "GPU_draw.h" #include "GPU_material.h" #include "GPU_basic_shader.h" @@ -325,8 +327,10 @@ void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm, } } -void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, - Object *ob, DerivedMesh *dm, const int draw_flags) +void draw_mesh_paint( + const EvaluationContext *eval_ctx, + View3D *v3d, RegionView3D *rv3d, + Object *ob, DerivedMesh *dm, const int draw_flags) { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; @@ -336,21 +340,21 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL)) facemask = wpaint__setSolidDrawOptions_facemask; - if (ob->mode & OB_MODE_WEIGHT_PAINT) { + if (eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { draw_mesh_paint_weight_faces(dm, use_light, facemask, me); } - else if (ob->mode & OB_MODE_VERTEX_PAINT) { + else if (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) { draw_mesh_paint_vcolor_faces(dm, use_light, facemask, me, me); } /* draw face selection on top */ if (draw_flags & DRAW_FACE_SELECT) { - bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0; + bool draw_select_edges = (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) == 0; draw_mesh_face_select(rv3d, me, dm, draw_select_edges); } else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) { - const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT); - const bool use_alpha = (ob->mode & OB_MODE_VERTEX_PAINT) == 0; + const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT); + const bool use_alpha = (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT) == 0; if (use_alpha == false) { set_inverted_drawing(1); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 51dc56bafaf..8bbbc4ac489 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -314,13 +314,15 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) /* check for glsl drawing */ -bool draw_glsl_material(Scene *scene, ViewLayer *view_layer, Object *ob, View3D *v3d, const char dt) +bool draw_glsl_material( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + Object *ob, View3D *v3d, const char dt) { if (G.f & G_PICKSEL) return false; if (!check_object_draw_texture(scene, v3d, dt)) return false; - if (ob == OBACT(view_layer) && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) + if (ob == OBACT(view_layer) && (ob && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT)) return false; if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) @@ -334,7 +336,7 @@ bool draw_glsl_material(Scene *scene, ViewLayer *view_layer, Object *ob, View3D return false; } -static bool check_alpha_pass(Base *base) +static bool check_alpha_pass(const EvaluationContext *eval_ctx, Base *base) { if (base->flag_legacy & OB_FROMDUPLI) return false; @@ -342,8 +344,9 @@ static bool check_alpha_pass(Base *base) if (G.f & G_PICKSEL) return false; - if (base->object->mode & OB_MODE_ALL_PAINT) + if (eval_ctx->object_mode & OB_MODE_ALL_PAINT) { return false; + } return (base->object->dtx & OB_DRAWTRANSP); } @@ -3892,8 +3895,9 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index) } } -static void draw_em_fancy(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, - Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt) +static void draw_em_fancy( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, + Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt) { RegionView3D *rv3d = ar->regiondata; @@ -3930,7 +3934,7 @@ static void draw_em_fancy(Scene *scene, ViewLayer *view_layer, ARegion *ar, View glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } else if (check_object_draw_texture(scene, v3d, dt)) { - if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { + if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) { glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind, @@ -4223,10 +4227,12 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D /* Mesh drawing routines */ -void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */ +void draw_mesh_object_outline( + const EvaluationContext *eval_ctx, View3D *v3d, + Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */ { if ((v3d->transp == false) && /* not when we draw the transparent pass */ - (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ + (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(GL_FALSE); @@ -4249,10 +4255,12 @@ void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const un } } -static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object *ob, Mesh *me, const bool is_active) +static void draw_mesh_object_outline_new( + const EvaluationContext *eval_ctx, View3D *v3d, RegionView3D *rv3d, + Mesh *me, const bool is_active) { if ((v3d->transp == false) && /* not when we draw the transparent pass */ - (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ + (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(GL_FALSE); @@ -4302,7 +4310,9 @@ static void draw_mesh_fancy( const char dt, const unsigned char ob_wire_col[4], const short dflag) { #ifdef WITH_GAMEENGINE - Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object; + Object *ob = ( + (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? + BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object); #else Object *ob = base->object; #endif @@ -4311,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(ob)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(eval_ctx, ob)) ? DRAW_FACE_SELECT : 0; if (!dm) return; @@ -4349,7 +4359,7 @@ static void draw_mesh_fancy( draw_bounding_volume(ob, ob->boundtype, ob_wire_col); } else if ((no_faces && no_edges) || - ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) + ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) { glPointSize(1.5f); dm->drawVerts(dm); @@ -4357,7 +4367,7 @@ static void draw_mesh_fancy( else if ((dt == OB_WIRE) || no_faces) { draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */ } - else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || + else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) || check_object_draw_texture(scene, v3d, dt)) { bool draw_loose = true; @@ -4368,15 +4378,17 @@ static void draw_mesh_fancy( !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && (draw_wire == OBDRAW_WIRE_OFF)) { - draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); } - if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { Paint *p; glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && + (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) + { GPUVertexAttribs gattribs; float planes[4][4]; float (*fpl)[4] = NULL; @@ -4439,7 +4451,7 @@ static void draw_mesh_fancy( (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) { - draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); } /* materials arent compatible with vertex colors */ @@ -4463,12 +4475,12 @@ static void draw_mesh_fancy( (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) { - draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); } glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { + if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) { float planes[4][4]; float (*fpl)[4] = NULL; const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); @@ -4500,7 +4512,7 @@ static void draw_mesh_fancy( } } else if (dt == OB_PAINT) { - draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); + draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags); /* since we already draw wire as wp guide, don't draw over the top */ draw_wire = OBDRAW_WIRE_OFF; @@ -4515,7 +4527,7 @@ static void draw_mesh_fancy( * with the background. */ if ((dflag & DRAW_CONSTCOLOR) == 0) { - if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { + if (is_obact && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) { float color[3]; ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color); glColor3fv(color); @@ -4548,7 +4560,7 @@ static void draw_mesh_fancy( } } - if (is_obact && BKE_paint_select_vert_test(ob)) { + if (is_obact && BKE_paint_select_vert_test(eval_ctx, ob)) { const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); @@ -4617,13 +4629,13 @@ static bool draw_mesh_object( if (use_material) { if (dt > OB_WIRE) { - const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL); } } - draw_em_fancy(scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt); + draw_em_fancy(eval_ctx, scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt); if (use_material) { GPU_end_object_materials(); @@ -4636,12 +4648,13 @@ static bool draw_mesh_object( /* ob->bb was set by derived mesh system, do NULL check just to be sure */ if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) { if (dt > OB_WIRE) { - const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt); if (dt == OB_SOLID || glsl) { - const bool check_alpha = check_alpha_pass(base); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, - (check_alpha) ? &do_alpha_after : NULL); + const bool check_alpha = check_alpha_pass(eval_ctx, base); + GPU_begin_object_materials( + v3d, rv3d, scene, view_layer, ob, + glsl, eval_ctx->object_mode, (check_alpha) ? &do_alpha_after : NULL); } } @@ -4718,7 +4731,9 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL } #ifdef WITH_GAMEENGINE - Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object; + Object *ob = ( + (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? + BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object); #else Object *ob = base->object; #endif @@ -4727,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(ob)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(eval_ctx, ob)) ? DRAW_FACE_SELECT : 0; if (!dm) return; @@ -4770,7 +4785,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL draw_bounding_volume(ob, ob->boundtype, ob_wire_col); } else if ((no_faces && no_edges) || - ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) + ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) { glPointSize(1.5f); // dm->drawVerts(dm); @@ -4836,7 +4851,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL GWN_batch_draw(batch); #endif } - else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || + else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) || check_object_draw_texture(scene, v3d, dt)) { bool draw_loose = true; @@ -4847,15 +4862,17 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && (draw_wire == OBDRAW_WIRE_OFF)) { - draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer))); + draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer))); } - if (draw_glsl_material(scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { Paint *p; glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && + (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) + { GPUVertexAttribs gattribs; float planes[4][4]; float (*fpl)[4] = NULL; @@ -4914,7 +4931,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) { - draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer))); + draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer))); } /* materials arent compatible with vertex colors */ @@ -4939,12 +4956,12 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL (ob->sculpt == NULL)) { /* TODO: move this into a separate pass */ - draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer))); + draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer))); } glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { + if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode))) { float planes[4][4]; float (*fpl)[4] = NULL; const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); @@ -4976,7 +4993,7 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL } } else if (dt == OB_PAINT) { - draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); + draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags); /* since we already draw wire as wp guide, don't draw over the top */ draw_wire = OBDRAW_WIRE_OFF; @@ -5085,9 +5102,9 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scen DM_update_materials(cageDM, ob); } - const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(&eval_ctx, scene, view_layer, ob, v3d, dt); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx.object_mode, NULL); } draw_em_fancy_new(scene, ar, v3d, ob, me, em, cageDM, finalDM, dt); @@ -5103,12 +5120,13 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scen /* ob->bb was set by derived mesh system, do NULL check just to be sure */ if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) { if (solid) { - const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(&eval_ctx, scene, view_layer, ob, v3d, dt); if (dt == OB_SOLID || glsl) { - const bool check_alpha = check_alpha_pass(base); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, - (check_alpha) ? &do_alpha_after : NULL); + const bool check_alpha = check_alpha_pass(&eval_ctx, base); + GPU_begin_object_materials( + v3d, rv3d, scene, view_layer, ob, + eval_ctx.object_mode, glsl, (check_alpha) ? &do_alpha_after : NULL); } } @@ -5425,7 +5443,9 @@ static void drawCurveDMWired(Object *ob) } /* return true when nothing was drawn */ -static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt) +static bool drawCurveDerivedMesh( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, + Base *base, const char dt) { Object *ob = base->object; DerivedMesh *dm = ob->derivedFinal; @@ -5439,8 +5459,10 @@ static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3 glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); if (dt > OB_WIRE && dm->getNumPolys(dm)) { - bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); + bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt); + GPU_begin_object_materials( + v3d, rv3d, scene, view_layer, ob, + eval_ctx->object_mode, glsl, NULL); if (!glsl) dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); @@ -5461,8 +5483,9 @@ static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3 * Only called by #drawDispList * \return true when nothing was drawn */ -static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const short dflag, const unsigned char ob_wire_col[4]) +static bool drawDispList_nobackface( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, + Base *base, const char dt, const short dflag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; ListBase *lb = NULL; @@ -5502,13 +5525,13 @@ static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D /* pass */ } else { - if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL); + if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) { + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, true); GPU_end_object_materials(); } else { - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } @@ -5537,13 +5560,13 @@ static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D if (dl->nors == NULL) BKE_displist_normals_add(lb); - if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL); + if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) { + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, true); GPU_end_object_materials(); } else { - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } @@ -5562,13 +5585,13 @@ static bool drawDispList_nobackface(Scene *scene, ViewLayer *view_layer, View3D if (solid) { - if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, NULL); + if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) { + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, eval_ctx->object_mode, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, true); GPU_end_object_materials(); } else { - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, eval_ctx->object_mode, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } @@ -5599,7 +5622,7 @@ static bool drawDispList( ensure_curve_cache(eval_ctx, scene, base->object); #endif - if (drawCurveDerivedMesh(scene, view_layer, v3d, rv3d, base, dt) == false) { + if (drawCurveDerivedMesh(eval_ctx, scene, view_layer, v3d, rv3d, base, dt) == false) { retval = false; } else { @@ -5615,7 +5638,7 @@ static bool drawDispList( glFrontFace(mode); - retval = drawDispList_nobackface(scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col); + retval = drawDispList_nobackface(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col); if (mode != GL_CCW) { glFrontFace(GL_CCW); @@ -5939,7 +5962,7 @@ static void draw_new_particle_system( if (pars == NULL) return; /* don't draw normal paths in edit mode */ - if (psys_in_edit_mode(eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0) + if (psys_in_edit_mode(eval_ctx, eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0) return; if (part->draw_as == PART_DRAW_REND) @@ -8296,7 +8319,7 @@ static void draw_object_selected_outline( if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->bb)) { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); if (dm) { - draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); } else { /* only draw 'solid' parts of the display list as wire. */ @@ -8313,7 +8336,7 @@ static void draw_object_selected_outline( } } else if (ob->type == OB_ARMATURE) { - if (!(ob->mode & OB_MODE_POSE && base == view_layer->basact)) { + if (!(eval_ctx->object_mode & OB_MODE_POSE && base == view_layer->basact)) { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); draw_armature(eval_ctx, scene, view_layer, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true); } @@ -8423,11 +8446,13 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, immUnbindProgram(); } -void draw_object_wire_color(Scene *scene, ViewLayer *view_layer, Base *base, unsigned char r_ob_wire_col[4]) +void draw_object_wire_color( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + Base *base, unsigned char r_ob_wire_col[4]) { Object *ob = base->object; int colindex = 0; - const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0; + const bool is_edit = (eval_ctx->object_mode & OB_MODE_EDIT) != 0; /* confusing logic here, there are 2 methods of setting the color * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id. * @@ -8489,10 +8514,12 @@ void draw_object_wire_color(Scene *scene, ViewLayer *view_layer, Base *base, uns r_ob_wire_col[3] = 255; } -static void draw_object_matcap_check(View3D *v3d, Object *ob) +static void draw_object_matcap_check( + const EvaluationContext *eval_ctx, View3D *v3d, Object *ob) { /* fixed rule, active object draws as matcap */ - BLI_assert((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0); + BLI_assert((eval_ctx->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0); + UNUSED_VARS_NDEBUG(eval_ctx); (void)ob; if (v3d->defmaterial == NULL) { @@ -8604,7 +8631,7 @@ void draw_object( return; } - if (ob->mode == OB_MODE_OBJECT) { + if (eval_ctx->object_mode == OB_MODE_OBJECT) { ParticleSystem *psys; skip_object = render_override; @@ -8644,7 +8671,7 @@ void draw_object( /* xray delay? */ if ((dflag & DRAW_PICKING) == 0 && (base->flag_legacy & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) { /* don't do xray in particle mode, need the z-buffer */ - if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { + if (!(eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ if (!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) { ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag); @@ -8695,7 +8722,7 @@ void draw_object( ED_view3d_project_base(ar, base); - draw_object_wire_color(scene, view_layer, base, _ob_wire_col); + draw_object_wire_color(eval_ctx, scene, view_layer, base, _ob_wire_col); ob_wire_col = _ob_wire_col; //glColor3ubv(ob_wire_col); @@ -8711,14 +8738,14 @@ void draw_object( /* faceselect exception: also draw solid when (dt == wire), except in editmode */ if (is_obact) { - if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) { + if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) { if (ob->type == OB_MESH) { if (dt < OB_SOLID) { zbufoff = true; dt = OB_SOLID; } - if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { + if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { dt = OB_PAINT; } @@ -8734,13 +8761,13 @@ void draw_object( (is_paint == false && is_picking == false) && ((v3d->flag2 & V3D_RENDER_SHADOW) == 0)) { - draw_object_matcap_check(v3d, ob); + draw_object_matcap_check(eval_ctx, v3d, ob); } /* draw-extra supported for boundbox drawmode too */ if (dt >= OB_BOUNDBOX) { dtx = ob->dtx; - if (ob->mode & OB_MODE_EDIT) { + if (eval_ctx->object_mode & OB_MODE_EDIT) { /* the only 2 extra drawtypes alowed in editmode */ dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE); } @@ -8749,7 +8776,7 @@ void draw_object( if (!skip_object) { /* draw outline for selected objects, mesh does itself */ if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) { - if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) { + if (dt > OB_WIRE && (eval_ctx->object_mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) { if (!(ob->dtx & OB_DRAWWIRE) && (base->flag & BASE_SELECTED) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) { draw_object_selected_outline(eval_ctx, scene, view_layer, v3d, ar, base, ob_wire_col); } @@ -8857,7 +8884,7 @@ void draw_object( case OB_LATTICE: if (!render_override) { /* Do not allow boundbox in edit nor pose mode! */ - if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT)) + if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & OB_MODE_EDIT)) dt = OB_WIRE; if (dt == OB_BOUNDBOX) { draw_bounding_volume(ob, ob->boundtype, ob_wire_col); @@ -8873,7 +8900,7 @@ void draw_object( case OB_ARMATURE: if (!render_override) { /* Do not allow boundbox in edit nor pose mode! */ - if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE))) + if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & (OB_MODE_EDIT | OB_MODE_POSE))) dt = OB_WIRE; if (dt == OB_BOUNDBOX) { draw_bounding_volume(ob, ob->boundtype, ob_wire_col); @@ -8941,7 +8968,7 @@ afterdraw: for (psys = ob->particlesystem.first; psys; psys = psys->next) { /* run this so that possible child particles get cached */ - if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { + if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) { PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob); if (edit && edit->psys == psys) draw_update_ptcache_edit(eval_ctx, scene, view_layer, ob, edit); @@ -8962,7 +8989,7 @@ afterdraw: (!scene->obedit)) { - if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { + if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) { PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob); if (edit) { gpuLoadMatrix(rv3d->viewmat); @@ -9063,7 +9090,7 @@ afterdraw: } } - if ((ob->gameflag & OB_BOUNDS) && (ob->mode == OB_MODE_OBJECT)) { + if ((ob->gameflag & OB_BOUNDS) && (eval_ctx->object_mode == OB_MODE_OBJECT)) { if (ob->boundtype != ob->collision_boundtype || (dtx & OB_DRAWBOUNDOX) == 0) { setlinestyle(2); draw_bounding_volume(ob, ob->collision_boundtype, ob_wire_col); @@ -9159,7 +9186,7 @@ afterdraw: } /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) { + if (!is_obact || !(eval_ctx->object_mode & OB_MODE_ALL_PAINT)) { int do_draw_center = -1; /* defines below are zero or positive... */ if (render_override) { @@ -9759,7 +9786,7 @@ void draw_object_backbufsel( switch (ob->type) { case OB_MESH: - if (ob->mode & OB_MODE_EDIT) { + if (eval_ctx->object_mode & OB_MODE_EDIT) { Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; @@ -9805,7 +9832,7 @@ void draw_object_backbufsel( Mesh *me = ob->data; if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) && /* currently vertex select supports weight paint and vertex paint*/ - ((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT))) + ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) || (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT))) { bbs_mesh_solid_verts(eval_ctx, scene, ob); } @@ -9834,7 +9861,7 @@ static void draw_object_mesh_instance( Mesh *me = ob->data; DerivedMesh *dm = NULL, *edm = NULL; - if (ob->mode & OB_MODE_EDIT) { + if (eval_ctx->object_mode & OB_MODE_EDIT) { edm = editbmesh_get_derived_base(ob, me->edit_btmesh, CD_MASK_BAREMESH); DM_update_materials(edm, ob); } @@ -9852,11 +9879,11 @@ static void draw_object_mesh_instance( } else { if (outline) - draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col); + draw_mesh_object_outline(eval_ctx, v3d, ob, dm ? dm : edm, ob_wire_col); if (dm) { - bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); + bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL); } glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 644a6956e54..b87637ef081 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -789,8 +789,11 @@ static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt)) { 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(ob))) + BKE_object_is_in_wpaint_select_vert(&eval_ctx, ob))) { MDeformVert *dvert_act = ED_mesh_active_dvert_get_only(ob); if (dvert_act) { @@ -1127,6 +1130,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; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1152,7 +1157,7 @@ static void view3d_panel_transform(const bContext *C, Panel *pa) v3d_editvertex_buts(col, v3d, ob, lim); } } - else if (ob->mode & OB_MODE_POSE) { + else if (eval_ctx.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 3c4cc4d11b9..af8a3369732 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1326,7 +1326,7 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) return v3d->grid * ED_scene_grid_scale(scene, grid_unit); } -static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer) +static bool is_cursor_visible(const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer) { if (U.app_flag & USER_APP_VIEW3D_HIDE_CURSOR) { return false; @@ -1335,16 +1335,16 @@ static bool is_cursor_visible(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 && eval_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 (eval_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) { - const Paint *p = BKE_paint_get_active(scene, view_layer); + else if (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) { + const Paint *p = BKE_paint_get_active(scene, view_layer, eval_ctx->object_mode); if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) { if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) { @@ -1718,7 +1718,8 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) * framenum, object name, bone name (if available), marker name (if available) */ -static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) +static void draw_selected_name( + const EvaluationContext *eval_ctx, Scene *scene, Object *ob, rcti *rect) { const int cfra = CFRA; const char *msg_pin = " (Pinned)"; @@ -1760,7 +1761,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) s += BLI_strcpy_rlen(s, arm->act_edbone->name); } } - else if (ob->mode & OB_MODE_POSE) { + else if (eval_ctx->object_mode & OB_MODE_POSE) { if (arm->act_bone) { if (arm->act_bone->layer & arm->layer) { @@ -1773,14 +1774,16 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) 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 && ob->mode & OB_MODE_WEIGHT_PAINT) { + if (ob->type == OB_MESH && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { Object *armobj = BKE_object_pose_armature_get(ob); - if (armobj && armobj->mode & OB_MODE_POSE) { + if (armobj) { bArmature *arm = armobj->data; - if (arm->act_bone) { - if (arm->act_bone->layer & arm->layer) { - s += BLI_strcpy_rlen(s, msg_sep); - s += BLI_strcpy_rlen(s, arm->act_bone->name); + if (arm->flag & ARM_POSEMODE) { + if (arm->act_bone) { + if (arm->act_bone->layer & arm->layer) { + s += BLI_strcpy_rlen(s, msg_sep); + s += BLI_strcpy_rlen(s, arm->act_bone->name); + } } } } @@ -1832,6 +1835,8 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) */ 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); @@ -1864,7 +1869,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int offset) if (U.uiflag & USER_DRAWVIEWINFO) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - draw_selected_name(scene, ob, &rect); + draw_selected_name(&eval_ctx, scene, ob, &rect); } #if 0 /* TODO */ if (grid_unit) { /* draw below the viewport name */ @@ -1951,7 +1956,7 @@ void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *sce RenderEngineType *engine_type = eval_ctx->engine_type; if (engine_type->flag & RE_USE_LEGACY_PIPELINE) { /* shadow buffers, before we setup matrices */ - if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype)) { + if (draw_glsl_material(eval_ctx, scene, view_layer, NULL, v3d, v3d->drawtype)) { VP_deprecated_gpu_update_lamps_shadows_world(eval_ctx, scene, v3d); } } @@ -2077,7 +2082,7 @@ void ED_view3d_draw_offscreen( } else { DRW_draw_render_loop_offscreen( - depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode, + eval_ctx->depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode, do_sky, ofs, viewport); } @@ -2354,9 +2359,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( * * \{ */ -void VP_legacy_drawcursor(Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d) +void VP_legacy_drawcursor( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d) { - if (is_cursor_visible(scene, view_layer)) { + if (is_cursor_visible(eval_ctx, scene, view_layer)) { drawcursor(scene, ar, v3d); } } @@ -2371,9 +2377,9 @@ void VP_legacy_draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) draw_viewport_name(ar, v3d, rect); } -void VP_legacy_draw_selected_name(Scene *scene, Object *ob, rcti *rect) +void VP_legacy_draw_selected_name(const EvaluationContext *eval_ctx, Scene *scene, Object *ob, rcti *rect) { - draw_selected_name(scene, ob, rect); + draw_selected_name(eval_ctx, scene, ob, 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 7cb362ffb92..5b7f7e78310 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -211,7 +211,9 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect) /* *********************** backdraw for selection *************** */ -static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, wmWindow *win, ARegion *ar, View3D *v3d) +static void backdrawview3d( + const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + wmWindow *win, ARegion *ar, View3D *v3d) { RegionView3D *rv3d = ar->regiondata; struct Base *base = view_layer->basact; @@ -219,18 +221,18 @@ static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scen BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); - if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || - BKE_paint_select_face_test(base->object))) + if (base && (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || + BKE_paint_select_face_test(eval_ctx, base->object))) { /* do nothing */ } /* texture paint mode sampling */ - else if (base && (base->object->mode & OB_MODE_TEXTURE_PAINT) && + else if (base && (eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT) && (v3d->drawtype > OB_WIRE)) { /* do nothing */ } - else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && + else if ((base && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) && V3D_IS_ZBUF(v3d)) { /* do nothing */ @@ -1946,8 +1948,9 @@ static void update_lods(Scene *scene, float camera_pos[3]) } #endif -static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d, - ARegion *ar, const char **grid_unit) +static void view3d_main_region_draw_objects( + const bContext *C, Scene *scene, ViewLayer *view_layer, View3D *v3d, + ARegion *ar, const char **grid_unit) { wmWindow *win = CTX_wm_window(C); EvaluationContext eval_ctx; @@ -1960,7 +1963,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie bool do_compositing = false; /* shadow buffers, before we setup matrices */ - if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype)) + if (draw_glsl_material(&eval_ctx, scene, view_layer, NULL, v3d, v3d->drawtype)) gpu_update_lamps_shadows_world(&eval_ctx, scene, v3d); /* reset default OpenGL lights if needed (i.e. after preferences have been altered) */ @@ -2033,10 +2036,13 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie } } -static void view3d_main_region_draw_info(const bContext *C, Scene *scene, - ARegion *ar, View3D *v3d, - const char *grid_unit, bool render_border) +static void view3d_main_region_draw_info( + const bContext *C, Scene *scene, + ARegion *ar, View3D *v3d, + const char *grid_unit, bool render_border) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); const Depsgraph *depsgraph = CTX_data_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); wmWindowManager *wm = CTX_wm_manager(C); @@ -2059,7 +2065,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, } if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - VP_legacy_drawcursor(scene, view_layer, ar, v3d); /* 3D cursor */ + VP_legacy_drawcursor(&eval_ctx, scene, view_layer, ar, v3d); /* 3D cursor */ if (U.uiflag & USER_SHOW_ROTVIEWICON) VP_legacy_draw_view_axis(rv3d, &rect); @@ -2068,7 +2074,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, if (U.uiflag & USER_DRAWVIEWINFO) { Object *ob = OBACT(view_layer); - VP_legacy_draw_selected_name(scene, ob, &rect); + VP_legacy_draw_selected_name(&eval_ctx, scene, ob, &rect); } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ba9432b932d..6c80033f9df 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -244,21 +244,24 @@ 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); 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 && (ob_act->mode & OB_MODE_ALL_PAINT) && + if (ob_act && (eval_ctx.object_mode & OB_MODE_ALL_PAINT) && /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ - ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) + ((eval_ctx.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 (ob_act->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { + if (eval_ctx.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); @@ -268,7 +271,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) } is_set = true; } - else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { + else if (ob_act && (eval_ctx.object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { Curve *cu = ob_act->data; EditFont *ef = cu->editfont; int i; @@ -283,7 +286,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) is_set = true; } - else if (ob_act == NULL || ob_act->mode == OB_MODE_OBJECT) { + else if (ob_act == NULL || eval_ctx.object_mode == OB_MODE_OBJECT) { /* object mode use boundbox centers */ Base *base; unsigned int tot = 0; @@ -2792,6 +2795,8 @@ 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); ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); @@ -2815,15 +2820,18 @@ static int viewselected_exec(bContext *C, wmOperator *op) ob = NULL; } - if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) { + if (ob && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) { /* hard-coded exception, we look for the one selected armature */ /* this is weak code this way, we should make a generic active/selection callback interface once... */ Base *base; for (base = view_layer->object_bases.first; base; base = base->next) { if (TESTBASELIB(base)) { - if (base->object->type == OB_ARMATURE) - if (base->object->mode & OB_MODE_POSE) + if (base->object->type == OB_ARMATURE) { + const bArmature *arm = base->object->data; + if (arm->flag & ARM_POSEMODE) { break; + } + } } } if (base) @@ -2849,17 +2857,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 && (ob->mode & OB_MODE_POSE)) { + else if (ob && (eval_ctx.object_mode & OB_MODE_POSE)) { ok = BKE_pose_minmax(ob, min, max, true, true); } - else if (BKE_paint_select_face_test(ob)) { + else if (BKE_paint_select_face_test(&eval_ctx, ob)) { ok = paintface_minmax(ob, min, max); } - else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { + else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) { ok = PE_minmax(scene, view_layer, min, max); } else if (ob && - (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) + (eval_ctx.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); @@ -2966,13 +2974,15 @@ 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 (obact->mode & OB_MODE_POSE) { + if (eval_ctx.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_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 5e34bc188f0..16731336d00 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -54,6 +54,7 @@ struct wmKeyConfig; struct wmManipulatorGroupType; struct wmManipulatorType; struct wmWindowManager; +struct EvaluationContext; /* drawing flags: */ enum { @@ -154,13 +155,19 @@ void draw_object_select( const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, struct ARegion *ar, View3D *v3d, Base *base, const short dflag); -void draw_mesh_object_outline(View3D *v3d, struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]); +void draw_mesh_object_outline( + const struct EvaluationContext *eval_ctx, View3D *v3d, + struct Object *ob, struct DerivedMesh *dm, const unsigned char ob_wire_col[4]); -bool draw_glsl_material(Scene *scene, struct ViewLayer *view_layer, struct Object *ob, View3D *v3d, const char dt); +bool draw_glsl_material( + const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, + struct Object *ob, View3D *v3d, const char dt); void draw_object_instance(const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline, const float wire_col[4]); void draw_object_backbufsel(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob); -void draw_object_wire_color(Scene *scene, struct ViewLayer *, Base *base, unsigned char r_ob_wire_col[4]); +void draw_object_wire_color( + const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *, + Base *base, unsigned char r_ob_wire_col[4]); void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]); void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, const char dt, const short dflag, const unsigned char ob_wire_col[4], @@ -209,8 +216,10 @@ void draw_mesh_paint_vcolor_faces(struct DerivedMesh *dm, const bool use_light, void draw_mesh_paint_weight_edges(RegionView3D *rv3d, struct DerivedMesh *dm, const bool use_depth, const bool use_alpha, void *edgemask_cb, void *user_data); -void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, - struct Object *ob, struct DerivedMesh *dm, const int draw_flags); +void draw_mesh_paint( + const struct EvaluationContext *eval_ctx, + View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); /* drawsimdebug.c */ void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar); @@ -367,10 +376,13 @@ extern bool view3d_camera_border_hack_test; #endif /* temporary for legacy viewport to work */ -void VP_legacy_drawcursor(Scene *scene, struct ViewLayer *view_layer, ARegion *ar, View3D *v3d); +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(Scene *scene, struct Object *ob, rcti *rect); +void VP_legacy_draw_selected_name( + const struct EvaluationContext *eval_ctx, Scene *scene, struct Object *ob, 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 28e15b3bfee..ce3c30d50e0 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -209,6 +209,7 @@ static void edbm_backbuf_check_and_select_tfaces(Mesh *me, const bool select) /* *********************** GESTURE AND LASSO ******************* */ typedef struct LassoSelectUserData { + const EvaluationContext *eval_ctx; ViewContext *vc; const rcti *rect; const rctf *rect_fl; @@ -251,14 +252,16 @@ static int view3d_selectable_data(bContext *C) return 0; if (ob) { - if (ob->mode & OB_MODE_EDIT) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + if (eval_ctx.object_mode & OB_MODE_EDIT) { if (ob->type == OB_FONT) { return 0; } } else { - if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && - !BKE_paint_select_elem_test(ob)) + 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)) { return 0; } @@ -387,8 +390,10 @@ static void object_deselect_all_visible(ViewLayer *view_layer) } } -static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], const short moves, - const bool extend, const bool select) +static void do_lasso_select_objects( + const EvaluationContext *eval_ctx, + ViewContext *vc, const int mcords[][2], const short moves, + const bool extend, const bool select) { Base *base; @@ -403,7 +408,7 @@ static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], cons ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); } } - if (vc->obact == base->object && (base->object->mode & OB_MODE_POSE)) { + if (vc->obact == base->object && (eval_ctx->object_mode & OB_MODE_POSE)) { do_lasso_select_pose(vc, base->object, mcords, moves, select); } } @@ -810,20 +815,20 @@ 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(ob)) { + if (BKE_paint_select_face_test(&eval_ctx, ob)) { do_lasso_select_paintface(&eval_ctx, vc, mcords, moves, extend, select); } - else if (BKE_paint_select_vert_test(ob)) { + else if (BKE_paint_select_vert_test(&eval_ctx, ob)) { do_lasso_select_paintvert(&eval_ctx, vc, mcords, moves, extend, select); } - else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { + else if (ob && (eval_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { /* pass */ } - else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { + else if (ob && (eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) { PE_lasso_select(C, mcords, moves, extend, select); } else { - do_lasso_select_objects(vc, mcords, moves, extend, select); + do_lasso_select_objects(&eval_ctx, vc, mcords, moves, extend, select); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } } @@ -1544,7 +1549,10 @@ static bool ed_object_select_pick( } } } - else if (ED_do_pose_selectbuffer(scene, view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) { + else if (ED_do_pose_selectbuffer( + &eval_ctx, scene, view_layer, + basact, buffer, hits, extend, deselect, toggle, do_nearest)) + { /* then bone is found */ /* we make the armature selected: @@ -1557,7 +1565,7 @@ static bool ed_object_select_pick( WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object); /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ - if (BASACT(view_layer) && (BASACT(view_layer)->object->mode & OB_MODE_WEIGHT_PAINT)) { + if (BASACT(view_layer) && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT)) { /* prevent activating */ basact = NULL; } @@ -2050,7 +2058,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b CTX_data_eval_ctx(C, &eval_ctx); - if ((ob) && (ob->mode & OB_MODE_POSE)) + if ((ob) && (eval_ctx.object_mode & OB_MODE_POSE)) bone_only = 1; else bone_only = 0; @@ -2205,16 +2213,16 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } } else { /* no editmode, unified for bones and objects */ - if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) { + 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(vc.obact)) { + else if (vc.obact && BKE_paint_select_face_test(&eval_ctx, vc.obact)) { ret = do_paintface_box_select(&eval_ctx, &vc, &rect, select, extend); } - else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) { + else if (vc.obact && BKE_paint_select_vert_test(&eval_ctx, vc.obact)) { ret = do_paintvert_box_select(&eval_ctx, &vc, &rect, select, extend); } - else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) { + else if (vc.obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) { ret = PE_border_select(C, &rect, select, extend); } else { /* object mode with none active */ @@ -2300,6 +2308,8 @@ 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); Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); bool extend = RNA_boolean_get(op->ptr, "extend"); @@ -2311,9 +2321,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(obact) || + BKE_paint_select_elem_test(&eval_ctx, obact) || /* so its possible to select bones in weightpaint mode (LMB select) */ - (obact && (obact->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact)))); + (obact && (eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact)))); bool retval = false; int location[2]; @@ -2347,11 +2357,11 @@ static int view3d_select_exec(bContext *C, wmOperator *op) retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle); } - else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) + else if (obact && eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) return PE_mouse_particles(C, location, extend, deselect, toggle); - else if (obact && BKE_paint_select_face_test(obact)) + else if (obact && BKE_paint_select_face_test(&eval_ctx, obact)) retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle); - else if (BKE_paint_select_vert_test(obact)) + else if (BKE_paint_select_vert_test(&eval_ctx, obact)) 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); @@ -2856,6 +2866,8 @@ static bool object_circle_select(ViewContext *vc, const bool select, const int m /* not a real operator, only for circle test */ static int view3d_circle_select_exec(bContext *C, wmOperator *op) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); const int radius = RNA_int_get(op->ptr, "radius"); @@ -2863,35 +2875,33 @@ 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(obact) || - (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) + if (CTX_data_edit_object(C) || BKE_paint_select_elem_test(&eval_ctx, obact) || + (obact && (eval_ctx.object_mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) { - EvaluationContext eval_ctx; ViewContext vc; - + view3d_operator_needs_opengl(C); - - CTX_data_eval_ctx(C, &eval_ctx); + view3d_set_viewcontext(C, &vc); if (CTX_data_edit_object(C)) { 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(obact)) { + else if (BKE_paint_select_face_test(&eval_ctx, obact)) { 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(obact)) { + else if (BKE_paint_select_vert_test(&eval_ctx, obact)) { paint_vertsel_circle_select(&eval_ctx, &vc, select, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); } - else if (obact->mode & OB_MODE_POSE) + else if (eval_ctx.object_mode & OB_MODE_POSE) pose_circle_select(&vc, select, mval, (float)radius); else return PE_circle_select(C, select, mval, (float)radius); } - else if (obact && obact->mode & OB_MODE_SCULPT) { + else if (obact && eval_ctx.object_mode & OB_MODE_SCULPT) { return OPERATOR_CANCELLED; } else { |