parent
461fecd1d2
commit
ff52977dcf
|
@ -39,14 +39,13 @@ namespace
|
||||||
deuterG_Magnitude = deuterG.Dot( normal );
|
deuterG_Magnitude = deuterG.Dot( normal );
|
||||||
|
|
||||||
// bounce
|
// bounce
|
||||||
Float impulse = Formula::CollisionResponse::Bounce( deuterState.GetRestitutionCoeff(),
|
Float4 bounceD = normal * -Formula::CollisionResponse::Bounce( deuterState.GetRestitutionCoeff(),
|
||||||
deuterState.GetMass(), deuterG_Magnitude,
|
deuterState.GetMass(), deuterG_Magnitude,
|
||||||
protoState.GetMass(), protoG_Magnitude );;
|
protoState.GetMass(), protoG_Magnitude );
|
||||||
Float4 sumJ = normal*impulse;
|
|
||||||
|
|
||||||
sumJ -= Formula::CollisionResponse::Friction( impulse, normal,
|
//sumJ -= Formula::CollisionResponse::Friction( impulse, normal,
|
||||||
protoState.GetLinearMomentum(), protoState.GetFrictionCoeff_Static(), protoState.GetFrictionCoeff_Kinetic(), protoState.GetMass(),
|
// protoState.GetLinearMomentum(), protoState.GetFrictionCoeff_Static(), protoState.GetFrictionCoeff_Kinetic(), protoState.GetMass(),
|
||||||
deuterState.GetLinearMomentum(), deuterState.GetFrictionCoeff_Static(), deuterState.GetFrictionCoeff_Kinetic(), deuterState.GetMass());
|
// deuterState.GetLinearMomentum(), deuterState.GetFrictionCoeff_Static(), deuterState.GetFrictionCoeff_Kinetic(), deuterState.GetMass());
|
||||||
|
|
||||||
// calc from perspective of proto
|
// calc from perspective of proto
|
||||||
proto->GetNormalAt( worldPointOfContact, normal );
|
proto->GetNormalAt( worldPointOfContact, normal );
|
||||||
|
@ -54,15 +53,19 @@ namespace
|
||||||
deuterG_Magnitude = deuterG.Dot( normal );
|
deuterG_Magnitude = deuterG.Dot( normal );
|
||||||
|
|
||||||
// bounce
|
// bounce
|
||||||
sumJ -= normal * Formula::CollisionResponse::Bounce( protoState.GetRestitutionCoeff(),
|
Float4 bounceP = normal * Formula::CollisionResponse::Bounce( protoState.GetRestitutionCoeff(),
|
||||||
protoState.GetMass(), protoG_Magnitude,
|
protoState.GetMass(), protoG_Magnitude,
|
||||||
deuterState.GetMass(), deuterG_Magnitude );
|
deuterState.GetMass(), deuterG_Magnitude );
|
||||||
|
|
||||||
|
Float4 bounce = Average( bounceD, bounceP );
|
||||||
|
//Float4 bounce = bounceD + bounceP;
|
||||||
|
|
||||||
// FRICTION
|
// FRICTION
|
||||||
// Apply
|
// Apply
|
||||||
//sumJ += ( 1 / deuterState.GetMass() )*frictionImpulse;
|
//sumJ += ( 1 / deuterState.GetMass() )*frictionImpulse;
|
||||||
// FRICTION END
|
// FRICTION END
|
||||||
|
|
||||||
protoState.ApplyImpulse( sumJ, worldPointOfContact, normal );
|
protoState.ApplyImpulse( bounce, worldPointOfContact, normal );
|
||||||
proto->SetState( protoState );
|
proto->SetState( protoState );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -38,7 +38,8 @@ namespace Oyster { namespace Physics { namespace Formula
|
||||||
{
|
{
|
||||||
inline ::Oyster::Math::Float Bounce( ::Oyster::Math::Float e, ::Oyster::Math::Float mA, ::Oyster::Math::Float gA, ::Oyster::Math::Float mB, ::Oyster::Math::Float gB )
|
inline ::Oyster::Math::Float Bounce( ::Oyster::Math::Float e, ::Oyster::Math::Float mA, ::Oyster::Math::Float gA, ::Oyster::Math::Float mB, ::Oyster::Math::Float gB )
|
||||||
{
|
{
|
||||||
return (e + 1) * (mB*gA - mA*gB) / (mA + mB);
|
//return (e + 1) * (mB*gA - mA*gB) / (mA + mB);
|
||||||
|
return (e + 1) * (mA*gB - mB*gA) / (mA + mB);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::Oyster::Math::Float4 Friction( ::Oyster::Math::Float i, ::Oyster::Math::Float4 iN, ::Oyster::Math::Float4 momA, ::Oyster::Math::Float sFA, ::Oyster::Math::Float dFA, ::Oyster::Math::Float mA, ::Oyster::Math::Float4 momB, ::Oyster::Math::Float sFB, ::Oyster::Math::Float dFB, ::Oyster::Math::Float mB )
|
inline ::Oyster::Math::Float4 Friction( ::Oyster::Math::Float i, ::Oyster::Math::Float4 iN, ::Oyster::Math::Float4 momA, ::Oyster::Math::Float sFA, ::Oyster::Math::Float dFA, ::Oyster::Math::Float mA, ::Oyster::Math::Float4 momB, ::Oyster::Math::Float sFB, ::Oyster::Math::Float dFB, ::Oyster::Math::Float mB )
|
||||||
|
|
|
@ -108,13 +108,13 @@ void RigidBody::Update_LeapFrog( Float deltaTime )
|
||||||
// updating the linear
|
// updating the linear
|
||||||
// dG = F * dt
|
// dG = F * dt
|
||||||
// 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
|
||||||
Float3 linearImpulse = this->impulseForceSum * deltaTime; // aka deltaLinearMomentum
|
Float3 linearImpulse = this->impulseForceSum; // HACK: * deltaTime; // aka deltaLinearMomentum
|
||||||
Float3 deltaPos = ( deltaTime / this->mass ) * ::Utility::Value::AverageWithDelta( this->linearMomentum, linearImpulse );
|
Float3 deltaPos = ( deltaTime / this->mass ) * ::Utility::Value::AverageWithDelta( this->linearMomentum, linearImpulse );
|
||||||
|
|
||||||
// updating the angular
|
// updating the angular
|
||||||
// dH = T * dt
|
// dH = T * dt
|
||||||
// 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
|
||||||
Float3 angularImpulse = this->impulseTorqueSum * deltaTime; // aka deltaAngularMomentum
|
Float3 angularImpulse = this->impulseTorqueSum; // HACK: * deltaTime; // aka deltaAngularMomentum
|
||||||
Float3 rotationAxis = Formula::AngularVelocity( wMomentOfInertiaTensor.GetInverse(),
|
Float3 rotationAxis = Formula::AngularVelocity( wMomentOfInertiaTensor.GetInverse(),
|
||||||
::Utility::Value::AverageWithDelta(this->angularMomentum, angularImpulse) );
|
::Utility::Value::AverageWithDelta(this->angularMomentum, angularImpulse) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue