Alembic import: fixed mesh corruption when changing topology
authorSybren A. Stüvel <sybren@stuvel.eu>
Sun, 29 Oct 2017 12:55:42 +0000 (13:55 +0100)
committerSybren A. Stüvel <sybren@stuvel.eu>
Sun, 29 Oct 2017 13:36:10 +0000 (14:36 +0100)
When the mesh changed topology but kept the vertex count the same, it would
result in a corrupt mesh. By checking the face & loop counts too, this has
become less likely.

I've checked IPolyMeshSchema::isConstant(), but it returns true even when
we see that the mesh changed topology.

source/blender/alembic/intern/abc_mesh.cc

index 6545ced8e4a52dfab1ec7f3643170fde2d1c2f45..36b134f8b0c3f3ce2689368f06f5c7623c4c4154 100644 (file)
@@ -1082,7 +1082,10 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm,
        ImportSettings settings;
        settings.read_flag |= read_flag;
 
-       if (dm->getNumVerts(dm) != positions->size()) {
+       bool topology_changed =  positions->size() != dm->getNumVerts(dm) ||
+                                face_counts->size() != dm->getNumPolys(dm) ||
+                                face_indices->size() != dm->getNumLoops(dm);
+       if (topology_changed) {
                new_dm = CDDM_from_template(dm,
                                            positions->size(),
                                            0,