From ee5e5ff8cee7bedb50484fcdcbf73cf9cee0d93b Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Tue, 14 Jan 2014 09:12:37 +0100 Subject: [PATCH] linear collision response fix moved improved version of Robin's implementation --- .../Implementation/PhysicsAPI_Impl.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 0d0d31b2..c61f9ce9 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -38,6 +38,23 @@ namespace Float protoG_Magnitude = protoG.Dot( normal ), deuterG_Magnitude = deuterG.Dot( normal ); + // if they are not relatively moving towards eachother, there is no collision + Float deltaPos = normal.Dot( deuterState.GetCenterPosition() - protoState.GetCenterPosition() ); + if( deltaPos < 0.0f ) + { + if( protoG_Magnitude >= deuterG_Magnitude ) + { + break; + } + } + else if( deltaPos > 0.0f ) + { + if( protoG_Magnitude <= deuterG_Magnitude ) + { + break; + } + } + // bounce Float4 bounceD = normal * -Formula::CollisionResponse::Bounce( deuterState.GetRestitutionCoeff(), deuterState.GetMass(), deuterG_Magnitude,