From: <ole...@us...> - 2012-11-04 23:08:38
|
Revision: 1906 http://opende.svn.sourceforge.net/opende/?rev=1906&view=rev Author: oleh_derevenko Date: 2012-11-04 23:08:30 +0000 (Sun, 04 Nov 2012) Log Message: ----------- Modified Paths: -------------- trunk/CHANGELOG.txt trunk/OPCODE/OPC_RayTriOverlap.h trunk/OPCODE/OPC_TriTriOverlap.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-11-04 20:24:26 UTC (rev 1905) +++ trunk/CHANGELOG.txt 2012-11-04 23:08:30 UTC (rev 1906) @@ -8,6 +8,10 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +11/05/12 Oleh Derevenko + * Fixed zero comparisons in OPCODE to use relative error instead of + absolute epsilon value (found by Bill Sellers) + 06/08/12 Daniel K. O. * Removed the need for defining dSINGLE/dDOUBLE; this is stored now in the generated ode/precision.h header. Modified: trunk/OPCODE/OPC_RayTriOverlap.h =================================================================== --- trunk/OPCODE/OPC_RayTriOverlap.h 2012-11-04 20:24:26 UTC (rev 1905) +++ trunk/OPCODE/OPC_RayTriOverlap.h 2012-11-04 23:08:30 UTC (rev 1906) @@ -30,7 +30,7 @@ if(mCulling) { - if(det<LOCAL_EPSILON) return FALSE; + if(det <= LOCAL_EPSILON * FCMin2(edge1.SquareMagnitude(), edge2.SquareMagnitude())) return FALSE; // From here, det is > 0. So we can use integer cmp. // Calculate distance from vert0 to ray origin @@ -62,7 +62,7 @@ else { // the non-culling branch - if(det>-LOCAL_EPSILON && det<LOCAL_EPSILON) return FALSE; + if(FastFabs(det) <= LOCAL_EPSILON * FCMin2(edge1.SquareMagnitude(), edge2.SquareMagnitude())) return FALSE; float OneOverDet = 1.0f / det; // Calculate distance from vert0 to ray origin Modified: trunk/OPCODE/OPC_TriTriOverlap.h =================================================================== --- trunk/OPCODE/OPC_TriTriOverlap.h 2012-11-04 20:24:26 UTC (rev 1905) +++ trunk/OPCODE/OPC_TriTriOverlap.h 2012-11-04 23:08:30 UTC (rev 1906) @@ -195,9 +195,19 @@ // Coplanarity robustness check #ifdef OPC_TRITRI_EPSILON_TEST - if(fabsf(du0)<LOCAL_EPSILON) du0 = 0.0f; - if(fabsf(du1)<LOCAL_EPSILON) du1 = 0.0f; - if(fabsf(du2)<LOCAL_EPSILON) du2 = 0.0f; + float absd1 = FastFabs(d1), sqmagN1 = N1.SquareMagnitude(); + if (absd1>=sqmagN1) + { + if(FastFabs(du0)<=LOCAL_EPSILON*absd1) du0 = 0.0f; + if(FastFabs(du1)<=LOCAL_EPSILON*absd1) du1 = 0.0f; + if(FastFabs(du2)<=LOCAL_EPSILON*absd1) du2 = 0.0f; + } + else + { + if(FastFabs(du0)<=LOCAL_EPSILON*FCMax2(absd1, FCMin2(sqmagN1, U0.SquareMagnitude()))) du0 = 0.0f; + if(FastFabs(du1)<=LOCAL_EPSILON*FCMax2(absd1, FCMin2(sqmagN1, U1.SquareMagnitude()))) du1 = 0.0f; + if(FastFabs(du2)<=LOCAL_EPSILON*FCMax2(absd1, FCMin2(sqmagN1, U2.SquareMagnitude()))) du2 = 0.0f; + } #endif const float du0du1 = du0 * du1; const float du0du2 = du0 * du2; @@ -218,9 +228,19 @@ float dv2 = (N2|V2) + d2; #ifdef OPC_TRITRI_EPSILON_TEST - if(fabsf(dv0)<LOCAL_EPSILON) dv0 = 0.0f; - if(fabsf(dv1)<LOCAL_EPSILON) dv1 = 0.0f; - if(fabsf(dv2)<LOCAL_EPSILON) dv2 = 0.0f; + float absd2 = FastFabs(d2), sqmagN2 = N2.SquareMagnitude(); + if (absd2>=sqmagN2) + { + if(FastFabs(dv0)<=LOCAL_EPSILON*absd2) dv0 = 0.0f; + if(FastFabs(dv1)<=LOCAL_EPSILON*absd2) dv1 = 0.0f; + if(FastFabs(dv2)<=LOCAL_EPSILON*absd2) dv2 = 0.0f; + } + else + { + if(FastFabs(dv0)<=LOCAL_EPSILON*FCMax2(absd2, FCMin2(sqmagN2, V0.SquareMagnitude()))) dv0 = 0.0f; + if(FastFabs(dv1)<=LOCAL_EPSILON*FCMax2(absd2, FCMin2(sqmagN2, V1.SquareMagnitude()))) dv1 = 0.0f; + if(FastFabs(dv2)<=LOCAL_EPSILON*FCMax2(absd2, FCMin2(sqmagN2, V2.SquareMagnitude()))) dv2 = 0.0f; + } #endif const float dv0dv1 = dv0 * dv1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |