Merge branch 'Physics' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-04 14:02:03 +01:00
commit ad16d51f75
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;
}