Cycles: Fix wrong render result in certain configuration of render layer's surface...
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 9 Apr 2015 16:21:48 +0000 (21:21 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 9 Apr 2015 16:22:48 +0000 (21:22 +0500)
There were some synchronization missing in cases when only one of those settings
was disabled.

Also added a render test for such configurations now.

intern/cycles/blender/blender_mesh.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/mesh.h
tests/python/CMakeLists.txt

index deae36f0130ed5e8f979411c7e1711933a78e73d..d88ebb854d22b9dba2f26251976b883d58b19809 100644 (file)
@@ -621,7 +621,13 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
        }
        
        /* test if we need to sync */
-       bool use_mesh_geometry = render_layer.use_surfaces || render_layer.use_hair;
+       int requested_geometry_flags = Mesh::GEOMETRY_NONE;
+       if(render_layer.use_surfaces) {
+               requested_geometry_flags |= Mesh::GEOMETRY_TRIANGLES;
+       }
+       if(render_layer.use_hair) {
+               requested_geometry_flags |= Mesh::GEOMETRY_CURVES;
+       }
        Mesh *mesh;
 
        if(!mesh_map.sync(&mesh, key)) {
@@ -630,7 +636,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
                /* test if shaders changed, these can be object level so mesh
                 * does not get tagged for recalc */
                else if(mesh->used_shaders != used_shaders);
-               else if(use_mesh_geometry != mesh->geometry_synced);
+               else if(requested_geometry_flags != mesh->geometry_flags);
                else {
                        /* even if not tagged for recalc, we may need to sync anyway
                         * because the shader needs different mesh attributes */
@@ -664,7 +670,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
        mesh->used_shaders = used_shaders;
        mesh->name = ustring(b_ob_data.name().c_str());
 
-       if(use_mesh_geometry) {
+       if(requested_geometry_flags != Mesh::GEOMETRY_NONE) {
                /* mesh objects does have special handle in the dependency graph,
                 * they're ensured to have properly updated.
                 *
@@ -697,8 +703,8 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
                        /* free derived mesh */
                        b_data.meshes.remove(b_mesh);
                }
-               mesh->geometry_synced = true;
        }
+       mesh->geometry_flags = requested_geometry_flags;
 
        /* displacement method */
        if(cmesh.data) {
index 1d453164aa8849bc9eec0317fa63e9818018a9cc..b31e09c6ef95d8b5e3eda8875eb97c5bad551a13 100644 (file)
@@ -135,7 +135,7 @@ void Mesh::clear()
        transform_applied = false;
        transform_negative_scaled = false;
        transform_normal = transform_identity();
-       geometry_synced = false;
+       geometry_flags = GEOMETRY_NONE;
 }
 
 int Mesh::split_vertex(int vertex)
index 62e775e5bc9be780390b27fd476958dac819934e..6eaafea8729b135b9f6eeb9371b786da1949ae89 100644 (file)
@@ -71,8 +71,13 @@ public:
        ustring name;
 
        /* Mesh Data */
-       bool geometry_synced;  /* used to distinguish meshes with no verts
-                                 and meshed for which geometry is not created */
+       enum GeometryFlags {
+               GEOMETRY_NONE      = 0,
+               GEOMETRY_TRIANGLES = (1 << 0),
+               GEOMETRY_CURVES    = (1 << 1),
+       };
+       int geometry_flags;  /* used to distinguish meshes with no verts
+                               and meshed for which geometry is not created */
 
        vector<float3> verts;
        vector<Triangle> triangles;
index fd47bba418212e39681777868d20c883738faf1e..81438d357e44e36ba83b28892faecca3dd76b1ef 100644 (file)
@@ -395,6 +395,12 @@ if(WITH_CYCLES)
                        -testdir "${TEST_SRC_DIR}/cycles/ctests/reports"
                        -idiff "${OPENIMAGEIO_IDIFF}"
                )
+               add_test(cycles_render_test
+                       ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
+                       -blender "${TEST_BLENDER_EXE_BARE}"
+                       -testdir "${TEST_SRC_DIR}/cycles/ctests/render"
+                       -idiff "${OPENIMAGEIO_IDIFF}"
+               )
                add_test(cycles_shaders_test
                        ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
                        -blender "${TEST_BLENDER_EXE_BARE}"