Merge branch 'Physics' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-04 16:39:21 +01:00
commit ac278555ea
3 changed files with 18 additions and 1 deletions

View File

@ -51,6 +51,15 @@ namespace
Float4 protoG = protoState.GetLinearMomentum( worldPointOfContact.xyz ), Float4 protoG = protoState.GetLinearMomentum( worldPointOfContact.xyz ),
deuterG = deuterState.GetLinearMomentum( worldPointOfContact.xyz ); deuterG = deuterState.GetLinearMomentum( worldPointOfContact.xyz );
if( normal != normal ) // debug: trap
const char *breakpoint = "This should never happen";
if( protoG != protoG ) // debug: trap
const char *breakpoint = "This should never happen";
if( deuterG != deuterG ) // debug: trap
const char *breakpoint = "This should never happen";
Float protoG_Magnitude = protoG.Dot( normal ), Float protoG_Magnitude = protoG.Dot( normal ),
deuterG_Magnitude = deuterG.Dot( normal ); deuterG_Magnitude = deuterG.Dot( normal );
@ -106,7 +115,10 @@ namespace
protoG_Magnitude = -protoG_Magnitude; protoG_Magnitude = -protoG_Magnitude;
deuterG_Magnitude = -deuterG_Magnitude; deuterG_Magnitude = -deuterG_Magnitude;
} }
if( normal != normal ) // debug: trap
const char *breakpoint = "This should never happen";
// bounce // bounce
Float4 bounceP = normal * Formula::CollisionResponse::Bounce( protoState.GetRestitutionCoeff(), Float4 bounceP = normal * Formula::CollisionResponse::Bounce( protoState.GetRestitutionCoeff(),
protoState.GetMass(), protoG_Magnitude, protoState.GetMass(), protoG_Magnitude,
@ -223,6 +235,9 @@ void API_Impl::Update()
} }
} }
if( gravityImpulse != gravityImpulse ) // debug: trap
const char *breakpoint = "This should never happen";
if( gravityImpulse != Float4::null ) if( gravityImpulse != Float4::null )
{ {
state.ApplyLinearImpulse( gravityImpulse.xyz ); state.ApplyLinearImpulse( gravityImpulse.xyz );

View File

@ -332,6 +332,7 @@ UpdateState SimpleRigidBody::Update( Float timeStepLength )
this->rigid.centerPos = Lerp( this->collisionRebound.previousSpatial.center, this->rigid.centerPos, this->collisionRebound.timeOfContact ); this->rigid.centerPos = Lerp( this->collisionRebound.previousSpatial.center, this->rigid.centerPos, this->collisionRebound.timeOfContact );
this->rigid.SetRotation( Lerp(this->collisionRebound.previousSpatial.axis, this->rigid.axis, this->collisionRebound.timeOfContact) ); this->rigid.SetRotation( Lerp(this->collisionRebound.previousSpatial.axis, this->rigid.axis, this->collisionRebound.timeOfContact) );
this->rigid.boundingReach = Lerp( this->collisionRebound.previousSpatial.reach, this->rigid.boundingReach, this->collisionRebound.timeOfContact ); this->rigid.boundingReach = Lerp( this->collisionRebound.previousSpatial.reach, this->rigid.boundingReach, this->collisionRebound.timeOfContact );
timeStepLength *= 2.0f - this->collisionRebound.timeOfContact; // compensate for rebounded time
this->collisionRebound.timeOfContact = 1.0f; this->collisionRebound.timeOfContact = 1.0f;
} }

View File

@ -254,6 +254,7 @@ UpdateState SphericalRigidBody::Update( Float timeStepLength )
this->rigid.centerPos = Lerp( this->collisionRebound.previousSpatial.center, this->rigid.centerPos, this->collisionRebound.timeOfContact ); this->rigid.centerPos = Lerp( this->collisionRebound.previousSpatial.center, this->rigid.centerPos, this->collisionRebound.timeOfContact );
this->rigid.SetRotation( Lerp(this->collisionRebound.previousSpatial.axis, this->rigid.axis, this->collisionRebound.timeOfContact) ); this->rigid.SetRotation( Lerp(this->collisionRebound.previousSpatial.axis, this->rigid.axis, this->collisionRebound.timeOfContact) );
this->rigid.boundingReach = Lerp( this->collisionRebound.previousSpatial.reach, this->rigid.boundingReach, this->collisionRebound.timeOfContact ); this->rigid.boundingReach = Lerp( this->collisionRebound.previousSpatial.reach, this->rigid.boundingReach, this->collisionRebound.timeOfContact );
timeStepLength *= 2.0f - this->collisionRebound.timeOfContact; // compensate for rebounded time
this->collisionRebound.timeOfContact = 1.0f; this->collisionRebound.timeOfContact = 1.0f;
} }