Prefix for "sinking" objects

This commit is contained in:
Robin Engman 2014-01-31 13:41:06 +01:00
parent 0a04c1c9f1
commit c7bc7281d8
5 changed files with 26 additions and 16 deletions

View File

@ -198,24 +198,27 @@ void API_Impl::Update()
proto = updateList.begin();
for( ; proto != updateList.end(); ++proto )
{
Float3 lM = state.GetLinearMomentum() + state.GetLinearImpulse();
(*proto)->GetState( state );
Float3 lM = state.GetLinearMomentum();
if( lM.x < this->epsilon )
//LinearAlgebra3D::InterpolateAxisYToNormal_UsingNlerp(state.SetOrientation(, Float4(state.GetGravityNormal(), 0.0f), 1.0f);
if( abs(lM.x) < this->epsilon )
{
state.SetLinearMomentum( Float3(0, lM.y, lM.z) );
state.SetLinearImpulse( Float3(0, lM.y, lM.z) );
state.linearMomentum.x = 0;
}
if( lM.y < this->epsilon )
if( abs(lM.y) < this->epsilon )
{
state.SetLinearMomentum( Float3(lM.x, 0, lM.z) );
state.SetLinearImpulse( Float3(lM.x, 0, lM.z) );
state.linearMomentum.y = 0;
}
if( lM.z < this->epsilon )
if( abs(lM.z) < this->epsilon )
{
state.SetLinearMomentum( Float3(lM.x, lM.y, 0) );
state.SetLinearImpulse( Float3(lM.x, lM.y, 0) );
state.linearMomentum.z = 0;
}
(*proto)->SetState( state );
switch( (*proto)->Update(this->updateFrameLength) )
{
case UpdateState_altered:

View File

@ -34,7 +34,7 @@ namespace Oyster
namespace Constant
{
const float gravity_constant = (const float)6.67284e-11; //!< The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
const float epsilon = (const float)1.0e-7;
const float epsilon = (const float)1.0e-3;
}
class PHYSICS_DLL_USAGE API

View File

@ -115,11 +115,13 @@ namespace Oyster { namespace Physics
bool IsDisturbed() const;
bool IsForwarded() const;
::Oyster::Math::Float3 linearMomentum;
private:
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, kineticFrictionCoeff;
::Oyster::Physics3D::MomentOfInertia inertiaTensor;
::Oyster::Math::Float3 reach, centerPos, angularAxis;
::Oyster::Math::Float3 linearMomentum, angularMomentum;
::Oyster::Math::Float3 angularMomentum;
::Oyster::Math::Float3 linearImpulse, angularImpulse;
::Oyster::Math::Float3 deltaPos, deltaAxis; // Forwarding data sum
::Oyster::Math::Float3 gravityNormal;

View File

@ -784,7 +784,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
if( Intersect(box, sphere) )
{
Float distance;
Ray ray( box.center, sphere.center - box.center );
Ray ray( box.center, (sphere.center - box.center).Normalize() );
Intersect( sphere, ray, distance );
worldPointOfContact = ray.origin + ray.direction*distance;

View File

@ -50,7 +50,12 @@ void RigidBody::Update_LeapFrog( Float updateFrameLength )
// updating the linear
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
this->centerPos += ( updateFrameLength / this->mass ) * AverageWithDelta( this->momentum_Linear, this->impulse_Linear );
Float3 deltaPos = ( updateFrameLength / this->mass ) * AverageWithDelta( this->momentum_Linear, this->impulse_Linear );
if( deltaPos.GetLength() < 0.001f )
{
deltaPos = Float3::null;
}
this->centerPos += deltaPos;
// updating the angular
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H