2013-11-06 22:52:00 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by Dan Andersson 2013
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Point.h"
|
2013-11-12 12:33:52 +01:00
|
|
|
#include "OysterCollision3D.h"
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-10 02:27:16 +01:00
|
|
|
using namespace ::Oyster::Collision3D;
|
|
|
|
using namespace ::Oyster::Math3D;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-27 15:20:29 +01:00
|
|
|
Point::Point( ) : ICollideable(Type_point)
|
|
|
|
{
|
|
|
|
this->center = Float3::null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Point::Point( const Float3 &pos ) : ICollideable(Type_point)
|
|
|
|
{
|
|
|
|
this->center = pos;
|
|
|
|
}
|
|
|
|
|
2013-11-10 02:27:16 +01:00
|
|
|
Point::~Point( ) {}
|
2013-11-06 22:52:00 +01:00
|
|
|
|
|
|
|
Point & Point::operator = ( const Point &point )
|
|
|
|
{
|
2013-11-10 02:27:16 +01:00
|
|
|
this->center = point.center;
|
2013-11-06 22:52:00 +01:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:50:08 +01:00
|
|
|
::Utility::DynamicMemory::UniquePointer<ICollideable> Point::Clone( ) const
|
2013-11-27 15:20:29 +01:00
|
|
|
{
|
|
|
|
return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Point(*this) );
|
|
|
|
}
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2013-11-25 14:22:38 +01:00
|
|
|
bool Point::Intersects( const ICollideable &target ) const
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-25 14:22:38 +01:00
|
|
|
switch( target.type )
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-10 02:27:16 +01:00
|
|
|
case Type_universe: return true;
|
2013-11-25 14:22:38 +01:00
|
|
|
case Type_point: return Utility::Intersect( *this, *(Point*)&target );
|
|
|
|
case Type_ray: return Utility::Intersect( *(Ray*)&target, *this, ((Ray*)&target)->collisionDistance );
|
|
|
|
case Type_sphere: Utility::Intersect( *(Sphere*)&target, *this );
|
|
|
|
case Type_plane: return Utility::Intersect( *(Plane*)&target, *this );
|
2013-11-21 11:47:34 +01:00
|
|
|
//case Type_triangle: return false; // TODO:
|
2013-11-25 14:22:38 +01:00
|
|
|
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this );
|
|
|
|
case Type_box: return Utility::Intersect( *(Box*)&target, *this );
|
2013-11-10 02:27:16 +01:00
|
|
|
case Type_frustrum: return false; // TODO:
|
2013-11-06 22:52:00 +01:00
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:22:38 +01:00
|
|
|
bool Point::Contains( const ICollideable &target ) const
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-25 14:22:38 +01:00
|
|
|
switch( target.type )
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2013-11-25 14:22:38 +01:00
|
|
|
case Type_point: return Utility::Intersect( *this, *(Point*)&target );
|
2013-11-06 22:52:00 +01:00
|
|
|
default: return false;
|
|
|
|
}
|
2013-11-10 02:27:16 +01:00
|
|
|
}
|