2013-11-20 11:09:27 +01:00
|
|
|
#ifndef PHYSICS_API_H
|
|
|
|
#define PHYSICS_API_H
|
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
#include "OysterCollision3D.h"
|
2013-11-20 11:09:27 +01:00
|
|
|
#include "OysterMath.h"
|
|
|
|
#include "Utilities.h"
|
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Physics
|
|
|
|
{
|
|
|
|
class API;
|
|
|
|
class IRigidBody;
|
|
|
|
class IParticle;
|
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
enum UpdateState
|
|
|
|
{
|
|
|
|
resting,
|
|
|
|
altered
|
|
|
|
};
|
|
|
|
|
2013-11-20 11:09:27 +01:00
|
|
|
namespace Constant
|
|
|
|
{
|
|
|
|
const float gravity_constant = (const float)6.67284e-11; // The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
|
|
|
}
|
|
|
|
|
|
|
|
class API
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef void (*EventAction_Collision)( unsigned int, unsigned int );
|
|
|
|
typedef void (*EventAction_Destruction)( unsigned int, ::Utility::DynamicMemory::UniquePointer<IRigidBody> );
|
|
|
|
|
|
|
|
static API & Instance();
|
|
|
|
|
|
|
|
virtual void SetDeltaTime( float deltaTime ) = 0;
|
|
|
|
virtual void SetGravityConstant( float g ) = 0;
|
|
|
|
virtual void SetAction( EventAction_Collision functionPointer ) = 0;
|
|
|
|
virtual void SetAction( EventAction_Destruction functionPointer ) = 0;
|
|
|
|
|
|
|
|
virtual void Update() = 0;
|
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
virtual bool IsInLimbo( unsigned int objRef ) = 0;
|
|
|
|
virtual void MoveToLimbo( unsigned int objRef ) = 0;
|
|
|
|
virtual void ReleaseFromLimbo( unsigned int objRef ) = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
virtual unsigned int AddObject( ::Utility::DynamicMemory::UniquePointer<IRigidBody> handle ) = 0;
|
|
|
|
virtual ::Utility::DynamicMemory::UniquePointer<IRigidBody> ExtractObject( unsigned int objRef ) = 0;
|
|
|
|
virtual void DestroyObject( unsigned int objRef ) = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class IRigidBody
|
|
|
|
{
|
|
|
|
public:
|
2013-11-21 15:19:32 +01:00
|
|
|
virtual ~IRigidBody() {};
|
|
|
|
|
|
|
|
virtual UpdateState Update( ::Oyster::Math::Float timeStepLength ) = 0;
|
|
|
|
|
|
|
|
virtual bool IsSubscribingCollisions() const = 0;
|
|
|
|
virtual bool IsIntersecting( const IRigidBody &object, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-21 15:19:32 +01:00
|
|
|
virtual unsigned int GetReference() const = 0;
|
|
|
|
virtual ::Oyster::Collision3D::Sphere & GetBoundingSphere( ::Oyster::Collision3D::Sphere &targetMem = ::Oyster::Collision3D::Sphere() ) const = 0;
|
|
|
|
virtual ::Oyster::Math::Float3 & GetNormalAt( const ::Oyster::Math::Float3 &worldPos, ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const = 0;
|
2013-11-20 11:09:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class IParticle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Collision
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
#endif
|