From b66a2ba9e319cffb518a770b53ae6e342c316ec4 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Sun, 20 Apr 2014 17:12:02 -0700 Subject: [PATCH] Fix an uninitialized value in hsBounds. --- Sources/Plasma/CoreLib/hsBounds.cpp | 32 +++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsBounds.cpp b/Sources/Plasma/CoreLib/hsBounds.cpp index e8676994..dabd8b12 100644 --- a/Sources/Plasma/CoreLib/hsBounds.cpp +++ b/Sources/Plasma/CoreLib/hsBounds.cpp @@ -2208,9 +2208,11 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsVector3 tstAxis; float tstDepth; int i; + for( i = 0; i < 3; i++ ) { - bool tryAxis; + bool tryAxis = false; + if( other.fExtFlags & kAxisAligned ) { // first try the other box axes @@ -2223,31 +2225,28 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, effMin += velDist; effMax += fRadius; effMin -= fRadius; - + if( effMax < other.fMins[i] ) return false; if( effMin > other.fMaxs[i] ) return false; - - if( (other.fMins[i] <= effMin) - &&(other.fMaxs[i] <= effMax) ) + + if ((other.fMins[i] <= effMin) && + (other.fMaxs[i] <= effMax)) { tstDepth = other.fMaxs[i] - effMin; hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); tstAxis.Set(i == 0 ? 1.f : 0, i & 1 ? 1.f : 0, i & 2 ? 1.f : 0); tryAxis = true; } - else - if( (other.fMins[i] >= effMin) - &&(other.fMaxs[i] >= effMax) ) + else if ((other.fMins[i] >= effMin) && + (other.fMaxs[i] >= effMax)) { tstDepth = effMax - other.fMins[i]; hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); tstAxis.Set(i == 0 ? -1.f : 0, i & 1 ? -1.f : 0, i & 2 ? -1.f : 0); tryAxis = true; } - else - tryAxis = false; } else { @@ -2263,7 +2262,7 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, effMin += velDist; effMax += radScaled; effMin -= radScaled; - + if( !(other.fExtFlags & kDistsSet) ) other.IMakeDists(); @@ -2271,24 +2270,21 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, return false; if( effMin > other.fDists[i].fY ) return false; - - if( centerDist <= other.fDists[i].fX ) + + if (centerDist <= other.fDists[i].fX) { tstDepth = effMax - other.fDists[i].fX; tstAxis = -other.fAxes[i]; hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); } - else - if( centerDist >= other.fDists[i].fY ) + else if (centerDist >= other.fDists[i].fY) { tstDepth = other.fDists[i].fY - effMin; tstAxis = other.fAxes[i]; hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); } - else - tryAxis = false; - } + if( tryAxis ) { float magSq = tstAxis.MagnitudeSquared();