compile errors fixed

This commit is contained in:
Dander7BD 2013-12-18 09:25:04 +01:00
parent dbb0c38432
commit 96bf20e5ae
3 changed files with 14 additions and 5 deletions

View File

@ -671,14 +671,14 @@ namespace Oyster { namespace Collision3D { namespace Utility
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere, Float4 &worldPointOfContact ) bool Intersect( const BoxAxisAligned &box, const Sphere &sphere, Float4 &worldPointOfContact )
{ // by Robin Engman { // by Robin Engman
if( Intersect(box, sphere) )
if(Intersect(box, sphere))
{ {
Float distance; Float distance;
Float3 boxMiddle = (box.maxVertex - box.minVertex)*0.5f; Float4 boxMiddle = (box.maxVertex - box.minVertex) * 0.5f;
Ray ray(boxMiddle, Float3(sphere.center - boxMiddle).Normalize()); Ray ray( boxMiddle, (sphere.center - boxMiddle).Normalize() );
Intersect( sphere, ray, distance ); Intersect( sphere, ray, distance );
worldPointOfContact = ray.origin + ray.direction * distance; worldPointOfContact = ray.origin + ray.direction * distance;
return true;
} }
return false; return false;
@ -784,10 +784,11 @@ namespace Oyster { namespace Collision3D { namespace Utility
if( Intersect(box, sphere) ) if( Intersect(box, sphere) )
{ {
Float distance; Float distance;
Ray ray( sphere.center, Float3(box.center - sphere.center) ); Ray ray( sphere.center, box.center - sphere.center );
Intersect( box, ray, distance ); Intersect( box, ray, distance );
worldPointOfContact = ray.origin + ray.direction*distance; worldPointOfContact = ray.origin + ray.direction*distance;
return true;
} }
return false; return false;

View File

@ -22,6 +22,13 @@ Ray::Ray( const Float3 &o, const Float3 &d ) : ICollideable(Type_ray)
this->collisionDistance = 0.0f; this->collisionDistance = 0.0f;
} }
Ray::Ray( const Float4 &o, const Float4 &d ) : ICollideable(Type_ray)
{
this->origin = o;
this->direction = d;
this->collisionDistance = 0.0f;
}
Ray::~Ray( ) {} Ray::~Ray( ) {}
Ray & Ray::operator = ( const Ray &ray ) Ray & Ray::operator = ( const Ray &ray )

View File

@ -30,6 +30,7 @@ namespace Oyster { namespace Collision3D
Ray( ); Ray( );
Ray( const ::Oyster::Math::Float3 &origin, const ::Oyster::Math::Float3 &normalizedDirection ); Ray( const ::Oyster::Math::Float3 &origin, const ::Oyster::Math::Float3 &normalizedDirection );
Ray( const ::Oyster::Math::Float4 &origin, const ::Oyster::Math::Float4 &normalizedDirection );
virtual ~Ray( ); virtual ~Ray( );
Ray & operator = ( const Ray &ray ); Ray & operator = ( const Ray &ray );