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
This commit is contained in:
Sergey Sharybin 2018-01-18 15:58:02 +01:00
parent 9cac97fb3c
commit e46c49ff3d
Notes: blender-bot 2023-02-14 06:15:57 +01:00
Referenced by issue #53788, Camera animation not working
38 changed files with 231 additions and 129 deletions

View File

@ -39,6 +39,7 @@ extern "C" {
#include "DNA_vec_types.h"
struct Camera;
struct Depsgraph;
struct Main;
struct Object;
struct RegionView3D;
@ -113,7 +114,7 @@ typedef struct CameraParams {
void BKE_camera_params_init(CameraParams *params);
void BKE_camera_params_from_object(CameraParams *params, const struct Object *camera);
void BKE_camera_params_from_view3d(CameraParams *params, const struct View3D *v3d, const struct RegionView3D *rv3d);
void BKE_camera_params_from_view3d(CameraParams *params, const struct Depsgraph *depsgraph, const struct View3D *v3d, const struct RegionView3D *rv3d);
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy);
void BKE_camera_params_compute_matrix(CameraParams *params);

View File

@ -57,6 +57,8 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
#include "GPU_compositing.h"
@ -262,7 +264,7 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
}
}
void BKE_camera_params_from_view3d(CameraParams *params, const View3D *v3d, const RegionView3D *rv3d)
void BKE_camera_params_from_view3d(CameraParams *params, const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d)
{
/* common */
params->lens = v3d->lens;
@ -271,7 +273,8 @@ void BKE_camera_params_from_view3d(CameraParams *params, const View3D *v3d, cons
if (rv3d->persp == RV3D_CAMOB) {
/* camera view */
BKE_camera_params_from_object(params, v3d->camera);
Object *camera_object = DEG_get_evaluated_object(depsgraph, v3d->camera);
BKE_camera_params_from_object(params, camera_object);
params->zoom = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);

View File

@ -45,6 +45,7 @@
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "eevee_private.h"
#include "GPU_extensions.h"
@ -96,7 +97,8 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
const float *viewport_size = DRW_viewport_size_get();
Camera *cam = (Camera *)v3d->camera->data;
Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
Camera *cam = (Camera *)camera_object->data;
/* Retreive Near and Far distance */
effects->dof_near_far[0] = -cam->clipsta;
@ -145,7 +147,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
float rotation = cam->gpu_dof.rotation;
float ratio = 1.0f / cam->gpu_dof.ratio;
float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
float focus_dist = BKE_camera_object_dof_distance(v3d->camera);
float focus_dist = BKE_camera_object_dof_distance(camera_object);
float focal_len = cam->lens;
UNUSED_VARS(rotation, ratio);

View File

@ -40,6 +40,7 @@
#include "ED_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "eevee_private.h"
#include "GPU_texture.h"
@ -147,11 +148,12 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
float persmat[4][4];
float ctime = BKE_scene_frame_get(scene);
float delta = BKE_collection_engine_property_value_get_float(props, "motion_blur_shutter");
Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
/* Current matrix */
eevee_motion_blur_camera_get_matrix_at_time(scene,
ar, rv3d, v3d,
v3d->camera,
camera_object,
ctime,
effects->current_ndc_to_world);
@ -165,7 +167,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
/* Past matrix */
eevee_motion_blur_camera_get_matrix_at_time(scene,
ar, rv3d, v3d,
v3d->camera,
camera_object,
ctime - delta,
effects->past_world_to_ndc);
@ -173,7 +175,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
/* Future matrix */
eevee_motion_blur_camera_get_matrix_at_time(scene,
ar, rv3d, v3d,
v3d->camera,
camera_object,
ctime + delta,
effects->future_world_to_ndc);
#endif

View File

@ -61,6 +61,8 @@
#include "draw_manager_text.h"
#include "draw_common.h"
#include "DEG_depsgraph_query.h"
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
extern struct GPUTexture *globals_ramp; /* draw_common.c */
extern GlobalsUboStorage ts;
@ -506,8 +508,14 @@ static void OBJECT_engine_init(void *vedata)
e_data.zneg_flag = e_data.zpos_flag = CLIP_ZNEG | CLIP_ZPOS;
}
float dist = (rv3d->persp == RV3D_CAMOB && v3d->camera)
? ((Camera *)v3d->camera)->clipend : v3d->far;
float dist;
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
dist = ((Camera *)camera_object)->clipend;
}
else {
dist = v3d->far;
}
e_data.grid_settings[0] = dist / 2.0f; /* gridDistance */
e_data.grid_settings[1] = grid_res; /* gridResolution */

View File

@ -929,7 +929,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
float pval[2] = {0, 0};
ED_view3d_project_float_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP);
ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal, false);
ED_view3d_win_to_ray(CTX_data_depsgraph(C), ar, v3d, pval, ray_start, ray_normal, false);
mul_v3_fl(ray_normal, distance * progress / length);
add_v3_v3(stk->points[i].p, ray_normal);
@ -1486,6 +1486,7 @@ static int cmpIntersections(const void *i1, const void *i2)
/* returns the maximum number of intersections per stroke */
static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Stroke *gesture)
{
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
@ -1526,7 +1527,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
mval[0] = vi[0];
mval[1] = vi[1];
ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end, true);
ED_view3d_win_to_segment(depsgraph, ar, v3d, mval, ray_start, ray_end, true);
isect_line_line_v3(stk->points[s_i].p,
stk->points[s_i + 1].p,

View File

@ -93,6 +93,8 @@ struct StrokeElem {
};
struct CurveDrawData {
const Depsgraph *depsgraph;
short init_event_type;
short curve_type;
@ -199,7 +201,7 @@ static bool stroke_elem_project(
if (cdd->project.use_plane) {
/* get the view vector to 'location' */
float ray_origin[3], ray_direction[3];
ED_view3d_win_to_ray(cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false);
ED_view3d_win_to_ray(cdd->depsgraph, cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false);
float lambda;
if (isect_ray_plane_v3(ray_origin, ray_direction, cdd->project.plane, &lambda, true)) {
@ -603,6 +605,8 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__);
cdd->depsgraph = CTX_data_depsgraph(C);
if (is_invoke) {
view3d_set_viewcontext(C, &cdd->vc);
if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) {

View File

@ -1672,6 +1672,7 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
void ED_gpencil_draw_view3d(wmWindowManager *wm,
Scene *scene,
ViewLayer *view_layer,
const struct Depsgraph *depsgraph,
View3D *v3d,
ARegion *ar,
bool only3d)
@ -1688,7 +1689,7 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm,
* deal with the camera border, otherwise map the coords to the camera border. */
if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) {
rctf rectf;
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, true); /* no shift */
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &rectf, true); /* no shift */
offsx = round_fl_to_int(rectf.xmin);
offsy = round_fl_to_int(rectf.ymin);

View File

@ -1111,7 +1111,8 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect)
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
Scene *scene = CTX_data_scene(C);
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, true); /* no shift */
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, subrect, true); /* no shift */
return 1;
}
}

View File

@ -1609,7 +1609,7 @@ static void gp_session_cleanup(tGPsdata *p)
}
/* init new stroke */
static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode)
static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, const Depsgraph *depsgraph)
{
Scene *scene = p->scene;
ToolSettings *ts = scene->toolsettings;
@ -1738,7 +1738,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode)
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, true); /* no shift */
ED_view3d_calc_camera_border(p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); /* no shift */
p->subrect = &p->subrect_data;
}
}
@ -1979,7 +1979,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
}
/* init painting data */
gp_paint_initstroke(p, paintmode);
gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C));
if (p->status == GP_STATUS_ERROR) {
gpencil_draw_exit(C, op);
return 0;
@ -2056,7 +2056,7 @@ static void gpencil_draw_status_indicators(tGPsdata *p)
/* ------------------------------- */
/* create a new stroke point at the point indicated by the painting context */
static void gpencil_draw_apply(wmOperator *op, tGPsdata *p)
static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, const Depsgraph *depsgraph)
{
/* handle drawing/erasing -> test for erasing first */
if (p->paintmode == GP_PAINTMODE_ERASER) {
@ -2078,7 +2078,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p)
/* finish off old stroke */
gp_paint_strokeend(p);
/* And start a new one!!! Else, projection errors! */
gp_paint_initstroke(p, p->paintmode);
gp_paint_initstroke(p, p->paintmode, depsgraph);
/* start a new stroke, starting from previous point */
/* XXX Must manually reset inittime... */
@ -2111,7 +2111,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p)
}
/* handle draw event */
static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event)
static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event, const Depsgraph *depsgraph)
{
tGPsdata *p = op->customdata;
PointerRNA itemptr;
@ -2216,7 +2216,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event)
RNA_float_set(&itemptr, "time", p->curtime - p->inittime);
/* apply the current latest drawing point */
gpencil_draw_apply(op, p);
gpencil_draw_apply(op, p, depsgraph);
/* force refresh */
ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */
@ -2228,6 +2228,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event)
static int gpencil_draw_exec(bContext *C, wmOperator *op)
{
tGPsdata *p = NULL;
Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* printf("GPencil - Starting Re-Drawing\n"); */
@ -2265,7 +2266,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
if ((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) {
/* TODO: both of these ops can set error-status, but we probably don't need to worry */
gp_paint_strokeend(p);
gp_paint_initstroke(p, p->paintmode);
gp_paint_initstroke(p, p->paintmode, depsgraph);
}
}
@ -2280,7 +2281,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
}
/* apply this data as necessary now (as per usual) */
gpencil_draw_apply(op, p);
gpencil_draw_apply(op, p, depsgraph);
}
RNA_END;
@ -2339,7 +2340,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
p->status = GP_STATUS_PAINTING;
/* handle the initial drawing - i.e. for just doing a simple dot */
gpencil_draw_apply_event(op, event);
gpencil_draw_apply_event(op, event, CTX_data_depsgraph(C));
op->flag |= OP_IS_MODAL_CURSOR_REGION;
}
else {
@ -2380,7 +2381,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
* it'd be nice to allow changing paint-mode when in sketching-sessions */
if (gp_session_initdata(C, p))
gp_paint_initstroke(p, p->paintmode);
gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
if (p->status != GP_STATUS_ERROR) {
p->status = GP_STATUS_PAINTING;
@ -2671,7 +2672,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) || (p->flags & GP_PAINTFLAG_FIRSTRUN)) {
/* handle drawing event */
/* printf("\t\tGP - add point\n"); */
gpencil_draw_apply_event(op, event);
gpencil_draw_apply_event(op, event, CTX_data_depsgraph(C));
/* finish painting operation if anything went wrong just now */
if (p->status == GP_STATUS_ERROR) {

View File

@ -553,7 +553,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &r_gsc->subrect_data, true); /* no shift */
ED_view3d_calc_camera_border(scene, CTX_data_depsgraph(C), ar, v3d, rv3d, &r_gsc->subrect_data, true); /* no shift */
r_gsc->subrect = &r_gsc->subrect_data;
}
}

View File

@ -35,6 +35,7 @@
struct ID;
struct ListBase;
struct bContext;
struct Depsgraph;
struct ScrArea;
struct ARegion;
struct View3D;
@ -152,6 +153,7 @@ void ED_gpencil_draw_view2d(const struct bContext *C, bool onlyv2d);
void ED_gpencil_draw_view3d(struct wmWindowManager *wm,
struct Scene *scene,
struct ViewLayer *view_layer,
const struct Depsgraph *depsgraph,
struct View3D *v3d,
struct ARegion *ar,
bool only3d);

View File

@ -40,6 +40,7 @@ struct EvaluationContext;
struct View3D;
struct ARegion;
struct bContext;
struct Depsgraph;
struct wmOperator;
struct wmKeyConfig;
struct ReportList;
@ -126,6 +127,7 @@ void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag);
void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag);
bool BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
const struct Depsgraph *depsgraph,
struct ARegion *ar, struct View3D *v3d, struct Object *obedit);
/* editmesh_select.c */

View File

@ -227,9 +227,11 @@ eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *ar, const fl
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip);
bool ED_view3d_clip_segment(const struct RegionView3D *rv3d, float ray_start[3], float ray_end[3]);
bool ED_view3d_win_to_ray(
const struct Depsgraph *depsgraph,
const struct ARegion *ar, const struct View3D *v3d, const float mval[2],
float ray_start[3], float ray_normal[3], const bool do_clip);
bool ED_view3d_win_to_ray_ex(
const struct Depsgraph *depsgraph,
const struct ARegion *ar, const struct View3D *v3d, const float mval[2],
float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip);
void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3]);
@ -244,7 +246,8 @@ void ED_view3d_win_to_3d_int(
void ED_view3d_win_to_delta(const struct ARegion *ar, const float mval[2], float out[3], const float zfac);
void ED_view3d_win_to_origin(const struct ARegion *ar, const float mval[2], float out[3]);
void ED_view3d_win_to_vector(const struct ARegion *ar, const float mval[2], float out[3]);
bool ED_view3d_win_to_segment(const struct ARegion *ar, struct View3D *v3d, const float mval[2],
bool ED_view3d_win_to_segment(const struct Depsgraph *depsgraph,
const struct ARegion *ar, struct View3D *v3d, const float mval[2],
float r_ray_start[3], float r_ray_end[3], const bool do_clip);
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
void ED_view3d_ob_project_mat_get_from_obmat(const struct RegionView3D *rv3d, float obmat[4][4], float pmat[4][4]);
@ -259,24 +262,29 @@ void ED_view3d_dist_range_get(
const struct View3D *v3d,
float r_dist_range[2]);
bool ED_view3d_clip_range_get(
const struct Depsgraph *depsgraph,
const struct View3D *v3d, const struct RegionView3D *rv3d,
float *r_clipsta, float *r_clipend, const bool use_ortho_factor);
bool ED_view3d_viewplane_get(
const struct Depsgraph *depsgraph,
const struct View3D *v3d, const struct RegionView3D *rv3d, int winxi, int winyi,
struct rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize);
void ED_view3d_polygon_offset(const struct RegionView3D *rv3d, const float dist);
void ED_view3d_calc_camera_border(
const struct Scene *scene, const struct ARegion *ar,
const struct Scene *scene, const struct Depsgraph *depsgraph,
const struct ARegion *ar,
const struct View3D *v3d, const struct RegionView3D *rv3d,
struct rctf *r_viewborder, const bool no_shift);
void ED_view3d_calc_camera_border_size(
const struct Scene *scene, const struct ARegion *ar,
const struct Scene *scene, const struct Depsgraph *depsgraph,
const struct ARegion *ar,
const struct View3D *v3d, const struct RegionView3D *rv3d,
float r_size[2]);
bool ED_view3d_calc_render_border(
const struct Scene *scene, struct View3D *v3d,
const struct Scene *scene, const struct Depsgraph *depsgraph,
struct View3D *v3d,
struct ARegion *ar, struct rcti *rect);
void ED_view3d_clipping_calc_from_boundbox(float clip[6][4], const struct BoundBox *clipbb, const bool is_flip);

View File

@ -195,7 +195,7 @@ bool manipulator_window_project_2d(
float ray_origin[3], ray_direction[3];
if (ED_view3d_win_to_ray(ar, v3d, mval, ray_origin, ray_direction, false)) {
if (ED_view3d_win_to_ray(CTX_data_depsgraph(C), ar, v3d, mval, ray_origin, ray_direction, false)) {
float lambda;
if (isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, true)) {
float co[3];

View File

@ -262,6 +262,7 @@ static int manipulator_arrow_modal(
for (int j = 0; j < 2; j++) {
if (ED_view3d_win_to_ray(
CTX_data_depsgraph(C),
ar, v3d, proj[j].mval,
proj[j].ray_origin, proj[j].ray_direction, false))
{

View File

@ -191,6 +191,7 @@ static void dial_ghostarc_draw(
}
static void dial_ghostarc_get_angles(
const struct Depsgraph *depsgraph,
const wmManipulator *mpr,
const wmEvent *event,
const ARegion *ar, const View3D *v3d,
@ -218,7 +219,7 @@ static void dial_ghostarc_get_angles(
plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec);
if (!ED_view3d_win_to_ray(ar, v3d, inter->init_mval, ray_co, ray_no, false) ||
if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) ||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
{
goto fail;
@ -226,7 +227,7 @@ static void dial_ghostarc_get_angles(
madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda);
sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]);
if (!ED_view3d_win_to_ray(ar, v3d, mval, ray_co, ray_no, false) ||
if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, mval, ray_co, ray_no, false) ||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
{
goto fail;
@ -396,6 +397,7 @@ static int manipulator_dial_modal(
dial_calc_matrix(mpr, matrix);
dial_ghostarc_get_angles(
CTX_data_depsgraph(C),
mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta);
DialInteraction *inter = mpr->interaction_data;

View File

@ -1562,8 +1562,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
}
/* unproject screen line */
ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s1, v1, v3, true);
ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s2, v2, v4, true);
ED_view3d_win_to_segment(kcd->eval_ctx.depsgraph, kcd->ar, kcd->vc.v3d, s1, v1, v3, true);
ED_view3d_win_to_segment(kcd->eval_ctx.depsgraph, kcd->ar, kcd->vc.v3d, s2, v2, v4, true);
mul_m4_v3(kcd->ob->imat, v1);
mul_m4_v3(kcd->ob->imat, v2);
@ -2519,7 +2519,8 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd)
mul_v3_mat3_m4v3(kcd->proj_zaxis, kcd->ob->imat, kcd->vc.rv3d->viewinv[2]);
normalize_v3(kcd->proj_zaxis);
kcd->is_ortho = ED_view3d_clip_range_get(kcd->vc.v3d, kcd->vc.rv3d,
kcd->is_ortho = ED_view3d_clip_range_get(kcd->eval_ctx.depsgraph,
kcd->vc.v3d, kcd->vc.rv3d,
&kcd->clipsta, &kcd->clipend, true);
}

View File

@ -416,6 +416,7 @@ static BMElem *edbm_hover_preselect(
BMElem *ele_best = NULL;
if (ED_view3d_win_to_ray(
CTX_data_depsgraph(C),
vc.ar, vc.v3d, mval_fl,
ray_origin, ray_direction, true))
{

View File

@ -1392,7 +1392,9 @@ static void scale_point(float c1[3], const float p[3], const float s)
add_v3_v3(c1, p);
}
bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Object *obedit)
bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e,
const struct Depsgraph *depsgraph,
ARegion *ar, View3D *v3d, Object *obedit)
{
BMFace *f;
float co1[3], co2[3], co3[3], dir1[3], dir2[3], dir3[3];
@ -1402,7 +1404,7 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v
const float mval_f[2] = {ar->winx / 2.0f,
ar->winy / 2.0f};
ED_view3d_win_to_segment(ar, v3d, mval_f, origin, end, false);
ED_view3d_win_to_segment(depsgraph, ar, v3d, mval_f, origin, end, false);
invert_m4_m4(invmat, obedit->obmat);
mul_m4_v3(invmat, origin);

View File

@ -3517,6 +3517,7 @@ static int particle_intersect_dm(const bContext *C, Scene *scene, Object *ob, De
static int brush_add(const bContext *C, PEData *data, short number)
{
EvaluationContext eval_ctx;
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene= data->scene;
Object *ob= data->ob;
DerivedMesh *dm;
@ -3580,7 +3581,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
mco[0] = data->mval[0] + dmx;
mco[1] = data->mval[1] + dmy;
ED_view3d_win_to_segment(data->vc.ar, data->vc.v3d, mco, co1, co2, true);
ED_view3d_win_to_segment(depsgraph, data->vc.ar, data->vc.v3d, mco, co1, co2, true);
mul_m4_v3(imat, co1);
mul_m4_v3(imat, co2);

View File

@ -1067,6 +1067,7 @@ typedef struct RenderPreview {
wmJob *job;
Scene *scene;
Depsgraph *depsgraph;
ScrArea *sa;
ARegion *ar;
View3D *v3d;
@ -1081,7 +1082,8 @@ typedef struct RenderPreview {
bool has_freestyle;
} RenderPreview;
static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rcti *disprect)
static int render_view3d_disprect(Scene *scene, const Depsgraph *depsgraph,
ARegion *ar, View3D *v3d, RegionView3D *rv3d, rcti *disprect)
{
/* copied code from view3d_draw.c */
rctf viewborder;
@ -1094,7 +1096,7 @@ static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, Region
if (draw_border) {
if (rv3d->persp == RV3D_CAMOB) {
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false);
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false);
disprect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder);
disprect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder);
@ -1116,13 +1118,15 @@ static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, Region
}
/* returns true if OK */
static bool render_view3d_get_rects(ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewplane, RenderEngine *engine,
float *r_clipsta, float *r_clipend, float *r_pixsize, bool *r_ortho)
static bool render_view3d_get_rects(
const Depsgraph *depsgraph,
ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewplane, RenderEngine *engine,
float *r_clipsta, float *r_clipend, float *r_pixsize, bool *r_ortho)
{
if (ar->winx < 4 || ar->winy < 4) return false;
*r_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, viewplane, r_clipsta, r_clipend, r_pixsize);
*r_ortho = ED_view3d_viewplane_get(depsgraph, v3d, rv3d, ar->winx, ar->winy, viewplane, r_clipsta, r_clipend, r_pixsize);
engine->resolution_x = ar->winx;
engine->resolution_y = ar->winy;
@ -1229,7 +1233,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
G.is_break = false;
if (false == render_view3d_get_rects(rp->ar, rp->v3d, rp->rv3d, &viewplane, rp->engine, &clipsta, &clipend, &pixsize, &orth))
if (false == render_view3d_get_rects(rp->depsgraph, rp->ar, rp->v3d, rp->rv3d, &viewplane, rp->engine, &clipsta, &clipend, &pixsize, &orth))
return;
rp->stop = stop;
@ -1262,8 +1266,9 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda
}
}
use_border = render_view3d_disprect(rp->scene, rp->ar, rp->v3d,
rp->rv3d, &cliprct);
use_border = render_view3d_disprect(rp->scene, rp->depsgraph,
rp->ar, rp->v3d, rp->rv3d,
&cliprct);
if ((update_flag & (PR_UPDATE_RENDERSIZE | PR_UPDATE_DATABASE | PR_UPDATE_VIEW)) || rstats->convertdone == 0) {
RenderData rdata;
@ -1386,6 +1391,7 @@ static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C)
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Render *re;
rctf viewplane;
rcti disprect;
@ -1435,14 +1441,14 @@ static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C)
job_update_flag |= PR_UPDATE_VIEW;
}
render_view3d_get_rects(ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);
render_view3d_get_rects(depsgraph, ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);
if (BLI_rctf_compare(&viewplane, &engine->last_viewplane, 0.00001f) == 0) {
engine->last_viewplane = viewplane;
job_update_flag |= PR_UPDATE_VIEW;
}
render_view3d_disprect(scene, ar, v3d, rv3d, &disprect);
render_view3d_disprect(scene, depsgraph, ar, v3d, rv3d, &disprect);
if (BLI_rcti_compare(&disprect, &engine->last_disprect) == 0) {
engine->last_disprect = disprect;
job_update_flag |= PR_UPDATE_RENDERSIZE;
@ -1462,6 +1468,7 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C)
wmJob *wm_job;
RenderPreview *rp;
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
int width = ar->winx, height = ar->winy;
int divider = BKE_render_preview_pixel_size(&scene->r);
@ -1486,6 +1493,7 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C)
/* customdata for preview thread */
rp->scene = scene;
rp->depsgraph = depsgraph;
rp->engine = engine;
rp->sa = CTX_wm_area(C);
rp->ar = CTX_wm_region(C);
@ -1543,6 +1551,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
bool force_fallback = false;
bool need_fallback = true;
@ -1551,7 +1560,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
rcti clip_rect;
int xof, yof;
if (render_view3d_disprect(scene, ar, v3d, rv3d, &clip_rect)) {
if (render_view3d_disprect(scene, depsgraph, ar, v3d, rv3d, &clip_rect)) {
scale_x = (float) BLI_rcti_size_x(&clip_rect) / rres.rectx;
scale_y = (float) BLI_rcti_size_y(&clip_rect) / rres.recty;
xof = clip_rect.xmin;

View File

@ -227,6 +227,7 @@ typedef struct ProjPaintState {
View3D *v3d;
RegionView3D *rv3d;
ARegion *ar;
const Depsgraph *depsgraph;
Scene *scene;
int source; /* PROJ_SRC_**** */
@ -3133,7 +3134,7 @@ static void proj_paint_state_viewport_init(
ED_view3d_ob_project_mat_get_from_obmat(ps->rv3d, ps->obmat, ps->projectMat);
ps->is_ortho = ED_view3d_clip_range_get(ps->v3d, ps->rv3d, &ps->clipsta, &ps->clipend, true);
ps->is_ortho = ED_view3d_clip_range_get(ps->depsgraph, ps->v3d, ps->rv3d, &ps->clipsta, &ps->clipend, true);
}
else {
/* re-projection */
@ -5098,6 +5099,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->rv3d = CTX_wm_region_view3d(C);
ps->ar = CTX_wm_region(C);
ps->depsgraph = CTX_data_depsgraph(C);
ps->scene = scene;
ps->ob = ob; /* allow override of active object */
@ -5508,7 +5510,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
array = (float *)IDP_Array(view_data);
memcpy(array, rv3d->winmat, sizeof(rv3d->winmat)); array += sizeof(rv3d->winmat) / sizeof(float);
memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat) / sizeof(float);
is_ortho = ED_view3d_clip_range_get(v3d, rv3d, &array[0], &array[1], true);
is_ortho = ED_view3d_clip_range_get(CTX_data_depsgraph(C), v3d, rv3d, &array[0], &array[1], true);
/* using float for a bool is dodgy but since its an extra member in the array...
* easier then adding a single bool prop */
array[2] = is_ortho ? 1.0f : 0.0f;

View File

@ -4692,7 +4692,7 @@ static float sculpt_raycast_init(
RegionView3D *rv3d = vc->ar->regiondata;
/* TODO: what if the segment is totally clipped? (return == 0) */
ED_view3d_win_to_segment(vc->ar, vc->v3d, mouse, ray_start, ray_end, true);
ED_view3d_win_to_segment(vc->depsgraph, vc->ar, vc->v3d, mouse, ray_start, ray_end, true);
invert_m4_m4(obimat, ob->obmat);
mul_m4_v3(obimat, ray_start);

View File

@ -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(&params);
BKE_camera_params_from_view3d(&params, v3d, rv3d);
BKE_camera_params_from_view3d(&params, depsgraph, v3d, rv3d);
if (no_zoom)
params.zoom = 1.0f;
BKE_camera_params_compute_viewplane(&params, 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)

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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};

View File

@ -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) {

View File

@ -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(&params);
BKE_camera_params_from_view3d(&params, v3d, rv3d);
BKE_camera_params_from_view3d(&params, 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(&params);
BKE_camera_params_from_view3d(&params, v3d, rv3d);
BKE_camera_params_from_view3d(&params, depsgraph, v3d, rv3d);
BKE_camera_params_compute_viewplane(&params, 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;

View File

@ -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);

View File

@ -6034,7 +6034,9 @@ static void calcEdgeSlide_mval_range(
continue;
/* This test is only relevant if object is not wire-drawn! See [#32068]. */
if (use_occlude_geometry && !BMBVH_EdgeVisible(bmbvh, e_other, ar, v3d, t->obedit)) {
if (use_occlude_geometry &&
!BMBVH_EdgeVisible(bmbvh, e_other, t->depsgraph, ar, v3d, t->obedit))
{
continue;
}

View File

@ -43,6 +43,7 @@
/* ************************** Types ***************************** */
struct Depsgraph;
struct TransInfo;
struct TransData;
struct TransformOrientation;
@ -468,6 +469,7 @@ typedef struct TransInfo {
struct bContext *context; /* Only valid (non null) during an operator called function. */
struct ScrArea *sa;
struct ARegion *ar;
struct Depsgraph *depsgraph;
struct Scene *scene;
struct ViewLayer *view_layer;
struct RenderEngineType *engine_type;

View File

@ -1115,6 +1115,7 @@ static int initTransInfo_edit_pet_to_flag(const int proportional)
*/
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *sce = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
ToolSettings *ts = CTX_data_tool_settings(C);
@ -1125,7 +1126,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
bGPdata *gpd = CTX_data_gpencil_data(C);
RenderEngineType *engine_type = CTX_data_engine_type(C);
PropertyRNA *prop;
t->depsgraph = depsgraph;
t->scene = sce;
t->view_layer = view_layer;
t->engine_type = engine_type;

View File

@ -2372,6 +2372,7 @@ bool ED_transform_snap_object_project_view3d_ex(
ED_view3d_win_to_vector(ar, mval, ray_normal);
ED_view3d_clip_range_get(
sctx->eval_ctx.depsgraph,
sctx->v3d_data.v3d, sctx->v3d_data.ar->regiondata,
&depth_range[0], &depth_range[1], false);
@ -2438,6 +2439,7 @@ bool ED_transform_snap_object_project_all_view3d_ex(
float ray_start[3], ray_normal[3];
if (!ED_view3d_win_to_ray_ex(
sctx->eval_ctx.depsgraph,
sctx->v3d_data.ar, sctx->v3d_data.v3d,
mval, NULL, ray_normal, ray_start, true))
{

View File

@ -50,6 +50,8 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "GHOST_C-api.h"
@ -133,7 +135,8 @@ static bool wm_area_test_invalid_backbuf(ScrArea *sa)
return true;
}
static void wm_region_test_render_do_draw(const Scene *scene, ScrArea *sa, ARegion *ar)
static void wm_region_test_render_do_draw(const Scene *scene, const struct Depsgraph *depsgraph,
ScrArea *sa, ARegion *ar)
{
/* tag region for redraw from render engine preview running inside of it */
if (sa->spacetype == SPACE_VIEW3D) {
@ -146,7 +149,7 @@ static void wm_region_test_render_do_draw(const Scene *scene, ScrArea *sa, ARegi
rcti border_rect;
/* do partial redraw when possible */
if (ED_view3d_calc_render_border(scene, v3d, ar, &border_rect))
if (ED_view3d_calc_render_border(scene, depsgraph, v3d, ar, &border_rect))
ED_region_tag_redraw_partial(ar, &border_rect);
else
ED_region_tag_redraw(ar);
@ -882,7 +885,10 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
/* quick test to prevent changing window drawable */
static bool wm_draw_update_test_window(wmWindow *win)
{
const Scene *scene = WM_window_get_active_scene(win);
/*const*/ struct WorkSpace *workspace = WM_window_get_active_workspace(win);
/*const*/ Scene *scene = WM_window_get_active_scene(win);
/*const*/ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
const bScreen *screen = WM_window_get_active_screen(win);
ScrArea *sa;
ARegion *ar;
@ -899,7 +905,7 @@ static bool wm_draw_update_test_window(wmWindow *win)
for (sa = screen->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
wm_region_test_render_do_draw(scene, sa, ar);
wm_region_test_render_do_draw(scene, depsgraph, sa, ar);
if (ar->swinid && ar->do_draw)
do_draw = true;