diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-08-24 17:53:14 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2020-08-24 17:56:23 +0300 |
commit | 530350935472970dccc211b0e728e2db4fd1d8ef (patch) | |
tree | a5fbd6b0b5a46a2f423bb8e24b14bc441e144d0c /intern/cycles/blender | |
parent | 734abaa252b40a9aae6992365379556774641269 (diff) |
Fix T80076: Cycles Alembic Motion Blur Problem
The problem occurs when a deforming modifier is added to the object
after the MeshSequenceCache modifier. We should only consider the cached
velocities if the MeshSequenceCache modifier is the last one on the
object and we also need to check for the correct vertex count before
adding the motion vertex attribute.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index b390dffc2b5..e40e1f5f001 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -925,17 +925,15 @@ static void create_subd_mesh(Scene *scene, static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob) { - BL::Object::modifiers_iterator b_mod; + if (b_ob.modifiers.length() > 0) { + BL::Modifier b_mod = b_ob.modifiers[b_ob.modifiers.length() - 1]; - for (b_ob.modifiers.begin(b_mod); b_mod != b_ob.modifiers.end(); ++b_mod) { - if (!b_mod->is_a(&RNA_MeshSequenceCacheModifier)) { - continue; - } - - BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(*b_mod); + if (b_mod.type() == BL::Modifier::type_MESH_SEQUENCE_CACHE) { + BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(b_mod); - if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) { - return mesh_cache; + if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) { + return mesh_cache; + } } } @@ -953,14 +951,6 @@ static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *me return; } - /* Find or add attribute */ - float3 *P = &mesh->verts[0]; - Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); - - if (!attr_mP) { - attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); - } - if (!MeshSequenceCacheModifier_read_velocity_get(&b_mesh_cache.ptr)) { return; } @@ -971,6 +961,14 @@ static void sync_mesh_cached_velocities(BL::Object &b_ob, Scene *scene, Mesh *me return; } + /* Find or add attribute */ + float3 *P = &mesh->verts[0]; + Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); + + if (!attr_mP) { + attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); + } + /* Only export previous and next frame, we don't have any in between data. */ float motion_times[2] = {-1.0f, 1.0f}; for (int step = 0; step < 2; step++) { |