Browse Source

Fix an uninitialized value in hsBounds.

Darryl Pogue 11 years ago
parent
commit
b66a2ba9e3
  1. 32
      Sources/Plasma/CoreLib/hsBounds.cpp

32
Sources/Plasma/CoreLib/hsBounds.cpp

@ -2208,9 +2208,11 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel,
hsVector3 tstAxis; hsVector3 tstAxis;
float tstDepth; float tstDepth;
int i; int i;
for( i = 0; i < 3; i++ ) for( i = 0; i < 3; i++ )
{ {
bool tryAxis; bool tryAxis = false;
if( other.fExtFlags & kAxisAligned ) if( other.fExtFlags & kAxisAligned )
{ {
// first try the other box axes // first try the other box axes
@ -2223,31 +2225,28 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel,
effMin += velDist; effMin += velDist;
effMax += fRadius; effMax += fRadius;
effMin -= fRadius; effMin -= fRadius;
if( effMax < other.fMins[i] ) if( effMax < other.fMins[i] )
return false; return false;
if( effMin > other.fMaxs[i] ) if( effMin > other.fMaxs[i] )
return false; return false;
if( (other.fMins[i] <= effMin) if ((other.fMins[i] <= effMin) &&
&&(other.fMaxs[i] <= effMax) ) (other.fMaxs[i] <= effMax))
{ {
tstDepth = other.fMaxs[i] - effMin; tstDepth = other.fMaxs[i] - effMin;
hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); 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); tstAxis.Set(i == 0 ? 1.f : 0, i & 1 ? 1.f : 0, i & 2 ? 1.f : 0);
tryAxis = true; tryAxis = true;
} }
else else if ((other.fMins[i] >= effMin) &&
if( (other.fMins[i] >= effMin) (other.fMaxs[i] >= effMax))
&&(other.fMaxs[i] >= effMax) )
{ {
tstDepth = effMax - other.fMins[i]; tstDepth = effMax - other.fMins[i];
hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); 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); tstAxis.Set(i == 0 ? -1.f : 0, i & 1 ? -1.f : 0, i & 2 ? -1.f : 0);
tryAxis = true; tryAxis = true;
} }
else
tryAxis = false;
} }
else else
{ {
@ -2263,7 +2262,7 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel,
effMin += velDist; effMin += velDist;
effMax += radScaled; effMax += radScaled;
effMin -= radScaled; effMin -= radScaled;
if( !(other.fExtFlags & kDistsSet) ) if( !(other.fExtFlags & kDistsSet) )
other.IMakeDists(); other.IMakeDists();
@ -2271,24 +2270,21 @@ bool hsBounds3Ext::ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel,
return false; return false;
if( effMin > other.fDists[i].fY ) if( effMin > other.fDists[i].fY )
return false; return false;
if( centerDist <= other.fDists[i].fX ) if (centerDist <= other.fDists[i].fX)
{ {
tstDepth = effMax - other.fDists[i].fX; tstDepth = effMax - other.fDists[i].fX;
tstAxis = -other.fAxes[i]; tstAxis = -other.fAxes[i];
hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis");
} }
else else if (centerDist >= other.fDists[i].fY)
if( centerDist >= other.fDists[i].fY )
{ {
tstDepth = other.fDists[i].fY - effMin; tstDepth = other.fDists[i].fY - effMin;
tstAxis = other.fAxes[i]; tstAxis = other.fAxes[i];
hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis"); hsAssert(tstDepth > -kRealSmall, "Late to be finding sep axis");
} }
else
tryAxis = false;
} }
if( tryAxis ) if( tryAxis )
{ {
float magSq = tstAxis.MagnitudeSquared(); float magSq = tstAxis.MagnitudeSquared();

Loading…
Cancel
Save