diff options
Diffstat (limited to 'source/blender/editors/space_view3d/drawobject.c')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 220 |
1 files changed, 97 insertions, 123 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f46d3c500bc..2c6d977b552 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -314,15 +314,13 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) /* check for glsl drawing */ -bool draw_glsl_material( - const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, - Object *ob, View3D *v3d, const char dt) +bool draw_glsl_material(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 && eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT)) + if (ob == OBACT(view_layer) && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return false; if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) @@ -336,7 +334,7 @@ bool draw_glsl_material( return false; } -static bool check_alpha_pass(const EvaluationContext *eval_ctx, Base *base) +static bool check_alpha_pass(Base *base) { if (base->flag_legacy & OB_FROMDUPLI) return false; @@ -344,9 +342,8 @@ static bool check_alpha_pass(const EvaluationContext *eval_ctx, Base *base) if (G.f & G_PICKSEL) return false; - if (eval_ctx->object_mode & OB_MODE_ALL_PAINT) { + if (base->object->mode & OB_MODE_ALL_PAINT) return false; - } return (base->object->dtx & OB_DRAWTRANSP); } @@ -3893,9 +3890,8 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index) } } -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) +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) { RegionView3D *rv3d = ar->regiondata; @@ -3932,7 +3928,7 @@ static void draw_em_fancy( glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } else if (check_object_draw_texture(scene, v3d, dt)) { - if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt)) { + if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind, @@ -4225,12 +4221,10 @@ static void draw_em_fancy_new(Scene *UNUSED(scene), ARegion *UNUSED(ar), View3D /* Mesh drawing routines */ -void draw_mesh_object_outline( - const EvaluationContext *eval_ctx, View3D *v3d, - Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */ +void draw_mesh_object_outline(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 */ - (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ + (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(GL_FALSE); @@ -4253,12 +4247,10 @@ void draw_mesh_object_outline( } } -static void draw_mesh_object_outline_new( - const EvaluationContext *eval_ctx, View3D *v3d, RegionView3D *rv3d, - Mesh *me, const bool is_active) +static void draw_mesh_object_outline_new(View3D *v3d, RegionView3D *rv3d, Object *ob, Mesh *me, const bool is_active) { if ((v3d->transp == false) && /* not when we draw the transparent pass */ - (eval_ctx->object_mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ + (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(GL_FALSE); @@ -4308,9 +4300,7 @@ 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, eval_ctx->object_mode) : base->object); + Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object; #else Object *ob = base->object; #endif @@ -4319,7 +4309,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, eval_ctx->object_mode)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0; if (!dm) return; @@ -4357,7 +4347,7 @@ static void draw_mesh_fancy( draw_bounding_volume(ob, ob->boundtype, ob_wire_col); } else if ((no_faces && no_edges) || - ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) + ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) { glPointSize(1.5f); dm->drawVerts(dm); @@ -4365,7 +4355,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 && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) || + else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || check_object_draw_texture(scene, v3d, dt)) { bool draw_loose = true; @@ -4376,17 +4366,15 @@ static void draw_mesh_fancy( !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && (draw_wire == OBDRAW_WIRE_OFF)) { - draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); } - if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if (draw_glsl_material(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, eval_ctx->object_mode))) - { + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { GPUVertexAttribs gattribs; float planes[4][4]; float (*fpl)[4] = NULL; @@ -4449,7 +4437,7 @@ static void draw_mesh_fancy( (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) { - draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); } /* materials arent compatible with vertex colors */ @@ -4473,12 +4461,12 @@ static void draw_mesh_fancy( (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) { - draw_mesh_object_outline(eval_ctx, v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(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, eval_ctx->object_mode))) { + if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { float planes[4][4]; float (*fpl)[4] = NULL; const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); @@ -4510,7 +4498,7 @@ static void draw_mesh_fancy( } } else if (dt == OB_PAINT) { - draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags); + draw_mesh_paint(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; @@ -4525,7 +4513,7 @@ static void draw_mesh_fancy( * with the background. */ if ((dflag & DRAW_CONSTCOLOR) == 0) { - if (is_obact && (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) { + if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { float color[3]; ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color); glColor3fv(color); @@ -4558,7 +4546,7 @@ static void draw_mesh_fancy( } } - if (is_obact && BKE_paint_select_vert_test(ob, eval_ctx->object_mode)) { + if (is_obact && BKE_paint_select_vert_test(ob)) { const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); @@ -4577,7 +4565,7 @@ static bool draw_mesh_object( const char dt, const unsigned char ob_wire_col[4], const short dflag) { Object *ob = base->object; - Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; bool do_alpha_after = false, drawlinked = false, retval = false; @@ -4627,13 +4615,13 @@ static bool draw_mesh_object( if (use_material) { if (dt > OB_WIRE) { - const bool glsl = draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); - GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, eval_ctx->object_mode, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); } } - draw_em_fancy(eval_ctx, scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt); + draw_em_fancy(scene, view_layer, ar, v3d, ob, em, cageDM, finalDM, dt); if (use_material) { GPU_end_object_materials(); @@ -4646,13 +4634,12 @@ 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(eval_ctx, scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); if (dt == OB_SOLID || glsl) { - 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); + 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); } } @@ -4731,9 +4718,7 @@ static void draw_mesh_fancy_new( } #ifdef WITH_GAMEENGINE - Object *ob = ( - (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? - BKE_object_lod_meshob_get(base->object, view_layer, eval_ctx->object_mode) : base->object); + Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, view_layer) : base->object; #else Object *ob = base->object; #endif @@ -4742,7 +4727,7 @@ static void draw_mesh_fancy_new( 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, eval_ctx->object_mode)) ? DRAW_FACE_SELECT : 0; + int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0; if (!dm) return; @@ -4785,7 +4770,7 @@ static void draw_mesh_fancy_new( draw_bounding_volume(ob, ob->boundtype, ob_wire_col); } else if ((no_faces && no_edges) || - ((!is_obact || (eval_ctx->object_mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) + ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob))) { glPointSize(1.5f); // dm->drawVerts(dm); @@ -4851,7 +4836,7 @@ static void draw_mesh_fancy_new( GWN_batch_draw(batch); #endif } - else if (((is_obact && eval_ctx->object_mode & OB_MODE_TEXTURE_PAINT)) || + else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || check_object_draw_texture(scene, v3d, dt)) { bool draw_loose = true; @@ -4862,17 +4847,15 @@ static void draw_mesh_fancy_new( !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && (draw_wire == OBDRAW_WIRE_OFF)) { - draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer))); + draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer))); } - if (draw_glsl_material(eval_ctx, scene, view_layer, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if (draw_glsl_material(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, eval_ctx->object_mode))) - { + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { GPUVertexAttribs gattribs; float planes[4][4]; float (*fpl)[4] = NULL; @@ -4931,7 +4914,7 @@ static void draw_mesh_fancy_new( (draw_wire == OBDRAW_WIRE_OFF) && (ob->sculpt == NULL)) { - draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer))); + draw_mesh_object_outline_new(v3d, rv3d, ob, me, (ob == OBACT(view_layer))); } /* materials arent compatible with vertex colors */ @@ -4956,12 +4939,12 @@ static void draw_mesh_fancy_new( (ob->sculpt == NULL)) { /* TODO: move this into a separate pass */ - draw_mesh_object_outline_new(eval_ctx, v3d, rv3d, me, (ob == OBACT(view_layer))); + draw_mesh_object_outline_new(v3d, rv3d, ob, 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, eval_ctx->object_mode))) { + if (ob->sculpt && (p = BKE_paint_get_active(scene, view_layer))) { float planes[4][4]; float (*fpl)[4] = NULL; const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); @@ -4993,7 +4976,7 @@ static void draw_mesh_fancy_new( } } else if (dt == OB_PAINT) { - draw_mesh_paint(eval_ctx, v3d, rv3d, ob, dm, draw_flags); + draw_mesh_paint(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; @@ -5055,7 +5038,7 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)( /* TODO: handle shadow pass separately */ return true; } - Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(eval_ctx->view_layer); if (obedit && ob != obedit && ob->data == obedit->data) { if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {} @@ -5100,9 +5083,9 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)( DM_update_materials(cageDM, ob); } - const bool glsl = draw_glsl_material(eval_ctx, scene, eval_ctx->view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(scene, eval_ctx->view_layer, ob, v3d, dt); - GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl, eval_ctx->object_mode, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl, NULL); } draw_em_fancy_new(scene, ar, v3d, ob, me, em, cageDM, finalDM, dt); @@ -5118,13 +5101,12 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)( /* 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(eval_ctx, scene, eval_ctx->view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(scene, eval_ctx->view_layer, ob, v3d, dt); if (dt == OB_SOLID || glsl) { - const bool check_alpha = check_alpha_pass(eval_ctx, base); - GPU_begin_object_materials( - v3d, rv3d, scene, eval_ctx->view_layer, ob, - eval_ctx->object_mode, glsl, (check_alpha) ? &do_alpha_after : NULL); + const bool check_alpha = check_alpha_pass(base); + GPU_begin_object_materials(v3d, rv3d, scene, eval_ctx->view_layer, ob, glsl, + (check_alpha) ? &do_alpha_after : NULL); } } @@ -5441,9 +5423,7 @@ static void drawCurveDMWired(Object *ob) } /* return true when nothing was drawn */ -static bool drawCurveDerivedMesh( - const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, - Base *base, const char dt) +static bool drawCurveDerivedMesh(Scene *scene, ViewLayer *view_layer, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt) { Object *ob = base->object; DerivedMesh *dm = ob->derivedFinal; @@ -5457,10 +5437,8 @@ static bool drawCurveDerivedMesh( glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); if (dt > OB_WIRE && dm->getNumPolys(dm)) { - 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); + bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); if (!glsl) dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); @@ -5481,9 +5459,8 @@ static bool drawCurveDerivedMesh( * Only called by #drawDispList * \return true when nothing was drawn */ -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]) +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]) { Object *ob = base->object; ListBase *lb = NULL; @@ -5523,13 +5500,13 @@ static bool drawDispList_nobackface( /* pass */ } else { - 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); + if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, 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, eval_ctx->object_mode, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } @@ -5558,13 +5535,13 @@ static bool drawDispList_nobackface( if (dl->nors == NULL) BKE_displist_normals_add(lb); - 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); + if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, 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, eval_ctx->object_mode, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } @@ -5583,13 +5560,13 @@ static bool drawDispList_nobackface( if (solid) { - 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); + if (draw_glsl_material(scene, view_layer, ob, v3d, dt)) { + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 1, 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, eval_ctx->object_mode, NULL); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, 0, NULL); drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } @@ -5620,7 +5597,7 @@ static bool drawDispList( ensure_curve_cache(eval_ctx, scene, base->object); #endif - if (drawCurveDerivedMesh(eval_ctx, scene, view_layer, v3d, rv3d, base, dt) == false) { + if (drawCurveDerivedMesh(scene, view_layer, v3d, rv3d, base, dt) == false) { retval = false; } else { @@ -5636,7 +5613,7 @@ static bool drawDispList( glFrontFace(mode); - retval = drawDispList_nobackface(eval_ctx, scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col); + retval = drawDispList_nobackface(scene, view_layer, v3d, rv3d, base, dt, dflag, ob_wire_col); if (mode != GL_CCW) { glFrontFace(GL_CCW); @@ -5960,7 +5937,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, eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0) + if (psys_in_edit_mode(eval_ctx->view_layer, psys) && (pset->flag & PE_DRAW_PART) == 0) return; if (part->draw_as == PART_DRAW_REND) @@ -8319,7 +8296,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(eval_ctx, v3d, ob, dm, ob_wire_col); + draw_mesh_object_outline(v3d, ob, dm, ob_wire_col); } else { /* only draw 'solid' parts of the display list as wire. */ @@ -8336,7 +8313,7 @@ static void draw_object_selected_outline( } } else if (ob->type == OB_ARMATURE) { - if (!(eval_ctx->object_mode & OB_MODE_POSE && base == view_layer->basact)) { + if (!(ob->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); } @@ -8447,13 +8424,11 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, immUnbindProgram(); } -void draw_object_wire_color( - const EvaluationContext *eval_ctx, ViewLayer *view_layer, - Base *base, unsigned char r_ob_wire_col[4]) +void draw_object_wire_color(ViewLayer *view_layer, Base *base, unsigned char r_ob_wire_col[4]) { Object *ob = base->object; int colindex = 0; - const bool is_edit = (eval_ctx->object_mode & OB_MODE_EDIT) != 0; + const bool is_edit = (ob->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. * @@ -8461,7 +8436,7 @@ void draw_object_wire_color( int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE; int theme_shade = 0; - if (((eval_ctx->object_mode & OB_MODE_EDIT) == 0) && + if (((ob->mode & OB_MODE_EDIT) == 0) && (G.moving & G_TRANSFORM_OBJ) && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) { @@ -8515,12 +8490,10 @@ void draw_object_wire_color( r_ob_wire_col[3] = 255; } -static void draw_object_matcap_check( - const EvaluationContext *eval_ctx, View3D *v3d, Object *ob) +static void draw_object_matcap_check(View3D *v3d, Object *ob) { /* fixed rule, active object draws as matcap */ - BLI_assert((eval_ctx->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0); - UNUSED_VARS_NDEBUG(eval_ctx); + BLI_assert((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0); (void)ob; if (v3d->defmaterial == NULL) { @@ -8606,9 +8579,10 @@ void draw_object( unsigned char _ob_wire_col[4]; /* dont initialize this */ const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */ bool zbufoff = false, is_paint = false, empty_object = false; - const bool is_obact = (ob == OBACT(view_layer)); + Object *ob_active = OBACT(view_layer); + const bool is_obact = (ob == ob_active); /* this could be moved to a 'dflag'. */ - const bool is_obedit = (is_obact && (ob == OBEDIT_FROM_EVAL_CTX(eval_ctx))); + const bool is_obedit = (is_obact && (ob == OBEDIT_FROM_OBACT(ob_active))); const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0; const bool is_picking = (G.f & G_PICKSEL) != 0; const bool has_particles = (ob->particlesystem.first != NULL); @@ -8634,7 +8608,7 @@ void draw_object( return; } - if (eval_ctx->object_mode == OB_MODE_OBJECT) { + if (ob->mode == OB_MODE_OBJECT) { ParticleSystem *psys; skip_object = render_override; @@ -8674,7 +8648,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 (!(eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT)) { + if (!(ob->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); @@ -8725,7 +8699,7 @@ void draw_object( ED_view3d_project_base(ar, base); - draw_object_wire_color(eval_ctx, view_layer, base, _ob_wire_col); + draw_object_wire_color(view_layer, base, _ob_wire_col); ob_wire_col = _ob_wire_col; //glColor3ubv(ob_wire_col); @@ -8741,14 +8715,14 @@ void draw_object( /* faceselect exception: also draw solid when (dt == wire), except in editmode */ if (is_obact) { - if (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) { + if (ob->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 (eval_ctx->object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { dt = OB_PAINT; } @@ -8764,13 +8738,13 @@ void draw_object( (is_paint == false && is_picking == false) && ((v3d->flag2 & V3D_RENDER_SHADOW) == 0)) { - draw_object_matcap_check(eval_ctx, v3d, ob); + draw_object_matcap_check(v3d, ob); } /* draw-extra supported for boundbox drawmode too */ if (dt >= OB_BOUNDBOX) { dtx = ob->dtx; - if (eval_ctx->object_mode & OB_MODE_EDIT) { + if (ob->mode & OB_MODE_EDIT) { /* the only 2 extra drawtypes alowed in editmode */ dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE); } @@ -8779,7 +8753,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 && (eval_ctx->object_mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) { + if (dt > OB_WIRE && (ob->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); } @@ -8887,7 +8861,7 @@ void draw_object( case OB_LATTICE: if (!render_override) { /* Do not allow boundbox in edit nor pose mode! */ - if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & OB_MODE_EDIT)) + if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT)) dt = OB_WIRE; if (dt == OB_BOUNDBOX) { draw_bounding_volume(ob, ob->boundtype, ob_wire_col); @@ -8903,7 +8877,7 @@ void draw_object( case OB_ARMATURE: if (!render_override) { /* Do not allow boundbox in edit nor pose mode! */ - if ((dt == OB_BOUNDBOX) && (eval_ctx->object_mode & (OB_MODE_EDIT | OB_MODE_POSE))) + if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE))) dt = OB_WIRE; if (dt == OB_BOUNDBOX) { draw_bounding_volume(ob, ob->boundtype, ob_wire_col); @@ -8971,7 +8945,7 @@ afterdraw: for (psys = ob->particlesystem.first; psys; psys = psys->next) { /* run this so that possible child particles get cached */ - if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) { + if (ob->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, ob, edit); @@ -8992,7 +8966,7 @@ afterdraw: (is_obedit == false)) { - if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) { + if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) { PTCacheEdit *edit = PE_create_current(eval_ctx, scene, ob); if (edit) { gpuLoadMatrix(rv3d->viewmat); @@ -9093,7 +9067,7 @@ afterdraw: } } - if ((ob->gameflag & OB_BOUNDS) && (eval_ctx->object_mode == OB_MODE_OBJECT)) { + if ((ob->gameflag & OB_BOUNDS) && (ob->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); @@ -9189,7 +9163,7 @@ afterdraw: } /* object centers, need to be drawn in viewmat space for speed, but OK for picking select */ - if (!is_obact || !(eval_ctx->object_mode & OB_MODE_ALL_PAINT)) { + if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) { int do_draw_center = -1; /* defines below are zero or positive... */ if (render_override) { @@ -9789,7 +9763,7 @@ void draw_object_backbufsel( switch (ob->type) { case OB_MESH: - if (eval_ctx->object_mode & OB_MODE_EDIT) { + if (ob->mode & OB_MODE_EDIT) { Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; @@ -9835,7 +9809,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*/ - ((eval_ctx->object_mode & OB_MODE_WEIGHT_PAINT) || (eval_ctx->object_mode & OB_MODE_VERTEX_PAINT))) + ((ob->mode & OB_MODE_WEIGHT_PAINT) || (ob->mode & OB_MODE_VERTEX_PAINT))) { bbs_mesh_solid_verts(eval_ctx, scene, ob); } @@ -9864,7 +9838,7 @@ static void draw_object_mesh_instance( Mesh *me = ob->data; DerivedMesh *dm = NULL, *edm = NULL; - if (eval_ctx->object_mode & OB_MODE_EDIT) { + if (ob->mode & OB_MODE_EDIT) { edm = editbmesh_get_derived_base(ob, me->edit_btmesh, CD_MASK_BAREMESH); DM_update_materials(edm, ob); } @@ -9882,11 +9856,11 @@ static void draw_object_mesh_instance( } else { if (outline) - draw_mesh_object_outline(eval_ctx, v3d, ob, dm ? dm : edm, ob_wire_col); + draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col); if (dm) { - 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); + bool glsl = draw_glsl_material(scene, view_layer, ob, v3d, dt); + GPU_begin_object_materials(v3d, rv3d, scene, view_layer, ob, glsl, NULL); } glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); |