From 96bf20e5ae07c1d77689c70ad7f6fe49f66251ef Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 18 Dec 2013 09:25:04 +0100 Subject: [PATCH] compile errors fixed --- Code/OysterPhysics3D/OysterCollision3D.cpp | 11 ++++++----- Code/OysterPhysics3D/Ray.cpp | 7 +++++++ Code/OysterPhysics3D/Ray.h | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Code/OysterPhysics3D/OysterCollision3D.cpp b/Code/OysterPhysics3D/OysterCollision3D.cpp index 526f87e7..00684898 100644 --- a/Code/OysterPhysics3D/OysterCollision3D.cpp +++ b/Code/OysterPhysics3D/OysterCollision3D.cpp @@ -671,14 +671,14 @@ namespace Oyster { namespace Collision3D { namespace Utility bool Intersect( const BoxAxisAligned &box, const Sphere &sphere, Float4 &worldPointOfContact ) { // by Robin Engman - - if(Intersect(box, sphere)) + if( Intersect(box, sphere) ) { Float distance; - Float3 boxMiddle = (box.maxVertex - box.minVertex)*0.5f; - Ray ray(boxMiddle, Float3(sphere.center - boxMiddle).Normalize()); + Float4 boxMiddle = (box.maxVertex - box.minVertex) * 0.5f; + Ray ray( boxMiddle, (sphere.center - boxMiddle).Normalize() ); Intersect( sphere, ray, distance ); worldPointOfContact = ray.origin + ray.direction * distance; + return true; } return false; @@ -784,10 +784,11 @@ namespace Oyster { namespace Collision3D { namespace Utility if( Intersect(box, sphere) ) { Float distance; - Ray ray( sphere.center, Float3(box.center - sphere.center) ); + Ray ray( sphere.center, box.center - sphere.center ); Intersect( box, ray, distance ); worldPointOfContact = ray.origin + ray.direction*distance; + return true; } return false; diff --git a/Code/OysterPhysics3D/Ray.cpp b/Code/OysterPhysics3D/Ray.cpp index b68ee68e..e7f21de8 100644 --- a/Code/OysterPhysics3D/Ray.cpp +++ b/Code/OysterPhysics3D/Ray.cpp @@ -22,6 +22,13 @@ Ray::Ray( const Float3 &o, const Float3 &d ) : ICollideable(Type_ray) 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::operator = ( const Ray &ray ) diff --git a/Code/OysterPhysics3D/Ray.h b/Code/OysterPhysics3D/Ray.h index 79be0c21..a85580b3 100644 --- a/Code/OysterPhysics3D/Ray.h +++ b/Code/OysterPhysics3D/Ray.h @@ -30,6 +30,7 @@ namespace Oyster { namespace Collision3D Ray( ); Ray( const ::Oyster::Math::Float3 &origin, const ::Oyster::Math::Float3 &normalizedDirection ); + Ray( const ::Oyster::Math::Float4 &origin, const ::Oyster::Math::Float4 &normalizedDirection ); virtual ~Ray( ); Ray & operator = ( const Ray &ray );