[Bf-blender-cvs] [5883b6fde2d] master: Fix T70021: Alembic incomplete crease import

Sybren A. Stüvel noreply at git.blender.org
Thu Sep 19 17:38:52 CEST 2019


Commit: 5883b6fde2d843e759016a07ae16abe762eb4d19
Author: Sybren A. Stüvel
Date:   Thu Sep 19 17:30:52 2019 +0200
Branches: master
https://developer.blender.org/rB5883b6fde2d843e759016a07ae16abe762eb4d19

Fix T70021: Alembic incomplete crease import

Creases are stored by the vertex indices of the edges. Sometimes they
were stored with (v1, v2) when the edge itself was stored with (v2, v1).
We now search for both orientations.

Sorting the vertex indices before searching avoids the second search
altogether when loading the example file of T70021.

===================================================================

M	source/blender/alembic/intern/abc_mesh.cc

===================================================================

diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 4d00b1904a8..12c59964a8c 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -1414,11 +1414,24 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
   Int32ArraySamplePtr indices = sample.getCreaseIndices();
   Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses();
 
-  MEdge *edges = mesh->medge;
-
   if (indices && sharpnesses) {
+    MEdge *edges = mesh->medge;
+    int totedge = mesh->totedge;
+
     for (int i = 0, s = 0, e = indices->size(); i < e; i += 2, s++) {
-      MEdge *edge = find_edge(edges, mesh->totedge, (*indices)[i], (*indices)[i + 1]);
+      int v1 = (*indices)[i];
+      int v2 = (*indices)[i + 1];
+
+      if (v2 < v1) {
+        /* It appears to be common to store edges with the smallest index first, in which case this
+         * prevents us from doing the second search below. */
+        std::swap(v1, v2);
+      }
+
+      MEdge *edge = find_edge(edges, totedge, v1, v2);
+      if (edge == NULL) {
+        edge = find_edge(edges, totedge, v2, v1);
+      }
 
       if (edge) {
         edge->crease = unit_float_to_uchar_clamp((*sharpnesses)[s]);



More information about the Bf-blender-cvs mailing list