Added algorithms for collision stubs
This commit is contained in:
parent
e8952dc739
commit
9cdbe2c861
|
@ -422,7 +422,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
return true; // Passed all tests, is in same position
|
return true; // Passed all tests, is in same position
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Point &pointA, const Point &pointB, ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Point &pointA, const Point &pointB, ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
|
@ -458,13 +458,13 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Ray &ray, const Point &point, ::Oyster::Math::Float &connectDistance, ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Ray &ray, const Point &point, ::Oyster::Math::Float &connectDistance, ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Ray &rayA, const Ray &rayB, ::Oyster::Math::Float &connectDistanceA, ::Oyster::Math::Float &connectDistanceB, ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Ray &rayA, const Ray &rayB, ::Oyster::Math::Float &connectDistanceA, ::Oyster::Math::Float &connectDistanceB, ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
|
@ -512,34 +512,35 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Sphere &sphere, const Point &point, ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Sphere &sphere, const Point &point, ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Sphere &sphere, const Ray &ray, ::Oyster::Math::Float &connectDistance, ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Sphere &sphere, const Ray &ray, ::Oyster::Math::Float &connectDistance, ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Sphere &sphereA, const Sphere &sphereB, ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Sphere &sphereA, const Sphere &sphereB, ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
|
{ // by Robin Engman
|
||||||
|
Float3 C = sphereA.center;
|
||||||
|
C -= sphereB.center;
|
||||||
|
Float r = sphereA.radius + sphereB.radius;
|
||||||
|
|
||||||
|
if ( r*r >= C.Dot(C) )
|
||||||
{
|
{
|
||||||
//Float3 C = sphereA.center;
|
Float distance;
|
||||||
//C -= sphereB.center;
|
Ray ray(sphereB.center, C.Normalize());
|
||||||
//Float r = (sphereA.radius + sphereB.radius);
|
|
||||||
|
|
||||||
//if (r*r >= C.Dot(C))
|
Intersect( sphereA, ray, distance );
|
||||||
//{
|
|
||||||
// Float distance;
|
|
||||||
|
|
||||||
// Intersect(sphereA, Ray(sphereB.center, C.Normalize()), distance);
|
worldPointOfContact = ray.origin + ray.direction*distance;
|
||||||
|
|
||||||
// worldPointOfContact = sphereB.center+C.Normalize()*distance;
|
return true;
|
||||||
|
}
|
||||||
// return true; // Intersect detected!
|
|
||||||
//}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -587,25 +588,25 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
return true; // none parallell planes ALWAYS intersects somewhere
|
return true; // none parallell planes ALWAYS intersects somewhere
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Plane &plane, const Point &point, const ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Plane &plane, const Point &point, const ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Plane &plane, const Ray &ray, ::Oyster::Math::Float &connectDistance, const ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Plane &plane, const Ray &ray, ::Oyster::Math::Float &connectDistance, const ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Plane &plane, const Sphere &sphere, const ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Plane &plane, const Sphere &sphere, const ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Plane &planeA, const Plane &planeB, const ::Oyster::Math::Float3& worldPointOfContact )
|
bool Intersect( const Plane &planeA, const Plane &planeB, const ::Oyster::Math::Float3 &worldPointOfContact )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement Stub
|
//! @todo TODO: implement Stub
|
||||||
return false;
|
return false;
|
||||||
|
@ -668,9 +669,18 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere, Float3 &worldPointOfContact )
|
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere, Float3 &worldPointOfContact )
|
||||||
|
{ // by Robin Engman
|
||||||
|
|
||||||
|
if(Intersect(box, sphere))
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement stub
|
Float distance;
|
||||||
return Intersect( box, sphere );
|
Float3 boxMiddle = (box.maxVertex - box.minVertex)*0.5f;
|
||||||
|
Ray ray(boxMiddle, Float3(sphere.center - boxMiddle).Normalize());
|
||||||
|
Intersect( sphere, ray, distance );
|
||||||
|
worldPointOfContact = ray.origin + ray.direction * distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const BoxAxisAligned &box, const Plane &plane )
|
bool Intersect( const BoxAxisAligned &box, const Plane &plane )
|
||||||
|
@ -769,9 +779,17 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Box &box, const Sphere &sphere, Float3 &worldPointOfContact )
|
bool Intersect( const Box &box, const Sphere &sphere, Float3 &worldPointOfContact )
|
||||||
|
{ // by Robin Engman
|
||||||
|
if( Intersect(box, sphere) )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement stub
|
Float distance;
|
||||||
return Intersect( box, sphere );
|
Ray ray( sphere.center, Float3(box.center - sphere.center) );
|
||||||
|
|
||||||
|
Intersect( box, ray, distance );
|
||||||
|
worldPointOfContact = ray.origin + ray.direction*distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Intersect( const Box &box, const Plane &plane )
|
bool Intersect( const Box &box, const Plane &plane )
|
||||||
|
|
Loading…
Reference in New Issue