2013-11-20 11:09:27 +01:00
|
|
|
#include "PhysicsAPI_Impl.h"
|
2013-11-21 17:22:13 +01:00
|
|
|
#include "SimpleRigidBody.h"
|
2013-11-22 11:52:45 +01:00
|
|
|
#include "OysterPhysics3D.h"
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
using namespace ::Oyster::Physics;
|
2013-11-25 16:57:38 +01:00
|
|
|
using namespace ::Oyster::Physics3D;
|
2013-11-21 17:22:13 +01:00
|
|
|
using namespace ::Oyster::Math;
|
|
|
|
using namespace ::Oyster::Collision3D;
|
|
|
|
using namespace ::Utility::DynamicMemory;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 16:35:56 +01:00
|
|
|
API_Impl API_instance;
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius)
|
2013-11-22 11:52:45 +01:00
|
|
|
{
|
2013-11-25 16:57:38 +01:00
|
|
|
return Formula::MomentOfInertia::Sphere(mass, radius);
|
2013-11-22 11:52:45 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius)
|
2013-11-22 11:52:45 +01:00
|
|
|
{
|
2013-11-25 16:57:38 +01:00
|
|
|
return Formula::MomentOfInertia::HollowSphere(mass, radius);
|
2013-11-22 11:52:45 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth )
|
2013-11-22 11:52:45 +01:00
|
|
|
{
|
2013-11-25 16:57:38 +01:00
|
|
|
return Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
|
2013-11-22 11:52:45 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius )
|
2013-11-22 11:52:45 +01:00
|
|
|
{
|
2013-11-25 16:57:38 +01:00
|
|
|
return Formula::MomentOfInertia::Cylinder(mass, height, radius);
|
2013-11-22 11:52:45 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length )
|
2013-11-22 11:52:45 +01:00
|
|
|
{
|
2013-11-25 16:57:38 +01:00
|
|
|
return Formula::MomentOfInertia::RodCenter(mass, length);
|
2013-11-22 11:52:45 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 12:21:44 +01:00
|
|
|
API & API::Instance()
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
2013-11-25 16:35:56 +01:00
|
|
|
return API_instance;
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
API_Impl::API_Impl()
|
2013-11-25 16:57:38 +01:00
|
|
|
: gravityConstant( Constant::gravity_constant ),
|
|
|
|
updateFrameLength( 1.0f / 120.0f ),
|
2013-11-28 10:26:29 +01:00
|
|
|
destructionAction( Default::EventAction_Destruction )
|
2013-11-25 16:57:38 +01:00
|
|
|
{}
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
API_Impl::~API_Impl() {}
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
void API_Impl::Init( unsigned int numObjects, unsigned int numGravityWells , const Float3 &worldSize )
|
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-20 11:09:27 +01:00
|
|
|
void API_Impl::SetDeltaTime( float deltaTime )
|
|
|
|
{
|
2013-11-25 16:35:56 +01:00
|
|
|
updateFrameLength = deltaTime;
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
2013-11-28 10:26:29 +01:00
|
|
|
|
2013-11-20 11:09:27 +01:00
|
|
|
void API_Impl::SetGravityConstant( float g )
|
|
|
|
{
|
2013-11-25 16:57:38 +01:00
|
|
|
this->gravityConstant = g;
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
2013-11-28 10:26:29 +01:00
|
|
|
|
|
|
|
void API_Impl::SetSubscription( API::EventAction_Destruction functionPointer )
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
2013-11-28 10:26:29 +01:00
|
|
|
if( functionPointer )
|
|
|
|
{
|
|
|
|
this->destructionAction = functionPointer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->destructionAction = Default::EventAction_Destruction;
|
|
|
|
}
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void API_Impl::Update()
|
|
|
|
{
|
|
|
|
/** @todo TODO: Fix this function.*/
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
bool API_Impl::IsInLimbo( const ICustomBody* objRef )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::MoveToLimbo( const ICustomBody* objRef )
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
|
|
|
/** @todo TODO: Fix this function.*/
|
|
|
|
}
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef )
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
|
|
|
/** @todo TODO: Fix this function.*/
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle )
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
|
|
|
/** @todo TODO: Fix this function.*/
|
|
|
|
}
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> API_Impl::ExtractObject( const ICustomBody* objRef )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::DestroyObject( const ICustomBody* objRef )
|
2013-11-20 11:09:27 +01:00
|
|
|
{
|
|
|
|
/** @todo TODO: Fix this function.*/
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::ApplyForceAt( const ICustomBody* objRef, const Float3 &worldPos, const Float3 &worldF )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::ApplyCollisionResponse( const ICustomBody* objRefA, const ICustomBody* objRefB, Float &deltaWhen, Float3 &worldPointOfContact )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const Float4x4 &localI )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const Float4x4 &localI )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetMass_KeepVelocity( const ICustomBody* objRef, Float m )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetMass_KeepMomentum( const ICustomBody* objRef, Float m )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetCenter( const ICustomBody* objRef, const Float3 &worldPos )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetRotation( const ICustomBody* objRef, const Float4x4 &rotation )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
void API_Impl::SetOrientation( const ICustomBody* objRef, const Float4x4 &orientation )
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
void API_Impl::SetSize( const ICustomBody* objRef, const Float3 &size )
|
|
|
|
{
|
|
|
|
//! @todo TODO: implement stub
|
|
|
|
}
|
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
UniquePointer<ICustomBody> API_Impl::CreateSimpleRigidBody() const
|
|
|
|
{
|
|
|
|
return new SimpleRigidBody();
|
2013-11-28 10:26:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Oyster { namespace Physics { namespace Default
|
|
|
|
{
|
|
|
|
|
|
|
|
void EventAction_Destruction( ::Utility::DynamicMemory::UniquePointer<::Oyster::Physics::ICustomBody> proto )
|
|
|
|
{ /* Do nothing except allowing the proto uniquePointer destroy itself. */ }
|
|
|
|
|
|
|
|
::Oyster::Physics::ICustomBody::SubscriptMessage EventAction_Collision( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter )
|
|
|
|
{ /* Do nothing except returning business as usual. */
|
|
|
|
return ::Oyster::Physics::ICustomBody::SubscriptMessage_none;
|
|
|
|
}
|
|
|
|
|
|
|
|
} } }
|