From 1cc6a39fb6aee2e92e55bffc81070d050e5863d6 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Mon, 19 Jul 2010 19:22:25 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@354 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/reactphysics3d/constraint/Contact.cpp | 5 ++++- sources/reactphysics3d/constraint/Contact.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sources/reactphysics3d/constraint/Contact.cpp b/sources/reactphysics3d/constraint/Contact.cpp index 903f47e7..3286984e 100644 --- a/sources/reactphysics3d/constraint/Contact.cpp +++ b/sources/reactphysics3d/constraint/Contact.cpp @@ -87,7 +87,10 @@ void Contact::evaluate() { upperBound = INFINITY_CONST; // Compute the error value of the constraint - errorValue = -PENETRATION_FACTOR * penetrationDepth; + Vector3D velocity1 = rigidBody1->getCurrentBodyState().getLinearVelocity(); + Vector3D velocity2 = rigidBody2->getCurrentBodyState().getLinearVelocity(); + double restitutionCoeff = rigidBody1->getRestitution() * rigidBody2->getRestitution(); + errorValue = restitutionCoeff * (normal.scalarProduct(velocity1) - normal.scalarProduct(velocity2)) + PENETRATION_FACTOR * penetrationDepth; // TODO : Add penetration // Compute the auxiliary jacobian matrix (this corresponds to the friction constraint) Vector3D r1CrossU1 = r1.crossProduct(frictionVectors[0]); diff --git a/sources/reactphysics3d/constraint/Contact.h b/sources/reactphysics3d/constraint/Contact.h index 1b4a1a96..6710027a 100644 --- a/sources/reactphysics3d/constraint/Contact.h +++ b/sources/reactphysics3d/constraint/Contact.h @@ -29,8 +29,8 @@ namespace reactphysics3d { // Constants -const double FRICTION_COEFFICIENT = 0.2; // Friction coefficient -const double PENETRATION_FACTOR = 0.1; // Penetration factor (between 0 and 1) which specify the importance of the +const double FRICTION_COEFFICIENT = 0.1; // Friction coefficient +const double PENETRATION_FACTOR = 0.6; // Penetration factor (between 0 and 1) which specify the importance of the // penetration depth in order to calculate the correct impulse for the contact /* -------------------------------------------------------------------