From 2c699590e2dfd92cafef5f177e7718480fa200cf Mon Sep 17 00:00:00 2001 From: Steffen Date: Sun, 15 Feb 2015 16:12:11 +0100 Subject: [PATCH] Changed position constraints so they dont bounce the door up and down. --- physics.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/physics.cc b/physics.cc index bc8706e..ddf7499 100644 --- a/physics.cc +++ b/physics.cc @@ -36,7 +36,8 @@ void Physics::takeUpdateStep(float timeDiff) if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition()) //if constraint != position of the body because otherwise dir = 0 { btVector3 dir = allPositionConstraints[i].position - allPositionConstraints[i].body->getCenterOfMassPosition(); - dir = dir*allPositionConstraints[i].strength - allPositionConstraints[i].body->getLinearVelocity(); + dir = dir*allPositionConstraints[i].strength - allPositionConstraints[i].body->getLinearVelocity() + *allPositionConstraints[i].body->getLinearVelocity().length(); allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength); //apply a foce upon the object pushing it towards the constraint position } }