From 15798bfca9bf61b53461b3ffc56ec495d4ab1bfe Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Tue, 4 Feb 2014 14:00:33 +0100 Subject: [PATCH] minor bug found and fixed in rebound --- Code/OysterPhysics3D/OysterCollision3D.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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; }