forked from bartvdbraak/blender
Fix T39585: cycles motion vector pass problem with curves.
This commit is contained in:
parent
fe00dbcc23
commit
5f01b3d96e
@ -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;
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
void tag_update(Scene *scene);
|
||||
|
||||
void compute_bounds(bool motion_blur);
|
||||
void apply_transform();
|
||||
void apply_transform(bool apply_to_motion);
|
||||
|
||||
vector<float> motion_times();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user