Prefix for "sinking" objects
This commit is contained in:
parent
0a04c1c9f1
commit
c7bc7281d8
|
@ -26,7 +26,7 @@ namespace
|
||||||
ICustomBody::State protoState; proto->GetState( protoState );
|
ICustomBody::State protoState; proto->GetState( protoState );
|
||||||
ICustomBody::State deuterState; deuter->GetState( deuterState );
|
ICustomBody::State deuterState; deuter->GetState( deuterState );
|
||||||
|
|
||||||
Float4 protoG = protoState.GetLinearMomentum( worldPointOfContact.xyz ),
|
Float4 protoG = protoState.GetLinearMomentum(worldPointOfContact.xyz ),
|
||||||
deuterG = deuterState.GetLinearMomentum( worldPointOfContact.xyz );
|
deuterG = deuterState.GetLinearMomentum( worldPointOfContact.xyz );
|
||||||
|
|
||||||
// calc from perspective of deuter
|
// calc from perspective of deuter
|
||||||
|
@ -198,24 +198,27 @@ void API_Impl::Update()
|
||||||
proto = updateList.begin();
|
proto = updateList.begin();
|
||||||
for( ; proto != updateList.end(); ++proto )
|
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.linearMomentum.x = 0;
|
||||||
state.SetLinearImpulse( Float3(0, lM.y, lM.z) );
|
|
||||||
}
|
}
|
||||||
if( lM.y < this->epsilon )
|
if( abs(lM.y) < this->epsilon )
|
||||||
{
|
{
|
||||||
state.SetLinearMomentum( Float3(lM.x, 0, lM.z) );
|
state.linearMomentum.y = 0;
|
||||||
state.SetLinearImpulse( Float3(lM.x, 0, lM.z) );
|
|
||||||
}
|
}
|
||||||
if( lM.z < this->epsilon )
|
if( abs(lM.z) < this->epsilon )
|
||||||
{
|
{
|
||||||
state.SetLinearMomentum( Float3(lM.x, lM.y, 0) );
|
state.linearMomentum.z = 0;
|
||||||
state.SetLinearImpulse( Float3(lM.x, lM.y, 0) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(*proto)->SetState( state );
|
||||||
|
|
||||||
switch( (*proto)->Update(this->updateFrameLength) )
|
switch( (*proto)->Update(this->updateFrameLength) )
|
||||||
{
|
{
|
||||||
case UpdateState_altered:
|
case UpdateState_altered:
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Oyster
|
||||||
namespace Constant
|
namespace Constant
|
||||||
{
|
{
|
||||||
const float gravity_constant = (const float)6.67284e-11; //!< The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
|
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
|
class PHYSICS_DLL_USAGE API
|
||||||
|
|
|
@ -115,11 +115,13 @@ namespace Oyster { namespace Physics
|
||||||
bool IsDisturbed() const;
|
bool IsDisturbed() const;
|
||||||
bool IsForwarded() const;
|
bool IsForwarded() const;
|
||||||
|
|
||||||
|
::Oyster::Math::Float3 linearMomentum;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, kineticFrictionCoeff;
|
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, kineticFrictionCoeff;
|
||||||
::Oyster::Physics3D::MomentOfInertia inertiaTensor;
|
::Oyster::Physics3D::MomentOfInertia inertiaTensor;
|
||||||
::Oyster::Math::Float3 reach, centerPos, angularAxis;
|
::Oyster::Math::Float3 reach, centerPos, angularAxis;
|
||||||
::Oyster::Math::Float3 linearMomentum, angularMomentum;
|
::Oyster::Math::Float3 angularMomentum;
|
||||||
::Oyster::Math::Float3 linearImpulse, angularImpulse;
|
::Oyster::Math::Float3 linearImpulse, angularImpulse;
|
||||||
::Oyster::Math::Float3 deltaPos, deltaAxis; // Forwarding data sum
|
::Oyster::Math::Float3 deltaPos, deltaAxis; // Forwarding data sum
|
||||||
::Oyster::Math::Float3 gravityNormal;
|
::Oyster::Math::Float3 gravityNormal;
|
||||||
|
|
|
@ -784,7 +784,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
||||||
if( Intersect(box, sphere) )
|
if( Intersect(box, sphere) )
|
||||||
{
|
{
|
||||||
Float distance;
|
Float distance;
|
||||||
Ray ray( box.center, sphere.center - box.center );
|
Ray ray( box.center, (sphere.center - box.center).Normalize() );
|
||||||
|
|
||||||
Intersect( sphere, ray, distance );
|
Intersect( sphere, ray, distance );
|
||||||
worldPointOfContact = ray.origin + ray.direction*distance;
|
worldPointOfContact = ray.origin + ray.direction*distance;
|
||||||
|
|
|
@ -50,7 +50,12 @@ void RigidBody::Update_LeapFrog( Float updateFrameLength )
|
||||||
|
|
||||||
// updating the linear
|
// updating the linear
|
||||||
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
|
// 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
|
// updating the angular
|
||||||
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H
|
||||||
|
|
Loading…
Reference in New Issue