diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index d1be7d61..46abac8f 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -333,23 +333,23 @@ UpdateState SimpleRigidBody::Update( Float timeStepLength ) // this->isForwarded = false; //} - this->rigid.Update_LeapFrog( timeStepLength ); - { // Rebound if needed if( this->collisionRebound.timeOfContact < 1.0f ) { 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 ); + this->collisionRebound.timeOfContact = 1.0f; } // Update rebound data this->collisionRebound.previousSpatial.center = this->rigid.centerPos; this->collisionRebound.previousSpatial.axis = this->rigid.axis; this->collisionRebound.previousSpatial.reach = this->rigid.boundingReach; - this->collisionRebound.timeOfContact = 1.0f; } + this->rigid.Update_LeapFrog( timeStepLength ); + { // Maintain rotation resolution by keeping axis within [0, 2pi] (trigonometric methods gets faster too) Float3 n; ::std::modf( this->rigid.axis * (0.5f / pi), n ); diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index 49aed408..a3eecae2 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -254,23 +254,23 @@ UpdateState SphericalRigidBody::Update( Float timeStepLength ) // this->isForwarded = false; //} - this->rigid.Update_LeapFrog( timeStepLength ); - { // Rebound if needed if( this->collisionRebound.timeOfContact < 1.0f ) { 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 ); + this->collisionRebound.timeOfContact = 1.0f; } // Update rebound data this->collisionRebound.previousSpatial.center = this->rigid.centerPos; this->collisionRebound.previousSpatial.axis = this->rigid.axis; this->collisionRebound.previousSpatial.reach = this->rigid.boundingReach; - this->collisionRebound.timeOfContact = 1.0f; } + this->rigid.Update_LeapFrog( timeStepLength ); + { // Maintain rotation resolution by keeping axis within [0, 2pi] (trigonometric methods gets faster too) Float3 n; ::std::modf( this->rigid.axis * (0.5f / pi), n );