angular collision response fix

Incorrect formula found and corrected
This commit is contained in:
Dander7BD 2014-01-14 09:02:46 +01:00
parent 8ecd263318
commit c1c3b5e6af
2 changed files with 4 additions and 2 deletions

View File

@ -147,7 +147,9 @@ namespace Oyster
inline ::Oyster::Math::Float4 CustomBodyState::GetLinearMomentum( const ::Oyster::Math::Float4 &at ) const
{
//return this->linearMomentum + ::Oyster::Physics3D::Formula::TangentialLinearMomentum( this->angularMomentum, at - this->centerPos ); // C3083 error?
return this->linearMomentum + ::Oyster::Math::Float4( this->angularMomentum.xyz.Cross((at - this->centerPos).xyz), 0.0f );
::Oyster::Math::Float4 offset = at - this->centerPos;
return this->linearMomentum + ( ::Oyster::Math::Float4(this->angularMomentum.xyz.Cross(offset.xyz), 0.0f) /= offset.Dot(offset) );
}
inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularMomentum() const

View File

@ -63,7 +63,7 @@ namespace Oyster { namespace Physics3D
******************************************************************/
inline ::Oyster::Math::Float4 TangentialLinearMomentum( const ::Oyster::Math::Float4 &angularMomentum, const ::Oyster::Math::Float4 &worldOffset )
{
return ::Oyster::Math::Float4( angularMomentum.xyz.Cross(worldOffset.xyz), 0.0f );
return ::Oyster::Math::Float4( angularMomentum.xyz.Cross(worldOffset.xyz), 0.0f ) /= worldOffset.Dot( worldOffset );
}
/******************************************************************