fix [#36685] crash calculating tangent space data on degenerate geometry

the error was that the range check was done on the float before converting to an int.
now convert to and int first and ensure a valid range on that.
This commit is contained in:
Campbell Barton
2013-09-09 09:33:34 +00:00
parent 35e3111475
commit 0392acc607

View File

@@ -440,8 +440,8 @@ static const int g_iCells = 2048;
static NOINLINE int FindGridCell(const float fMin, const float fMax, const float fVal)
{
const float fIndex = g_iCells * ((fVal-fMin)/(fMax-fMin));
const int iIndex = fIndex<0?0:((int)fIndex);
return iIndex<g_iCells?iIndex:(g_iCells-1);
const int iIndex = (int)fIndex;
return iIndex < g_iCells ? (iIndex >= 0 ? iIndex : 0) : (g_iCells - 1);
}
static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext * pContext, const int iL_in, const int iR_in);