Merge branch 'Physics' of https://github.com/dean11/Danbias into GameServer
This commit is contained in:
commit
60736c52fe
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
||||||
|
|
Loading…
Reference in New Issue