Cycles: Fix crash when empty mesh has subdivision
authorMai Lavelle <mai.lavelle@gmail.com>
Tue, 23 Aug 2016 18:49:10 +0000 (14:49 -0400)
committerMai Lavelle <mai.lavelle@gmail.com>
Wed, 24 Aug 2016 14:39:00 +0000 (10:39 -0400)
OpenSubdiv doesn't like empty meshes, so we need to be careful not to
subdivide when the mesh is empty.

intern/cycles/render/mesh_subdivision.cpp

index f87425f00421af8efed14ca854ec74ecf5a59496..c8cc3abf7d9134766ce3cba48b3fa61170224d01 100644 (file)
@@ -299,7 +299,9 @@ void Mesh::tessellate(DiagSplit *split)
        bool need_packed_patch_table = false;
 
        if(subdivision_type == SUBDIVISION_CATMULL_CLARK) {
-               osd_data.build_from_mesh(this);
+               if(subd_faces.size()) {
+                       osd_data.build_from_mesh(this);
+               }
        }
        else
 #endif
@@ -468,7 +470,7 @@ void Mesh::tessellate(DiagSplit *split)
                                /* keep subdivision for corner attributes disabled for now */
                                attr.flags &= ~ATTR_SUBDIVIDED;
                        }
-                       else {
+                       else if(subd_faces.size()) {
                                osd_data.subdivide_attribute(attr);
 
                                need_packed_patch_table = true;