Merge remote-tracking branch 'origin/Physics' into GameLogic

This commit is contained in:
Erik Persson 2014-02-21 11:11:28 +01:00
commit 29ad63cc48
5 changed files with 18 additions and 6 deletions

View File

@ -288,6 +288,7 @@ void API_Impl::UpdateWorld()
{
this->customBodies[i]->CallSubscription_Move();
}
simpleBody->SetPreviousVelocity(simpleBody->GetState().previousVelocity);
}
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);

View File

@ -423,3 +423,8 @@ void SimpleRigidBody::ReleaseFromLimbo()
{
this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
}
void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity)
{
this->state.previousVelocity = velocity;
}

View File

@ -64,6 +64,7 @@ namespace Oyster
void SetCollisionShape(btCollisionShape* shape);
void SetMotionState(btDefaultMotionState* motionState);
void SetRigidBody(btRigidBody* rigidBody);
void SetPreviousVelocity(Math::Float3 velocity);
void PreStep(const btCollisionWorld* collisionWorld);
@ -72,6 +73,8 @@ namespace Oyster
void MoveToLimbo();
void ReleaseFromLimbo();
private:
btCollisionShape* collisionShape;

View File

@ -10,7 +10,7 @@ namespace Oyster
{
namespace Struct
{
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float3 reach, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float dynamicFrictionCoeff, const ::Oyster::Math::Float3 &centerPos, const ::Oyster::Math::Quaternion& quaternion)
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float3 reach, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float dynamicFrictionCoeff, const ::Oyster::Math::Float3 &centerPos, const ::Oyster::Math::Quaternion& quaternion, ::Oyster::Math::Float3 previousVelocity)
{
this->mass = mass;
this->reach = reach;
@ -19,6 +19,7 @@ namespace Oyster
this->dynamicFrictionCoeff = dynamicFrictionCoeff;
this->centerPos = centerPos;
this->quaternion = quaternion;
this->previousVelocity = ::Oyster::Math::Float3::null;
}
inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state )
@ -30,6 +31,7 @@ namespace Oyster
this->dynamicFrictionCoeff = state.dynamicFrictionCoeff;
this->centerPos = state.centerPos;
this->quaternion = state.quaternion;
this->previousVelocity = state.previousVelocity;
return *this;
}

View File

@ -16,12 +16,13 @@ namespace Oyster
public:
// Default constructor
CustomBodyState( ::Oyster::Math::Float mass = 1.0f,
::Oyster::Math::Float3 reach = ::Oyster::Math::Float3(0,0,0),
::Oyster::Math::Float3 reach = ::Oyster::Math::Float3::null,
::Oyster::Math::Float restitutionCoeff = 0.5f,
::Oyster::Math::Float staticFrictionCoeff = 1.0f,
::Oyster::Math::Float dynamicFrictionCoeff = 1.0f,
const ::Oyster::Math::Float3 &centerPos = ::Oyster::Math::Float3::null,
const ::Oyster::Math::Quaternion &quaternion = ::Oyster::Math::Quaternion(::Oyster::Math::Float3(0, 0, 0), 1));
const ::Oyster::Math::Quaternion &quaternion = ::Oyster::Math::Quaternion(::Oyster::Math::Float3(0, 0, 0), 1),
::Oyster::Math::Float3 previousVelocity = ::Oyster::Math::Float3::null);
// Assignment operator
CustomBodyState & operator = ( const CustomBodyState &state );
@ -34,7 +35,7 @@ namespace Oyster
// Variables for state
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, dynamicFrictionCoeff;
::Oyster::Math::Float3 reach, centerPos;
::Oyster::Math::Float3 reach, centerPos, previousVelocity;
::Oyster::Math::Quaternion quaternion;
};
}