Added ability to get previous velocity for rigid bodies
This commit is contained in:
parent
3bee35785a
commit
e73c988b81
|
@ -287,7 +287,8 @@ void API_Impl::UpdateWorld()
|
|||
if(simpleBody->GetRigidBody()->getActivationState() == ACTIVE_TAG)
|
||||
{
|
||||
this->customBodies[i]->CallSubscription_Move();
|
||||
}
|
||||
}
|
||||
simpleBody->SetPreviousVelocity(simpleBody->GetState().previousVelocity);
|
||||
}
|
||||
|
||||
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
||||
|
@ -312,7 +313,7 @@ void API_Impl::UpdateWorld()
|
|||
|
||||
ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer();
|
||||
ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer();
|
||||
|
||||
|
||||
bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
|
||||
bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
|
||||
}
|
||||
|
|
|
@ -422,4 +422,9 @@ void SimpleRigidBody::MoveToLimbo()
|
|||
void SimpleRigidBody::ReleaseFromLimbo()
|
||||
{
|
||||
this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity)
|
||||
{
|
||||
this->state.previousVelocity = velocity;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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 ¢erPos, 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 ¢erPos, 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;
|
||||
}
|
||||
|
|
|
@ -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 ¢erPos = ::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;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue