Extractable collision point for SphereVSSphere

This commit is contained in:
Robin Engman 2013-12-16 10:28:49 +01:00 committed by Dander7BD
parent a3ced24fea
commit d8b323e230
3 changed files with 21 additions and 9 deletions

View File

@ -249,7 +249,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
return true; // Passed all tests, is in same position
}
bool Intersect( const Point &pointA, const Point &pointB, const ::Oyster::Math::Float3& worldPointOfContact )
bool Intersect( const Point &pointA, const Point &pointB, ::Oyster::Math::Float3& worldPointOfContact )
{
return false;
}
@ -284,12 +284,12 @@ namespace Oyster { namespace Collision3D { namespace Utility
return false;
}
bool Intersect( const Ray &ray, const Point &point, ::Oyster::Math::Float &connectDistance, const ::Oyster::Math::Float3& worldPointOfContact )
bool Intersect( const Ray &ray, const Point &point, ::Oyster::Math::Float &connectDistance, ::Oyster::Math::Float3& worldPointOfContact )
{
return false;
}
bool Intersect( const Ray &rayA, const Ray &rayB, ::Oyster::Math::Float &connectDistanceA, ::Oyster::Math::Float &connectDistanceB, const ::Oyster::Math::Float3& worldPointOfContact )
bool Intersect( const Ray &rayA, const Ray &rayB, ::Oyster::Math::Float &connectDistanceA, ::Oyster::Math::Float &connectDistanceB, ::Oyster::Math::Float3& worldPointOfContact )
{
return false;
}
@ -336,20 +336,32 @@ namespace Oyster { namespace Collision3D { namespace Utility
return false;
}
bool Intersect( const Sphere &sphere, const Point &point, const ::Oyster::Math::Float3& worldPointOfContact )
bool Intersect( const Sphere &sphere, const Point &point, ::Oyster::Math::Float3& worldPointOfContact )
{
return false;
}
bool Intersect( const Sphere &sphere, const Ray &ray, ::Oyster::Math::Float &connectDistance, const ::Oyster::Math::Float3& worldPointOfContact )
bool Intersect( const Sphere &sphere, const Ray &ray, ::Oyster::Math::Float &connectDistance, ::Oyster::Math::Float3& worldPointOfContact )
{
return false;
}
bool Intersect( const Sphere &sphereA, const Sphere &sphereB, const ::Oyster::Math::Float3& worldPointOfContact )
bool Intersect( const Sphere &sphereA, const Sphere &sphereB, ::Oyster::Math::Float3& worldPointOfContact )
{
Ray sphereRay(sphereA.center, Float3(sphereB.center-sphereA.center).Normalize());
//Float3 C = sphereA.center;
//C -= sphereB.center;
//Float r = (sphereA.radius + sphereB.radius);
//if (r*r >= C.Dot(C))
//{
// Float distance;
// Intersect(sphereA, Ray(sphereB.center, C.Normalize()), distance);
// worldPointOfContact = sphereB.center+C.Normalize()*distance;
// return true; // Intersect detected!
//}
return false;
}

View File

@ -56,7 +56,7 @@ bool Point::Intersects( const ICollideable &target, ::Oyster::Math::Float3 &worl
case Type_point: return Utility::Intersect( *this, *(Point*)&target, worldPointOfContact );
case Type_ray: return Utility::Intersect( *(Ray*)&target, *this, ((Ray*)&target)->collisionDistance, worldPointOfContact );
case Type_sphere: return Utility::Intersect( *(Sphere*)&target, *this, worldPointOfContact );
case Type_plane: return Utility::Intersect( *(Plane*)&target, *this, worldPointOfContact );
//case Type_plane: return Utility::Intersect( *(Plane*)&target, *this, worldPointOfContact );
// case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return false; // return Utility::Intersect( *(BoxAxisAligned*)&target, *this, worldPointOfContact );
case Type_box: return false; // return Utility::Intersect( *(Box*)&target, *this, worldPointOfContact );

View File

@ -53,7 +53,7 @@ bool Sphere::Intersects( const ICollideable &target, ::Oyster::Math::Float3 &wor
case Type_point: return Utility::Intersect( *this, *(Point*)&target, worldPointOfContact );
case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance, worldPointOfContact );
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target, worldPointOfContact );
case Type_plane: return Utility::Intersect( *(Plane*)&target, *this, worldPointOfContact );
//case Type_plane: return Utility::Intersect( *(Plane*)&target, *this, worldPointOfContact );
// case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return false; // return Utility::Intersect( *(BoxAxisAligned*)&target, *this, worldPointOfContact );
case Type_box: return false; // return Utility::Intersect( *(Box*)&target, *this, worldPointOfContact );