[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59943] trunk/blender/intern/mikktspace/ mikktspace.c: fix [#36685] crash calculating tangent space data on degenerate geometry

Campbell Barton ideasman42 at gmail.com
Mon Sep 9 11:33:34 CEST 2013


Revision: 59943
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59943
Author:   campbellbarton
Date:     2013-09-09 09:33:34 +0000 (Mon, 09 Sep 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/intern/mikktspace/mikktspace.c

Modified: trunk/blender/intern/mikktspace/mikktspace.c
===================================================================
--- trunk/blender/intern/mikktspace/mikktspace.c	2013-09-09 09:27:25 UTC (rev 59942)
+++ trunk/blender/intern/mikktspace/mikktspace.c	2013-09-09 09:33:34 UTC (rev 59943)
@@ -440,8 +440,8 @@
 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);




More information about the Bf-blender-cvs mailing list