diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 61bcb706..ede0c289 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -51,6 +51,15 @@ namespace Float4 protoG = protoState.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 ), deuterG_Magnitude = deuterG.Dot( normal ); @@ -106,7 +115,10 @@ namespace protoG_Magnitude = -protoG_Magnitude; deuterG_Magnitude = -deuterG_Magnitude; } - + + if( normal != normal ) // debug: trap + const char *breakpoint = "This should never happen"; + // bounce Float4 bounceP = normal * Formula::CollisionResponse::Bounce( protoState.GetRestitutionCoeff(), 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 ) { state.ApplyLinearImpulse( gravityImpulse.xyz ); diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index 034cedea..b57c2a97 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -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.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 ); + timeStepLength *= 2.0f - this->collisionRebound.timeOfContact; // compensate for rebounded time this->collisionRebound.timeOfContact = 1.0f; } diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index 6b4cd4ed..ac566abd 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -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.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 ); + timeStepLength *= 2.0f - this->collisionRebound.timeOfContact; // compensate for rebounded time this->collisionRebound.timeOfContact = 1.0f; }