Page MenuHome
Paste P590

Inspiration fix for T53788
ActivePublic

Authored by Sergey Sharybin (sergey) on Jan 16 2018, 10:56 AM.
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index a462e5b215c..e70c64f50a6 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -2194,6 +2194,13 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene,
{
BLI_assert(scene != NULL);
BLI_assert(view_layer != NULL);
+ if (scene->id.tag & LIB_TAG_COPY_ON_WRITE) {
+ scene = (Scene *)scene->id.newid;
+ view_layer = (ViewLayer *)BLI_findstring(
+ &scene->view_layers,
+ view_layer->name,
+ offsetof(ViewLayer, name));
+ }
/* Make sure hash itself exists. */
if (allocate) {
BKE_scene_ensure_depsgraph_hash(scene);
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 36f433d5ffb..41253a166bb 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -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,10 @@ 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;
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(draw_ctx->scene, draw_ctx->view_layer, true);
+ Object *camera_object_orig = v3d->camera;
+ Object *camera_object_cow = DEG_get_evaluated_object(depsgraph, camera_object_orig);
+ Camera *cam = camera_object_cow->data;
/* Retreive Near and Far distance */
effects->dof_near_far[0] = -cam->clipsta;
@@ -145,7 +149,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_cow);
float focal_len = cam->lens;
UNUSED_VARS(rotation, ratio);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index b1140113601..5fb2969f503 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -95,6 +95,9 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
#include "view3d_intern.h" /* own include */
/* ******************** general functions ***************** */
@@ -120,11 +123,14 @@ static bool use_depth_doit(Scene *scene, View3D *v3d)
* \note keep this synced with #ED_view3d_mats_rv3d_backup/#ED_view3d_mats_rv3d_restore
*/
void ED_view3d_update_viewmat(
- const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d, ARegion *ar,
+ const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d_orig, ARegion *ar,
float viewmat[4][4], float winmat[4][4], const rcti *rect)
{
RegionView3D *rv3d = ar->regiondata;
+ View3D v3d_cow = *v3d_orig;
+ v3d_cow.camera = DEG_get_evaluated_object(eval_ctx->depsgraph, v3d_cow.camera);
+ View3D *v3d = &v3d_cow;
/* setup window matrices */
if (winmat)

Event Timeline

Sergey Sharybin (sergey) created this object with edit policy "Administrators".