[Bf-blender-cvs] [bef5cb3] master: Fix T40405: Blender crashes on FBX export instantly.

Bastien Montagne noreply at git.blender.org
Wed May 28 13:56:48 CEST 2014


Commit: bef5cb3aa2e5a7a992f3fa096943ba671c98e7b1
Author: Bastien Montagne
Date:   Wed May 28 13:47:37 2014 +0200
https://developer.blender.org/rBbef5cb3aa2e5a7a992f3fa096943ba671c98e7b1

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.

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

M	source/blender/blenkernel/intern/mesh_evaluate.c

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

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index cad436c..7c6fe9c 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);




More information about the Bf-blender-cvs mailing list