From d3d356c9c157e7a8f5665714a88c64686cfd2caf Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 6 Mar 2010 17:48:34 +0000 Subject: [PATCH] Compute effect of gravity correctly --- src/Engine.cpp | 10 +++++----- src/Train.cpp | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Engine.cpp b/src/Engine.cpp index 10550a5..a16cdb7 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -161,8 +161,8 @@ double Engine::resistance() const const double sign = mySpeed < 0.0 ? -1.0 : 1.0; const double a = 0.0; - const double b = 0.09; - const double c = 0.02; + const double b = 0.1; + const double c = 0.04; const double absSpeed = abs(mySpeed); @@ -173,7 +173,7 @@ double Engine::resistance() const double Engine::gravity(float gradient) const { const double g = 9.78; - return -g * gradient; + return -g * gradient * myMass; } // Calculate the magnitude of the braking force @@ -184,9 +184,9 @@ double Engine::brakeForce() const // Brake always acts against direction of motion double dir; - if (abs(mySpeed) < STOP_SPEED) + /*if (abs(mySpeed) < STOP_SPEED) dir = 0.0; - else if (mySpeed < 0.0) + else*/ if (mySpeed < 0.0) dir = -1.0; else dir = 1.0; diff --git a/src/Train.cpp b/src/Train.cpp index 93b39e8..facfa40 100644 --- a/src/Train.cpp +++ b/src/Train.cpp @@ -115,9 +115,11 @@ Train::Train(IMapPtr aMap) // Bit of a hack to put the engine in the right place move(0.275); - + +#if 0 for (int i = 1; i <= 4; i++) addPart(loadWaggon("coal_truck")); +#endif smokeTrail = makeSmokeTrail(); } -- 2.39.2