diff --git a/Code/OysterPhysics3D/OysterCollision3D.cpp b/Code/OysterPhysics3D/OysterCollision3D.cpp index cc68d536..41e11875 100644 --- a/Code/OysterPhysics3D/OysterCollision3D.cpp +++ b/Code/OysterPhysics3D/OysterCollision3D.cpp @@ -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; }