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"
|
2014-02-09 21:24:09 +01:00
|
|
|
#include <btBulletDynamicsCommon.h>
|
2013-11-20 11:09:27 +01:00
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Physics
|
|
|
|
{
|
|
|
|
class API_Impl : public API
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
API_Impl();
|
|
|
|
virtual ~API_Impl();
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void Init();
|
2013-11-20 11:09:27 +01:00
|
|
|
|
2013-11-25 10:54:27 +01:00
|
|
|
bool IsInLimbo( const ICustomBody* objRef );
|
|
|
|
void MoveToLimbo( const ICustomBody* objRef );
|
|
|
|
void ReleaseFromLimbo( const ICustomBody* objRef );
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
// Bullet physics
|
2014-02-10 14:18:45 +01:00
|
|
|
ICustomBody* AddCollisionSphere(float radius, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
|
|
|
ICustomBody* AddCollisionBox(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
|
|
|
ICustomBody* AddCollisionCylinder(::Oyster::Math::Float3 halfSize, ::Oyster::Math::Float4 rotation, ::Oyster::Math::Float3 position, float mass, float restitution, float staticFriction, float dynamicFriction);
|
2013-11-25 10:54:27 +01:00
|
|
|
|
2014-02-11 09:15:21 +01:00
|
|
|
void SetTimeStep(float timeStep);
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void UpdateWorld();
|
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-11-25 16:57:38 +01:00
|
|
|
private:
|
2014-02-09 21:24:09 +01:00
|
|
|
btBroadphaseInterface* broadphase;
|
|
|
|
btDefaultCollisionConfiguration* collisionConfiguration;
|
|
|
|
btCollisionDispatcher* dispatcher;
|
|
|
|
btSequentialImpulseConstraintSolver* solver;
|
|
|
|
btDiscreteDynamicsWorld* dynamicsWorld;
|
|
|
|
std::vector<ICustomBody*> customBodies;
|
2014-02-11 09:15:21 +01:00
|
|
|
|
|
|
|
float timeStep;
|
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
|