From b2398ba6434704e3cc31ee6142bc63953d4e74f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20F=C3=BCndgens?= Date: Fri, 13 Feb 2015 13:00:47 +0100 Subject: [PATCH] Reduced camera mass so the camera can practically not move objects anymore. Fixed the scaling of forces on the camera with the (no more inverted) mass. --- physics.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/physics.cc b/physics.cc index 95a2482..05d1e5b 100644 --- a/physics.cc +++ b/physics.cc @@ -53,7 +53,7 @@ void Physics::takeUpdateStep(float timeDiff) position.setY(playerBall->getCenterOfMassPosition().getY() + 1); btVector3 dir = cameraBody->getCenterOfMassPosition() - position; - float str = cameraBody->getInvMass()*50 * dir.length(); + float str = 50 * dir.length() / cameraBody->getInvMass(); cameraBody->applyCentralForce(-dir*str);//scale the force by camera mass counter=0; float speed = cameraBody->getLinearVelocity().length(); @@ -333,7 +333,7 @@ void Physics::addCamera() //Camera Creator automatically called when player is c direction*=5; //create a offset of lenth 5 so we have a stable camera at the beginning btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),playerBall->getCenterOfMassPosition()+direction)); - btRigidBody::btRigidBodyConstructionInfo info(1,motion,sphere,inertia); + btRigidBody::btRigidBodyConstructionInfo info(0.001,motion,sphere,inertia); cameraBody = new btRigidBody(info); @@ -391,7 +391,7 @@ void Physics::updateCameraPos(glm::vec2 mouseMovement, float strength) change *= (mouseMovement.y);//we start with left/right movement because this needs to be calculated via a crossproduct, and the up down value would alter that change = btCross(btVector3(0,1,0),change); change.setY(mouseMovement.x/5);//scaleing because otherwise oup/down much stronger then left right - change*= strength; + change *= strength / cameraBody->getInvMass(); cameraBody->applyCentralForce(change);