Added gravity normal to state struct
This commit is contained in:
parent
39e4f7881b
commit
5c85580ffd
|
@ -101,7 +101,8 @@ SimpleRigidBody::State SimpleRigidBody::GetState() const
|
|||
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
||||
this->rigid.GetMomentOfInertia(), this->rigid.boundingReach,
|
||||
this->rigid.centerPos, this->rigid.axis,
|
||||
this->rigid.momentum_Linear, this->rigid.momentum_Angular );
|
||||
this->rigid.momentum_Linear, this->rigid.momentum_Angular,
|
||||
this->rigid.gravityNormal );
|
||||
}
|
||||
|
||||
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
|
||||
|
@ -110,7 +111,8 @@ SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targ
|
|||
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
||||
this->rigid.GetMomentOfInertia(), this->rigid.boundingReach,
|
||||
this->rigid.centerPos, this->rigid.axis,
|
||||
this->rigid.momentum_Linear, this->rigid.momentum_Angular );
|
||||
this->rigid.momentum_Linear, this->rigid.momentum_Angular,
|
||||
this->rigid.gravityNormal );
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
||||
|
@ -127,6 +129,7 @@ void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
|||
this->rigid.frictionCoeff_Kinetic = state.GetFrictionCoeff_Kinetic();
|
||||
this->rigid.SetMass_KeepMomentum( state.GetMass() );
|
||||
this->rigid.SetMomentOfInertia_KeepMomentum( state.GetMomentOfInertia() );
|
||||
this->rigid.gravityNormal = state.GetGravityNormal();
|
||||
|
||||
if( state.IsForwarded() )
|
||||
{
|
||||
|
@ -333,6 +336,7 @@ void SimpleRigidBody::SetGravity( bool ignore)
|
|||
void SimpleRigidBody::SetGravityNormal( const Float3 &normalizedVector )
|
||||
{
|
||||
this->gravityNormal = normalizedVector;
|
||||
this->rigid.gravityNormal = Float4( this->gravityNormal, 0 );
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetCustomTag( void *ref )
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Oyster
|
|||
this->ignoreGravity = false;
|
||||
}
|
||||
|
||||
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float kineticFrictionCoeff, const ::Oyster::Math::Float4x4 &inertiaTensor, const ::Oyster::Math::Float4 &reach, const ::Oyster::Math::Float4 ¢erPos, const ::Oyster::Math::Float4 &rotation, const ::Oyster::Math::Float4 &linearMomentum, const ::Oyster::Math::Float4 &angularMomentum )
|
||||
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float kineticFrictionCoeff, const ::Oyster::Math::Float4x4 &inertiaTensor, const ::Oyster::Math::Float4 &reach, const ::Oyster::Math::Float4 ¢erPos, const ::Oyster::Math::Float4 &rotation, const ::Oyster::Math::Float4 &linearMomentum, const ::Oyster::Math::Float4 &angularMomentum, const ::Oyster::Math::Float4 &gravityNormal )
|
||||
{
|
||||
this->mass = mass;
|
||||
this->restitutionCoeff = restitutionCoeff;
|
||||
|
@ -54,6 +54,7 @@ namespace Oyster
|
|||
this->linearImpulse = this->angularImpulse = ::Oyster::Math::Float4::null;
|
||||
this->deltaPos = this->deltaAxis = ::Oyster::Math::Float4::null;
|
||||
this->isSpatiallyAltered = this->isDisturbed = this->isForwarded = false;
|
||||
this->gravityNormal = gravityNormal;
|
||||
}
|
||||
|
||||
inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state )
|
||||
|
@ -75,6 +76,7 @@ namespace Oyster
|
|||
this->isSpatiallyAltered = state.isSpatiallyAltered;
|
||||
this->isDisturbed = state.isDisturbed;
|
||||
this->isForwarded = state.isForwarded;
|
||||
this->gravityNormal = state.gravityNormal;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -183,6 +185,11 @@ namespace Oyster
|
|||
return this->deltaAxis;
|
||||
}
|
||||
|
||||
inline const ::Oyster::Math::Float4 & CustomBodyState::GetGravityNormal() const
|
||||
{
|
||||
return this->gravityNormal;
|
||||
}
|
||||
|
||||
inline void CustomBodyState::SetMass_KeepMomentum( ::Oyster::Math::Float m )
|
||||
{
|
||||
this->mass = m;
|
||||
|
@ -285,6 +292,11 @@ namespace Oyster
|
|||
this->isDisturbed = true;
|
||||
}
|
||||
|
||||
inline void CustomBodyState::SetGravityNormal( const ::Oyster::Math::Float4 &gravityNormal )
|
||||
{
|
||||
this->gravityNormal = gravityNormal;
|
||||
}
|
||||
|
||||
inline void CustomBodyState::AddRotation( const ::Oyster::Math::Float4 &angularAxis )
|
||||
{
|
||||
this->angularAxis += angularAxis;
|
||||
|
|
|
@ -53,7 +53,8 @@ namespace Oyster { namespace Physics
|
|||
const ::Oyster::Math::Float4 ¢erPos = ::Oyster::Math::Float4::standard_unit_w,
|
||||
const ::Oyster::Math::Float4 &rotation = ::Oyster::Math::Float4::null,
|
||||
const ::Oyster::Math::Float4 &linearMomentum = ::Oyster::Math::Float4::null,
|
||||
const ::Oyster::Math::Float4 &angularMomentum = ::Oyster::Math::Float4::null );
|
||||
const ::Oyster::Math::Float4 &angularMomentum = ::Oyster::Math::Float4::null,
|
||||
const ::Oyster::Math::Float4 &gravityNormal = ::Oyster::Math::Float4::null);
|
||||
|
||||
CustomBodyState & operator = ( const CustomBodyState &state );
|
||||
|
||||
|
@ -78,6 +79,7 @@ namespace Oyster { namespace Physics
|
|||
const ::Oyster::Math::Float4 & GetAngularImpulse() const;
|
||||
const ::Oyster::Math::Float4 & GetForward_DeltaPos() const;
|
||||
const ::Oyster::Math::Float4 & GetForward_DeltaAxis() const;
|
||||
const ::Oyster::Math::Float4 & GetGravityNormal() const;
|
||||
|
||||
void SetMass_KeepMomentum( ::Oyster::Math::Float m );
|
||||
void SetMass_KeepVelocity( ::Oyster::Math::Float m );
|
||||
|
@ -95,6 +97,7 @@ namespace Oyster { namespace Physics
|
|||
void SetAngularMomentum( const ::Oyster::Math::Float4 &h );
|
||||
void SetLinearImpulse( const ::Oyster::Math::Float4 &j );
|
||||
void SetAngularImpulse( const ::Oyster::Math::Float4 &j );
|
||||
void SetGravityNormal( const ::Oyster::Math::Float4 &gravityNormal );
|
||||
|
||||
void AddRotation( const ::Oyster::Math::Float4 &angularAxis );
|
||||
void AddTranslation( const ::Oyster::Math::Float4 &deltaPos );
|
||||
|
@ -115,6 +118,7 @@ namespace Oyster { namespace Physics
|
|||
::Oyster::Math::Float4 linearMomentum, angularMomentum;
|
||||
::Oyster::Math::Float4 linearImpulse, angularImpulse;
|
||||
::Oyster::Math::Float4 deltaPos, deltaAxis; // Forwarding data sum
|
||||
::Oyster::Math::Float4 gravityNormal;
|
||||
|
||||
bool isSpatiallyAltered, isDisturbed, isForwarded;
|
||||
};
|
||||
|
|
|
@ -20,7 +20,8 @@ namespace Oyster { namespace Physics3D
|
|||
momentum_Linear, //!< The linear momentum G (kg*m/s).
|
||||
momentum_Angular, //!< The angular momentum H (Nm*s) around an parallell axis.
|
||||
impulse_Linear, //!< The linear impulse sum Jl (kg*m/s) that will be consumed each update.
|
||||
impulse_Angular; //!< The angular impulse sum Ja (kg*m^2/s) that will be consumed each update.
|
||||
impulse_Angular, //!< The angular impulse sum Ja (kg*m^2/s) that will be consumed each update.
|
||||
gravityNormal;
|
||||
::Oyster::Math::Float restitutionCoeff, //!<
|
||||
frictionCoeff_Static, //!<
|
||||
frictionCoeff_Kinetic; //!<
|
||||
|
|
Loading…
Reference in New Issue