Options for rigid bodies are now set directly
This commit is contained in:
parent
8547d17d0f
commit
bd8722f107
|
@ -142,19 +142,15 @@ void API_Impl::UpdateWorld()
|
||||||
|
|
||||||
for(unsigned int i = 0; i < this->customBodies.size(); i++ )
|
for(unsigned int i = 0; i < this->customBodies.size(); i++ )
|
||||||
{
|
{
|
||||||
this->customBodies[i]->GetState(state);
|
|
||||||
|
|
||||||
btTransform trans;
|
btTransform trans;
|
||||||
dynamic_cast<SimpleRigidBody*>(this->customBodies[i])->GetMotionState()->getWorldTransform(trans);
|
dynamic_cast<SimpleRigidBody*>(this->customBodies[i])->GetMotionState()->getWorldTransform(trans);
|
||||||
state.centerPos = Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z());
|
this->customBodies[i]->SetPosition(Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z()));
|
||||||
state.quaternion = Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w());
|
this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w()));
|
||||||
|
|
||||||
if(dynamic_cast<SimpleRigidBody*>(this->customBodies[i])->GetRigidBody()->getActivationState() == ACTIVE_TAG)
|
if(dynamic_cast<SimpleRigidBody*>(this->customBodies[i])->GetRigidBody()->getActivationState() == ACTIVE_TAG)
|
||||||
{
|
{
|
||||||
dynamic_cast<SimpleRigidBody*>(this->customBodies[i])->CallSubscription_Move();
|
dynamic_cast<SimpleRigidBody*>(this->customBodies[i])->CallSubscription_Move();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->customBodies[i]->SetState(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int numManifolds = this->dynamicsWorld->getDispatcher()->getNumManifolds();
|
int numManifolds = this->dynamicsWorld->getDispatcher()->getNumManifolds();
|
||||||
|
|
|
@ -69,12 +69,31 @@ void SimpleRigidBody::SetLinearVelocity(Float3 velocity)
|
||||||
this->rigidBody->setLinearVelocity(btVector3(velocity.x, velocity.y, velocity.z));
|
this->rigidBody->setLinearVelocity(btVector3(velocity.x, velocity.y, velocity.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleRigidBody::SetPosition(::Oyster::Math::Float3 position)
|
||||||
|
{
|
||||||
|
btTransform trans;
|
||||||
|
this->motionState->getWorldTransform(trans);
|
||||||
|
trans.setOrigin(btVector3(position.x, position.y, position.z));
|
||||||
|
this->motionState->setWorldTransform(trans);
|
||||||
|
this->state.centerPos = position;
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::SetRotation(Float4 quaternion)
|
void SimpleRigidBody::SetRotation(Float4 quaternion)
|
||||||
{
|
{
|
||||||
btTransform trans;
|
btTransform trans;
|
||||||
this->motionState->getWorldTransform(trans);
|
this->motionState->getWorldTransform(trans);
|
||||||
trans.setRotation(btQuaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w));
|
trans.setRotation(btQuaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w));
|
||||||
this->motionState->setWorldTransform(trans);
|
this->motionState->setWorldTransform(trans);
|
||||||
|
this->state.quaternion = Quaternion(quaternion.xyz, quaternion.w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimpleRigidBody::SetRotation(::Oyster::Math::Quaternion quaternion)
|
||||||
|
{
|
||||||
|
btTransform trans;
|
||||||
|
this->motionState->getWorldTransform(trans);
|
||||||
|
trans.setRotation(btQuaternion(quaternion.imaginary.x, quaternion.imaginary.y, quaternion.imaginary.z, quaternion.real));
|
||||||
|
this->motionState->setWorldTransform(trans);
|
||||||
|
this->state.quaternion = quaternion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::SetRotation(Float3 eulerAngles)
|
void SimpleRigidBody::SetRotation(Float3 eulerAngles)
|
||||||
|
@ -83,6 +102,27 @@ void SimpleRigidBody::SetRotation(Float3 eulerAngles)
|
||||||
this->motionState->getWorldTransform(trans);
|
this->motionState->getWorldTransform(trans);
|
||||||
trans.setRotation(btQuaternion(eulerAngles.x, eulerAngles.y, eulerAngles.z));
|
trans.setRotation(btQuaternion(eulerAngles.x, eulerAngles.y, eulerAngles.z));
|
||||||
this->motionState->setWorldTransform(trans);
|
this->motionState->setWorldTransform(trans);
|
||||||
|
this->state.quaternion = Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w());
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 SimpleRigidBody::GetRotation() const
|
||||||
|
{
|
||||||
|
return this->state.GetRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 SimpleRigidBody::GetOrientation() const
|
||||||
|
{
|
||||||
|
return this->state.GetOrientation();
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 SimpleRigidBody::GetView() const
|
||||||
|
{
|
||||||
|
return this->state.GetView();
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 SimpleRigidBody::GetView( const ::Oyster::Math::Float3 &offset ) const
|
||||||
|
{
|
||||||
|
return this->state.GetView(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Oyster::Math::Float kineticEnergyLoss)
|
void SimpleRigidBody::CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Oyster::Math::Float kineticEnergyLoss)
|
||||||
|
@ -112,22 +152,6 @@ btRigidBody* SimpleRigidBody::GetRigidBody() const
|
||||||
return this->rigidBody;
|
return this->rigidBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleRigidBody::State SimpleRigidBody::GetState() const
|
|
||||||
{
|
|
||||||
return this->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
|
|
||||||
{
|
|
||||||
targetMem = this->state;
|
|
||||||
return targetMem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
|
||||||
{
|
|
||||||
this->state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * SimpleRigidBody::GetCustomTag() const
|
void * SimpleRigidBody::GetCustomTag() const
|
||||||
{
|
{
|
||||||
return this->customTag;
|
return this->customTag;
|
||||||
|
|
|
@ -22,16 +22,19 @@ namespace Oyster
|
||||||
void SetSubscription(EventAction_Move function);
|
void SetSubscription(EventAction_Move function);
|
||||||
|
|
||||||
void SetLinearVelocity(Math::Float3 velocity);
|
void SetLinearVelocity(Math::Float3 velocity);
|
||||||
|
void SetPosition(::Oyster::Math::Float3 position);
|
||||||
void SetRotation(Math::Float4 quaternion);
|
void SetRotation(Math::Float4 quaternion);
|
||||||
|
void SetRotation(::Oyster::Math::Quaternion quaternion);
|
||||||
void SetRotation(Math::Float3 eulerAngles);
|
void SetRotation(Math::Float3 eulerAngles);
|
||||||
|
|
||||||
|
Math::Float4x4 GetRotation() const;
|
||||||
|
Math::Float4x4 GetOrientation() const;
|
||||||
|
Math::Float4x4 GetView() const;
|
||||||
|
Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const;
|
||||||
|
|
||||||
void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss);
|
void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss);
|
||||||
void CallSubscription_Move();
|
void CallSubscription_Move();
|
||||||
|
|
||||||
State GetState() const;
|
|
||||||
State & GetState( State &targetMem ) const;
|
|
||||||
void SetState( const State &state );
|
|
||||||
|
|
||||||
btCollisionShape* GetCollisionShape() const;
|
btCollisionShape* GetCollisionShape() const;
|
||||||
btDefaultMotionState* GetMotionState() const;
|
btDefaultMotionState* GetMotionState() const;
|
||||||
btRigidBody* GetRigidBody() const;
|
btRigidBody* GetRigidBody() const;
|
||||||
|
|
|
@ -123,31 +123,21 @@ namespace Oyster
|
||||||
|
|
||||||
virtual ~ICustomBody() {};
|
virtual ~ICustomBody() {};
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Gets the current state of the rigid body
|
|
||||||
* @return the current state of the rigid body
|
|
||||||
********************************************************/
|
|
||||||
virtual State GetState() const = 0;
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Gets the current state of the rigid body
|
|
||||||
* @param targetMem: The state is copied into targetMem
|
|
||||||
* @return the current state of the rigid body
|
|
||||||
********************************************************/
|
|
||||||
virtual State & GetState( State &targetMem ) const = 0;
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Sets the current state of the rigid body
|
|
||||||
********************************************************/
|
|
||||||
virtual void SetState( const State &state ) = 0;
|
|
||||||
|
|
||||||
virtual void SetSubscription(EventAction_AfterCollisionResponse function) = 0;
|
virtual void SetSubscription(EventAction_AfterCollisionResponse function) = 0;
|
||||||
virtual void SetSubscription(EventAction_Move function) = 0;
|
virtual void SetSubscription(EventAction_Move function) = 0;
|
||||||
|
|
||||||
virtual void SetLinearVelocity(::Oyster::Math::Float3 velocity) = 0;
|
virtual void SetLinearVelocity(::Oyster::Math::Float3 velocity) = 0;
|
||||||
|
virtual void SetPosition(::Oyster::Math::Float3 position) = 0;
|
||||||
virtual void SetRotation(::Oyster::Math::Float4 quaternion) = 0;
|
virtual void SetRotation(::Oyster::Math::Float4 quaternion) = 0;
|
||||||
|
virtual void SetRotation(::Oyster::Math::Quaternion quaternion) = 0;
|
||||||
virtual void SetRotation(::Oyster::Math::Float3 eulerAngles) = 0;
|
virtual void SetRotation(::Oyster::Math::Float3 eulerAngles) = 0;
|
||||||
|
|
||||||
|
::Oyster::Math::Float4x4 GetRotation() const;
|
||||||
|
::Oyster::Math::Float4x4 GetOrientation() const;
|
||||||
|
::Oyster::Math::Float4x4 GetView() const;
|
||||||
|
::Oyster::Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* @return the void pointer set by SetCustomTag.
|
* @return the void pointer set by SetCustomTag.
|
||||||
* nullptr if none is set.
|
* nullptr if none is set.
|
||||||
|
|
|
@ -31,12 +31,6 @@ namespace Oyster
|
||||||
::Oyster::Math::Float4x4 GetView() const;
|
::Oyster::Math::Float4x4 GetView() const;
|
||||||
::Oyster::Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const;
|
::Oyster::Math::Float4x4 GetView( const ::Oyster::Math::Float3 &offset ) const;
|
||||||
|
|
||||||
::Oyster::Math::Float GetMass() const;
|
|
||||||
::Oyster::Math::Float GetStaticFriction() const;
|
|
||||||
::Oyster::Math::Float GetDynamicFriction() const;
|
|
||||||
::Oyster::Math::Float GetRestitution() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Variables for state
|
// Variables for state
|
||||||
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, dynamicFrictionCoeff;
|
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, dynamicFrictionCoeff;
|
||||||
::Oyster::Math::Float3 reach, centerPos;
|
::Oyster::Math::Float3 reach, centerPos;
|
||||||
|
|
Loading…
Reference in New Issue