2013-11-20 11:09:27 +01:00
|
|
|
#ifndef PHYSICS_API_IMPL_H
|
|
|
|
#define PHYSICS_API_IMPL_H
|
|
|
|
|
|
|
|
#include "../PhysicsAPI.h"
|
2013-11-28 17:59:12 +01:00
|
|
|
#include "Octree.h"
|
2013-11-20 11:09:27 +01:00
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Physics
|
|
|
|
{
|
|
|
|
class API_Impl : public API
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
API_Impl();
|
|
|
|
virtual ~API_Impl();
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
void Init( unsigned int numObjects, unsigned int numGravityWells , const ::Oyster::Math::Float3 &worldSize );
|
|
|
|
|
2013-11-28 17:59:12 +01:00
|
|
|
void SetFrameTimeLength( float deltaTime );
|
2013-11-20 11:09:27 +01:00
|
|
|
void SetGravityConstant( float g );
|
2014-01-29 12:22:18 +01:00
|
|
|
void SetEpsilon( float e );
|
2013-11-28 10:26:29 +01:00
|
|
|
void SetSubscription( EventAction_Destruction functionPointer );
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-12-20 11:43:12 +01:00
|
|
|
float GetFrameTimeLength() const;
|
|
|
|
|
2013-11-20 11:09:27 +01:00
|
|
|
void Update();
|
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
bool IsInLimbo( const ICustomBody* objRef );
|
|
|
|
void MoveToLimbo( const ICustomBody* objRef );
|
|
|
|
void ReleaseFromLimbo( const ICustomBody* objRef );
|
|
|
|
|
|
|
|
void AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle );
|
|
|
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef );
|
|
|
|
void DestroyObject( const ICustomBody* objRef );
|
|
|
|
|
2014-01-17 13:30:07 +01:00
|
|
|
void AddGravity( const API::Gravity &g );
|
|
|
|
void RemoveGravity( const API::Gravity &g );
|
2014-01-15 10:44:31 +01:00
|
|
|
|
2014-01-28 10:18:26 +01:00
|
|
|
void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void* args, void(hitAction)(ICustomBody*, void*) );
|
2014-01-21 14:10:31 +01:00
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
//void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
|
|
|
|
|
|
|
//void SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI );
|
|
|
|
//void SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI );
|
|
|
|
//void SetMass_KeepVelocity( const ICustomBody* objRef, ::Oyster::Math::Float m );
|
|
|
|
//void SetMass_KeepMomentum( const ICustomBody* objRef, ::Oyster::Math::Float m );
|
|
|
|
//void SetCenter( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos );
|
|
|
|
//void SetRotation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &rotation );
|
|
|
|
//void SetOrientation( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &orientation );
|
|
|
|
//void SetSize( const ICustomBody* objRef, const ::Oyster::Math::Float3 &size );
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-28 11:58:46 +01:00
|
|
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateRigidBody( const SimpleBodyDescription &desc ) const;
|
|
|
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> CreateRigidBody( const SphericalBodyDescription &desc ) const;
|
|
|
|
|
2013-11-25 16:57:38 +01:00
|
|
|
private:
|
2014-01-29 12:22:18 +01:00
|
|
|
::Oyster::Math::Float gravityConstant, updateFrameLength, epsilon;
|
2013-11-25 16:57:38 +01:00
|
|
|
EventAction_Destruction destructionAction;
|
2014-01-17 13:30:07 +01:00
|
|
|
::std::vector<API::Gravity> gravity;
|
2013-11-28 17:59:12 +01:00
|
|
|
Octree worldScene;
|
2013-11-20 11:09:27 +01:00
|
|
|
};
|
|
|
|
|
2013-11-28 10:26:29 +01:00
|
|
|
namespace Default
|
|
|
|
{
|
|
|
|
void EventAction_Destruction( ::Utility::DynamicMemory::UniquePointer<::Oyster::Physics::ICustomBody> proto );
|
2014-01-29 11:22:04 +01:00
|
|
|
::Oyster::Physics::ICustomBody::SubscriptMessage EventAction_BeforeCollisionResponse( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter );
|
|
|
|
void EventAction_AfterCollisionResponse( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss );
|
2014-01-17 16:07:25 +01:00
|
|
|
void EventAction_Move( const ::Oyster::Physics::ICustomBody *object );
|
2013-11-28 10:26:29 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-20 11:09:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|