Merge branch 'Physics' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
ad16d51f75
|
@ -1064,38 +1064,42 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
|
|
||||||
Float TimeOfContact( const Sphere &protoStart, const Sphere &protoEnd, const Point &deuter )
|
Float TimeOfContact( const Sphere &protoStart, const Sphere &protoEnd, const Point &deuter )
|
||||||
{ // Bisection with 5 levels of detail
|
{ // Bisection with 5 levels of detail
|
||||||
Float t = 0.5f;
|
Float t = 0.5f,
|
||||||
|
d = 0.25f;
|
||||||
Sphere s;
|
Sphere s;
|
||||||
for( int i = 0; i < 5; ++i )
|
for( int i = 0; i < 5; ++i )
|
||||||
{
|
{
|
||||||
Nlerp( protoStart, protoEnd, t, s );
|
Nlerp( protoStart, protoEnd, t, s );
|
||||||
if( Intersect(s, deuter) )
|
if( Intersect(s, deuter) )
|
||||||
{
|
{
|
||||||
t *= 0.5f;
|
t -= d;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t *= 1.5f;
|
t += d;
|
||||||
}
|
}
|
||||||
|
d *= 0.5f;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Float TimeOfContact( const Box &protoStart, const Box &protoEnd, const Point &deuter )
|
Float TimeOfContact( const Box &protoStart, const Box &protoEnd, const Point &deuter )
|
||||||
{ // Bisection with 5 levels of detail
|
{ // Bisection with 5 levels of detail
|
||||||
Float t = 0.5f;
|
Float t = 0.5f,
|
||||||
|
d = 0.25f;
|
||||||
Box b;
|
Box b;
|
||||||
for( int i = 0; i < 5; ++i )
|
for( int i = 0; i < 5; ++i )
|
||||||
{
|
{
|
||||||
Nlerp( protoStart, protoEnd, t, b );
|
Nlerp( protoStart, protoEnd, t, b );
|
||||||
if( Intersect(b, deuter) )
|
if( Intersect(b, deuter) )
|
||||||
{
|
{
|
||||||
t *= 0.5f;
|
t -= d;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t *= 1.5f;
|
t += d;
|
||||||
}
|
}
|
||||||
|
d *= 0.5f;
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue