[Bf-blender-cvs] [0552d58] master: Fix T49384: crash in tangent space calculation with NaN mesh vertices.

Brecht Van Lommel noreply at git.blender.org
Sun Sep 18 13:39:04 CEST 2016


Commit: 0552d5820b70d2bc60a703af23cdea6828317ab4
Author: Brecht Van Lommel
Date:   Sun Sep 18 13:06:15 2016 +0200
Branches: master
https://developer.blender.org/rB0552d5820b70d2bc60a703af23cdea6828317ab4

Fix T49384: crash in tangent space calculation with NaN mesh vertices.

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

M	intern/mikktspace/mikktspace.c

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

diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c
index 7e5861e..8d51816 100644
--- a/intern/mikktspace/mikktspace.c
+++ b/intern/mikktspace/mikktspace.c
@@ -579,11 +579,10 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
 {
 	// make bbox
 	int c=0, l=0, channel=0;
-	float fvMin[3], fvMax[3];
+	float fvMin[3] = {INFINITY, INFINITY, INFINITY};
+	float fvMax[3] = {-INFINITY, -INFINITY, -INFINITY};
 	float dx=0, dy=0, dz=0, fSep=0;
-	for (c=0; c<3; c++)
-	{	fvMin[c]=pTmpVert[iL_in].vert[c]; fvMax[c]=fvMin[c];	}
-	for (l=(iL_in+1); l<=iR_in; l++)
+	for (l=iL_in; l<=iR_in; l++)
 		for (c=0; c<3; c++)
 			if (fvMin[c]>pTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c];
 			else if (fvMax[c]<pTmpVert[l].vert[c]) fvMax[c]=pTmpVert[l].vert[c];
@@ -598,6 +597,10 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
 
 	fSep = 0.5f*(fvMax[channel]+fvMin[channel]);
 
+	// stop if all vertices are NaNs
+	if (!isfinite(fSep))
+		return;
+
 	// terminate recursion when the separation/average value
 	// is no longer strictly between fMin and fMax values.
 	if (fSep>=fvMax[channel] || fSep<=fvMin[channel])




More information about the Bf-blender-cvs mailing list