Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-09-19 18:30:52 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-09-19 18:36:18 +0300
commit5883b6fde2d843e759016a07ae16abe762eb4d19 (patch)
treee484cf15dc832b8e6230711fb98e41a6052496ef /source/blender/alembic
parentc1612ca114df6d4c8b992808fb05ec03199392c1 (diff)
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.
Diffstat (limited to 'source/blender/alembic')
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc19
1 files changed, 16 insertions, 3 deletions
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]);