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@stuvel.eu>2018-12-28 20:05:31 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-12-28 20:05:31 +0300
commita7c5f4f20657e12b43337e32bc62a876cbbe6292 (patch)
tree8b1f10eca32f755c97c02bf73cfbf767257d4cfd /source/blender/alembic
parent196a5116aa2f7a3b46daf2047e957b43bee26083 (diff)
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.
Diffstat (limited to 'source/blender/alembic')
-rw-r--r--source/blender/alembic/intern/abc_curves.cc20
1 files changed, 17 insertions, 3 deletions
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) {