From 754d3a2fe626fbe57bb6ef47581368e3859f6390 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Feb 2018 19:29:08 +1100 Subject: Object Mode: remove Scene.obedit for 3D View --- source/blender/editors/armature/armature_edit.c | 12 ++--- source/blender/editors/armature/armature_intern.h | 2 +- source/blender/editors/armature/armature_select.c | 9 ++-- source/blender/editors/armature/pose_select.c | 8 +-- source/blender/editors/include/ED_armature.h | 4 +- source/blender/editors/object/object_transform.c | 2 +- source/blender/editors/sculpt_paint/paint_image.c | 6 ++- source/blender/editors/space_image/image_ops.c | 6 ++- source/blender/editors/space_view3d/drawobject.c | 61 ++++++++++++---------- source/blender/editors/space_view3d/space_view3d.c | 5 +- source/blender/editors/space_view3d/view3d_draw.c | 10 ++-- .../editors/space_view3d/view3d_draw_legacy.c | 11 ++-- .../blender/editors/space_view3d/view3d_header.c | 12 ++--- .../blender/editors/space_view3d/view3d_intern.h | 4 +- .../blender/editors/space_view3d/view3d_select.c | 2 +- source/blender/editors/space_view3d/view3d_view.c | 2 +- 16 files changed, 82 insertions(+), 74 deletions(-) diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index a2fbfe645f7..6c8779202e9 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -50,6 +50,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_report.h" +#include "BKE_object.h" #include "RNA_access.h" #include "RNA_define.h" @@ -138,17 +139,16 @@ void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do /* exported for use in editors/object/ */ /* 0 == do center, 1 == center new, 2 == center cursor */ -void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int centermode, int around) +void ED_armature_origin_set(Object *ob, float cursor[3], int centermode, int around) { - Object *obedit = scene->obedit; // XXX get from context + const bool is_editmode = BKE_object_is_in_editmode(ob); EditBone *ebone; bArmature *arm = ob->data; float cent[3]; /* Put the armature into editmode */ - if (ob != obedit) { + if (is_editmode == false) { ED_armature_to_edit(arm); - obedit = NULL; /* we cant use this so behave as if there is no obedit */ } /* Find the centerpoint */ @@ -188,13 +188,13 @@ void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int cente } /* Turn the list into an armature */ - if (obedit == NULL) { + if (is_editmode == false) { ED_armature_from_edit(arm); ED_armature_edit_free(arm); } /* Adjust object location for new centerpoint */ - if (centermode && obedit == NULL) { + if (centermode && (is_editmode == false)) { mul_mat3_m4_v3(ob->obmat, cent); /* omit translation part */ add_v3_v3(ob->loc, cent); } diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 192bb8eea61..0ba720a17d0 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -250,7 +250,7 @@ void armature_tag_unselect(struct bArmature *arm); void *get_nearest_bone(struct bContext *C, const int xy[2], bool findunsel); void *get_bone_from_selectbuffer( - struct Scene *scene, struct Base *base, const unsigned int *buffer, short hits, + struct Base *base, struct Object *obedit, const unsigned int *buffer, short hits, bool findunsel, bool do_nearest); int bone_looper(struct Object *ob, struct Bone *bone, void *data, diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index b87942fed84..f178ad640b6 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -77,10 +77,9 @@ Bone *get_indexed_bone(Object *ob, int index) /* See if there are any selected bones in this buffer */ /* only bones from base are checked on */ void *get_bone_from_selectbuffer( - Scene *scene, Base *base, const unsigned int *buffer, short hits, + Base *base, Object *obedit, const unsigned int *buffer, short hits, bool findunsel, bool do_nearest) { - Object *obedit = scene->obedit; // XXX get from context Bone *bone; EditBone *ebone; void *firstunSel = NULL, *firstSel = NULL, *data; @@ -183,9 +182,9 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel) hits = view3d_opengl_select(&eval_ctx, &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST); - if (hits > 0) - return get_bone_from_selectbuffer(vc.scene, vc.view_layer->basact, buffer, hits, findunsel, true); - + if (hits > 0) { + return get_bone_from_selectbuffer(vc.view_layer->basact, vc.obedit, buffer, hits, findunsel, true); + } return NULL; } diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index a43f3ff4acc..16f5bb59641 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -135,7 +135,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) /* assumes scene obact and basact is still on old situation */ bool ED_do_pose_selectbuffer( const EvaluationContext *eval_ctx, - Scene *scene, ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits, + ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits, bool extend, bool deselect, bool toggle, bool do_nearest) { Object *ob = base->object; @@ -143,11 +143,13 @@ bool ED_do_pose_selectbuffer( if (!ob || !ob->pose) return 0; - nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1, do_nearest); + Object *ob_act = OBACT(view_layer); + Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx); + + nearBone = get_bone_from_selectbuffer(base, obedit, buffer, hits, 1, do_nearest); /* if the bone cannot be affected, don't do anything */ if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) { - Object *ob_act = OBACT(view_layer); bArmature *arm = ob->data; /* since we do unified select, we don't shift+select a bone if the diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 5ad242003e3..18eb442766b 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -144,7 +144,7 @@ void ED_armature_deselect_all_visible(struct Object *obedit); bool ED_do_pose_selectbuffer( const struct EvaluationContext *eval_ctx, - struct Scene *scene, struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits, + struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits, bool extend, bool deselect, bool toggle, bool do_nearest); bool ED_armature_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); int join_armature_exec(struct bContext *C, struct wmOperator *op); @@ -169,7 +169,7 @@ void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]); void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]); void transform_armature_mirror_update(struct Object *obedit); -void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around); +void ED_armature_origin_set(struct Object *ob, float cursor[3], int centermode, int around); void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props); void ED_armature_apply_transform(struct Object *ob, float mat[4][4], const bool do_props); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index d69d8f8b26e..b336b560ef2 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -983,7 +983,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* Function to recenter armatures in editarmature.c * Bone + object locations are handled there. */ - ED_armature_origin_set(scene, ob, cursor, centermode, around); + ED_armature_origin_set(ob, cursor, centermode, around); tot_change++; arm->id.tag |= LIB_TAG_DOIT; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index d42bbfdc43a..1cb37fc10cd 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1429,8 +1429,10 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - if (!sima->pin) - ED_space_image_set(sima, scene, scene->obedit, ima); + if (!sima->pin) { + Object *obedit = CTX_data_edit_object(C); + ED_space_image_set(sima, scene, obedit, ima); + } } } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 0ff30c228b4..6ee9d547ac3 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -275,12 +275,14 @@ int space_image_main_region_poll(bContext *C) /* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode or editmode */ static int space_image_main_area_not_uv_brush_poll(bContext *C) { + const WorkSpace *workspace = CTX_wm_workspace(C); SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); ToolSettings *toolsettings = scene->toolsettings; - if (sima && !toolsettings->uvsculpt && !scene->obedit) + if (sima && !toolsettings->uvsculpt && ((workspace->object_mode & OB_MODE_EDIT) == 0)) { return 1; + } return 0; } @@ -2459,7 +2461,7 @@ static int image_new_exec(bContext *C, wmOperator *op) SpaceImage *sima_other = (SpaceImage *)sl; if (!sima_other->pin) { - ED_space_image_set(sima_other, scene, scene->obedit, ima); + ED_space_image_set(sima_other, scene, obedit, ima); } } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 7ad5f733f02..b12756c8299 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -4579,7 +4579,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 = scene->obedit; + Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx); Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; bool do_alpha_after = false, drawlinked = false, retval = false; @@ -4720,8 +4720,10 @@ static void make_color_variations(const unsigned char base_ubyte[4], float low[4 high[3] = base[3]; } -static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const unsigned char ob_wire_col[4], const short dflag, const bool other_obedit) +static void draw_mesh_fancy_new( + const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, + const char dt, const unsigned char ob_wire_col[4], const short dflag, const bool other_obedit) { if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { /* too complicated! use existing methods */ @@ -5042,22 +5044,20 @@ static void draw_mesh_fancy_new(EvaluationContext *eval_ctx, Scene *scene, ViewL dm->release(dm); } -static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const unsigned char ob_wire_col[4], const short dflag) +static bool UNUSED_FUNCTION(draw_mesh_object_new)( + const EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, + const char dt, const unsigned char ob_wire_col[4], const short dflag) { - EvaluationContext eval_ctx; Object *ob = base->object; - Object *obedit = scene->obedit; Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; bool do_alpha_after = false, drawlinked = false, retval = false; - CTX_data_eval_ctx(C, &eval_ctx); - if (v3d->flag2 & V3D_RENDER_SHADOW) { /* TODO: handle shadow pass separately */ return true; } + Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx); if (obedit && ob != obedit && ob->data == obedit->data) { if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {} @@ -5083,7 +5083,7 @@ static bool UNUSED_FUNCTION(draw_mesh_object_new)(const bContext *C, Scene *scen } else { cageDM = editbmesh_get_derived_cage_and_final( - &eval_ctx, scene, ob, em, scene->customdata_mask, + eval_ctx, scene, ob, em, scene->customdata_mask, &finalDM); } @@ -5102,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(&eval_ctx, scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(eval_ctx, scene, eval_ctx->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, eval_ctx->view_layer, ob, glsl, eval_ctx->object_mode, NULL); } draw_em_fancy_new(scene, ar, v3d, ob, me, em, cageDM, finalDM, dt); @@ -5120,19 +5120,19 @@ 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(&eval_ctx, scene, view_layer, ob, v3d, dt); + const bool glsl = draw_glsl_material(eval_ctx, scene, eval_ctx->view_layer, ob, v3d, dt); if (dt == OB_SOLID || glsl) { - const bool check_alpha = check_alpha_pass(&eval_ctx, base); + 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); + v3d, rv3d, scene, eval_ctx->view_layer, ob, + eval_ctx->object_mode, glsl, (check_alpha) ? &do_alpha_after : NULL); } } const bool other_obedit = obedit && (obedit != ob); - draw_mesh_fancy_new(&eval_ctx, scene, view_layer, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, other_obedit); + draw_mesh_fancy_new(eval_ctx, scene, eval_ctx->view_layer, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, other_obedit); GPU_end_object_materials(); @@ -8345,7 +8345,8 @@ static void draw_object_selected_outline( glDepthMask(GL_TRUE); } -static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, const unsigned char ob_wire_col[4]) +static void draw_wire_extra( + RegionView3D *rv3d, Object *ob, const bool is_obedit, const unsigned char ob_wire_col[4]) { if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)) { unsigned char wire_edit_col[4]; @@ -8362,13 +8363,13 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, const drawCurveDMWired(ob); } else { - drawDispListwire(&ob->curve_cache->disp, ob->type, (scene->obedit == ob) ? wire_edit_col : ob_wire_col); + drawDispListwire(&ob->curve_cache->disp, ob->type, is_obedit ? wire_edit_col : ob_wire_col); } } } else if (ob->type == OB_MBALL) { if (BKE_mball_is_basis(ob)) { - drawDispListwire(&ob->curve_cache->disp, ob->type, (scene->obedit == ob) ? wire_edit_col : ob_wire_col); + drawDispListwire(&ob->curve_cache->disp, ob->type, is_obedit ? wire_edit_col : ob_wire_col); } } @@ -8447,7 +8448,7 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, } void draw_object_wire_color( - const EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, + const EvaluationContext *eval_ctx, ViewLayer *view_layer, Base *base, unsigned char r_ob_wire_col[4]) { Object *ob = base->object; @@ -8460,7 +8461,7 @@ void draw_object_wire_color( int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE; int theme_shade = 0; - if ((scene->obedit == NULL) && + if (((eval_ctx->object_mode & OB_MODE_EDIT) == 0) && (G.moving & G_TRANSFORM_OBJ) && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) { @@ -8606,13 +8607,15 @@ void draw_object( 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)); + /* this could be moved to a 'dflag'. */ + const bool is_obedit = (is_obact && (ob == OBEDIT_FROM_EVAL_CTX(eval_ctx))); 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); bool skip_object = false; /* Draw particles but not their emitter object. */ SmokeModifierData *smd = NULL; - if (ob != scene->obedit) { + if (is_obedit == false) { if (ob->restrictflag & OB_RESTRICT_VIEW) return; @@ -8722,7 +8725,7 @@ void draw_object( ED_view3d_project_base(ar, base); - draw_object_wire_color(eval_ctx, scene, view_layer, base, _ob_wire_col); + draw_object_wire_color(eval_ctx, view_layer, base, _ob_wire_col); ob_wire_col = _ob_wire_col; //glColor3ubv(ob_wire_col); @@ -8956,7 +8959,7 @@ afterdraw: /* code for new particle system */ if ((ob->particlesystem.first) && - (ob != scene->obedit)) + (is_obedit == false)) { ParticleSystem *psys; @@ -8986,7 +8989,7 @@ afterdraw: /* draw edit particles last so that they can draw over child particles */ if ((dflag & DRAW_PICKING) == 0 && - (!scene->obedit)) + (is_obedit == false)) { if (eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT && is_obact) { @@ -9135,7 +9138,7 @@ afterdraw: } if ((dtx & OB_DRAWWIRE) && dt >= OB_SOLID) { if ((dflag & DRAW_CONSTCOLOR) == 0) { - draw_wire_extra(scene, rv3d, ob, ob_wire_col); + draw_wire_extra(rv3d, ob, is_obedit, ob_wire_col); } } } @@ -9239,11 +9242,11 @@ afterdraw: immUniformColor3ubv(ob_wire_col); /* draw hook center and offset line */ - if (ob != scene->obedit) + if (is_obedit == false) draw_hooks(ob, pos); /* help lines and so */ - if (ob != scene->obedit && ob->parent) { + if ((is_obedit == false) && ob->parent) { const eObjectVisibilityCheck mode = eval_ctx->mode != DAG_EVAL_VIEWPORT ? OB_VISIBILITY_CHECK_FOR_RENDER : OB_VISIBILITY_CHECK_FOR_VIEWPORT; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 2f2e0db8c7a..3941ea85efd 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1132,9 +1132,8 @@ static void view3d_main_region_message_subscribe( /* concept is to retrieve cursor type context-less */ static void view3d_main_region_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *UNUSED(ar)) { - const Scene *scene = WM_window_get_active_scene(win); - - if (scene->obedit) { + WorkSpace *workspace = WM_window_get_active_workspace(win); + if (workspace->object_mode & OB_MODE_EDIT) { WM_cursor_set(win, CURSOR_EDIT); } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7ce1978dca2..f96dead513c 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -99,15 +99,15 @@ /* ******************** general functions ***************** */ -static bool use_depth_doit(Scene *scene, View3D *v3d) +static bool use_depth_doit(View3D *v3d, Object *obedit) { if (v3d->drawtype > OB_WIRE) return true; /* special case (depth for wire color) */ if (v3d->drawtype <= OB_WIRE) { - if (scene->obedit && scene->obedit->type == OB_MESH) { - Mesh *me = scene->obedit->data; + if (obedit && obedit->type == OB_MESH) { + Mesh *me = obedit->data; if (me->drawflag & ME_DRAWEIGHT) { return true; } @@ -2406,9 +2406,9 @@ void VP_legacy_view3d_stereo3d_setup(const EvaluationContext *eval_ctx, Scene *s view3d_stereo3d_setup(eval_ctx, scene, v3d, ar, NULL); } -bool VP_legacy_use_depth(Scene *scene, View3D *v3d) +bool VP_legacy_use_depth(View3D *v3d, Object *obedit) { - return use_depth_doit(scene, v3d); + return use_depth_doit(v3d, obedit); } void VP_drawviewborder(Scene *scene, const struct Depsgraph *depsgraph, ARegion *ar, View3D *v3d) diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 0b85ac47781..a21b3fd7e45 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -237,7 +237,7 @@ static void backdrawview3d( { /* do nothing */ } - else if (scene->obedit && + else if ((eval_ctx->object_mode & OB_MODE_EDIT) && V3D_IS_ZBUF(v3d)) { /* do nothing */ @@ -1304,7 +1304,7 @@ void ED_view3d_draw_select_loop( for (base = view_layer->object_bases.first; base; base = base->next) { if ((base->flag & BASE_VISIBLED) != 0) { if (((base->flag & BASE_SELECTABLED) == 0) || - (use_obedit_skip && (scene->obedit->data == base->object->data))) + (use_obedit_skip && (vc->obedit->data == base->object->data))) { base->object->select_color = 0; } @@ -1508,6 +1508,7 @@ static void view3d_draw_objects( Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; Base *base; + Object *obedit = OBEDIT_FROM_EVAL_CTX(eval_ctx); const bool do_camera_frame = !draw_offscreen; const bool draw_grids = !draw_offscreen && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0; const bool draw_floor = (rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO); @@ -1524,7 +1525,7 @@ static void view3d_draw_objects( view3d_draw_clipping(rv3d); /* set zbuffer after we draw clipping region */ - v3d->zbuf = VP_legacy_use_depth(scene, v3d); + v3d->zbuf = VP_legacy_use_depth(v3d, obedit); if (v3d->zbuf) { glEnable(GL_DEPTH_TEST); @@ -1601,7 +1602,7 @@ static void view3d_draw_objects( draw_dupli_objects(eval_ctx, scene, view_layer, ar, v3d, base); } if ((base->flag & BASE_SELECTED) == 0) { - if (base->object != scene->obedit) + if (base->object != obedit) draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); } } @@ -1613,7 +1614,7 @@ static void view3d_draw_objects( /* draw selected and editmode */ for (base = view_layer->object_bases.first; base; base = base->next) { if ((base->flag & BASE_VISIBLED) != 0) { - if (base->object == scene->obedit || (base->flag & BASE_SELECTED)) { + if ((base->object == scene->obedit) || (base->flag & BASE_SELECTED)) { draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0); } } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 5f38cbddce0..bf4abf1852d 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -95,14 +95,14 @@ static void handle_view3d_lock(bContext *C) * - uiTemplateLayers in interface/ code for buttons * - ED_view3d_view_layer_set for RNA */ -static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d) +static void view3d_layers_editmode_ensure(View3D *v3d, Object *obedit) { /* sanity check - when in editmode disallow switching the editmode layer off since its confusing * an alternative would be to always draw the editmode object. */ - if (scene->obedit && (scene->obedit->lay & v3d->lay) == 0) { + if (obedit && (obedit->lay & v3d->lay) == 0) { int bit; for (bit = 0; bit < 32; bit++) { - if (scene->obedit->lay & (1u << bit)) { + if (obedit->lay & (1u << bit)) { v3d->lay |= (1u << bit); break; } @@ -112,9 +112,9 @@ static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d) static int view3d_layers_exec(bContext *C, wmOperator *op) { - Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; + Object *obedit = CTX_data_edit_object(C); int nr = RNA_int_get(op->ptr, "nr"); const bool toggle = RNA_boolean_get(op->ptr, "toggle"); @@ -130,7 +130,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) /* return to active layer only */ v3d->lay = v3d->lay_prev; - view3d_layers_editmode_ensure(scene, v3d); + view3d_layers_editmode_ensure(v3d, obedit); } else { v3d->lay_prev = v3d->lay; @@ -151,7 +151,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) v3d->lay = (1 << nr); } - view3d_layers_editmode_ensure(scene, v3d); + view3d_layers_editmode_ensure(v3d, obedit); /* set active layer, ensure to always have one */ if (v3d->lay & (1 << nr)) diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 0b913ad179d..0eb7a964fdf 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -166,7 +166,7 @@ void draw_object_instance(const struct EvaluationContext *eval_ctx, Scene *scene void draw_object_backbufsel(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob); void draw_object_wire_color( - const struct EvaluationContext *eval_ctx, Scene *scene, struct ViewLayer *, + const struct EvaluationContext *eval_ctx, 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, @@ -388,7 +388,7 @@ void VP_legacy_view3d_main_region_setup_view(const struct EvaluationContext *eva bool VP_legacy_view3d_stereo3d_active(struct wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d); void VP_legacy_view3d_stereo3d_setup(const struct EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar); void draw_dupli_objects(const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, ARegion *ar, View3D *v3d, Base *base); -bool VP_legacy_use_depth(Scene *scene, View3D *v3d); +bool VP_legacy_use_depth(View3D *v3d, struct Object *obedit); void VP_drawviewborder(Scene *scene, const struct Depsgraph *depsgraph, ARegion *ar, View3D *v3d); void VP_drawrenderborder(ARegion *ar, View3D *v3d); void VP_view3d_draw_background_none(void); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 89a033236f1..27625a02daa 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1549,7 +1549,7 @@ static bool ed_object_select_pick( } } else if (ED_do_pose_selectbuffer( - &eval_ctx, scene, view_layer, + &eval_ctx, view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) { /* then bone is found */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index a0918066887..4ccf86138e7 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -879,7 +879,7 @@ int view3d_opengl_select( ARegion *ar = vc->ar; rcti rect; int hits; - const bool use_obedit_skip = (scene->obedit != NULL) && (vc->obedit == NULL); + const bool use_obedit_skip = (OBEDIT_FROM_EVAL_CTX(eval_ctx) != NULL) && (vc->obedit == NULL); const bool is_pick_select = (U.gpu_select_pick_deph != 0); const bool do_passes = ( (is_pick_select == false) && -- cgit v1.2.3