This commit is contained in:
Dander7BD 2014-02-04 16:56:31 +01:00
parent c8e8d3510d
commit fb4025eb1a
2 changed files with 13 additions and 4 deletions

View File

@ -322,10 +322,14 @@ namespace Oyster
inline void CustomBodyState::ApplyImpulse( const ::Oyster::Math::Float3 &j, const ::Oyster::Math::Float3 &at, const ::Oyster::Math::Float3 &normal ) inline void CustomBodyState::ApplyImpulse( const ::Oyster::Math::Float3 &j, const ::Oyster::Math::Float3 &at, const ::Oyster::Math::Float3 &normal )
{ {
::Oyster::Math::Float3 offset = at - this->centerPos; ::Oyster::Math::Float3 offset = at - this->centerPos;
if( offset.Dot(offset) > 0.0f )
{
::Oyster::Math::Float3 deltaAngularImpulse = ::Oyster::Physics3D::Formula::AngularMomentum( j, offset ); ::Oyster::Math::Float3 deltaAngularImpulse = ::Oyster::Physics3D::Formula::AngularMomentum( j, offset );
this->linearImpulse += j - ::Oyster::Physics3D::Formula::TangentialLinearMomentum( deltaAngularImpulse, offset );
this->linearImpulse -= ::Oyster::Physics3D::Formula::TangentialLinearMomentum( deltaAngularImpulse, offset );
this->angularImpulse += deltaAngularImpulse; this->angularImpulse += deltaAngularImpulse;
}
this->linearImpulse += j;
this->isDisturbed = true; this->isDisturbed = true;
} }

View File

@ -148,7 +148,12 @@ Float3 RigidBody::GetVelocity_Angular() const
Float3 RigidBody::GetLinearMomentum( const Float3 &atWorldPos ) const Float3 RigidBody::GetLinearMomentum( const Float3 &atWorldPos ) const
{ // by Dan Andersson { // by Dan Andersson
return this->momentum_Linear + Formula::TangentialLinearMomentum( this->momentum_Angular, atWorldPos - this->centerPos ); Float3 offset = atWorldPos - this->centerPos;
if( offset.Dot(offset) > 0.0f )
{
return this->momentum_Linear + Formula::TangentialLinearMomentum( this->momentum_Angular, offset );
}
return this->momentum_Linear;
} }
void RigidBody::SetMomentOfInertia_KeepVelocity( const MomentOfInertia &localTensorI ) void RigidBody::SetMomentOfInertia_KeepVelocity( const MomentOfInertia &localTensorI )