minor bug found and fixed in rebound

This commit is contained in:
Dander7BD 2014-02-04 14:00:33 +01:00
parent e39eb5fb4b
commit 15798bfca9
1 changed files with 10 additions and 6 deletions

View File

@ -1064,38 +1064,42 @@ namespace Oyster { namespace Collision3D { namespace Utility
Float TimeOfContact( const Sphere &protoStart, const Sphere &protoEnd, const Point &deuter )
{ // Bisection with 5 levels of detail
Float t = 0.5f;
Float t = 0.5f,
d = 0.25f;
Sphere s;
for( int i = 0; i < 5; ++i )
{
Nlerp( protoStart, protoEnd, t, s );
if( Intersect(s, deuter) )
{
t *= 0.5f;
t -= d;
}
else
{
t *= 1.5f;
t += d;
}
d *= 0.5f;
}
return t;
}
Float TimeOfContact( const Box &protoStart, const Box &protoEnd, const Point &deuter )
{ // Bisection with 5 levels of detail
Float t = 0.5f;
Float t = 0.5f,
d = 0.25f;
Box b;
for( int i = 0; i < 5; ++i )
{
Nlerp( protoStart, protoEnd, t, b );
if( Intersect(b, deuter) )
{
t *= 0.5f;
t -= d;
}
else
{
t *= 1.5f;
t += d;
}
d *= 0.5f;
}
return t;
}