2013-11-21 17:22:13 +01:00
|
|
|
#include "SimpleRigidBody.h"
|
2013-11-25 16:35:56 +01:00
|
|
|
#include "PhysicsAPI_Impl.h"
|
2013-11-21 17:22:13 +01:00
|
|
|
|
|
|
|
using namespace ::Oyster::Physics;
|
2013-11-28 11:58:46 +01:00
|
|
|
using namespace ::Oyster::Physics3D;
|
2013-11-25 16:35:56 +01:00
|
|
|
using namespace ::Oyster::Math3D;
|
2013-11-21 17:22:13 +01:00
|
|
|
using namespace ::Oyster::Collision3D;
|
|
|
|
using namespace ::Utility::DynamicMemory;
|
2013-11-25 16:35:56 +01:00
|
|
|
using namespace ::Utility::Value;
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
SimpleRigidBody::SimpleRigidBody()
|
2013-11-28 11:58:46 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->collisionShape = NULL;
|
|
|
|
this->motionState = NULL;
|
|
|
|
this->rigidBody = NULL;
|
|
|
|
|
|
|
|
this->state.centerPos = Float3(0.0f, 0.0f, 0.0f);
|
|
|
|
this->state.quaternion = Quaternion(Float3(0.0f, 0.0f, 0.0f), 1.0f);
|
|
|
|
this->state.dynamicFrictionCoeff = 0.0f;
|
|
|
|
this->state.staticFrictionCoeff = 0.0f;
|
|
|
|
this->state.mass = 0.0f;
|
|
|
|
this->state.restitutionCoeff = 0.0f;
|
|
|
|
this->state.reach = Float3(0.0f, 0.0f, 0.0f);
|
2014-02-03 15:48:42 +01:00
|
|
|
|
2014-01-20 13:44:12 +01:00
|
|
|
this->customTag = nullptr;
|
2013-11-28 11:58:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SimpleRigidBody::SimpleRigidBody( const API::SimpleBodyDescription &desc )
|
2014-02-03 15:48:42 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->collisionShape = NULL;
|
|
|
|
this->motionState = NULL;
|
|
|
|
this->rigidBody = NULL;
|
2013-12-19 21:39:20 +01:00
|
|
|
|
2014-01-20 13:44:12 +01:00
|
|
|
this->customTag = nullptr;
|
2013-11-28 11:58:46 +01:00
|
|
|
}
|
2013-11-21 17:22:13 +01:00
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
SimpleRigidBody::~SimpleRigidBody()
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
delete this->motionState;
|
|
|
|
this->motionState = NULL;
|
|
|
|
delete this->collisionShape;
|
|
|
|
this->collisionShape = NULL;
|
|
|
|
delete this->rigidBody;
|
|
|
|
this->rigidBody = NULL;
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void SimpleRigidBody::SetCollisionShape(btCollisionShape* shape)
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->collisionShape = shape;
|
2013-12-06 09:46:30 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void SimpleRigidBody::SetMotionState(btDefaultMotionState* motionState)
|
2013-12-06 09:46:30 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->motionState = motionState;
|
2013-12-06 09:46:30 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody)
|
2013-12-19 10:53:55 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->rigidBody = rigidBody;
|
|
|
|
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function)
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->afterCollision = function;
|
2013-12-18 08:57:27 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void SimpleRigidBody::CallSubsciptMessage(ICustomBody* bodyA, ICustomBody* bodyB, Oyster::Math::Float kineticEnergyLoss)
|
2013-12-18 08:57:27 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->CallSubsciptMessage(bodyA, bodyB, kineticEnergyLoss);
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
btDefaultMotionState* SimpleRigidBody::GetMotionState() const
|
2014-02-03 15:48:42 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
return this->motionState;
|
2014-02-03 15:48:42 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
SimpleRigidBody::State SimpleRigidBody::GetState() const
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
return this->state;
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
|
2013-11-21 17:22:13 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
targetMem = this->state;
|
2013-12-18 14:49:47 +01:00
|
|
|
return targetMem;
|
2013-11-21 17:22:13 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
2013-11-26 13:27:34 +01:00
|
|
|
{
|
2014-02-09 21:24:09 +01:00
|
|
|
this->state = state;
|
2013-11-26 13:27:34 +01:00
|
|
|
}
|
|
|
|
|
2014-01-20 13:44:12 +01:00
|
|
|
void * SimpleRigidBody::GetCustomTag() const
|
|
|
|
{
|
|
|
|
return this->customTag;
|
|
|
|
}
|
|
|
|
|
2013-11-26 13:27:34 +01:00
|
|
|
|
2014-01-20 13:44:12 +01:00
|
|
|
void SimpleRigidBody::SetCustomTag( void *ref )
|
|
|
|
{
|
|
|
|
this->customTag = ref;
|
|
|
|
}
|
|
|
|
|
2014-02-09 21:24:09 +01:00
|
|
|
|