Extended friction content of the ICustomBody::State struct
This commit is contained in:
parent
56dec6cf5d
commit
9cee69edd6
|
@ -44,7 +44,8 @@ UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
|
||||||
|
|
||||||
SimpleRigidBody::State SimpleRigidBody::GetState() const
|
SimpleRigidBody::State SimpleRigidBody::GetState() const
|
||||||
{
|
{
|
||||||
return State( this->rigid.GetMass(), this->rigid.restitutionCoeff, this->rigid.frictionCoeff,
|
return State( this->rigid.GetMass(), this->rigid.restitutionCoeff,
|
||||||
|
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
||||||
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
||||||
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
||||||
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
||||||
|
@ -52,10 +53,11 @@ SimpleRigidBody::State SimpleRigidBody::GetState() const
|
||||||
|
|
||||||
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
|
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
|
||||||
{
|
{
|
||||||
return targetMem = State( this->rigid.GetMass(), this->rigid.restitutionCoeff, this->rigid.frictionCoeff,
|
return targetMem = State( this->rigid.GetMass(), this->rigid.restitutionCoeff,
|
||||||
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
||||||
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
||||||
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
||||||
|
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
|
||||||
|
|
|
@ -46,7 +46,8 @@ UniquePointer<ICustomBody> SphericalRigidBody::Clone() const
|
||||||
|
|
||||||
SphericalRigidBody::State SphericalRigidBody::GetState() const
|
SphericalRigidBody::State SphericalRigidBody::GetState() const
|
||||||
{
|
{
|
||||||
return State( this->rigid.GetMass(), this->rigid.restitutionCoeff, this->rigid.frictionCoeff,
|
return State( this->rigid.GetMass(), this->rigid.restitutionCoeff,
|
||||||
|
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
||||||
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
||||||
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
||||||
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
||||||
|
@ -54,7 +55,8 @@ SphericalRigidBody::State SphericalRigidBody::GetState() const
|
||||||
|
|
||||||
SphericalRigidBody::State & SphericalRigidBody::GetState( SphericalRigidBody::State &targetMem ) const
|
SphericalRigidBody::State & SphericalRigidBody::GetState( SphericalRigidBody::State &targetMem ) const
|
||||||
{
|
{
|
||||||
return targetMem = State( this->rigid.GetMass(), this->rigid.restitutionCoeff, this->rigid.frictionCoeff,
|
return targetMem = State( this->rigid.GetMass(), this->rigid.restitutionCoeff,
|
||||||
|
this->rigid.frictionCoeff_Static, this->rigid.frictionCoeff_Kinetic,
|
||||||
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
this->rigid.GetMomentOfInertia(), this->rigid.box.boundingOffset,
|
||||||
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
this->rigid.box.center, AngularAxis(this->rigid.box.rotation),
|
||||||
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
Float4(this->rigid.linearMomentum, 0.0f), Float4(this->rigid.angularMomentum, 0.0f) );
|
||||||
|
|
|
@ -28,11 +28,12 @@ namespace Oyster { namespace Physics
|
||||||
this->ignoreGravity = false;
|
this->ignoreGravity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float frictionCoeff, 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 )
|
||||||
{
|
{
|
||||||
this->mass = mass;
|
this->mass = mass;
|
||||||
this->restitutionCoeff = restitutionCoeff;
|
this->restitutionCoeff = restitutionCoeff;
|
||||||
this->frictionCoeff = frictionCoeff;
|
this->staticFrictionCoeff = staticFrictionCoeff;
|
||||||
|
this->kineticFrictionCoeff = kineticFrictionCoeff;
|
||||||
this->inertiaTensor = inertiaTensor;
|
this->inertiaTensor = inertiaTensor;
|
||||||
this->reach = ::Oyster::Math::Float4( reach.xyz, 0.0f );
|
this->reach = ::Oyster::Math::Float4( reach.xyz, 0.0f );
|
||||||
this->centerPos = ::Oyster::Math::Float4( centerPos.xyz, 1.0f );
|
this->centerPos = ::Oyster::Math::Float4( centerPos.xyz, 1.0f );
|
||||||
|
@ -47,7 +48,8 @@ namespace Oyster { namespace Physics
|
||||||
{
|
{
|
||||||
this->mass = state.mass;
|
this->mass = state.mass;
|
||||||
this->restitutionCoeff = state.restitutionCoeff;
|
this->restitutionCoeff = state.restitutionCoeff;
|
||||||
this->frictionCoeff = state.frictionCoeff;
|
this->staticFrictionCoeff = state.staticFrictionCoeff;
|
||||||
|
this->kineticFrictionCoeff = state.kineticFrictionCoeff;
|
||||||
this->inertiaTensor = state.inertiaTensor;
|
this->inertiaTensor = state.inertiaTensor;
|
||||||
this->reach = state.reach;
|
this->reach = state.reach;
|
||||||
this->centerPos = state.centerPos;
|
this->centerPos = state.centerPos;
|
||||||
|
@ -71,9 +73,14 @@ namespace Oyster { namespace Physics
|
||||||
return this->restitutionCoeff;
|
return this->restitutionCoeff;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff() const
|
inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff_Static() const
|
||||||
{
|
{
|
||||||
return this->frictionCoeff;
|
return this->staticFrictionCoeff;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::Oyster::Math::Float CustomBodyState::GetFrictionCoeff_Kinetic() const
|
||||||
|
{
|
||||||
|
return this->kineticFrictionCoeff;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ::Oyster::Math::Float4x4 & CustomBodyState::GetMomentOfInertia() const
|
inline const ::Oyster::Math::Float4x4 & CustomBodyState::GetMomentOfInertia() const
|
||||||
|
@ -163,9 +170,10 @@ namespace Oyster { namespace Physics
|
||||||
this->restitutionCoeff = e;
|
this->restitutionCoeff = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CustomBodyState::SetFrictionCoeff( ::Oyster::Math::Float u )
|
inline void CustomBodyState::SetFrictionCoeff( ::Oyster::Math::Float staticU, ::Oyster::Math::Float kineticU )
|
||||||
{
|
{
|
||||||
this->frictionCoeff = u;
|
this->staticFrictionCoeff = staticU;
|
||||||
|
this->kineticFrictionCoeff = kineticU;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CustomBodyState::SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &tensor )
|
inline void CustomBodyState::SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &tensor )
|
||||||
|
|
|
@ -38,7 +38,8 @@ namespace Oyster { namespace Physics
|
||||||
public:
|
public:
|
||||||
CustomBodyState( ::Oyster::Math::Float mass = 1.0f,
|
CustomBodyState( ::Oyster::Math::Float mass = 1.0f,
|
||||||
::Oyster::Math::Float restitutionCoeff = 1.0f,
|
::Oyster::Math::Float restitutionCoeff = 1.0f,
|
||||||
::Oyster::Math::Float frictionCoeff = 1.0f,
|
::Oyster::Math::Float staticFrictionCoeff = 1.0f,
|
||||||
|
::Oyster::Math::Float kineticFrictionCoeff = 1.0f,
|
||||||
const ::Oyster::Math::Float4x4 &inertiaTensor = ::Oyster::Math::Float4x4::identity,
|
const ::Oyster::Math::Float4x4 &inertiaTensor = ::Oyster::Math::Float4x4::identity,
|
||||||
const ::Oyster::Math::Float4 &reach = ::Oyster::Math::Float4::null,
|
const ::Oyster::Math::Float4 &reach = ::Oyster::Math::Float4::null,
|
||||||
const ::Oyster::Math::Float4 ¢erPos = ::Oyster::Math::Float4::standard_unit_w,
|
const ::Oyster::Math::Float4 ¢erPos = ::Oyster::Math::Float4::standard_unit_w,
|
||||||
|
@ -50,7 +51,8 @@ namespace Oyster { namespace Physics
|
||||||
|
|
||||||
const ::Oyster::Math::Float GetMass() const;
|
const ::Oyster::Math::Float GetMass() const;
|
||||||
const ::Oyster::Math::Float GetRestitutionCoeff() const;
|
const ::Oyster::Math::Float GetRestitutionCoeff() const;
|
||||||
const ::Oyster::Math::Float GetFrictionCoeff() const;
|
const ::Oyster::Math::Float GetFrictionCoeff_Static() const;
|
||||||
|
const ::Oyster::Math::Float GetFrictionCoeff_Kinetic() const;
|
||||||
const ::Oyster::Math::Float4x4 & GetMomentOfInertia() const;
|
const ::Oyster::Math::Float4x4 & GetMomentOfInertia() const;
|
||||||
const ::Oyster::Math::Float4 & GetReach() const;
|
const ::Oyster::Math::Float4 & GetReach() const;
|
||||||
::Oyster::Math::Float4 GetSize() const;
|
::Oyster::Math::Float4 GetSize() const;
|
||||||
|
@ -68,7 +70,7 @@ namespace Oyster { namespace Physics
|
||||||
void SetMass_KeepMomentum( ::Oyster::Math::Float m );
|
void SetMass_KeepMomentum( ::Oyster::Math::Float m );
|
||||||
void SetMass_KeepVelocity( ::Oyster::Math::Float m );
|
void SetMass_KeepVelocity( ::Oyster::Math::Float m );
|
||||||
void SetRestitutionCoeff( ::Oyster::Math::Float e );
|
void SetRestitutionCoeff( ::Oyster::Math::Float e );
|
||||||
void SetFrictionCoeff( ::Oyster::Math::Float u );
|
void SetFrictionCoeff( ::Oyster::Math::Float staticU, ::Oyster::Math::Float kineticU );
|
||||||
void SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &tensor );
|
void SetMomentOfInertia_KeepMomentum( const ::Oyster::Math::Float4x4 &tensor );
|
||||||
void SetMomentOfInertia_KeepVelocity( const ::Oyster::Math::Float4x4 &tensor );
|
void SetMomentOfInertia_KeepVelocity( const ::Oyster::Math::Float4x4 &tensor );
|
||||||
void SetSize( const ::Oyster::Math::Float4 &size );
|
void SetSize( const ::Oyster::Math::Float4 &size );
|
||||||
|
@ -93,7 +95,7 @@ namespace Oyster { namespace Physics
|
||||||
bool IsDisturbed() const;
|
bool IsDisturbed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::Oyster::Math::Float mass, restitutionCoeff, frictionCoeff;
|
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, kineticFrictionCoeff;
|
||||||
::Oyster::Math::Float4x4 inertiaTensor;
|
::Oyster::Math::Float4x4 inertiaTensor;
|
||||||
::Oyster::Math::Float4 reach, centerPos, angularAxis;
|
::Oyster::Math::Float4 reach, centerPos, angularAxis;
|
||||||
::Oyster::Math::Float4 linearMomentum, angularMomentum;
|
::Oyster::Math::Float4 linearMomentum, angularMomentum;
|
||||||
|
|
|
@ -17,7 +17,8 @@ RigidBody::RigidBody( const Box &b, Float m, const Float4x4 &inertiaTensor )
|
||||||
this->impulseTorqueSum = Float3::null;
|
this->impulseTorqueSum = Float3::null;
|
||||||
this->impulseForceSum = Float3::null;
|
this->impulseForceSum = Float3::null;
|
||||||
this->restitutionCoeff = 1.0f;
|
this->restitutionCoeff = 1.0f;
|
||||||
this->frictionCoeff = 1.0f;
|
this->frictionCoeff_Static = 1.0f;
|
||||||
|
this->frictionCoeff_Kinetic = 1.0f;
|
||||||
|
|
||||||
if( m != 0.0f )
|
if( m != 0.0f )
|
||||||
{
|
{
|
||||||
|
@ -46,7 +47,8 @@ RigidBody & RigidBody::operator = ( const RigidBody &body )
|
||||||
this->impulseTorqueSum = body.impulseTorqueSum;
|
this->impulseTorqueSum = body.impulseTorqueSum;
|
||||||
this->impulseForceSum = body.impulseForceSum;
|
this->impulseForceSum = body.impulseForceSum;
|
||||||
this->restitutionCoeff = body.restitutionCoeff;
|
this->restitutionCoeff = body.restitutionCoeff;
|
||||||
this->frictionCoeff = body.frictionCoeff;
|
this->frictionCoeff_Static = body.frictionCoeff_Static;
|
||||||
|
this->frictionCoeff_Kinetic = body.frictionCoeff_Kinetic;
|
||||||
this->mass = body.mass;
|
this->mass = body.mass;
|
||||||
this->momentOfInertiaTensor = body.momentOfInertiaTensor;
|
this->momentOfInertiaTensor = body.momentOfInertiaTensor;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Oyster { namespace Physics3D
|
||||||
linearMomentum, /** The linear momentum G (kg*m/s). (worldValue) */
|
linearMomentum, /** The linear momentum G (kg*m/s). (worldValue) */
|
||||||
impulseTorqueSum, /** The impulse torque T (Nm) that will be consumed each update. (worldValue) */
|
impulseTorqueSum, /** The impulse torque T (Nm) that will be consumed each update. (worldValue) */
|
||||||
impulseForceSum; /** The impulse force F (N) that will be consumed each update. (worldValue) */
|
impulseForceSum; /** The impulse force F (N) that will be consumed each update. (worldValue) */
|
||||||
::Oyster::Math::Float restitutionCoeff, frictionCoeff;
|
::Oyster::Math::Float restitutionCoeff, frictionCoeff_Static, frictionCoeff_Kinetic;
|
||||||
|
|
||||||
RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(),
|
RigidBody( const ::Oyster::Collision3D::Box &box = ::Oyster::Collision3D::Box(),
|
||||||
::Oyster::Math::Float mass = 12.0f,
|
::Oyster::Math::Float mass = 12.0f,
|
||||||
|
|
Loading…
Reference in New Issue