From 2d801c64a1d8ce0cf3f4f106d77c47fea33bbd4d Mon Sep 17 00:00:00 2001 From: michi_cc Date: Sun, 7 Nov 2010 13:35:07 +0000 Subject: (svn r21106) -Change: Tuned realistic acceleration to be a bit more realistic in order to make acceleration "slower", which highlights the differences between vehicle types more. --- src/ground_vehicle.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/ground_vehicle.cpp') diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index f3ba7d775..66e5b9933 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -30,12 +30,11 @@ void GroundVehicle::PowerChanged() uint16 max_track_speed = v->GetDisplayMaxSpeed(); for (const T *u = v; u != NULL; u = u->Next()) { - uint32 current_power = u->GetPower(); + uint32 current_power = u->GetPower() + u->GetPoweredPartPower(u); total_power += current_power; /* Only powered parts add tractive effort. */ if (current_power > 0) max_te += u->GetWeight() * u->GetTractiveEffort(); - total_power += u->GetPoweredPartPower(v); number_of_parts++; /* Get minimum max speed for this track. */ @@ -43,8 +42,6 @@ void GroundVehicle::PowerChanged() if (track_speed > 0) max_track_speed = min(max_track_speed, track_speed); } - this->acc_cache.cached_axle_resistance = 60 * number_of_parts; - byte air_drag; byte air_drag_value = v->GetAirDrag(); @@ -87,11 +84,14 @@ void GroundVehicle::CargoChanged() for (T *u = T::From(this); u != NULL; u = u->Next()) { uint32 current_weight = u->GetWeight(); weight += current_weight; - u->acc_cache.cached_slope_resistance = current_weight * u->GetSlopeSteepness(); + /* Slope steepness is in percent, result in N. */ + u->acc_cache.cached_slope_resistance = current_weight * u->GetSlopeSteepness() * 100; } /* Store consist weight in cache. */ this->acc_cache.cached_weight = max(1, weight); + /* Friction in bearings and other mechanical parts is 0.1% of the weight (result in N). */ + this->acc_cache.cached_axle_resistance = 10 * weight; /* Now update vehicle power (tractive effort is dependent on weight). */ this->PowerChanged(); @@ -106,7 +106,7 @@ int GroundVehicle::GetAcceleration() const { /* Templated class used for function calls for performance reasons. */ const T *v = T::From(this); - int32 speed = v->GetCurrentSpeed(); + int32 speed = v->GetCurrentSpeed(); // [km/h-ish] /* Weight is stored in tonnes. */ int32 mass = this->acc_cache.cached_weight; @@ -120,16 +120,15 @@ int GroundVehicle::GetAcceleration() const const int area = v->GetAirDragArea(); if (!maglev) { - resistance = (13 * mass) / 10; - resistance += this->acc_cache.cached_axle_resistance; - resistance += (v->GetRollingFriction() * mass * speed) / 1000; - resistance += (area * this->acc_cache.cached_air_drag * speed * speed) / 10000; - } else { - resistance += (area * this->acc_cache.cached_air_drag * speed * speed) / 20000; + /* Static resistance plus rolling friction. */ + resistance = this->acc_cache.cached_axle_resistance; + resistance += mass * v->GetRollingFriction(); } + /* Air drag; the air drag coefficient is in an arbitrary NewGRF-unit, + * so we need some magic conversion factor. */ + resistance += (area * this->acc_cache.cached_air_drag * speed * speed) / 500; resistance += this->GetSlopeResistance(); - resistance *= 4; //[N] /* This value allows to know if the vehicle is accelerating or braking. */ AccelStatus mode = v->GetAccelerationStatus(); @@ -138,9 +137,8 @@ int GroundVehicle::GetAcceleration() const int force; if (speed > 0) { if (!maglev) { - force = power / speed; //[N] - force *= 22; - force /= 10; + /* Conversion factor from km/h to m/s is 5/18 to get [N] in the end. */ + force = power * 18 / (speed * 5); if (mode == AS_ACCEL && force > max_te) force = max_te; } else { force = power / 25; -- cgit v1.2.3-54-g00ecf