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

This commit is contained in:
Brecht Van Lommel 2016-09-18 13:06:15 +02:00
parent 40247ee491
commit 0552d5820b
Notes: blender-bot 2023-02-14 11:08:33 +01:00
Referenced by issue #49384, Assigning UV for aniso tangent hangs Blender when rendering starts. Probably in rare cases only.
1 changed files with 7 additions and 4 deletions

View File

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