Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-04-04 21:06:22 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-04-21 04:05:38 +0300
commit8982f0cfee417f3cc9612666db1eac4f3e965de9 (patch)
treeff6a02fefa545c5c9eaf2f7347302be742879481 /intern/cycles/render
parentcc9528d3c8e71372528471e8071f494cdec067ee (diff)
Fix T62408: Cycles viewport adaptive subdivision hangs after updates
Backporting fix from the master branch.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/camera.cpp19
-rw-r--r--intern/cycles/render/camera.h2
-rw-r--r--intern/cycles/render/mesh.cpp4
3 files changed, 16 insertions, 9 deletions
diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp
index 5715892ba70..82aeb324a00 100644
--- a/intern/cycles/render/camera.cpp
+++ b/intern/cycles/render/camera.cpp
@@ -169,6 +169,8 @@ Camera::Camera()
cameratoworld = transform_identity();
worldtoraster = projection_identity();
+ full_rastertocamera = projection_identity();
+
dx = make_float3(0.0f, 0.0f, 0.0f);
dy = make_float3(0.0f, 0.0f, 0.0f);
@@ -251,7 +253,7 @@ void Camera::update(Scene *scene)
ProjectionTransform screentocamera = projection_inverse(cameratoscreen);
rastertocamera = screentocamera * rastertoscreen;
- ProjectionTransform full_rastertocamera = screentocamera * full_rastertoscreen;
+ full_rastertocamera = screentocamera * full_rastertoscreen;
cameratoraster = screentoraster * cameratoscreen;
cameratoworld = matrix;
@@ -627,7 +629,7 @@ float Camera::world_to_raster_size(float3 P)
if(offscreen_dicing_scale > 1.0f) {
float3 p = transform_point(&worldtocamera, P);
- float3 v = transform_perspective(&rastertocamera, make_float3(width, height, 0.0f));
+ float3 v = transform_perspective(&full_rastertocamera, make_float3(full_width, full_height, 0.0f));
/* Create point clamped to frustum */
float3 c;
@@ -644,8 +646,8 @@ float Camera::world_to_raster_size(float3 P)
}
else if(type == CAMERA_PERSPECTIVE) {
/* Calculate as if point is directly ahead of the camera. */
- float3 raster = make_float3(0.5f*width, 0.5f*height, 0.0f);
- float3 Pcamera = transform_perspective(&rastertocamera, raster);
+ float3 raster = make_float3(0.5f*full_width, 0.5f*full_height, 0.0f);
+ float3 Pcamera = transform_perspective(&full_rastertocamera, raster);
/* dDdx */
float3 Ddiff = transform_direction(&cameratoworld, Pcamera);
@@ -728,22 +730,21 @@ float Camera::world_to_raster_size(float3 P)
* point directly ahead seems to produce good enough results. */
#if 0
float2 dir = direction_to_panorama(&kernel_camera, kernel_camera_motion.data(), normalize(D));
- float3 raster = transform_perspective(&cameratoraster, make_float3(dir.x, dir.y, 0.0f));
+ float3 raster = transform_perspective(&full_cameratoraster, make_float3(dir.x, dir.y, 0.0f));
ray.t = 1.0f;
camera_sample_panorama(&kernel_camera, kernel_camera_motion.data(), raster.x, raster.y, 0.0f, 0.0f, &ray);
if(ray.t == 0.0f) {
/* No differentials, just use from directly ahead. */
- camera_sample_panorama(&kernel_camera, kernel_camera_motion.data(), 0.5f*width, 0.5f*height, 0.0f, 0.0f, &ray);
+ camera_sample_panorama(&kernel_camera, kernel_camera_motion.data(), 0.5f*full_width, 0.5f*full_height, 0.0f, 0.0f, &ray);
}
#else
- camera_sample_panorama(&kernel_camera, kernel_camera_motion.data(), 0.5f*width, 0.5f*height, 0.0f, 0.0f, &ray);
+ camera_sample_panorama(&kernel_camera, kernel_camera_motion.data(), 0.5f*full_width, 0.5f*full_height, 0.0f, 0.0f, &ray);
#endif
differential_transfer(&ray.dP, ray.dP, ray.D, ray.dD, ray.D, dist);
- return max(len(ray.dP.dx) * (float(width)/float(full_width)),
- len(ray.dP.dy) * (float(height)/float(full_height)));
+ return max(len(ray.dP.dx),len(ray.dP.dy));
}
return res;
diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h
index 37f5dea624f..961e8f918ea 100644
--- a/intern/cycles/render/camera.h
+++ b/intern/cycles/render/camera.h
@@ -160,6 +160,8 @@ public:
ProjectionTransform rastertocamera;
ProjectionTransform cameratoraster;
+ ProjectionTransform full_rastertocamera;
+
float3 dx;
float3 dy;
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 753224de1aa..b263d946321 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -2168,6 +2168,9 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
/* Tessellate meshes that are using subdivision */
if(total_tess_needed) {
+ Camera *dicing_camera = scene->dicing_camera;
+ dicing_camera->update(scene);
+
size_t i = 0;
foreach(Mesh *mesh, scene->meshes) {
if(mesh->need_update &&
@@ -2183,6 +2186,7 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
progress.set_status("Updating Mesh", msg);
+ mesh->subd_params->camera = dicing_camera;
DiagSplit dsplit(*mesh->subd_params);
mesh->tessellate(&dsplit);