diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-01-11 18:32:57 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-01-11 18:32:57 +0300 |
commit | 394fa07d41bf403920806522e6ca09a9531bca29 (patch) | |
tree | 0f4f1e56f96403139485bb47b501cf245b458fa1 /intern/cycles | |
parent | 38b01415546f2530ced77e91ac2d57b37b576b07 (diff) |
Cycles: Fix wrong motion blur when combining deformation motion blur with autosplit
The issue was that we used to compare number of vertices for mesh after the auto
smooth was applied (at the center of the shutter time) with number of vertices
prior to the auto smooth applied. This caused false-positive consideration of a
mesh as changing topology.
Now we do autosplit as early as possible and do it from blender side, so Cycles
does not need to re-implement splitting on it's side.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 42 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 7 |
2 files changed, 10 insertions, 39 deletions
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index a83e756de91..66893d4d668 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -671,28 +671,10 @@ static void create_mesh(Scene *scene, int shader = clamp(f->material_index(), 0, used_shaders.size()-1); bool smooth = f->use_smooth() || use_loop_normals; - /* split vertices if normal is different + /* Create triangles. * - * note all vertex attributes must have been set here so we can split - * and copy attributes in split_vertex without remapping later */ - if(use_loop_normals) { - BL::Array<float, 12> loop_normals = f->split_normals(); - - for(int i = 0; i < n; i++) { - float3 loop_N = make_float3(loop_normals[i * 3], loop_normals[i * 3 + 1], loop_normals[i * 3 + 2]); - - if(N[vi[i]] != loop_N) { - int new_vi = mesh->split_vertex(vi[i]); - - /* set new normal and vertex index */ - N = attr_N->data_float3(); - N[new_vi] = loop_N; - vi[i] = new_vi; - } - } - } - - /* create triangles */ + * NOTE: Autosmooth is already taken care about. + */ if(n == 4) { if(is_zero(cross(mesh->verts[vi[1]] - mesh->verts[vi[0]], mesh->verts[vi[2]] - mesh->verts[vi[0]])) || is_zero(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]]))) @@ -724,24 +706,8 @@ static void create_mesh(Scene *scene, vi.reserve(n); for(int i = 0; i < n; i++) { + /* NOTE: Autosmooth is already taken care about. */ vi[i] = b_mesh.loops[p->loop_start() + i].vertex_index(); - - /* split vertices if normal is different - * - * note all vertex attributes must have been set here so we can split - * and copy attributes in split_vertex without remapping later */ - if(use_loop_normals) { - float3 loop_N = get_float3(b_mesh.loops[p->loop_start() + i].normal()); - - if(N[vi[i]] != loop_N) { - int new_vi = mesh->split_vertex(vi[i]); - - /* set new normal and vertex index */ - N = attr_N->data_float3(); - N[new_vi] = loop_N; - vi[i] = new_vi; - } - } } /* create subd faces */ diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 92db5fdfd45..b67834cdea3 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -74,7 +74,12 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data, if((bool)me) { if(me.use_auto_smooth()) { - me.calc_normals_split(); + if(subdivision_type == Mesh::SUBDIVISION_CATMULL_CLARK) { + me.calc_normals_split(); + } + else { + me.split_faces(); + } } if(subdivision_type == Mesh::SUBDIVISION_NONE) { me.calc_tessface(true); |