From 5f01b3d96ed116d1c0416d5393911211d409a4ae Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 9 May 2014 17:02:08 +0200 Subject: Fix T39585: cycles motion vector pass problem with curves. --- intern/cycles/render/object.cpp | 60 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'intern/cycles/render/object.cpp') diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index e2d6ae6fa18..027bfd71931 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -79,7 +79,7 @@ void Object::compute_bounds(bool motion_blur) bounds = mbounds.transformed(&tfm); } -void Object::apply_transform() +void Object::apply_transform(bool apply_to_motion) { if(!mesh || tfm == transform_identity()) return; @@ -94,25 +94,28 @@ void Object::apply_transform() /* apply to mesh vertices */ for(size_t i = 0; i < mesh->verts.size(); i++) mesh->verts[i] = transform_point(&tfm, mesh->verts[i]); + + if(apply_to_motion) { + Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); - Attribute *attr = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); - if (attr) { - size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1); - float3 *vert_steps = attr->data_float3(); + if (attr) { + size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1); + float3 *vert_steps = attr->data_float3(); - for (size_t i = 0; i < steps_size; i++) - vert_steps[i] = transform_point(&tfm, vert_steps[i]); - } + for (size_t i = 0; i < steps_size; i++) + vert_steps[i] = transform_point(&tfm, vert_steps[i]); + } - Attribute *attr_N = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL); + Attribute *attr_N = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_NORMAL); - if(attr_N) { - Transform ntfm = mesh->transform_normal; - size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1); - float3 *normal_steps = attr_N->data_float3(); + if(attr_N) { + Transform ntfm = mesh->transform_normal; + size_t steps_size = mesh->verts.size() * (mesh->motion_steps - 1); + float3 *normal_steps = attr_N->data_float3(); - for (size_t i = 0; i < steps_size; i++) - normal_steps[i] = normalize(transform_direction(&ntfm, normal_steps[i])); + for (size_t i = 0; i < steps_size; i++) + normal_steps[i] = normalize(transform_direction(&ntfm, normal_steps[i])); + } } } @@ -134,20 +137,22 @@ void Object::apply_transform() mesh->curve_keys[i].w = radius; } - Attribute *curve_attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); + if(apply_to_motion) { + Attribute *curve_attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); - if (curve_attr) { - /* apply transform to motion curve keys */ - size_t steps_size = mesh->curve_keys.size() * (mesh->motion_steps - 1); - float4 *key_steps = curve_attr->data_float4(); + if (curve_attr) { + /* apply transform to motion curve keys */ + size_t steps_size = mesh->curve_keys.size() * (mesh->motion_steps - 1); + float4 *key_steps = curve_attr->data_float4(); - for (size_t i = 0; i < steps_size; i++) { - float3 co = transform_point(&tfm, float4_to_float3(key_steps[i])); - float radius = key_steps[i].w * scalar; + for (size_t i = 0; i < steps_size; i++) { + float3 co = transform_point(&tfm, float4_to_float3(key_steps[i])); + float radius = key_steps[i].w * scalar; - /* scale for curve radius is only correct for uniform scale */ - key_steps[i] = float3_to_float4(co); - key_steps[i].w = radius; + /* scale for curve radius is only correct for uniform scale */ + key_steps[i] = float3_to_float4(co); + key_steps[i].w = radius; + } } } } @@ -414,6 +419,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, u #ifdef __OBJECT_MOTION__ Scene::MotionType need_motion = scene->need_motion(); bool motion_blur = need_motion == Scene::MOTION_BLUR; + bool apply_to_motion = need_motion != Scene::MOTION_PASS; #else bool motion_blur = false; #endif @@ -436,7 +442,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, u if(mesh_users[object->mesh] == 1) { if(!(motion_blur && object->use_motion)) { if(!object->mesh->transform_applied) { - object->apply_transform(); + object->apply_transform(apply_to_motion); object->mesh->transform_applied = true; if(progress.get_cancel()) return; -- cgit v1.2.3