[Bf-blender-cvs] [a7c5f4f2065] master: Fix T57078: Alembic curve import: better check for topology similarity

Sybren A. Stüvel noreply at git.blender.org
Fri Dec 28 18:06:54 CET 2018


Commit: a7c5f4f20657e12b43337e32bc62a876cbbe6292
Author: Sybren A. Stüvel
Date:   Fri Dec 28 18:05:31 2018 +0100
Branches: master
https://developer.blender.org/rBa7c5f4f20657e12b43337e32bc62a876cbbe6292

Fix T57078: Alembic curve import: better check for topology similarity

The old code assumed that if the number of curves was the same, the
entire set of curves would have the same topology (in other words, it
assumed 'same number of curves => same number of vertices for each
curve').

I've added a more thorough check that also considers the number of
vertices in each curve. This still keeps certain assumptions in place
(for example that if the topology is the same, the weights won't change,
which is not necessarily true). However, when the assumption doesn't
hold, at least now Blender doesn't crash any more.

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

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

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

diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index f9880eda451..fa5e2214836 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -440,18 +440,32 @@ Mesh *AbcCurveReader::read_mesh(Mesh *existing_mesh,
 	const Int32ArraySamplePtr num_vertices = sample.getCurvesNumVertices();
 
 	int vertex_idx = 0;
-	int curve_idx = 0;
+	int curve_idx;
 	Curve *curve = static_cast<Curve *>(m_object->data);
 
 	const int curve_count = BLI_listbase_count(&curve->nurb);
+	bool same_topology = curve_count == num_vertices->size();
 
-	if (curve_count != num_vertices->size()) {
+	if (same_topology) {
+		Nurb *nurbs = static_cast<Nurb *>(curve->nurb.first);
+		for (curve_idx=0; nurbs; nurbs = nurbs->next, ++curve_idx) {
+			const int num_in_alembic = (*num_vertices)[curve_idx];
+			const int num_in_blender = nurbs->pntsu;
+
+			if (num_in_alembic != num_in_blender) {
+				same_topology = false;
+				break;
+			}
+		}
+	}
+
+	if (!same_topology) {
 		BKE_nurbList_free(&curve->nurb);
 		read_curve_sample(curve, m_curves_schema, sample_sel);
 	}
 	else {
 		Nurb *nurbs = static_cast<Nurb *>(curve->nurb.first);
-		for (; nurbs; nurbs = nurbs->next, ++curve_idx) {
+		for (curve_idx=0; nurbs; nurbs = nurbs->next, ++curve_idx) {
 			const int totpoint = (*num_vertices)[curve_idx];
 
 			if (nurbs->bp) {



More information about the Bf-blender-cvs mailing list