Commit: 8e6aaa08c201b1b3d4ce1d0f54f91f483d663ca9
Author: Brecht Van Lommel
Date:   Sun Sep 18 13:06:15 2016 +0200
Branches: blender-v2.78-release
https://developer.blender.org/rB8e6aaa08c201b1b3d4ce1d0f54f91f483d663ca9

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])

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to