diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_camera.h | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_constraint.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/camera.c | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 34 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 7 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 17 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_uvproject.c | 22 |
15 files changed, 110 insertions, 71 deletions
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index c647dd3cc0f..eb05e66cf06 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -129,9 +129,9 @@ bool BKE_camera_view_frame_fit_to_scene( struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_ob, float r_co[3], float *r_scale); bool BKE_camera_view_frame_fit_to_coords( - const struct Scene *scene, + const struct Depsgraph *depsgraph, const float (*cos)[3], int num_cos, - const struct Object *camera_ob, + struct Object *camera_ob, float r_co[3], float *r_scale); void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings); @@ -139,11 +139,11 @@ void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_set /* Camera multi-view API */ struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname); -void BKE_camera_multiview_view_matrix(struct RenderData *rd, struct Object *camera, const bool is_left, float r_viewmat[4][4]); -void BKE_camera_multiview_model_matrix(struct RenderData *rd, struct Object *camera, const char *viewname, float r_modelmat[4][4]); -float BKE_camera_multiview_shift_x(struct RenderData *rd, struct Object *camera, const char *viewname); -void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, struct Object *camera, const char *viewname); -bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, struct Object *camera); +void BKE_camera_multiview_view_matrix(struct RenderData *rd, const struct Object *camera, const bool is_left, float r_viewmat[4][4]); +void BKE_camera_multiview_model_matrix(struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4]); +float BKE_camera_multiview_shift_x(struct RenderData *rd, const struct Object *camera, const char *viewname); +void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, const struct Object *camera, const char *viewname); +bool BKE_camera_multiview_spherical_stereo(struct RenderData *rd, const struct Object *camera); /* Camera background image API */ struct CameraBGImage *BKE_camera_background_image_new(struct Camera *cam); diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 18f6301953c..98ba0f6f2a4 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -49,6 +49,7 @@ extern "C" { /* special struct for use in constraint evaluation */ typedef struct bConstraintOb { + struct Depsgraph *depsgraph;/* to get evaluated armature. */ struct Scene *scene; /* for system time, part of deglobalization, code nicer later with local time (ton) */ struct Object *ob; /* if pchan, then armature that it comes from, otherwise constraint owner */ struct bPoseChannel *pchan; /* pose channel that owns the constraints being evaluated */ @@ -144,7 +145,7 @@ void BKE_constraints_proxylocal_extract(struct ListBase *dst, struct ListBase *s bool BKE_constraints_proxylocked_owner(struct Object *ob, struct bPoseChannel *pchan); /* Constraint Evaluation function prototypes */ -struct bConstraintOb *BKE_constraints_make_evalob(struct Scene *scene, struct Object *ob, void *subdata, short datatype); +struct bConstraintOb *BKE_constraints_make_evalob(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, void *subdata, short datatype); void BKE_constraints_clear_evalob(struct bConstraintOb *cob); void BKE_constraint_mat_convertspace( diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index f80096b39eb..8dbfc35c774 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2239,7 +2239,7 @@ void BKE_pose_where_is_bone( /* prepare PoseChannel for Constraint solving * - makes a copy of matrix, and creates temporary struct to use */ - cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); + cob = BKE_constraints_make_evalob(depsgraph, scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); /* Solve PoseChannel's Constraints */ BKE_constraints_solve(depsgraph, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */ diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index f365ff04361..b1b4f18a6d5 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -268,7 +268,7 @@ void BKE_camera_params_from_view3d(CameraParams *params, Depsgraph *depsgraph, c if (rv3d->persp == RV3D_CAMOB) { /* camera view */ - Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); + const Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); BKE_camera_params_from_object(params, ob_camera_eval); params->zoom = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom); @@ -666,16 +666,18 @@ bool BKE_camera_view_frame_fit_to_scene( } bool BKE_camera_view_frame_fit_to_coords( - const Scene *scene, const float (*cos)[3], int num_cos, const Object *camera_ob, + const Depsgraph *depsgraph, const float (*cos)[3], int num_cos, Object *camera_ob, float r_co[3], float *r_scale) { + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); CameraParams params; CameraViewFrameData data_cb; /* just in case */ *r_scale = 1.0f; - camera_frame_fit_data_init(scene, camera_ob, ¶ms, &data_cb); + camera_frame_fit_data_init(scene_eval, camera_ob_eval, ¶ms, &data_cb); /* run callback on all given coordinates */ while (num_cos--) { @@ -687,12 +689,12 @@ bool BKE_camera_view_frame_fit_to_coords( /******************* multiview matrix functions ***********************/ -static void camera_model_matrix(Object *camera, float r_modelmat[4][4]) +static void camera_model_matrix(const Object *camera, float r_modelmat[4][4]) { copy_m4_m4(r_modelmat, camera->obmat); } -static void camera_stereo3d_model_matrix(Object *camera, const bool is_left, float r_modelmat[4][4]) +static void camera_stereo3d_model_matrix(const Object *camera, const bool is_left, float r_modelmat[4][4]) { Camera *data = (Camera *)camera->data; float interocular_distance, convergence_distance; @@ -790,7 +792,7 @@ static void camera_stereo3d_model_matrix(Object *camera, const bool is_left, flo } /* the view matrix is used by the viewport drawing, it is basically the inverted model matrix */ -void BKE_camera_multiview_view_matrix(RenderData *rd, Object *camera, const bool is_left, float r_viewmat[4][4]) +void BKE_camera_multiview_view_matrix(RenderData *rd, const Object *camera, const bool is_left, float r_viewmat[4][4]) { BKE_camera_multiview_model_matrix(rd, camera, is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME, r_viewmat); invert_m4(r_viewmat); @@ -805,7 +807,7 @@ static bool camera_is_left(const char *viewname) return true; } -void BKE_camera_multiview_model_matrix(RenderData *rd, Object *camera, const char *viewname, float r_modelmat[4][4]) +void BKE_camera_multiview_model_matrix(RenderData *rd, const Object *camera, const char *viewname, float r_modelmat[4][4]) { const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0; @@ -822,7 +824,7 @@ void BKE_camera_multiview_model_matrix(RenderData *rd, Object *camera, const cha normalize_m4(r_modelmat); } -bool BKE_camera_multiview_spherical_stereo(RenderData *rd, Object *camera) +bool BKE_camera_multiview_spherical_stereo(RenderData *rd, const Object *camera) { Camera *cam; const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0; @@ -895,7 +897,7 @@ Object *BKE_camera_multiview_render(Scene *scene, Object *camera, const char *vi } } -static float camera_stereo3d_shift_x(Object *camera, const char *viewname) +static float camera_stereo3d_shift_x(const Object *camera, const char *viewname) { Camera *data = camera->data; float shift = data->shiftx; @@ -933,7 +935,7 @@ static float camera_stereo3d_shift_x(Object *camera, const char *viewname) return shift; } -float BKE_camera_multiview_shift_x(RenderData *rd, Object *camera, const char *viewname) +float BKE_camera_multiview_shift_x(RenderData *rd, const Object *camera, const char *viewname) { const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0; Camera *data = camera->data; @@ -951,7 +953,7 @@ float BKE_camera_multiview_shift_x(RenderData *rd, Object *camera, const char *v } } -void BKE_camera_multiview_params(RenderData *rd, CameraParams *params, Object *camera, const char *viewname) +void BKE_camera_multiview_params(RenderData *rd, CameraParams *params, const Object *camera, const char *viewname) { if (camera->type == OB_CAMERA) { params->shiftx = BKE_camera_multiview_shift_x(rd, camera, viewname); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 6a477c9c06e..5cdf011eae6 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -84,6 +84,9 @@ #include "BIK_api.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + #ifdef WITH_PYTHON # include "BPY_extern.h" #endif @@ -116,7 +119,7 @@ void BKE_constraint_unique_name(bConstraint *con, ListBase *list) /* package an object/bone for use in constraint evaluation */ /* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */ -bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subdata, short datatype) +bConstraintOb *BKE_constraints_make_evalob(Depsgraph *depsgraph, Scene *scene, Object *ob, void *subdata, short datatype) { bConstraintOb *cob; @@ -125,6 +128,7 @@ bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subda /* for system time, part of deglobalization, code nicer later with local time (ton) */ cob->scene = scene; + cob->depsgraph = depsgraph; /* based on type of available data */ switch (datatype) { @@ -3903,20 +3907,25 @@ static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { + Depsgraph *depsgraph = cob->depsgraph; Scene *scene = cob->scene; bFollowTrackConstraint *data = con->data; MovieClip *clip = data->clip; MovieTracking *tracking; MovieTrackingTrack *track; MovieTrackingObject *tracking_object; - Object *camob = data->camera ? data->camera : scene->camera; + + Object *camob_eval = DEG_get_evaluated_object( + depsgraph, + data->camera ? data->camera : scene->camera); + float ctime = BKE_scene_frame_get(scene); float framenr; if (data->flag & FOLLOWTRACK_ACTIVECLIP) clip = scene->clip; - if (!clip || !data->track[0] || !camob) + if (!clip || !data->track[0] || !camob_eval) return; tracking = &clip->tracking; @@ -3945,7 +3954,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) { float imat[4][4]; - copy_m4_m4(mat, camob->obmat); + copy_m4_m4(mat, camob_eval->obmat); BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, imat); invert_m4(imat); @@ -3954,7 +3963,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]); } else { - BKE_tracking_get_camera_object_matrix(cob->scene, camob, mat); + BKE_tracking_get_camera_object_matrix(cob->scene, camob_eval, mat); mul_m4_m4m4(cob->matrix, obmat, mat); translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]); @@ -3966,7 +3975,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); float len, d; - BKE_object_where_is_calc_mat4(scene, camob, mat); + BKE_object_where_is_calc_mat4(scene, camob_eval, mat); /* camera axis */ vec[0] = 0.0f; @@ -4034,7 +4043,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase } BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, camob); + BKE_camera_params_from_object(¶ms, camob_eval); if (params.is_ortho) { vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx); @@ -4046,9 +4055,9 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase else vec[0] *= aspect; - mul_v3_m4v3(disp, camob->obmat, vec); + mul_v3_m4v3(disp, camob_eval->obmat, vec); - copy_m4_m4(rmat, camob->obmat); + copy_m4_m4(rmat, camob_eval->obmat); zero_v3(rmat[3]); mul_m4_m4m4(cob->matrix, cob->matrix, rmat); @@ -4066,10 +4075,10 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase else vec[0] *= aspect; - mul_v3_m4v3(disp, camob->obmat, vec); + mul_v3_m4v3(disp, camob_eval->obmat, vec); /* apply camera rotation so Z-axis would be co-linear */ - copy_m4_m4(rmat, camob->obmat); + copy_m4_m4(rmat, camob_eval->obmat); zero_v3(rmat[3]); mul_m4_m4m4(cob->matrix, cob->matrix, rmat); @@ -4088,7 +4097,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase invert_m4_m4(imat, depth_ob->obmat); - mul_v3_m4v3(ray_start, imat, camob->obmat[3]); + mul_v3_m4v3(ray_start, imat, camob_eval->obmat[3]); mul_v3_m4v3(ray_end, imat, cob->matrix[3]); sub_v3_v3v3(ray_nor, ray_end, ray_start); @@ -4811,6 +4820,7 @@ void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph, Scene *scene, cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb"); cob->type = ownertype; cob->scene = scene; + cob->depsgraph = depsgraph; switch (ownertype) { case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */ { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e36e5277f0c..39e190631ff 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2132,7 +2132,7 @@ void BKE_object_where_is_calc_time_ex( /* solve constraints */ if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; - cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = BKE_constraints_make_evalob(depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime); BKE_constraints_clear_evalob(cob); } diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 91571e8bf62..2d499e4684e 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -128,7 +128,7 @@ void BKE_object_eval_constraints(Depsgraph *depsgraph, * Not sure why, this is from Joshua - sergey * */ - cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = BKE_constraints_make_evalob(depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); BKE_constraints_solve(depsgraph, &ob->constraints, cob, ctime); BKE_constraints_clear_evalob(cob); } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 0a8eced8e59..e1a6d59a748 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -106,9 +106,11 @@ void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]); struct Camera *ED_view3d_camera_data_get(struct View3D *v3d, struct RegionView3D *rv3d); void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist); -void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist); +void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist); -void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); +void ED_view3d_from_object( + const struct Object *ob, + float ofs[3], float quat[4], float *dist, float *lens); void ED_view3d_to_object( const struct Depsgraph *depsgraph, struct Object *ob, const float ofs[3], const float quat[4], const float dist); @@ -305,6 +307,7 @@ float ED_view3d_radius_to_dist_persp(const float angle, const float radius); float ED_view3d_radius_to_dist_ortho(const float lens, const float radius); float ED_view3d_radius_to_dist( const struct View3D *v3d, const struct ARegion *ar, + const struct Depsgraph *depsgraph, const char persp, const bool use_aspect, const float radius); diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index a1435d5916a..76449b61d4d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -81,6 +81,7 @@ #include "BKE_texture.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "UI_interface.h" @@ -3083,7 +3084,7 @@ static void proj_paint_state_non_cddm_init(ProjPaintState *ps) } static void proj_paint_state_viewport_init( - ProjPaintState *ps, const char symmetry_flag) + ProjPaintState *ps, const Depsgraph *depsgraph, const char symmetry_flag) { float mat[3][3]; float viewmat[4][4]; @@ -3144,17 +3145,17 @@ static void proj_paint_state_viewport_init( invert_m4_m4(viewinv, viewmat); } else if (ps->source == PROJ_SRC_IMAGE_CAM) { - Object *cam_ob = ps->scene->camera; + Object *cam_ob_eval = DEG_get_evaluated_object(depsgraph, ps->scene->camera); CameraParams params; /* viewmat & viewinv */ - copy_m4_m4(viewinv, cam_ob->obmat); + copy_m4_m4(viewinv, cam_ob_eval->obmat); normalize_m4(viewinv); invert_m4_m4(viewmat, viewinv); /* window matrix, clipping and ortho */ BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, cam_ob); + BKE_camera_params_from_object(¶ms, cam_ob_eval); BKE_camera_params_compute_viewplane(¶ms, ps->winx, ps->winy, 1.0f, 1.0f); BKE_camera_params_compute_matrix(¶ms); @@ -3858,7 +3859,7 @@ static void project_paint_begin( proj_paint_state_cavity_init(ps); } - proj_paint_state_viewport_init(ps, symmetry_flag); + proj_paint_state_viewport_init(ps, CTX_data_depsgraph(C), symmetry_flag); /* calculate vert screen coords * run this early so we can calculate the x/y resolution of our bucket rect */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 16950637026..b44e2da3583 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -302,6 +302,7 @@ static void view3d_camera_border( { CameraParams params; rctf rect_view, rect_camera; + Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); /* get viewport viewplane */ BKE_camera_params_init(¶ms); @@ -316,7 +317,7 @@ static void view3d_camera_border( /* fallback for non camera objects */ params.clipsta = v3d->near; params.clipend = v3d->far; - BKE_camera_params_from_object(¶ms, v3d->camera); + BKE_camera_params_from_object(¶ms, camera_eval); if (no_shift) { params.shiftx = 0.0f; params.shifty = 0.0f; @@ -1417,13 +1418,16 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( if (rv3d->persp == RV3D_CAMOB && v3d->camera) { CameraParams params; Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname); + const Object *camera_eval = DEG_get_evaluated_object( + depsgraph, + camera); BKE_camera_params_init(¶ms); /* fallback for non camera objects */ params.clipsta = v3d->near; params.clipend = v3d->far; - BKE_camera_params_from_object(¶ms, camera); - BKE_camera_multiview_params(&scene->r, ¶ms, camera, viewname); + BKE_camera_params_from_object(¶ms, camera_eval); + BKE_camera_multiview_params(&scene->r, ¶ms, camera_eval, viewname); BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp); BKE_camera_params_compute_matrix(¶ms); @@ -1597,11 +1601,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( { CameraParams params; - Object *view_camera = BKE_camera_multiview_render(scene, v3d.camera, viewname); + const Object *view_camera_eval = DEG_get_evaluated_object( + depsgraph, + BKE_camera_multiview_render(scene, v3d.camera, viewname)); BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, view_camera); - BKE_camera_multiview_params(&scene->r, ¶ms, view_camera, viewname); + BKE_camera_params_from_object(¶ms, view_camera_eval); + BKE_camera_multiview_params(&scene->r, ¶ms, view_camera_eval, viewname); BKE_camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp); BKE_camera_params_compute_matrix(¶ms); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index cd5a18bd9a9..66eaf34865f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2654,7 +2654,7 @@ static void view3d_from_minmax( } if (ok_dist) { - new_dist = ED_view3d_radius_to_dist(v3d, ar, persp, true, (size / 2) * VIEW3D_MARGIN); + new_dist = ED_view3d_radius_to_dist(v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN); if (rv3d->is_persp) { /* don't zoom closer than the near clipping plane */ new_dist = max_ff(new_dist, v3d->near * 1.5f); @@ -3678,7 +3678,8 @@ static void axis_set_view( dist = rv3d->dist; /* so we animate _from_ the camera location */ - ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, &rv3d->dist, NULL); + Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera); + ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL); ED_view3d_smooth_view( C, v3d, ar, smooth_viewtx, diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index e18370d04a9..90b1b043de6 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1067,6 +1067,7 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius) */ float ED_view3d_radius_to_dist( const View3D *v3d, const ARegion *ar, + const struct Depsgraph *depsgraph, const char persp, const bool use_aspect, const float radius) { @@ -1087,7 +1088,8 @@ float ED_view3d_radius_to_dist( BKE_camera_params_init(¶ms); params.clipsta = v3d->near; params.clipend = v3d->far; - BKE_camera_params_from_object(¶ms, v3d->camera); + Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); + BKE_camera_params_from_object(¶ms, camera_eval); lens = params.lens; sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y); @@ -1277,7 +1279,7 @@ bool ED_view3d_lock(RegionView3D *rv3d) * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. * \param dist The view distance from ofs, normally from RegionView3D.dist. */ -void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist) +void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float *dist) { float nmat[3][3]; @@ -1322,13 +1324,14 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c /** * Set the RegionView3D members from an objects transformation and optionally lens. + * \param depsgraph The depsgraph to get the evaluated object for the lens calculation. * \param ob The object to set the view to. * \param ofs The view offset to be set, normally from RegionView3D.ofs. * \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat. * \param dist The view distance from ofs to be set, normally from RegionView3D.dist. * \param lens The view lens angle set for cameras and lamps, normally from View3D.lens. */ -void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens) +void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens) { ED_view3d_from_m4(ob->obmat, ofs, quat, dist); @@ -1343,6 +1346,7 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, /** * Set the object transformation from RegionView3D members. + * \param depsgraph The depsgraph to get the evaluated object parent for the transformation calculation. * \param ob The object which has the transformation assigned. * \param ofs The view offset, normally from RegionView3D.ofs. * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 2fe95f596c8..abf61462bc1 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -48,6 +48,7 @@ #include "BKE_scene.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "UI_resources.h" @@ -513,25 +514,26 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ Object *camera_ob = v3d ? v3d->camera : scene->camera; + Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); float r_co[3]; /* the new location to apply */ float r_scale; /* only for ortho cameras */ - if (camera_ob == NULL) { + if (camera_ob_eval == NULL) { BKE_report(op->reports, RPT_ERROR, "No active camera"); return OPERATOR_CANCELLED; } /* this function does all the important stuff */ - if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob, r_co, &r_scale)) { + if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob_eval, r_co, &r_scale)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; - if ((camera_ob->type == OB_CAMERA) && (((Camera *)camera_ob->data)->type == CAM_ORTHO)) { + if ((camera_ob_eval->type == OB_CAMERA) && (((Camera *)camera_ob_eval->data)->type == CAM_ORTHO)) { ((Camera *)camera_ob->data)->ortho_scale = r_scale; } - copy_m4_m4(obmat_new, camera_ob->obmat); + copy_m4_m4(obmat_new, camera_ob_eval->obmat); copy_v3_v3(obmat_new[3], r_co); /* only touch location */ diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 04507d1ed7e..a01192dad68 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -89,6 +89,8 @@ static const EnumPropertyItem space_items[] = { #include "DNA_scene_types.h" #include "DNA_view3d_types.h" +#include "DEG_depsgraph_query.h" + #include "MEM_guardedalloc.h" static void rna_Object_select_set(Object *ob, bContext *C, ReportList *reports, int action) @@ -173,13 +175,14 @@ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseC } static void rna_Object_calc_matrix_camera( - Object *ob, float mat_ret[16], int width, int height, float scalex, float scaley) + Object *ob, Depsgraph *depsgraph, float mat_ret[16], int width, int height, float scalex, float scaley) { + const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); CameraParams params; /* setup parameters */ BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, ob); + BKE_camera_params_from_object(¶ms, ob_eval); /* compute matrix, viewplane, .. */ BKE_camera_params_compute_viewplane(¶ms, width, height, scalex, scaley); @@ -189,9 +192,9 @@ static void rna_Object_calc_matrix_camera( } static void rna_Object_camera_fit_coords( - Object *ob, Scene *scene, int num_cos, float *cos, float co_ret[3], float *scale_ret) + Object *ob, Depsgraph *depsgraph, int num_cos, float *cos, float co_ret[3], float *scale_ret) { - BKE_camera_view_frame_fit_to_coords(scene, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); + BKE_camera_view_frame_fit_to_coords(depsgraph, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); } /* copied from Mesh_getFromObject and adapted to RNA interface */ @@ -518,6 +521,9 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera"); RNA_def_function_ui_description(func, "Generate the camera projection matrix of this object " "(mostly useful for Camera and Lamp types)"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", + "Depsgraph to get evaluated data from"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(parm, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(parm, "", "The camera projection matrix"); @@ -530,7 +536,8 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords"); RNA_def_function_ui_description(func, "Compute the coordinate (and scale for ortho cameras) " "given object should be to 'see' all given coordinates"); - parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to get render size information from, if available"); + parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", + "Depsgraph to get evaluated data from"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_float_array(func, "coordinates", 1, NULL, -FLT_MAX, FLT_MAX, "", "Coordinates to fit in", -FLT_MAX, FLT_MAX); diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 207c692071c..b491496caa4 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -55,7 +55,9 @@ #include "MEM_guardedalloc.h" +#include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" static void initData(ModifierData *md) { @@ -111,7 +113,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } typedef struct Projector { - Object *ob; /* object this projector is derived from */ + Object *ob_eval; /* object this projector is derived from */ float projmat[4][4]; /* projection matrix */ float normal[3]; /* projector normal in world space */ void *uci; /* optional uv-project info (panorama projection) */ @@ -119,6 +121,7 @@ typedef struct Projector { static Mesh *uvprojectModifier_do( UVProjectModifierData *umd, + Depsgraph *depsgraph, Object *ob, Mesh *mesh) { float (*coords)[3], (*co)[3]; @@ -137,7 +140,7 @@ static Mesh *uvprojectModifier_do( for (i = 0; i < umd->num_projectors; ++i) if (umd->projectors[i]) - projectors[num_projectors++].ob = umd->projectors[i]; + projectors[num_projectors++].ob_eval = DEG_get_evaluated_object(depsgraph, umd->projectors[i]); if (num_projectors == 0) return mesh; @@ -154,15 +157,14 @@ static Mesh *uvprojectModifier_do( float offsetmat[4][4]; Camera *cam = NULL; /* calculate projection matrix */ - invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); + invert_m4_m4(projectors[i].projmat, projectors[i].ob_eval->obmat); projectors[i].uci = NULL; - if (projectors[i].ob->type == OB_CAMERA) { - - cam = (Camera *)projectors[i].ob->data; + if (projectors[i].ob_eval->type == OB_CAMERA) { + cam = (Camera *)projectors[i].ob_eval->data; if (cam->type == CAM_PANO) { - projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy); + projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob_eval, NULL, aspx, aspy); BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay); free_uci = 1; } @@ -171,7 +173,7 @@ static Mesh *uvprojectModifier_do( /* setup parameters */ BKE_camera_params_init(¶ms); - BKE_camera_params_from_object(¶ms, projectors[i].ob); + BKE_camera_params_from_object(¶ms, projectors[i].ob_eval); /* compute matrix, viewplane, .. */ BKE_camera_params_compute_viewplane(¶ms, 1, 1, aspx, aspy); @@ -200,7 +202,7 @@ static Mesh *uvprojectModifier_do( projectors[i].normal[0] = 0; projectors[i].normal[1] = 0; projectors[i].normal[2] = 1; - mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); + mul_mat3_m4_v3(projectors[i].ob_eval->obmat, projectors[i].normal); } numPolys = mesh->totpoly; @@ -312,7 +314,7 @@ static Mesh *applyModifier( Mesh *result; UVProjectModifierData *umd = (UVProjectModifierData *) md; - result = uvprojectModifier_do(umd, ctx->object, mesh); + result = uvprojectModifier_do(umd, ctx->depsgraph, ctx->object, mesh); return result; } |