diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-05-28 15:47:37 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-05-28 15:54:29 +0400 |
commit | bef5cb3aa2e5a7a992f3fa096943ba671c98e7b1 (patch) | |
tree | 9219a4f30c0e6f99fe053d5a744117d0acdaaf19 /source/blender/blenkernel/intern/mesh_evaluate.c | |
parent | 67f5af05317862b4a3440f02ba6ad2fdfaa827f3 (diff) |
Fix T40405: Blender crashes on FBX export instantly.
This crash can only happen in case faces in same 'smooth fan' have reversed normals.
To support this, we have to always keep a way to get real values in loop_to_poly,
even when loop itself is tagged as done, it might be needed in computation of one of
its neighbor's split normal later.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_evaluate.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_evaluate.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index cad436c0111..7c6fe9c1a43 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -441,8 +441,8 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg copy_v3_v3(*lnors, polynors[mp_index]); /* No need to mark loop as done here, we won't run into it again anyway! */ } - /* This loop may have been already computed, in which case its 'to_poly' map is set to -1... */ - else if (loop_to_poly[ml_curr_index] != -1) { + /* This loop may have been already computed, in which case its 'to_poly' map is set to -(idx + 1)... */ + else if (loop_to_poly[ml_curr_index] >= 0) { /* Gah... We have to fan around current vertex, until we find the other non-smooth edge, * and accumulate face normals into the vertex! * Note in case this vertex has only one sharp edges, this is a waste because the normal is the same as @@ -506,7 +506,7 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg BLI_SMALLSTACK_PUSH(normal, &(r_loopnors[mlfan_vert_index][0])); /* And we are done with this loop, mark it as such! */ - loop_to_poly[mlfan_vert_index] = -1; + loop_to_poly[mlfan_vert_index] = -(loop_to_poly[mlfan_vert_index] + 1); if (IS_EDGE_SHARP(e2lfan_curr)) { /* Current edge is sharp, we have finished with this fan of faces around this vert! */ @@ -525,6 +525,13 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg */ mlfan_curr_index = (e2lfan_curr[0] == mlfan_curr_index) ? e2lfan_curr[1] : e2lfan_curr[0]; mpfan_curr_index = loop_to_poly[mlfan_curr_index]; + /* XXX This should not happen in a mesh with consistent normals, but can occur with + * inconsistent ones (with faces in a same fan being "reversed", mlfan_curr might be the loop + * of another vertex, not the one we are fanning around) , see T40405. + */ + if (mpfan_curr_index < 0) { + mpfan_curr_index = -mpfan_curr_index - 1; + } BLI_assert(mlfan_curr_index >= 0); BLI_assert(mpfan_curr_index >= 0); |