forked from bartvdbraak/blender
Fix T49384: crash in tangent space calculation with NaN mesh vertices.
This commit is contained in:
parent
40247ee491
commit
0552d5820b
@ -579,11 +579,10 @@ static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], cons
|
|||||||
{
|
{
|
||||||
// make bbox
|
// make bbox
|
||||||
int c=0, l=0, channel=0;
|
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;
|
float dx=0, dy=0, dz=0, fSep=0;
|
||||||
for (c=0; c<3; c++)
|
for (l=iL_in; l<=iR_in; l++)
|
||||||
{ fvMin[c]=pTmpVert[iL_in].vert[c]; fvMax[c]=fvMin[c]; }
|
|
||||||
for (l=(iL_in+1); l<=iR_in; l++)
|
|
||||||
for (c=0; c<3; c++)
|
for (c=0; c<3; c++)
|
||||||
if (fvMin[c]>pTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[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];
|
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]);
|
fSep = 0.5f*(fvMax[channel]+fvMin[channel]);
|
||||||
|
|
||||||
|
// stop if all vertices are NaNs
|
||||||
|
if (!isfinite(fSep))
|
||||||
|
return;
|
||||||
|
|
||||||
// terminate recursion when the separation/average value
|
// terminate recursion when the separation/average value
|
||||||
// is no longer strictly between fMin and fMax values.
|
// is no longer strictly between fMin and fMax values.
|
||||||
if (fSep>=fvMax[channel] || fSep<=fvMin[channel])
|
if (fSep>=fvMax[channel] || fSep<=fvMin[channel])
|
||||||
|
Loading…
Reference in New Issue
Block a user