SimpleRigid functions mirrored in SphericalRigid
The functions added to SimpleRigidBody has been added to SphericalRigidBody too.
This commit is contained in:
parent
ec0f0e0d14
commit
66e93fbdae
|
@ -14,7 +14,7 @@ SphericalRigidBody::SphericalRigidBody()
|
|||
this->rigid.SetMass_KeepMomentum( 10.0f );
|
||||
this->gravityNormal = Float3::null;
|
||||
this->collisionAction = Default::EventAction_Collision;
|
||||
this->ignoreGravity = false;
|
||||
this->ignoreGravity = this->isForwarded = false;
|
||||
this->scene = nullptr;
|
||||
this->body = Sphere( Float3::null, 0.5f );
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ SphericalRigidBody::SphericalRigidBody( const API::SphericalBodyDescription &des
|
|||
this->rigid.boundingReach = Float4( desc.radius, desc.radius, desc.radius, 0.0f );
|
||||
this->rigid.SetMass_KeepMomentum( desc.mass );
|
||||
this->rigid.SetMomentOfInertia_KeepMomentum( Formula::MomentOfInertia::CreateSphereMatrix( desc.mass, desc.radius ) );
|
||||
this->deltaPos = Float4::null;
|
||||
this->deltaAxis = Float4::null;
|
||||
|
||||
this->gravityNormal = Float3::null;
|
||||
|
||||
|
@ -82,6 +84,13 @@ void SphericalRigidBody::SetState( const SphericalRigidBody::State &state )
|
|||
this->rigid.frictionCoeff_Static = state.GetFrictionCoeff_Static();
|
||||
this->rigid.frictionCoeff_Kinetic = state.GetFrictionCoeff_Kinetic();
|
||||
|
||||
if( state.IsForwarded() )
|
||||
{
|
||||
this->deltaPos += state.GetForward_DeltaPos();
|
||||
this->deltaAxis += state.GetForward_DeltaAxis();
|
||||
this->isForwarded = false;
|
||||
}
|
||||
|
||||
if( this->scene )
|
||||
{
|
||||
if( state.IsSpatiallyAltered() )
|
||||
|
@ -171,6 +180,14 @@ Float3 SphericalRigidBody::GetRigidLinearVelocity() const
|
|||
|
||||
UpdateState SphericalRigidBody::Update( Float timeStepLength )
|
||||
{
|
||||
if( this->isForwarded )
|
||||
{
|
||||
this->rigid.Move( this->deltaPos, this->deltaAxis );
|
||||
this->deltaPos = Float4::null;
|
||||
this->deltaAxis = Float4::null;
|
||||
this->isForwarded = false;
|
||||
}
|
||||
|
||||
this->rigid.Update_LeapFrog( timeStepLength );
|
||||
this->body.center = this->rigid.centerPos;
|
||||
|
||||
|
@ -179,6 +196,11 @@ UpdateState SphericalRigidBody::Update( Float timeStepLength )
|
|||
return UpdateState_altered;
|
||||
}
|
||||
|
||||
void SphericalRigidBody::Predict( ::Oyster::Math::Float4 &outDeltaPos, ::Oyster::Math::Float4 &outDeltaAxis, const ::Oyster::Math::Float4 &actingLinearImpulse, const ::Oyster::Math::Float4 &actingAngularImpulse, ::Oyster::Math::Float deltaTime )
|
||||
{
|
||||
this->rigid.Predict_LeapFrog( outDeltaPos, outDeltaAxis, actingLinearImpulse, actingAngularImpulse, deltaTime );
|
||||
}
|
||||
|
||||
void SphericalRigidBody::SetSubscription( ICustomBody::EventAction_Collision functionPointer )
|
||||
{
|
||||
if( functionPointer )
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace Oyster { namespace Physics
|
|||
//::Oyster::Math::Float4x4 & GetView( ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||
|
||||
UpdateState Update( ::Oyster::Math::Float timeStepLength );
|
||||
void Predict( ::Oyster::Math::Float4 &outDeltaPos, ::Oyster::Math::Float4 &outDeltaAxis, const ::Oyster::Math::Float4 &actingLinearImpulse, const ::Oyster::Math::Float4 &actingAngularImpulse, ::Oyster::Math::Float deltaTime );
|
||||
|
||||
void SetScene( void *scene );
|
||||
void SetSubscription( EventAction_Collision functionPointer );
|
||||
|
@ -54,9 +55,10 @@ namespace Oyster { namespace Physics
|
|||
|
||||
private:
|
||||
::Oyster::Physics3D::RigidBody rigid;
|
||||
::Oyster::Math::Float4 deltaPos, deltaAxis;
|
||||
::Oyster::Math::Float3 gravityNormal;
|
||||
EventAction_Collision collisionAction;
|
||||
bool ignoreGravity;
|
||||
bool ignoreGravity, isForwarded;
|
||||
Octree *scene;
|
||||
::Oyster::Collision3D::Sphere body;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue