diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-18 17:58:02 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-19 13:12:22 +0300 |
commit | e46c49ff3dd67c7d759b581b677b4ab90cee3c46 (patch) | |
tree | 30164c0344ba42ca408d3b66a3a7bedccb50a150 /source/blender/editors/space_view3d | |
parent | 9cac97fb3cb2c737266bc3c8b34494fbea5ff7f2 (diff) |
Fix T53788: Camera animation not working
Both object level and camera datablock properties animation did not work with
copy on write enabled.
The root of the issue is going to the fact, that all interface elements are
referencing original datablock. For example, View3D has pointer to camera it's
using, and all areas which does access v3d->camera should in fact query for
the evaluated version of that camera, within the current context.
Annoying part of this change is that we now need to pass depsgraph in lots
of places. Which is rather annoying.
Alternative would be to cache evaluated camera in viewport itself, but then
it makes it annoying to keep things in sync.
Not sure if there is nicer solution here.
Reviewers: dfelinto, campbellbarton, mont29
Subscribers: dragoneex
Differential Revision: https://developer.blender.org/D3007
Diffstat (limited to 'source/blender/editors/space_view3d')
9 files changed, 101 insertions, 68 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b1140113601..cf43d65b44a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -123,14 +123,14 @@ void ED_view3d_update_viewmat( const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4], const rcti *rect) { + const Depsgraph *depsgraph = eval_ctx->depsgraph; RegionView3D *rv3d = ar->regiondata; - /* setup window matrices */ if (winmat) copy_m4_m4(rv3d->winmat, winmat); else - view3d_winmatrix_set(ar, v3d, rect); + view3d_winmatrix_set(depsgraph, ar, v3d, rect); /* setup view matrix */ if (viewmat) @@ -148,7 +148,7 @@ void ED_view3d_update_viewmat( /* store window coordinates scaling/offset */ if (rv3d->persp == RV3D_CAMOB && v3d->camera) { rctf cameraborder; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &cameraborder, false); + ED_view3d_calc_camera_border(scene, eval_ctx->depsgraph, ar, v3d, rv3d, &cameraborder, false); rv3d->viewcamtexcofac[0] = (float)ar->winx / BLI_rctf_size_x(&cameraborder); rv3d->viewcamtexcofac[1] = (float)ar->winy / BLI_rctf_size_y(&cameraborder); @@ -307,7 +307,8 @@ void ED_view3d_draw_setup_view( /* ******************** view border ***************** */ static void view3d_camera_border( - const Scene *scene, const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d, + const Scene *scene, const struct Depsgraph *depsgraph, + const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d, rctf *r_viewborder, const bool no_shift, const bool no_zoom) { CameraParams params; @@ -315,7 +316,7 @@ static void view3d_camera_border( /* get viewport viewplane */ BKE_camera_params_init(¶ms); - BKE_camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); if (no_zoom) params.zoom = 1.0f; BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); @@ -342,21 +343,23 @@ static void view3d_camera_border( } void ED_view3d_calc_camera_border_size( - const Scene *scene, const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d, + const Scene *scene, const Depsgraph *depsgraph, + const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d, float r_size[2]) { rctf viewborder; - view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, true, true); + view3d_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, true, true); r_size[0] = BLI_rctf_size_x(&viewborder); r_size[1] = BLI_rctf_size_y(&viewborder); } void ED_view3d_calc_camera_border( - const Scene *scene, const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d, + const Scene *scene, const Depsgraph *depsgraph, + const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d, rctf *r_viewborder, const bool no_shift) { - view3d_camera_border(scene, ar, v3d, rv3d, r_viewborder, no_shift, false); + view3d_camera_border(scene, depsgraph, ar, v3d, rv3d, r_viewborder, no_shift, false); } static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, float y2, float fac) @@ -435,7 +438,7 @@ static void drawviewborder_triangle( immEnd(); } -static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) +static void drawviewborder(Scene *scene, const Depsgraph *depsgraph, ARegion *ar, View3D *v3d) { float x1, x2, y1, y2; float x1i, x2i, y1i, y2i; @@ -449,7 +452,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (v3d->camera->type == OB_CAMERA) ca = v3d->camera->data; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false); /* the offsets */ x1 = viewborder.xmin; y1 = viewborder.ymin; @@ -1598,11 +1601,12 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) static void view3d_draw_border(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); if (rv3d->persp == RV3D_CAMOB) { - drawviewborder(scene, ar, v3d); + drawviewborder(scene, depsgraph, ar, v3d); } else if (v3d->flag2 & V3D_RENDER_BORDER) { drawrenderborder(ar, v3d); @@ -2019,6 +2023,10 @@ void ED_view3d_draw_offscreen( else view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL); + /* XXX, should take depsgraph as arg */ + Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false); + BLI_assert(depsgraph != NULL); + /* main drawing call */ RenderEngineType *engine_type = eval_ctx->engine_type; if (engine_type->flag & RE_USE_LEGACY_PIPELINE) { @@ -2053,7 +2061,7 @@ void ED_view3d_draw_offscreen( if (v3d->flag2 & V3D_SHOW_GPENCIL) { /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ - ED_gpencil_draw_view3d(NULL, scene, view_layer, v3d, ar, false); + ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, false); } /* freeing the images again here could be done after the operator runs, leaving for now */ @@ -2061,9 +2069,6 @@ void ED_view3d_draw_offscreen( } } else { - /* XXX, should take depsgraph as arg */ - Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false); - BLI_assert(depsgraph != NULL); DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine_type, ar, v3d, do_sky, ofs, viewport); } @@ -2094,6 +2099,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( /* output vars */ GPUFX *fx, GPUOffScreen *ofs, char err_out[256]) { + const Depsgraph *depsgraph = eval_ctx->depsgraph; RegionView3D *rv3d = ar->regiondata; const bool draw_sky = (alpha_mode == R_ADDSKY); const bool draw_background = (draw_flags & V3D_OFSDRAW_USE_BACKGROUND); @@ -2149,7 +2155,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( rctf viewplane; float clipsta, clipend; - is_ortho = ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL); + is_ortho = ED_view3d_viewplane_get(depsgraph, v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL); if (is_ortho) { orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend); } @@ -2393,9 +2399,9 @@ bool VP_legacy_use_depth(Scene *scene, View3D *v3d) return use_depth_doit(scene, v3d); } -void VP_drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) +void VP_drawviewborder(Scene *scene, const struct Depsgraph *depsgraph, ARegion *ar, View3D *v3d) { - drawviewborder(scene, ar, v3d); + drawviewborder(scene, depsgraph, ar, v3d); } void VP_drawrenderborder(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 5702c32a344..e44f03775a1 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -530,7 +530,8 @@ static void view3d_stereo_bgpic_setup(Scene *scene, View3D *v3d, Image *ima, Ima } } -static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, +static void view3d_draw_bgpic(Scene *scene, const Depsgraph *depsgraph, + ARegion *ar, View3D *v3d, const bool do_foreground, const bool do_camera_frame) { RegionView3D *rv3d = ar->regiondata; @@ -629,7 +630,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, { if (do_camera_frame) { rctf vb; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); x1 = vb.xmin; y1 = vb.ymin; x2 = vb.xmax; @@ -773,7 +774,8 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, } } -void view3d_draw_bgpic_test(Scene *scene, ARegion *ar, View3D *v3d, +void view3d_draw_bgpic_test(Scene *scene, const Depsgraph *depsgraph, + ARegion *ar, View3D *v3d, const bool do_foreground, const bool do_camera_frame) { RegionView3D *rv3d = ar->regiondata; @@ -797,11 +799,11 @@ void view3d_draw_bgpic_test(Scene *scene, ARegion *ar, View3D *v3d, if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { if (rv3d->persp == RV3D_CAMOB) { - view3d_draw_bgpic(scene, ar, v3d, do_foreground, do_camera_frame); + view3d_draw_bgpic(scene, depsgraph, ar, v3d, do_foreground, do_camera_frame); } } else { - view3d_draw_bgpic(scene, ar, v3d, do_foreground, do_camera_frame); + view3d_draw_bgpic(scene, depsgraph, ar, v3d, do_foreground, do_camera_frame); } } @@ -1182,7 +1184,7 @@ void ED_view3d_draw_depth_gpencil( glEnable(GL_DEPTH_TEST); if (v3d->flag2 & V3D_SHOW_GPENCIL) { - ED_gpencil_draw_view3d(NULL, scene, eval_ctx->view_layer, v3d, ar, true); + ED_gpencil_draw_view3d(NULL, scene, eval_ctx->view_layer, eval_ctx->depsgraph, v3d, ar, true); } v3d->zbuf = zbuf; @@ -1500,6 +1502,7 @@ static void view3d_draw_objects( const bool do_bgpic, const bool draw_offscreen, GPUFX *fx) { ViewLayer *view_layer = C ? CTX_data_view_layer(C) : BKE_view_layer_from_scene_get(scene); + Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; Base *base; const bool do_camera_frame = !draw_offscreen; @@ -1544,7 +1547,7 @@ static void view3d_draw_objects( /* important to do before clipping */ if (do_bgpic) { - view3d_draw_bgpic_test(scene, ar, v3d, false, do_camera_frame); + view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, false, do_camera_frame); } if (rv3d->rflag & RV3D_CLIPPING) { @@ -1625,7 +1628,7 @@ static void view3d_draw_objects( /* must be before xray draw which clears the depth buffer */ if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - ED_gpencil_draw_view3d(wm, scene, view_layer, v3d, ar, true); + ED_gpencil_draw_view3d(wm, scene, view_layer, depsgraph, v3d, ar, true); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -1654,7 +1657,7 @@ static void view3d_draw_objects( /* important to do after clipping */ if (do_bgpic) { - view3d_draw_bgpic_test(scene, ar, v3d, true, do_camera_frame); + view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, true, do_camera_frame); } /* cleanup */ @@ -1773,7 +1776,7 @@ static bool view3d_main_region_do_render_draw(const Scene *scene) return (type && type->view_update && type->render_to_view); } -bool ED_view3d_calc_render_border(const Scene *scene, View3D *v3d, ARegion *ar, rcti *rect) +bool ED_view3d_calc_render_border(const Scene *scene, const Depsgraph *depsgraph, View3D *v3d, ARegion *ar, rcti *rect) { RegionView3D *rv3d = ar->regiondata; bool use_border; @@ -1794,7 +1797,7 @@ bool ED_view3d_calc_render_border(const Scene *scene, View3D *v3d, ARegion *ar, /* compute border */ if (rv3d->persp == RV3D_CAMOB) { rctf viewborder; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false); rect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder); rect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder); @@ -1823,11 +1826,11 @@ static bool view3d_main_region_draw_engine( ARegion *ar, View3D *v3d, bool clip_border, const rcti *border_rect) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; RenderEngineType *type; GLint scissor[4]; - /* create render engine */ if (!rv3d->render_engine) { RenderEngine *engine; @@ -1872,7 +1875,7 @@ static bool view3d_main_region_draw_engine( Camera *cam = ED_view3d_camera_data_get(v3d, rv3d); if (cam->flag & CAM_SHOW_BG_IMAGE) { show_image = true; - view3d_draw_bgpic_test(scene, ar, v3d, false, true); + view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, false, true); } else { imm_draw_box_checker_2d(0, 0, ar->winx, ar->winy); @@ -1880,7 +1883,7 @@ static bool view3d_main_region_draw_engine( } if (show_image) { - view3d_draw_bgpic_test(scene, ar, v3d, false, true); + view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, false, true); } else { imm_draw_box_checker_2d(0, 0, ar->winx, ar->winy); @@ -1891,7 +1894,7 @@ static bool view3d_main_region_draw_engine( type->render_to_view(rv3d->render_engine, C); if (show_image) { - view3d_draw_bgpic_test(scene, ar, v3d, true, true); + view3d_draw_bgpic_test(scene, depsgraph, ar, v3d, true, true); } if (clip_border) { @@ -2033,6 +2036,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, ARegion *ar, View3D *v3d, const char *grid_unit, bool render_border) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); wmWindowManager *wm = CTX_wm_manager(C); RegionView3D *rv3d = ar->regiondata; @@ -2042,7 +2046,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, ED_region_visible_rect(ar, &rect); if (rv3d->persp == RV3D_CAMOB) { - VP_drawviewborder(scene, ar, v3d); + VP_drawviewborder(scene, CTX_data_depsgraph(C), ar, v3d); } else if (v3d->flag2 & V3D_RENDER_BORDER) { VP_drawrenderborder(ar, v3d); @@ -2050,7 +2054,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, if (v3d->flag2 & V3D_SHOW_GPENCIL) { /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ - ED_gpencil_draw_view3d(wm, scene, view_layer, v3d, ar, false); + ED_gpencil_draw_view3d(wm, scene, view_layer, depsgraph, v3d, ar, false); } if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { @@ -2097,6 +2101,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); EvaluationContext eval_ctx; Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -2106,7 +2111,7 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar) /* if we only redraw render border area, skip opengl draw and also * don't do scissor because it's already set */ - bool render_border = ED_view3d_calc_render_border(scene, v3d, ar, &border_rect); + bool render_border = ED_view3d_calc_render_border(scene, depsgraph, v3d, ar, &border_rect); bool clip_border = (render_border && !BLI_rcti_compare(&ar->drawrct, &border_rect)); gpuPushProjectionMatrix(); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 0dba87bef25..d286e608de4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -525,6 +525,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) typedef struct ViewOpsData { /* context pointers (assigned by viewops_data_alloc) */ + const Depsgraph *depsgraph; Scene *scene; ScrArea *sa; ARegion *ar; @@ -596,6 +597,7 @@ static void viewops_data_alloc(bContext *C, wmOperator *op) /* store data */ op->customdata = vod; + vod->depsgraph = CTX_data_depsgraph(C); vod->scene = CTX_data_scene(C); vod->sa = CTX_wm_area(C); vod->ar = CTX_wm_region(C); @@ -2153,7 +2155,7 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf) } static void view_zoom_mouseloc_camera( - Scene *scene, View3D *v3d, + Scene *scene, const Depsgraph *depsgraph, View3D *v3d, ARegion *ar, float dfac, int mx, int my) { RegionView3D *rv3d = ar->regiondata; @@ -2171,13 +2173,13 @@ static void view_zoom_mouseloc_camera( float pt_dst[2]; float delta_px[2]; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &camera_frame_old, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &camera_frame_old, false); BLI_rctf_translate(&camera_frame_old, ar->winrct.xmin, ar->winrct.ymin); rv3d->camzoom = camzoom_new; CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &camera_frame_new, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &camera_frame_new, false); BLI_rctf_translate(&camera_frame_new, ar->winrct.xmin, ar->winrct.ymin); BLI_rctf_transform_pt_v(&camera_frame_new, &camera_frame_old, pt_dst, pt_src); @@ -2324,7 +2326,7 @@ static void viewzoom_apply_camera( /* calculate inverted, then invert again (needed because of camera zoom scaling) */ zfac = 1.0f / zfac; view_zoom_mouseloc_camera( - vod->scene, vod->v3d, + vod->scene, vod->depsgraph, vod->v3d, vod->ar, zfac, vod->oldx, vod->oldy); } @@ -2438,6 +2440,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) static int viewzoom_exec(bContext *C, wmOperator *op) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d; RegionView3D *rv3d; @@ -2474,7 +2477,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) const float step = 1.2f; /* this min and max is also in viewmove() */ if (use_cam_zoom) { - view_zoom_mouseloc_camera(scene, v3d, ar, step, mx, my); + view_zoom_mouseloc_camera(scene, depsgraph, v3d, ar, step, mx, my); } else { if (rv3d->dist < dist_range[1]) { @@ -2485,7 +2488,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) else { const float step = 1.0f / 1.2f; if (use_cam_zoom) { - view_zoom_mouseloc_camera(scene, v3d, ar, step, mx, my); + view_zoom_mouseloc_camera(scene, depsgraph, v3d, ar, step, mx, my); } else { if (rv3d->dist > dist_range[0]) { @@ -3374,6 +3377,7 @@ void VIEW3D_OT_view_center_pick(wmOperatorType *ot) static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */ { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); float xfac, yfac; float size[2]; @@ -3388,7 +3392,7 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was rv3d->camdx = rv3d->camdy = 0.0f; - ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size); + ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size); /* 4px is just a little room from the edge of the area */ xfac = (float)ar->winx / (float)(size[0] + 4); @@ -3447,6 +3451,7 @@ void VIEW3D_OT_view_center_lock(wmOperatorType *ot) static int render_border_exec(bContext *C, wmOperator *op) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); @@ -3467,7 +3472,7 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); } else { vb.xmin = 0; @@ -3760,13 +3765,13 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) } /* sets the view to 1:1 camera/render-pixel */ -static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar, View3D *v3d) +static void view3d_set_1_to_1_viewborder(Scene *scene, const Depsgraph *depsgraph, ARegion *ar, View3D *v3d) { RegionView3D *rv3d = ar->regiondata; float size[2]; int im_width = (scene->r.size * scene->r.xsch) / 100; - ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size); + ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size); rv3d->camzoom = BKE_screen_view3d_zoom_from_fac((float)im_width / size[0]); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); @@ -3774,6 +3779,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar, View3D *v3d) static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d; @@ -3782,7 +3788,7 @@ static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* no NULL check is needed, poll checks */ ED_view3d_context_user_region(C, &v3d, &ar); - view3d_set_1_to_1_viewborder(scene, ar, v3d); + view3d_set_1_to_1_viewborder(scene, depsgraph, ar, v3d); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 5e7eddb1c22..8a48b1dc3aa 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -193,6 +193,7 @@ typedef struct FlyInfo { RegionView3D *rv3d; View3D *v3d; ARegion *ar; + const struct Depsgraph *depsgraph; Scene *scene; wmTimer *timer; /* needed for redraws */ @@ -242,7 +243,7 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), float x1, x2, y1, y2; if (fly->scene->camera) { - ED_view3d_calc_camera_border(fly->scene, fly->ar, fly->v3d, fly->rv3d, &viewborder, false); + ED_view3d_calc_camera_border(fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false); xoff = viewborder.xmin; yoff = viewborder.ymin; } @@ -351,6 +352,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->rv3d = CTX_wm_region_view3d(C); fly->v3d = CTX_wm_view3d(C); fly->ar = CTX_wm_region(C); + fly->depsgraph = CTX_data_depsgraph(C); fly->scene = CTX_data_scene(C); #ifdef NDOF_FLY_DEBUG @@ -422,7 +424,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent /* calculate center */ if (fly->scene->camera) { - ED_view3d_calc_camera_border(fly->scene, fly->ar, fly->v3d, fly->rv3d, &viewborder, false); + ED_view3d_calc_camera_border(fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false); fly->width = BLI_rctf_size_x(&viewborder); fly->height = BLI_rctf_size_y(&viewborder); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index ee0b628fdad..8897b473b98 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -233,8 +233,9 @@ void ED_view3d_draw_select_loop( void ED_view3d_draw_depth_loop( const struct EvaluationContext *eval_ctx, Scene *scene, ARegion *ar, View3D *v3d); -void view3d_draw_bgpic_test(Scene *scene, ARegion *ar, View3D *v3d, - const bool do_foreground, const bool do_camera_frame); +void view3d_draw_bgpic_test(Scene *scene, const struct Depsgraph *depsgraph, + ARegion *ar, View3D *v3d, + const bool do_foreground, const bool do_camera_frame); void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag); @@ -279,7 +280,7 @@ void ED_view3d_smooth_view_force_finish( struct bContext *C, struct View3D *v3d, struct ARegion *ar); -void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rcti *rect); +void view3d_winmatrix_set(const struct Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, const rcti *rect); void view3d_viewmatrix_set(const struct EvaluationContext *eval_ctx, Scene *scene, const View3D *v3d, RegionView3D *rv3d); void fly_modal_keymap(struct wmKeyConfig *keyconf); @@ -376,7 +377,7 @@ bool VP_legacy_view3d_stereo3d_active(struct wmWindow *win, Scene *scene, View3D 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); -void VP_drawviewborder(Scene *scene, ARegion *ar, View3D *v3d); +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); void VP_view3d_draw_background_world(Scene *scene, RegionView3D *rv3d); diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c index d020571930a..6a45ec5095f 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c @@ -378,11 +378,12 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmManipulato struct CameraViewWidgetGroup *viewgroup = mgroup->customdata; ARegion *ar = CTX_wm_region(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewgroup->state.view_border, false); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewgroup->state.view_border, false); } else { viewgroup->state.view_border = (rctf){.xmin = 0, .ymin = 0, .xmax = ar->winx, .ymax = ar->winy}; diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index f8b02f0b405..af44629a18e 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -304,6 +304,7 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f } static void view3d_win_to_ray_segment( + const struct Depsgraph *depsgraph, const ARegion *ar, const View3D *v3d, const float mval[2], float r_ray_co[3], float r_ray_dir[3], float r_ray_start[3], float r_ray_end[3]) { @@ -321,7 +322,7 @@ static void view3d_win_to_ray_segment( start_offset = -end_offset; } else { - ED_view3d_clip_range_get(v3d, rv3d, &start_offset, &end_offset, false); + ED_view3d_clip_range_get(depsgraph, v3d, rv3d, &start_offset, &end_offset, false); } if (r_ray_start) { @@ -360,12 +361,13 @@ bool ED_view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float * \return success, false if the ray is totally clipped. */ bool ED_view3d_win_to_ray_ex( + const struct Depsgraph *depsgraph, const ARegion *ar, const View3D *v3d, const float mval[2], float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip) { float ray_end[3]; - view3d_win_to_ray_segment(ar, v3d, mval, r_ray_co, r_ray_normal, r_ray_start, ray_end); + view3d_win_to_ray_segment(depsgraph, ar, v3d, mval, r_ray_co, r_ray_normal, r_ray_start, ray_end); /* bounds clipping */ if (do_clip) { @@ -389,10 +391,11 @@ bool ED_view3d_win_to_ray_ex( * \return success, false if the ray is totally clipped. */ bool ED_view3d_win_to_ray( + const struct Depsgraph *depsgraph, const ARegion *ar, const View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_normal[3], const bool do_clip) { - return ED_view3d_win_to_ray_ex(ar, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip); + return ED_view3d_win_to_ray_ex(depsgraph,ar, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip); } /** @@ -622,10 +625,11 @@ void ED_view3d_win_to_vector(const ARegion *ar, const float mval[2], float out[3 * \param do_clip Optionally clip the ray by the view clipping planes. * \return success, false if the segment is totally clipped. */ -bool ED_view3d_win_to_segment(const ARegion *ar, View3D *v3d, const float mval[2], +bool ED_view3d_win_to_segment(const struct Depsgraph *depsgraph, + const ARegion *ar, View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_end[3], const bool do_clip) { - view3d_win_to_ray_segment(ar, v3d, mval, NULL, NULL, r_ray_start, r_ray_end); + view3d_win_to_ray_segment(depsgraph, ar, v3d, mval, NULL, NULL, r_ray_start, r_ray_end); /* bounds clipping */ if (do_clip) { diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 880707f3b4b..72443a5a227 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -68,6 +68,7 @@ #include "DRW_engine.h" +#include "DEG_depsgraph_query.h" #ifdef WITH_GAMEENGINE # include "BLI_listbase.h" @@ -925,6 +926,7 @@ void ED_view3d_dist_range_get( /* copies logic of get_view3d_viewplane(), keep in sync */ bool ED_view3d_clip_range_get( + const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, float *r_clipsta, float *r_clipend, const bool use_ortho_factor) @@ -932,7 +934,7 @@ bool ED_view3d_clip_range_get( CameraParams params; BKE_camera_params_init(¶ms); - BKE_camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); if (use_ortho_factor && params.is_ortho) { const float fac = 2.0f / (params.clipend - params.clipsta); @@ -947,13 +949,14 @@ bool ED_view3d_clip_range_get( } bool ED_view3d_viewplane_get( + const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, int winx, int winy, rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize) { CameraParams params; BKE_camera_params_init(¶ms); - BKE_camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); BKE_camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); if (r_viewplane) *r_viewplane = params.viewplane; @@ -992,14 +995,14 @@ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) /** * \param rect optional for picking (can be NULL). */ -void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rcti *rect) +void view3d_winmatrix_set(const Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, const rcti *rect) { RegionView3D *rv3d = ar->regiondata; rctf viewplane; float clipsta, clipend; bool is_ortho; - is_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); + is_ortho = ED_view3d_viewplane_get(depsgraph, v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); rv3d->is_persp = !is_ortho; #if 0 @@ -1113,8 +1116,10 @@ void view3d_viewmatrix_set(const EvaluationContext *eval_ctx, Scene *scene, cons { if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { - BKE_object_where_is_calc(eval_ctx, scene, v3d->camera); - obmat_to_viewmat(rv3d, v3d->camera); + const Depsgraph *depsgraph = eval_ctx->depsgraph; + Object *camera_object = DEG_get_evaluated_object(depsgraph, v3d->camera); + BKE_object_where_is_calc(eval_ctx, scene, camera_object); + obmat_to_viewmat(rv3d, camera_object); } else { quat_to_mat4(rv3d->viewmat, rv3d->viewquat); @@ -1533,9 +1538,10 @@ static int game_engine_exec(bContext *C, wmOperator *op) (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) && (startscene->gm.stereoflag != STEREO_DOME)) { + const Depsgraph *depsgraph = CTX_data_depsgraph(C); /* Letterbox */ rctf cam_framef; - ED_view3d_calc_camera_border(startscene, ar, CTX_wm_view3d(C), rv3d, &cam_framef, false); + ED_view3d_calc_camera_border(startscene, depsgraph, ar, CTX_wm_view3d(C), rv3d, &cam_framef, false); cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin; cam_frame.xmax = cam_framef.xmax + ar->winrct.xmin; cam_frame.ymin = cam_framef.ymin + ar->winrct.ymin; diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index dd8607bb3eb..724f60734f1 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -249,6 +249,7 @@ typedef struct WalkInfo { RegionView3D *rv3d; View3D *v3d; ARegion *ar; + const struct Depsgraph *depsgraph; Scene *scene; ViewLayer *view_layer; RenderEngineType *engine_type; @@ -334,7 +335,7 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a rctf viewborder; if (walk->scene->camera) { - ED_view3d_calc_camera_border(walk->scene, ar, walk->v3d, walk->rv3d, &viewborder, false); + ED_view3d_calc_camera_border(walk->scene, walk->depsgraph, ar, walk->v3d, walk->rv3d, &viewborder, false); xoff = viewborder.xmin + BLI_rctf_size_x(&viewborder) * 0.5f; yoff = viewborder.ymin + BLI_rctf_size_y(&viewborder) * 0.5f; } @@ -513,6 +514,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d = CTX_wm_region_view3d(C); walk->v3d = CTX_wm_view3d(C); walk->ar = CTX_wm_region(C); + walk->depsgraph = CTX_data_depsgraph(C); walk->scene = CTX_data_scene(C); walk->view_layer = CTX_data_view_layer(C); walk->engine_type = CTX_data_engine_type(C); |