From 30e4009f0a5e7738ea6851b76b5a85e5d5f19710 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Feb 2015 22:06:31 +0500 Subject: [PATCH] Cycles: Solve dependency between camera and object synchronization IN theory object might depend on camera location (spatial adaptive subdivisions for example) which became not possible to achieve after camera in volume support. Should be no functional changes for artists. --- intern/cycles/render/camera.cpp | 16 +++++++++++++--- intern/cycles/render/camera.h | 1 + intern/cycles/render/scene.cpp | 16 ++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 9d03a9e360e..ea9b853d454 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -278,11 +278,20 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) kcam->nearclip = nearclip; kcam->cliplength = (farclip == FLT_MAX)? FLT_MAX: farclip - nearclip; - need_device_update = false; - previous_need_motion = need_motion; - /* Camera in volume. */ kcam->is_inside_volume = 0; + + previous_need_motion = need_motion; +} + +void Camera::device_update_volume(Device *device, + DeviceScene *dscene, + Scene *scene) +{ + if(!need_device_update) { + return; + } + KernelCamera *kcam = &dscene->data.cam; BoundBox viewplane_boundbox = viewplane_bounds_get(); for(size_t i = 0; i < scene->objects.size(); ++i) { Object *object = scene->objects[i]; @@ -294,6 +303,7 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) break; } } + need_device_update = false; } void Camera::device_free(Device *device, DeviceScene *dscene) diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index 1b431e88ac4..e1faee3543d 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -116,6 +116,7 @@ public: void update(); void device_update(Device *device, DeviceScene *dscene, Scene *scene); + void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene); void device_free(Device *device, DeviceScene *dscene); bool modified(const Camera& cam); diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index bb7c03cbe6d..64d6fa4b9b9 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -165,6 +165,11 @@ void Scene::device_update(Device *device_, Progress& progress) if(progress.get_cancel() || device->have_error()) return; + progress.set_status("Updating Camera"); + camera->device_update(device, &dscene, this); + + if(progress.get_cancel() || device->have_error()) return; + progress.set_status("Updating Objects"); object_manager->device_update(device, &dscene, this, progress); @@ -185,6 +190,11 @@ void Scene::device_update(Device *device_, Progress& progress) if(progress.get_cancel() || device->have_error()) return; + progress.set_status("Updating Camera Volume"); + camera->device_update_volume(device, &dscene, this); + + if(progress.get_cancel() || device->have_error()) return; + progress.set_status("Updating Hair Systems"); curve_system_manager->device_update(device, &dscene, this, progress); @@ -195,12 +205,6 @@ void Scene::device_update(Device *device_, Progress& progress) if(progress.get_cancel() || device->have_error()) return; - /* TODO(sergey): Make sure camera is not needed above. */ - progress.set_status("Updating Camera"); - camera->device_update(device, &dscene, this); - - if(progress.get_cancel() || device->have_error()) return; - progress.set_status("Updating Lights"); light_manager->device_update(device, &dscene, this, progress);