2013-11-06 22:52:00 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by Dan Andersson 2013
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
2013-11-10 02:28:07 +01:00
|
|
|
#ifndef OYSTER_COLLISION_3D_SPHERE_H
|
|
|
|
#define OYSTER_COLLISION_3D_SPHERE_H
|
2013-11-06 22:52:00 +01:00
|
|
|
|
|
|
|
#include "OysterMath.h"
|
|
|
|
#include "ICollideable.h"
|
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
namespace Oyster
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
namespace Collision3D
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
class Sphere : public ICollideable
|
2013-11-06 22:52:00 +01:00
|
|
|
{
|
2014-02-03 15:48:42 +01:00
|
|
|
public:
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct{ ::Oyster::Math::Float4 center; ::Oyster::Math::Float radius; };
|
|
|
|
char byte[sizeof(::Oyster::Math::Float4) + sizeof(::Oyster::Math::Float)];
|
|
|
|
};
|
|
|
|
|
|
|
|
Sphere( );
|
|
|
|
Sphere( const ::Oyster::Math::Float3 ¢er, const ::Oyster::Math::Float &radius );
|
|
|
|
Sphere( const ::Oyster::Math::Float4 ¢er, const ::Oyster::Math::Float &radius );
|
|
|
|
virtual ~Sphere( );
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
Sphere & operator = ( const Sphere &sphere );
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
|
|
|
bool Intersects( const ICollideable &target ) const;
|
|
|
|
bool Intersects( const ICollideable &target, ::Oyster::Math::Float4 &worldPointOfContact ) const;
|
|
|
|
bool Contains( const ICollideable &target ) const;
|
2013-11-06 22:52:00 +01:00
|
|
|
|
2014-02-03 15:48:42 +01:00
|
|
|
::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Math
|
|
|
|
{
|
|
|
|
/********************************************************************
|
|
|
|
* Normalized Linear Interpolation
|
|
|
|
********************************************************************/
|
|
|
|
::Oyster::Collision3D::Sphere & Nlerp( const ::Oyster::Collision3D::Sphere &start, const ::Oyster::Collision3D::Sphere &end, ::Oyster::Math::Float t, ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() );
|
|
|
|
}
|
|
|
|
}
|
2013-11-06 22:52:00 +01:00
|
|
|
|
|
|
|
#endif
|