Fix T74095: crash deleting all faces in edit mode with Cycles rendering
authorBrecht Van Lommel <brecht@blender.org>
Tue, 25 Feb 2020 10:52:32 +0000 (11:52 +0100)
committerBrecht Van Lommel <brecht@blender.org>
Tue, 25 Feb 2020 10:53:25 +0000 (11:53 +0100)
intern/cycles/blender/blender_curves.cpp
intern/cycles/blender/blender_geometry.cpp
intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/blender/blender_volume.cpp

index affd568533796c436414df3ad4cf74e99ccc4127..fe0f8f3b88a43022d5394f302cff548509aaecd6 100644 (file)
@@ -1154,7 +1154,10 @@ void BlenderSync::sync_particle_hair(
   }
 }
 
-void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Geometry *geom)
+void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph,
+                            BL::Object b_ob,
+                            Geometry *geom,
+                            const vector<Shader *> &used_shaders)
 {
   Hair *hair = (geom->type == Geometry::HAIR) ? static_cast<Hair *>(geom) : NULL;
   Mesh *mesh = (geom->type == Geometry::MESH) ? static_cast<Mesh *>(geom) : NULL;
@@ -1172,6 +1175,9 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Geometry
     oldtriangles.steal_data(mesh->triangles);
   }
 
+  geom->clear();
+  geom->used_shaders = used_shaders;
+
   if (view_layer.use_hair && scene->curve_system_manager->use_curves) {
     /* Particle hair. */
     bool need_undeformed = geom->need_attribute(scene, ATTR_STD_GENERATED);
index 8b803835b62771767fc72a5c09413990b82b0209..304b3d18e2720cdf8a21657ce647d9ab90096d38 100644 (file)
@@ -117,20 +117,18 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
 
   geometry_synced.insert(geom);
 
-  geom->clear();
-  geom->used_shaders = used_shaders;
   geom->name = ustring(b_ob_data.name().c_str());
 
   if (use_particle_hair) {
-    sync_hair(b_depsgraph, b_ob, geom);
+    sync_hair(b_depsgraph, b_ob, geom, used_shaders);
   }
   else if (object_fluid_gas_domain_find(b_ob)) {
     Mesh *mesh = static_cast<Mesh *>(geom);
-    sync_volume(b_ob, mesh);
+    sync_volume(b_ob, mesh, used_shaders);
   }
   else {
     Mesh *mesh = static_cast<Mesh *>(geom);
-    sync_mesh(b_depsgraph, b_ob, mesh);
+    sync_mesh(b_depsgraph, b_ob, mesh, used_shaders);
   }
 
   return geom;
index 42300f6eb6f4a8d110dc69a61d0749e6083f97dd..075c9250e8c1772396561a8cc4603a9c78c87f96 100644 (file)
@@ -941,7 +941,10 @@ static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
   }
 }
 
-void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh)
+void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph,
+                            BL::Object b_ob,
+                            Mesh *mesh,
+                            const vector<Shader *> &used_shaders)
 {
   array<int> oldtriangles;
   array<Mesh::SubdFace> oldsubd_faces;
@@ -950,6 +953,9 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *me
   oldsubd_faces.steal_data(mesh->subd_faces);
   oldsubd_face_corners.steal_data(mesh->subd_face_corners);
 
+  mesh->clear();
+  mesh->used_shaders = used_shaders;
+
   mesh->subdivision_type = Mesh::SUBDIVISION_NONE;
 
   if (view_layer.use_surfaces) {
index efd4511eb1eb78e3d8cf1ceeb9794e2132b42fa3..219a36158356712ca38ede9672ce90a3c8fea41c 100644 (file)
@@ -137,14 +137,20 @@ class BlenderSync {
                       bool *use_portal);
 
   /* Volume */
-  void sync_volume(BL::Object &b_ob, Mesh *mesh);
+  void sync_volume(BL::Object &b_ob, Mesh *mesh, const vector<Shader *> &used_shaders);
 
   /* Mesh */
-  void sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh);
+  void sync_mesh(BL::Depsgraph b_depsgraph,
+                 BL::Object b_ob,
+                 Mesh *mesh,
+                 const vector<Shader *> &used_shaders);
   void sync_mesh_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh, int motion_step);
 
   /* Hair */
-  void sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Geometry *geom);
+  void sync_hair(BL::Depsgraph b_depsgraph,
+                 BL::Object b_ob,
+                 Geometry *geom,
+                 const vector<Shader *> &used_shaders);
   void sync_hair_motion(BL::Depsgraph b_depsgraph,
                         BL::Object b_ob,
                         Geometry *geom,
index 87fb962072512ecbc660273f23243b421e602435..ae70e60d60e11974246dc90956bf76edf873b1c0 100644 (file)
@@ -80,10 +80,13 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
   }
 }
 
-void BlenderSync::sync_volume(BL::Object &b_ob, Mesh *mesh)
+void BlenderSync::sync_volume(BL::Object &b_ob, Mesh *mesh, const vector<Shader *> &used_shaders)
 {
   bool old_has_voxel_attributes = mesh->has_voxel_attributes();
 
+  mesh->clear();
+  mesh->used_shaders = used_shaders;
+
   /* Smoke domain. */
   sync_smoke_volume(scene, b_ob, mesh, b_scene.frame_current());