18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 03:37:09 +01:00

refactor(physics): six more of what the rest only reads are private, under names of their own

The mass of the empty vehicle, the braking force, the outcome of a derailment,
the departure signal, the traction mode of a dual-mode vehicle and the moment
of the motors are private to physics::Vehicle like the 53 before them, read
through Mass(), Fb(), Derailed(), DepartureSignal(), TractionMode() and Mm().
Inside the class they are emptyMass, brakingForce, derailOutcome,
departureSignalOn, tractionModeSetting and motorMoment, as the plain camelCase
names were taken by locals there.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 13:23:53 +01:00
parent 5879c228dc
commit ef8a1fdbfd
41 changed files with 167 additions and 160 deletions
+7 -7
View File
@@ -851,8 +851,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) {
return std::abs(mvControlling->Fb) <= Parameter; },
static_cast<float>(std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) )) ); // keep hint until 5% decrease
return std::abs(mvControlling->Fb()) <= Parameter; },
static_cast<float>(std::min( 0.0, 0.95 * std::abs( mvControlling->Fb() ) )) ); // keep hint until 5% decrease
break;
}
case driver_hint::brakingforceincrease: {
@@ -867,12 +867,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const Parameter) {
return std::abs(mvControlling->Fb) > Parameter || is_equal(occupied->brakes.HandlePositionSmooth(), occupied->brakes.driverValve->GetPos(bh_EB), 0.2); },
return std::abs(mvControlling->Fb()) > Parameter || is_equal(occupied->brakes.HandlePositionSmooth(), occupied->brakes.driverValve->GetPos(bh_EB), 0.2); },
static_cast<float>(std::max(
0.0,
std::max(
std::abs( mvControlling->Fb ) * 1.05,
std::abs( mvControlling->Fb ) + 5.0 ) )) );
std::abs( mvControlling->Fb() ) * 1.05,
std::abs( mvControlling->Fb() ) + 5.0 ) )) );
break;
}
case driver_hint::brakingforcesetzero: { // releases both train and independent brake
@@ -1052,7 +1052,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->Doors.has_warning == false || occupied->Doors.has_autowarning == true || occupied->DepartureSignal == true || occupied->Vel > 5.0; } );
return occupied->Doors.has_warning == false || occupied->Doors.has_autowarning == true || occupied->DepartureSignal() == true || occupied->Vel > 5.0; } );
break;
}
case driver_hint::departuresignaloff: {
@@ -1063,7 +1063,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->Doors.has_warning == false || occupied->Doors.has_autowarning == true || occupied->DepartureSignal == false; } );
return occupied->Doors.has_warning == false || occupied->Doors.has_autowarning == true || occupied->DepartureSignal() == false; } );
break;
}
// consist doors
+1 -1
View File
@@ -963,7 +963,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
STR_C("Forces:\n tractive: %.1f, brake: %.1f, drag: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: [%.2f, %.2f, %.2f]"),
// forces
physics.Ft() * 0.001f * ( physics.CabOccupied() ? physics.CabOccupied() : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabOccupied() : 1 ) + 0.001f,
physics.Fb * 0.001f,
physics.Fb() * 0.001f,
physics.FrictionForce() * 0.001f,
physics.SlippingWheels() ? " (!)" : "",
// acceleration
+1 -1
View File
@@ -306,7 +306,7 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle)
+ ( false == Vehicle->physics->Doors.instances[VehicleSide::right].is_closed ) * 32
#endif
+ Vehicle->physics->FuseFlag * 64
+ Vehicle->physics->DepartureSignal * 128;
+ Vehicle->physics->DepartureSignal() * 128;
// WriteLog("Zapisalem stare");
// WriteLog("Mam patykow "+IntToStr(t->DynamicObject->iAnimType[ANIM_PANTS]));
for (int p = 0; p < 4; p++)
+18 -18
View File
@@ -46,7 +46,7 @@ namespace
bool legacy_derailed_slides(physics::Vehicle const &Vehicle)
{
return Global.collisions == global_settings::collision_model::physical && TestFlag(Vehicle.CategoryFlag, 1) && Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) &&
Vehicle.Derailed == derailment::outcome::none;
Vehicle.Derailed() == derailment::outcome::none;
}
} // namespace
@@ -237,10 +237,10 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
// a vehicle derailed by the physical criteria slides on with the friction of ComputeTotalForce(), and so does one
// derailed the legacy way with physics.collisions new
if (DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this))
if (DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none && false == legacy_derailed_slides(*this))
accS = -Sign(travelSpeed) * g * 1; // random(0.0, 0.1)
// stuck in the ballast: the friction holds a derailed vehicle once it stopped, until the forces on it are larger
auto const stuck{(Derailed != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
auto const stuck{(derailOutcome != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
if (stuck)
accS = 0.0;
@@ -270,7 +270,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
// szarpanie
/*
#ifdef EU07_USE_FUZZYLOGIC
if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / vmax, 500000.0, p_accn ) ) {
if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * emptyMass * Vel / vmax, 500000.0, p_accn ) ) {
// Ra: czemu tu masa bez ładunku?
AccV /= ( 2.0 * 0.95 + 2.0 * Random() * 0.1 ); // 95-105% of base modifier (2.0)
}
@@ -349,9 +349,9 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh
accS = std::lerp(AccSprev, FTotal / totalMass, 0.5);
// std::clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim)
if (DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this))
if (DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none && false == legacy_derailed_slides(*this))
accS = -Sign(travelSpeed) * g * 1; // * random(0.0, 0.1)
auto const stuck{(Derailed != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
auto const stuck{(derailOutcome != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
if (stuck)
accS = 0.0;
@@ -376,7 +376,7 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh
// a vehicle derailed by the physical criteria slides on with the friction of ComputeTotalForce(), and so does one
// derailed the legacy way with physics.collisions new
if (true == DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this) && Vel < 1.0)
if (true == DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none && false == legacy_derailed_slides(*this) && Vel < 1.0)
{
travelSpeed = 0.0;
accS = 0.0;
@@ -745,7 +745,7 @@ void physics::Vehicle::ComputeConstans(void)
void physics::Vehicle::ComputeMass()
{
// Ra: na razie tak, ale nie wszędzie masy wirujące się wliczają
totalMass = Mass + mred;
totalMass = emptyMass + mred;
if (loadAmount == 0)
{
@@ -812,11 +812,11 @@ void physics::Vehicle::ComputeTotalForce(double dt)
FStand = FrictionForce(); // siła oporów ruchu
if (true == DamageFlag.HasAll(VehicleDamage::derailed))
{
if (Derailed != derailment::outcome::none)
if (derailOutcome != derailment::outcome::none)
{
// off the rails by the physical criteria: the vehicle slides on the sleepers and the ballast, or on its side;
// off the track on the ground, as far as it tipped over (physics.derailment new)
auto const friction{OffTrack.active() ? OffTrack.friction() : derailment::sliding_friction(Derailed)};
auto const friction{OffTrack.active() ? OffTrack.friction() : derailment::sliding_friction(derailOutcome)};
FStand = friction * (totalMass - mred) * g;
}
else if (legacy_derailed_slides(*this))
@@ -853,9 +853,9 @@ void physics::Vehicle::ComputeTotalForce(double dt)
FTrain *= FT_factor;
}
Fb = BrakeForce(RunningTrack);
brakingForce = BrakeForce(RunningTrack);
// poslizg
auto Fwheels{FTrain - Fb * Sign(travelSpeed)};
auto Fwheels{FTrain - brakingForce * Sign(travelSpeed)};
if (Vel > 0.1 // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
&& std::abs(Fwheels) > TotalMassxg * Adhesive(RunningTrack.friction))
{
@@ -885,16 +885,16 @@ void physics::Vehicle::ComputeTotalForce(double dt)
Fwheels = Sign(temp_nrot * M_PI * wheelDiameter - travelSpeed) * TotalMassxg * Adhesive(RunningTrack.friction);
if (Fwheels * Sign(travelSpeed) > 0)
{
FTrain = Fwheels + Fb * Sign(travelSpeed);
FTrain = Fwheels + brakingForce * Sign(travelSpeed);
}
else if (FTrain * Sign(travelSpeed) > 0)
{
Fb = FTrain * Sign(travelSpeed) - Fwheels * Sign(travelSpeed);
brakingForce = FTrain * Sign(travelSpeed) - Fwheels * Sign(travelSpeed);
}
else
{
double factor = FTrain - Fb * Sign(travelSpeed) != 0 ? Fwheels / (FTrain - Fb * Sign(travelSpeed)) : 1.0;
Fb *= factor;
double factor = FTrain - brakingForce * Sign(travelSpeed) != 0 ? Fwheels / (FTrain - brakingForce * Sign(travelSpeed)) : 1.0;
brakingForce *= factor;
FTrain *= factor;
}
if (std::abs(nrotValue) < 0.1)
@@ -930,7 +930,7 @@ void physics::Vehicle::ComputeTotalForce(double dt)
}
}
FStand += Fb;
FStand += brakingForce;
// doliczenie składowej stycznej grawitacji
FTrain /= FT_factor;
FTrain += TotalMassxg * RunningShape.dHtrack;
@@ -944,7 +944,7 @@ double physics::Vehicle::BrakeForceR(double ratio, double velocity) const
ratio = brakes.distributor->GetBrakeRatio(ratio);
if (brakes.config.maxPressureMass > 2)
{
press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (totalMass - Mass) / (brakes.config.maxPressureMass - Mass));
press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (totalMass - emptyMass) / (brakes.config.maxPressureMass - emptyMass));
}
else
{
+1 -1
View File
@@ -166,7 +166,7 @@ bool physics::Vehicle::CabDeactivisation(bool const Enforce)
CabActive = 0;
DirAbsolute = DirActive * CabActive;
cabMaster = false;
DepartureSignal = false; // nie buczeć z nieaktywnej kabiny
departureSignalOn = false; // nie buczeć z nieaktywnej kabiny
SecuritySystem.set_enabled(false); // deactivate alerter TODO: make it part of control based cab selection
SendCtrlToNext(VehicleCommand::cabActivation, 0, cabOccupied); // CabActive==0!
+11 -11
View File
@@ -171,7 +171,7 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
// the crush, the vehicles coupled to the wall push it on (crush_hit())
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
auto const wall = [crushing, coupled](physics::Vehicle const &Vehicle) {
return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.Derailed == derailment::outcome::none && false == coupled));
return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.derailOutcome == derailment::outcome::none && false == coupled));
};
if (false == wall(*this))
{
@@ -259,7 +259,7 @@ void physics::Vehicle::derail_in_collision(DerailReason const Reason, std::strin
return;
}
// upright, it slides on the sleepers and keeps passing the forces on
Derailed = derailment::outcome::off_rails;
derailOutcome = derailment::outcome::off_rails;
derailCause = derail_motion::cause::collision;
derailAcceleration = 0.0;
derailSide = 0;
@@ -372,8 +372,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
// train. the vehicles coupled to it push it on, as the train behind a derailed vehicle does: a wall to them, it
// stopped the whole train at once, and the vehicles behind it crushed by the energy of the train
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
auto const wall{false == coupled && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none};
auto const otherwall{false == coupled && othervehicle->DamageFlag.HasAll(VehicleDamage::derailed) && othervehicle->Derailed == derailment::outcome::none};
auto const wall{false == coupled && DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none};
auto const otherwall{false == coupled && othervehicle->DamageFlag.HasAll(VehicleDamage::derailed) && othervehicle->derailOutcome == derailment::outcome::none};
if (wall && otherwall)
{
return false;
@@ -670,9 +670,9 @@ double physics::Vehicle::centre_of_gravity() const
{
auto const kind{EngineType == TEngineType::None ? derailment::vehicle_class::unpowered : derailment::vehicle_class::powered};
auto const empty{CentreOfGravity > 0.0 ? CentreOfGravity : derailment::default_centre_of_gravity(Dim.H, kind)};
auto const loadmass{totalMass - Mass - mred};
auto const loadmass{totalMass - emptyMass - mred};
auto const loadshare{maxLoad > 0.f ? loadAmount / maxLoad : 1.0};
return derailment::loaded_centre_of_gravity(empty, Mass, loadmass, loadshare, Floor, Dim.H);
return derailment::loaded_centre_of_gravity(empty, emptyMass, loadmass, loadshare, Floor, Dim.H);
}
void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double const Distance)
@@ -734,7 +734,7 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
{
return;
}
Derailed = Verdict.result;
derailOutcome = Verdict.result;
derailCause = Verdict.result == derailment::outcome::overturned ? derail_motion::cause::overturned : derail_motion::cause::off_rails;
// out of the curve; a buckle bending the line against the curve more than the curve does throws it into the curve
derailAcceleration = std::abs(Track.radius) > 1e-3 && derailment::line_curvature(Track) < 0.0 ? -Verdict.acceleration : Verdict.acceleration;
@@ -754,7 +754,7 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
void physics::Vehicle::rerail()
{
DamageFlag.Clear(VehicleDamage::derailed);
Derailed = derailment::outcome::none;
derailOutcome = derailment::outcome::none;
// and back on the track; what derailed it before has no say in how it leaves the track the next time
OffTrack.reset();
derailCause = derail_motion::cause::off_rails;
@@ -821,7 +821,7 @@ void physics::Vehicle::Derail(DerailReason const Reason)
// ground as the vehicles the criteria derail do, and its brake hoses tear
if (Reason == END_OF_TRACK && Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1))
{
Derailed = derailment::outcome::off_rails;
derailOutcome = derailment::outcome::off_rails;
derailCause = derail_motion::cause::end_of_track;
derailAcceleration = 0.0;
derailSide = 0;
@@ -846,7 +846,7 @@ void physics::Vehicle::Derail(DerailReason const Reason)
bool physics::Vehicle::leaves_track() const
{
return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed != derailment::outcome::none &&
return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome != derailment::outcome::none &&
false == OffTrack.active();
}
@@ -857,7 +857,7 @@ void physics::Vehicle::pull_off(int const Side, double const Acceleration, std::
return;
}
// upright, its flange climbs the rail the coupling pulls it over
Derailed = derailment::outcome::off_rails;
derailOutcome = derailment::outcome::off_rails;
derailCause = derail_motion::cause::pulled_off;
derailAcceleration = Acceleration;
derailSide = Side;
+1 -1
View File
@@ -660,7 +660,7 @@ bool physics::Vehicle::RunDoorsCommand(VehicleCommand const Command, double CVal
}
else if (Command == VehicleCommand::departureSignal)
{
DepartureSignal = CValue1 == 1 ? true : false;
departureSignalOn = CValue1 == 1 ? true : false;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else
+5 -5
View File
@@ -413,9 +413,9 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp)
ft = ft * DirAbsolute; // DirActive * CabActive; //zwrot sily i jej wartosc
Fw = ft / nPoweredAxles; // sila na obwodzie kola
Mw = Fw * wheelDiameter / 2.0; // moment na osi kola
Mm = Mw / Transmision.Ratio; // moment silnika trakcyjnego
motorMoment = Mw / Transmision.Ratio; // moment silnika trakcyjnego
Im = dieselelectric_motor_current(Mm);
Im = dieselelectric_motor_current(motorMoment);
if (ShuntMode)
{
@@ -636,8 +636,8 @@ void physics::Vehicle::apply_dieselelectric_dynamic_brake(double const dt)
ft = travelSpeed > 0.0 ? -force : travelSpeed < 0.0 ? force : 0.0;
Fw = ft / nPoweredAxles;
Mw = Fw * wheelDiameter / 2.0;
Mm = Mw / Transmision.Ratio;
Im = dieselelectric_motor_current(Mm);
motorMoment = Mw / Transmision.Ratio;
Im = dieselelectric_motor_current(motorMoment);
EngineVoltage = 0.0;
EnginePower = 0.0;
}
@@ -1096,7 +1096,7 @@ double physics::Vehicle::dizel_Momentum(double Fill, double n, double dt)
{
Moment = (diesel.maxMoment - (diesel.maxMoment - diesel.maxRevolutionsMoment) * square((enrot - diesel.maxMomentRevolutions) / (diesel.maxMomentRevolutions - diesel.maxRevolutions))) * Fill - diesel.standingMoment;
}
Mm = Moment;
motorMoment = Moment;
diesel.fuelConsumptionActual = diesel.fuelConsumption * enrot * Fill;
diesel.fuelConsumedTotal += diesel.fuelConsumptionActual * dt / 3600.0;
if (retarder.present && retarder.placement == 2)
+2 -2
View File
@@ -338,13 +338,13 @@ bool physics::Vehicle::LockDoors(bool const State, range_t const Notify)
bool physics::Vehicle::signal_departure(bool const State, range_t const Notify)
{
if (DepartureSignal == State)
if (departureSignalOn == State)
{
// TBD: should the command be passed to other vehicles regardless of whether it affected the primary target?
return false;
}
DepartureSignal = State;
departureSignalOn = State;
if (Notify != range_t::local)
{
// wysłanie wyłączenia do pozostałych?
+3 -3
View File
@@ -321,7 +321,7 @@ public:
switch (ammeter)
{ // do asynchronicznych
case 1:
return vehicle.WindingRes() * vehicle.Mm / vehicle.Vadd;
return vehicle.WindingRes() * vehicle.Mm() / vehicle.Vadd;
case 2:
return vehicle.inductionMotor.forceShare * vehicle.WindingRes();
default:
@@ -352,8 +352,8 @@ class DieselMechanicalDrive final : public TractionDrive
public:
double UpdateEnginePower(physics::Vehicle &vehicle) const override
{
vehicle.diesel.power = vehicle.Mm * vehicle.enrot * (2.0 * M_PI / 1000.0);
vehicle.EnginePower = (vehicle.diesel.standingMoment + vehicle.Mm) * vehicle.enrot * (2.0 * M_PI / 1000.0);
vehicle.diesel.power = vehicle.Mm() * vehicle.enrot * (2.0 * M_PI / 1000.0);
vehicle.EnginePower = (vehicle.diesel.standingMoment + vehicle.Mm()) * vehicle.enrot * (2.0 * M_PI / 1000.0);
if (vehicle.MainCtrlPowerPos() > 1)
{
// dodatkowe opory z powodu sprezarki}
+7 -7
View File
@@ -57,7 +57,7 @@ int s2NNW(std::string s)
void physics::Vehicle::LoadFIZ_Param(std::string const &line)
{
extract_value(Mass, "M", line, "0");
extract_value(emptyMass, "M", line, "0");
extract_value(mred, "Mred", line, "0");
extract_value(vmax, "Vmax", line, "0");
extract_value(Power, "PWR", line, "0");
@@ -606,21 +606,21 @@ void physics::Vehicle::LoadFIZ_BuffCoupl(std::string const &line, int const Inde
else if (thiscoupler->CouplerType == TCouplerType::Bare)
{
thiscoupler->SpringKC = 50.0 * Mass + Ftmax / 0.05;
thiscoupler->SpringKC = 50.0 * emptyMass + Ftmax / 0.05;
thiscoupler->DmaxC = 0.05;
thiscoupler->FmaxC = 100.0 * Mass + 2 * Ftmax;
thiscoupler->SpringKB = 60.0 * Mass + Ftmax / 0.05;
thiscoupler->FmaxC = 100.0 * emptyMass + 2 * Ftmax;
thiscoupler->SpringKB = 60.0 * emptyMass + Ftmax / 0.05;
thiscoupler->DmaxB = 0.05;
thiscoupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax;
thiscoupler->FmaxB = 50.0 * emptyMass + 2.0 * Ftmax;
thiscoupler->beta = 0.3;
}
else if (thiscoupler->CouplerType == TCouplerType::Articulated)
{
/*
coupler->SpringKC = 60.0 * Mass + 1000;
coupler->SpringKC = 60.0 * emptyMass + 1000;
coupler->DmaxC = 0.05;
coupler->FmaxC = 20000000.0 + 2.0 * Ftmax;
coupler->SpringKB = 70.0 * Mass + 1000;
coupler->SpringKB = 70.0 * emptyMass + 1000;
coupler->DmaxB = 0.05;
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
coupler->beta = 0.55;
+6 -6
View File
@@ -230,7 +230,7 @@ void physics::Vehicle::CreateBrakeValve()
if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
else
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetLP(emptyMass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::KE:
@@ -241,7 +241,7 @@ void physics::Vehicle::CreateBrakeValve()
if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
else
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetLP(emptyMass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::NESt3:
@@ -255,7 +255,7 @@ void physics::Vehicle::CreateBrakeValve()
if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
else
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetLP(emptyMass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::LSt:
@@ -277,7 +277,7 @@ void physics::Vehicle::CreateBrakeValve()
}
else
{
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetLP(emptyMass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
}
break;
}
@@ -285,14 +285,14 @@ void physics::Vehicle::CreateBrakeValve()
{
WriteLog("XBT EP2");
brakes.distributor = std::make_shared<TEStEP2>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetLP(emptyMass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::EP1:
{
WriteLog("XBT EP1");
brakes.distributor = std::make_shared<TEStEP1>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetLP(emptyMass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetRM(brakes.config.rapidRatio);
break;
}
+10 -10
View File
@@ -445,13 +445,13 @@ bool physics::Vehicle::MotorBlowersSwitchOff(bool State, VehicleEnd const Side,
// the traction selector of a dual-mode vehicle: moves only with the line breaker open, and only where a genset is
bool physics::Vehicle::TractionModeSwitch(traction_mode const Mode, range_t const Notify)
{
auto const initialstate{TractionMode};
auto const initialstate{tractionModeSetting};
// refused with the line breaker closed, and then not passed on either, so the train stays on one source
auto const accepted{false == lineBreaker.IsClosed()};
if (Genset.fitted() && accepted)
{
TractionMode = Mode;
tractionModeSetting = Mode;
}
if (Notify != range_t::local && accepted)
@@ -459,7 +459,7 @@ bool physics::Vehicle::TractionModeSwitch(traction_mode const Mode, range_t cons
SendCtrlToNext(VehicleCommand::tractionMode, Mode == traction_mode::genset ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control);
}
return TractionMode != initialstate;
return tractionModeSetting != initialstate;
}
// *************************************************************************************************
@@ -706,7 +706,7 @@ void physics::Vehicle::SeriesMotorTractionForce(double dt)
// yB: szereg dwoch sekcji w ET42
if (trainType == train_type::et42 && Imax == imaxHi)
EngineVoltage = EngineVoltage / 2.0;
Mm = Momentum(Current(enrot, EngineVoltage)); // oblicza tez prad p/slinik
motorMoment = Momentum(Current(enrot, EngineVoltage)); // oblicza tez prad p/slinik
if (trainType == train_type::et42)
{
@@ -721,7 +721,7 @@ void physics::Vehicle::SeriesMotorTractionForce(double dt)
}
if (trainType == train_type::et22 && delayCtrlFlag) // szarpanie przy zmianie układu w byku
Mm = Mm * RList[MainCtrlActualPos].Bn / (RList[MainCtrlActualPos].Bn + 1); // zrobione w momencie, żeby nie dawac elektryki w przeliczaniu sił
motorMoment = motorMoment * RList[MainCtrlActualPos].Bn / (RList[MainCtrlActualPos].Bn + 1); // zrobione w momencie, żeby nie dawac elektryki w przeliczaniu sił
if (abs(Im) > Imax)
Vhyp += dt; //*(abs(Im) / Imax - 0.9) * 10; // zwieksz czas oddzialywania na PN
@@ -736,7 +736,7 @@ void physics::Vehicle::SeriesMotorTractionForce(double dt)
Itot = Im;
else
Itot = Im * RList[MainCtrlActualPos].Bn; // prad silnika * ilosc galezi
Mw = Mm * Transmision.Ratio * Transmision.Efficiency;
Mw = motorMoment * Transmision.Ratio * Transmision.Efficiency;
Fw = Mw * 2.0 / wheelDiameter;
ft = Fw * nPoweredAxles; // sila trakcyjna
}
@@ -789,7 +789,7 @@ void physics::Vehicle::SeriesMotorDynamicBrake(double dt)
Vadd = std::min(std::max(Vadd, TUHEX_MinIw), TUHEX_MaxIw);
}
if (Vadd > 0)
Mm = MomentumF(Im, Vadd, 0);
motorMoment = MomentumF(Im, Vadd, 0);
}
// the shunt field relays of a diesel-electric, each kind its own conditions on the current, the speed or the
@@ -1306,8 +1306,8 @@ void physics::Vehicle::InductionMotorDrive(double dt)
// power inverters
UpdateInverterFrequency();
Mm = inductionMotor.state.torque * DirAbsolute;
Mw = Mm * Transmision.Ratio * Transmision.Efficiency;
motorMoment = inductionMotor.state.torque * DirAbsolute;
Mw = motorMoment * Transmision.Ratio * Transmision.Efficiency;
Fw = Mw * 2.0 / wheelDiameter;
ft = Fw * nPoweredAxles * inductionMotor.inverterRatio;
inductionMotor.state.force = DirAbsolute * ft / 1000;
@@ -1375,7 +1375,7 @@ void physics::Vehicle::InductionMotorOff()
inv.IsActive = false;
}
Im = 0.0;
Mm = 0.0;
motorMoment = 0.0;
Mw = 0.0;
Fw = 0.0;
ft = 0.0;
+1 -1
View File
@@ -100,7 +100,7 @@ void physics::ConsistBrakeBlending::SumForces(Step &state, std::vector<Vehicle *
vehicle->brakes.config.maxPressureMass
+ ( vehicle->brakes.config.maxPressureMass > 1.0 ?
0.0 :
vehicle->Mass )
vehicle->Mass() )
+ vehicle->Mred();
auto const Nmax = ((vehicle->brakes.config.pressureToForce * vehicle->brakes.config.maxCylinderPressure[0] -
vehicle->brakes.config.cylinders.springForce) *
+14 -7
View File
@@ -643,7 +643,7 @@ class Vehicle
TPowerParameters LightPowerSource; /*zrodlo mocy dla oswietlenia*/
TPowerParameters AlterLightPowerSource; /*alternatywne mocy dla oswietlenia*/
double const &Vmax() const { return vmax; }
double Mass = 0.0;
double const &Mass() const { return emptyMass; }
double Power = 0.0; /*max. predkosc kontrukcyjna, masa wlasna, moc*/
double const &Mred() const { return mred; } /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/
double const &TotalMass() const { return totalMass; } /*wyliczane przez ComputeMass*/
@@ -957,7 +957,7 @@ class Vehicle
/*! rotacja kol [obr/s]*/
double EnginePower = 0.0; /*! chwilowa moc silnikow*/
double dL = 0.0;
double Fb = 0.0;
double const &Fb() const { return brakingForce; }
double Ff = 0.0; /*przesuniecie, sila hamowania i tarcia*/
double FTrain = 0.0;
double FStand = 0.0; /*! sila pociagowa i oporow ruchu*/
@@ -975,8 +975,8 @@ class Vehicle
genset_device Genset; // of a dual-mode vehicle, fitted() only with GensetPower
// the source the traction circuit takes its voltage from (the traction selector of a dual-mode vehicle)
enum class traction_mode { catenary, genset };
traction_mode TractionMode{traction_mode::catenary};
bool GensetSelected() const { return TractionMode == traction_mode::genset; }
traction_mode const &TractionMode() const { return tractionModeSetting; }
bool GensetSelected() const { return tractionModeSetting == traction_mode::genset; }
water_pump WaterPump;
water_heater WaterHeater;
bool const &WaterCircuitsLink() const { return waterCircuitsLink; } // optional connection between water circuits
@@ -1041,7 +1041,7 @@ class Vehicle
double LastSwitchingTime = 0.0; /*czas ostatniego przelaczania czegos*/
int const &WarningSignal() const { return warningSignal; } // 0: nie trabi, 1,2,4: trabi
void SetWarningSignal(int const Value) { warningSignal = Value; }
bool DepartureSignal = false; /*sygnal odjazdu*/
bool const &DepartureSignal() const { return departureSignalOn; } /*sygnal odjazdu*/
bool const &InsideConsist() const { return insideConsist; }
void SetInsideConsist(bool const Value) { insideConsist = Value; }
/*-zmienne dla lokomotywy elektrycznej*/
@@ -1056,7 +1056,7 @@ class Vehicle
double Itot = 0.0; // prad calkowity
double TotalCurrent = 0.0;
// momenty
double Mm = 0.0;
double const &Mm() const { return motorMoment; }
double Mw = 0.0;
// sily napedne
double Fw = 0.0;
@@ -1257,7 +1257,7 @@ class Vehicle
// how the vehicle left the rails by the criteria of derailment.h: upright, or on its side. none for any other
// derailment, which stops it as the legacy model does (with physics.collisions new by a friction of its weight, the
// forces of the vehicles coupled to it acting on it)
derailment::outcome Derailed{derailment::outcome::none};
derailment::outcome const &Derailed() const { return derailOutcome; }
// physics.derailment new: how the vehicle left the rails, for the way it leaves the track (vehicle/derailmotion.h):
// what derailed it, the lateral acceleration of its body out of the curve then [m/s2] (negative into the curve, where a
// buckle bends the line the other way), and the side it was pulled off to by a coupling (1 the left of its front, -1
@@ -1916,6 +1916,13 @@ class Vehicle
horn_supply hornSupply{horn_supply::air};
bool uniCtrlIntegratedLocalBrakeCtrl = false;
double windingRes = 0.0;
// what the vehicle works out or is defined with, which the rest of the simulator only reads
double brakingForce = 0.0;
derailment::outcome derailOutcome{derailment::outcome::none};
bool departureSignalOn = false;
double emptyMass = 0.0;
traction_mode tractionModeSetting{traction_mode::catenary};
double motorMoment = 0.0;
// the switches and the controllers the cab, the AI and the scenery change only through the operations above
double travelSpeed = 0.0;
TLocation location{0.0, 0.0, 0.0};
+1 -1
View File
@@ -81,7 +81,7 @@ std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle cons
on(false == Occupied.Doors.instances[VehicleSide::right].is_closed, device::doors_right) | on(Occupied.Radio(), device::radio) |
on(Controlling.trainHeating.IsOn(), device::heating) | on(Occupied.brakes.spring.isActive, device::spring_brake) | on(Controlling.ShuntMode, device::shunt_mode) |
// the doors as the cab works them: the permits, the departure signal, the steps and the lock
on(Occupied.DepartureSignal, device::departure_signal) | on(Occupied.Doors.instances[VehicleSide::left].open_permit, device::door_permit_left) |
on(Occupied.DepartureSignal(), device::departure_signal) | on(Occupied.Doors.instances[VehicleSide::left].open_permit, device::door_permit_left) |
on(Occupied.Doors.instances[VehicleSide::right].open_permit, device::door_permit_right) | on(Occupied.Doors.step_enabled, device::door_step) |
on(Occupied.Doors.lock_enabled, device::door_lock) | on(Occupied.Doors.is_locked, device::doors_locked) |
on(Occupied.brakes.distributor != nullptr && Occupied.brakes.distributor->Releaser(), device::brake_releaser) | on(Controlling.FuelPump.is_active, device::fuel_pump) |
+2 -2
View File
@@ -47,7 +47,7 @@ std::vector<channel> motion() {
{"AccS", [](auto const &M) { return M.AccS(); }},
{"nrot", [](auto const &M) { return M.nrot(); }},
{"Ft", [](auto const &M) { return M.Ft(); }},
{"Fb", [](auto const &M) { return M.Fb; }},
{"Fb", [](auto const &M) { return M.Fb(); }},
{"FStand", [](auto const &M) { return M.FStand; }},
{"SlippingWheels", [](auto const &M) { return M.SlippingWheels() ? 1.0 : 0.0; }},
};
@@ -129,7 +129,7 @@ std::vector<channel> parameters() {
{"TrainType", [](auto const &M) { return legacy_code(M.TrainType()); }},
{"EngineType", [](auto const &M) { return static_cast<int>(M.EngineType); }},
{"Vmax", [](auto const &M) { return M.Vmax(); }},
{"Mass", [](auto const &M) { return M.Mass; }},
{"Mass", [](auto const &M) { return M.Mass(); }},
{"TotalMass", [](auto const &M) { return M.TotalMass(); }},
{"Mred", [](auto const &M) { return M.Mred(); }},
{"Power", [](auto const &M) { return M.Power; }},
+4 -4
View File
@@ -41,12 +41,12 @@ std::vector<invariant> const &invariants() {
static std::vector<invariant> const rules{
{"every value a number",
[](auto const &M, double, auto const *) {
std::initializer_list<double> const values{M.V(), M.AccS(), M.Ft(), M.Fb, M.Im, M.Itot, M.EngineVoltage,
std::initializer_list<double> const values{M.V(), M.AccS(), M.Ft(), M.Fb(), M.Im, M.Itot, M.EngineVoltage,
M.enrot, M.brakePipe.Pressure(), M.brakes.cylinderPressure, M.brakes.independentCylinderPressure, M.mainPipe.Pressure(), M.air.MainReservoirPressure(), M.lowVoltage.BatteryVoltage()};
return std::ranges::all_of(values, [](double const Value) { return std::isfinite(Value); });
},
[](auto const &M) {
return values({{"V", M.V()}, {"AccS", M.AccS()}, {"Ft", M.Ft()}, {"Fb", M.Fb}, {"Im", M.Im}, {"Itot", M.Itot}, {"EngineVoltage", M.EngineVoltage},
return values({{"V", M.V()}, {"AccS", M.AccS()}, {"Ft", M.Ft()}, {"Fb", M.Fb()}, {"Im", M.Im}, {"Itot", M.Itot}, {"EngineVoltage", M.EngineVoltage},
{"enrot", M.enrot}, {"PipePress", M.brakePipe.Pressure()}, {"BrakePress", M.brakes.cylinderPressure}, {"LocBrakePress", M.brakes.independentCylinderPressure},
{"ScndPipePress", M.mainPipe.Pressure()}, {"Compressor", M.air.MainReservoirPressure()}, {"BatteryVoltage", M.lowVoltage.BatteryVoltage()}});
}},
@@ -115,8 +115,8 @@ std::vector<invariant> const &invariants() {
},
[](auto const &M) { return values({{"V", M.V()}, {"AccS", M.AccS()}}); }},
{"hand brake applied, the wheels braked on the move",
[](auto const &M, double, auto const *) { return false == M.brakes.config.hasHandBrake || M.brakes.HandBrakePosition() == 0 || std::abs(M.V()) < 0.5 || std::abs(M.Fb) > 0.0; },
[](auto const &M) { return values({{"ManualBrakePos", M.brakes.HandBrakePosition()}, {"V", M.V()}, {"Fb", M.Fb}}); }},
[](auto const &M, double, auto const *) { return false == M.brakes.config.hasHandBrake || M.brakes.HandBrakePosition() == 0 || std::abs(M.V()) < 0.5 || std::abs(M.Fb()) > 0.0; },
[](auto const &M) { return values({{"ManualBrakePos", M.brakes.HandBrakePosition()}, {"V", M.V()}, {"Fb", M.Fb()}}); }},
};
return rules;
}
+1 -1
View File
@@ -185,7 +185,7 @@ TEST_CASE("brake cycle: every material of the brake shoes and disks, braking a w
real.hold_brake_pipe(3.5);
real.run(20.0);
CHECK(real->Vel < speed - 10.0);
CHECK(real->Fb > 0.0);
CHECK(real->Fb() > 0.0);
trace.mark("emergency");
real.hold_brake_pipe(0.0);
real.run(60.0);
+2 -2
View File
@@ -185,7 +185,7 @@ TEST_CASE("brakes: a wagon standing braked on a gradient sleeps while the brakes
wagon.hold_brake_pipe(5.0);
wagon.run(60.0, slope);
CHECK(wagon->brakes.cylinderPressure < 0.1);
CHECK(wagon->Fb < 1.0);
CHECK(wagon->Fb() < 1.0);
CHECK(std::abs(wagon.speed()) > 1.0);
CHECK(wagon->PhysicActivation());
}
@@ -206,6 +206,6 @@ TEST_CASE("brakes: a wagon held by its hand brake on a gradient wakes and rolls
wagon->DecManualBrakeLevel(ManualBrakePosNo);
wagon.run(30.0, slope);
CHECK(wagon->Fb < 1.0);
CHECK(wagon->Fb() < 1.0);
CHECK(std::abs(wagon.speed()) > 1.0);
}
+3 -3
View File
@@ -690,7 +690,7 @@ TEST_CASE("collisions: a repaired vehicle has its ends rebuilt and is back on th
auto &physics{vehicle->physics()};
physics.repair_damage();
CHECK(physics.DamageFlag.Empty());
CHECK(physics.Derailed == derailment::outcome::none);
CHECK(physics.Derailed() == derailment::outcome::none);
CHECK(physics.CollisionDerail() == NONE);
CHECK(physics.pushed_off_monitor.distance() == 0.0);
CHECK(physics.pushed_off_monitor.time() == 0.0);
@@ -724,10 +724,10 @@ TEST_CASE("collisions: SetDamage taking the derailment off clears the collision'
vehicle wagon{definition::fiz("3wl_v2/3wl")};
wagon->derail_in_collision(COLLISION_PUSHED_OFF, "test");
REQUIRE(wagon->CollisionDerail() == COLLISION_PUSHED_OFF);
REQUIRE(wagon->Derailed == derailment::outcome::off_rails);
REQUIRE(wagon->Derailed() == derailment::outcome::off_rails);
wagon->RunCommand(VehicleCommand::setDamage, DamageSet{VehicleDamage::derailed}.Bits(), -1);
CHECK(wagon->CollisionDerail() == NONE);
CHECK(wagon->Derailed == derailment::outcome::none);
CHECK(wagon->Derailed() == derailment::outcome::none);
CHECK_FALSE(wagon->DamageFlag.HasAll(VehicleDamage::derailed));
}
+1 -1
View File
@@ -60,7 +60,7 @@ std::vector<test::channel> state() {
{"DoorLock", [](auto const &M) { return flag(M.Doors.lock_enabled); }},
{"DoorStep", [](auto const &M) { return flag(M.Doors.step_enabled); }},
{"DoorRemoteOnly", [](auto const &M) { return flag(M.Doors.remote_only); }},
{"DepartureSignal", [](auto const &M) { return flag(M.DepartureSignal); }},
{"DepartureSignal", [](auto const &M) { return flag(M.DepartureSignal()); }},
{"PantsValve", [](auto const &M) { return flag(M.pantographAir.valve.is_enabled) + 2 * flag(M.pantographAir.valve.is_disabled); }},
{"MaxCurrentHigh", [](auto const &M) { return flag(M.MotorOverloadRelayHighThreshold()); }},
{"Imin", [](auto const &M) { return M.Imin(); }},
+2 -2
View File
@@ -224,13 +224,13 @@ TEST_CASE("crew: what the AI held is let go when the driver leaves") {
cab->SetWarningSignal(1);
cab->signal_departure(true);
cab->Sandbox(true);
REQUIRE(cab->DepartureSignal);
REQUIRE(cab->DepartureSignal());
REQUIRE(cab->SandDose());
crew::secure(cab.physics(), cab.physics());
CHECK(cab->WarningSignal() == 0);
CHECK_FALSE(cab->DepartureSignal);
CHECK_FALSE(cab->DepartureSignal());
CHECK_FALSE(cab->SandDose());
}
+3 -3
View File
@@ -9,7 +9,7 @@ using test::vehicle;
TEST_CASE("definition: the wagon from data/wagon.json loads with its values") {
vehicle wagon{definition::load("wagon")};
CHECK(wagon->Mass == doctest::Approx(42200.0));
CHECK(wagon->Mass() == doctest::Approx(42200.0));
CHECK(wagon->Vmax() == doctest::Approx(120.0));
CHECK(wagon->Dim.L == doctest::Approx(26.8));
CHECK(wagon->WheelDiameter() == doctest::Approx(0.96));
@@ -21,7 +21,7 @@ TEST_CASE("definition: the wagon from data/wagon.json loads with its values") {
TEST_CASE("definition: keys set by the test reach the vehicle") {
vehicle heavy{definition::load("wagon").set("Param", "M", 60000).set("Wheels", "D", 1.0)};
CHECK(heavy->Mass == doctest::Approx(60000.0));
CHECK(heavy->Mass() == doctest::Approx(60000.0));
CHECK(heavy->WheelDiameter() == doctest::Approx(1.0));
}
@@ -61,7 +61,7 @@ TEST_CASE("definition: lines the loader skips or trims: comments, a hash anywher
}
physics::Vehicle wagon(0.0, "wagon", "test", 0);
REQUIRE(wagon.LoadFIZ_Text(crlf));
CHECK(wagon.Mass == doctest::Approx(42200.0));
CHECK(wagon.Mass() == doctest::Approx(42200.0));
CHECK(wagon.Vmax() == doctest::Approx(120.0));
CHECK(wagon.brakes.config.maxCylinderPressure[3] == doctest::Approx(3.8));
}
+5 -5
View File
@@ -416,7 +416,7 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n
for (int step = 0; step < 10; ++step) {
eu07vehicle.step(curve);
}
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
REQUIRE(eu07vehicle->Derailed() == dr::outcome::overturned);
CHECK(eu07vehicle->DerailCause() == dm::cause::overturned);
CHECK(eu07vehicle->DerailAcceleration() > eu07_tipping);
CHECK(eu07vehicle->leaves_track());
@@ -442,7 +442,7 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n
eu07vehicle.damage_track(dtrack_norail);
eu07vehicle.step();
REQUIRE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(eu07vehicle->Derailed == dr::outcome::off_rails);
CHECK(eu07vehicle->Derailed() == dr::outcome::off_rails);
CHECK(eu07vehicle->DerailCause() == dm::cause::end_of_track);
CHECK(eu07vehicle->leaves_track());
}
@@ -451,7 +451,7 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n
vehicle pulled{definition::fiz("4e_v1/4e"), 40.0};
pulled->pull_off(-1, 5.0, "test");
CHECK(pulled->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(pulled->Derailed == dr::outcome::off_rails);
CHECK(pulled->Derailed() == dr::outcome::off_rails);
CHECK(pulled->DerailCause() == dm::cause::pulled_off);
CHECK(pulled->DerailSide() == -1);
CHECK(pulled->leaves_track());
@@ -474,7 +474,7 @@ TEST_CASE("derail motion: with physics.derailment monitor and old the vehicle st
fast.step(curve);
}
REQUIRE(fast->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(fast->Derailed == dr::outcome::none);
CHECK(fast->Derailed() == dr::outcome::none);
CHECK_FALSE(fast->leaves_track());
CHECK_FALSE(fast->OffTrack.active());
// stopped dead by the legacy model
@@ -483,7 +483,7 @@ TEST_CASE("derail motion: with physics.derailment monitor and old the vehicle st
ending.damage_track(dtrack_norail);
ending.step();
REQUIRE(ending->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(ending->Derailed == dr::outcome::none);
CHECK(ending->Derailed() == dr::outcome::none);
CHECK_FALSE(ending->leaves_track());
// nor is a vehicle pulled off it
vehicle pulled{definition::fiz("4e_v1/4e"), 40.0};
+17 -17
View File
@@ -48,7 +48,7 @@ TEST_CASE("derailment: a vehicle too fast in a curve") {
eu07vehicle.step(curve);
}
CHECK_FALSE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(eu07vehicle->Derailed == dr::outcome::none);
CHECK(eu07vehicle->Derailed() == dr::outcome::none);
}
SUBCASE("over it, it falls over and slides to a stop on its side") {
vehicle eu07vehicle{definition::fiz("4e_v1/4e"), critical + 5.0};
@@ -58,7 +58,7 @@ TEST_CASE("derailment: a vehicle too fast in a curve") {
eu07vehicle.step(curve);
}
REQUIRE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(eu07vehicle->Derailed == dr::outcome::overturned);
CHECK(eu07vehicle->Derailed() == dr::outcome::overturned);
CHECK_FALSE(eu07vehicle->lineBreaker.IsClosed());
// not stopped dead as the legacy model has it: it slows down at half of g on the 80 of its 96 t
auto const start{eu07vehicle->V()};
@@ -79,7 +79,7 @@ TEST_CASE("derailment: a vehicle too fast in a curve") {
for (int step = 0; step < 50; ++step) {
high.step(curve);
}
CHECK(high->Derailed == dr::outcome::overturned);
CHECK(high->Derailed() == dr::outcome::overturned);
}
SUBCASE("the same with steps of 0.01 and 0.05 s") {
for (auto const dt : {0.01, 0.05}) {
@@ -89,12 +89,12 @@ TEST_CASE("derailment: a vehicle too fast in a curve") {
for (auto step = 0; step < steps; ++step) {
eu07vehicle.step(curve, dt);
}
CHECK(eu07vehicle->Derailed == dr::outcome::overturned);
CHECK(eu07vehicle->Derailed() == dr::outcome::overturned);
vehicle slower{definition::fiz("4e_v1/4e"), critical - 2.0};
for (auto step = 0; step < steps; ++step) {
slower.step(curve, dt);
}
CHECK(slower->Derailed == dr::outcome::none);
CHECK(slower->Derailed() == dr::outcome::none);
}
}
SUBCASE("a load raises the centre of gravity") {
@@ -126,7 +126,7 @@ TEST_CASE("derailment: the model of eu07.ini") {
}
// far over its threshold the draw comes out at once
CHECK(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(eu07vehicle->Derailed == dr::outcome::none);
CHECK(eu07vehicle->Derailed() == dr::outcome::none);
CHECK(eu07vehicle->V() == doctest::Approx(0.0).epsilon(0.01));
}
}
@@ -140,7 +140,7 @@ TEST_CASE("derailment: the brake hoses tear") {
for (int step = 0; step < 20; ++step) {
eu07vehicle.step(curve);
}
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
REQUIRE(eu07vehicle->Derailed() == dr::outcome::overturned);
CHECK(eu07vehicle->brakes.alarmChain);
}
@@ -155,7 +155,7 @@ TEST_CASE("derailment: a stopped derailed vehicle stays put on a gradient") {
for (int step = 0; step < 2000; ++step) {
eu07vehicle.step(curve);
}
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
REQUIRE(eu07vehicle->Derailed() == dr::outcome::overturned);
REQUIRE(eu07vehicle->V() == 0.0);
auto still{true};
for (int step = 0; step < 500; ++step) {
@@ -177,11 +177,11 @@ TEST_CASE("derailment: a repaired vehicle is back on the rails") {
for (int step = 0; step < 2000; ++step) {
repaired.step(curve);
}
REQUIRE(repaired->Derailed == dr::outcome::overturned);
REQUIRE(repaired->Derailed() == dr::outcome::overturned);
REQUIRE(repaired->V() == 0.0);
repaired->repair_damage();
CHECK(repaired->DamageFlag.Empty());
CHECK(repaired->Derailed == dr::outcome::none);
CHECK(repaired->Derailed() == dr::outcome::none);
CHECK(repaired->DerailmentDistance() == 0.0);
CHECK(repaired->OffsetTrackH() == 0.0);
CHECK(repaired->OffsetTrackV() == 0.0);
@@ -193,7 +193,7 @@ TEST_CASE("derailment: a repaired vehicle is back on the rails") {
repaired->SetAccS(0.0);
repaired->Derail(TOO_HIGH_SPEED);
fresh->Derail(TOO_HIGH_SPEED);
REQUIRE(repaired->Derailed == dr::outcome::none);
REQUIRE(repaired->Derailed() == dr::outcome::none);
auto const start{fresh->V()};
REQUIRE(start > 10.0);
for (int step = 0; step < 150; ++step) {
@@ -221,7 +221,7 @@ TEST_CASE("derailment: a repaired vehicle is back on the rails") {
for (int step = 0; step < 20; ++step) {
repaired.step(curve);
}
CHECK(repaired->Derailed == dr::outcome::overturned);
CHECK(repaired->Derailed() == dr::outcome::overturned);
}
}
@@ -233,14 +233,14 @@ TEST_CASE("derailment: SetDamage taking the derailment off puts the vehicle back
for (int step = 0; step < 20; ++step) {
eu07vehicle.step(curve);
}
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
REQUIRE(eu07vehicle->Derailed() == dr::outcome::overturned);
// another flag taken off leaves it derailed
eu07vehicle->RunCommand(VehicleCommand::setDamage, DamageSet{VehicleDamage::engine}.Bits(), 1);
eu07vehicle->RunCommand(VehicleCommand::setDamage, DamageSet{VehicleDamage::engine}.Bits(), -1);
CHECK(eu07vehicle->Derailed == dr::outcome::overturned);
CHECK(eu07vehicle->Derailed() == dr::outcome::overturned);
CHECK(eu07vehicle->RunCommand(VehicleCommand::setDamage, DamageSet{VehicleDamage::derailed}.Bits(), -1));
CHECK_FALSE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(eu07vehicle->Derailed == dr::outcome::none);
CHECK(eu07vehicle->Derailed() == dr::outcome::none);
}
TEST_CASE("derailment: monitor tells again on the same track after a repair") {
@@ -275,7 +275,7 @@ TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what t
eu07vehicle.step(curve);
}
CHECK_FALSE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(eu07vehicle->Derailed == dr::outcome::none);
CHECK(eu07vehicle->Derailed() == dr::outcome::none);
// once on a track, however long it stays over the criteria
CHECK(eu07vehicle->derailment_reports() == 1);
REQUIRE(eu07vehicle->derailment_reported.has_value());
@@ -302,7 +302,7 @@ TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what t
faster.step(curve);
}
CHECK(faster->DamageFlag.HasAll(VehicleDamage::derailed));
CHECK(faster->Derailed == dr::outcome::none);
CHECK(faster->Derailed() == dr::outcome::none);
CHECK(faster->V() == doctest::Approx(0.0).epsilon(0.01));
}
}
+4 -4
View File
@@ -25,8 +25,8 @@ TEST_CASE("fiz: every real vehicle loads and keeps its parameters") {
test::trace trace{"fiz/" + path, test::channels::parameters(), 1};
trace.sample(0.0, real.physics());
// what every vehicle has, the rest of its parameters are in the golden trace
CHECK(real->Mass > 0.0);
CHECK(real->TotalMass() >= real->Mass);
CHECK(real->Mass() > 0.0);
CHECK(real->TotalMass() >= real->Mass());
CHECK(real->Vmax() > 0.0);
CHECK(real->NAxles() > 0);
CHECK(real->WheelDiameter() > 0.0);
@@ -37,8 +37,8 @@ TEST_CASE("fiz: every real vehicle loads and keeps its parameters") {
TEST_CASE("fiz: changes made by a test reach the vehicle") {
auto const eu07{definition::fiz("4e_v1/4e")};
CHECK(vehicle{eu07}->Mass == doctest::Approx(80000.0));
CHECK(vehicle{definition{eu07}.set("Param", "M", 90000)}->Mass == doctest::Approx(90000.0));
CHECK(vehicle{eu07}->Mass() == doctest::Approx(80000.0));
CHECK(vehicle{definition{eu07}.set("Param", "M", 90000)}->Mass() == doctest::Approx(90000.0));
// a key the file doesn't have is added to its section
CHECK(vehicle{definition{eu07}.set("Brake", "MaxBP", 3.5)}->brakes.config.maxCylinderPressure[3] == doctest::Approx(3.5));
// removing a key brings its default back
+7 -7
View File
@@ -130,7 +130,7 @@ TEST_CASE("genset: a vehicle without the keys has none and stays on the catenary
CHECK(cab.Genset.power == 0.0);
CHECK_FALSE(cab.Genset.fitted());
CHECK_FALSE(cab.TractionModeSwitch(traction_mode::genset));
CHECK(cab.TractionMode == traction_mode::catenary);
CHECK(cab.TractionMode() == traction_mode::catenary);
CHECK_FALSE(cab.GensetSelected());
REQUIRE(test::start_up(test::driving(dragon6), wire));
CHECK(cab.pantographCircuit.SupplyVoltage() > 2900.0);
@@ -142,7 +142,7 @@ TEST_CASE("genset: a vehicle without the keys has none and stays on the catenary
run(dragon6, 20.0, wire);
CHECK_FALSE(cab.Genset.is_active);
CHECK(cab.Genset.voltage == 0.0);
CHECK(cab.TractionMode == traction_mode::catenary);
CHECK(cab.TractionMode() == traction_mode::catenary);
}
TEST_CASE("genset: the keys reach the vehicle") {
@@ -157,7 +157,7 @@ TEST_CASE("genset: the keys reach the vehicle") {
CHECK(genset.spinup_time == 3.0);
CHECK(genset.traction_share == 0.85);
CHECK(genset.start_type == start_t::manual);
CHECK(dragon6->TractionMode == traction_mode::catenary);
CHECK(dragon6->TractionMode() == traction_mode::catenary);
// the pantographs stay what they were
CHECK(dragon6->EnginePowerSource.SourceType == TPowerSource::CurrentCollector);
CHECK(dragon6->EnginePowerSource.CollectorParameters.MinV == 2000.0);
@@ -185,7 +185,7 @@ TEST_CASE("genset: the keys are ignored on other than induction motor vehicles")
vehicle other{definition::fiz(path).set("Power", "GensetPower", 520)};
CHECK_FALSE(other->Genset.fitted());
CHECK_FALSE(other->TractionModeSwitch(traction_mode::genset));
CHECK(other->TractionMode == traction_mode::catenary);
CHECK(other->TractionMode() == traction_mode::catenary);
}
}
@@ -195,7 +195,7 @@ TEST_CASE("genset: the selector moves only with the line breaker open") {
REQUIRE(test::start_up(test::driving(dragon6), wire));
REQUIRE(cab.lineBreaker.IsClosed());
CHECK_FALSE(cab.TractionModeSwitch(traction_mode::genset));
CHECK(cab.TractionMode == traction_mode::catenary);
CHECK(cab.TractionMode() == traction_mode::catenary);
run(dragon6, 2.0, wire);
CHECK(cab.lineBreaker.IsClosed());
cab.MainSwitch(false);
@@ -203,7 +203,7 @@ TEST_CASE("genset: the selector moves only with the line breaker open") {
CHECK(cab.TractionModeSwitch(traction_mode::genset));
CHECK(cab.GensetSelected());
CHECK(cab.TractionModeSwitch(traction_mode::catenary));
CHECK(cab.TractionMode == traction_mode::catenary);
CHECK(cab.TractionMode() == traction_mode::catenary);
}
TEST_CASE("genset: started, it closes the line breaker without a catenary") {
@@ -245,7 +245,7 @@ TEST_CASE("genset: on the catenary position the genset feeds nothing") {
cab.GensetSwitch(true);
run(dragon6, 20.0);
REQUIRE(cab.Genset.is_active);
CHECK(cab.TractionMode == traction_mode::catenary);
CHECK(cab.TractionMode() == traction_mode::catenary);
CHECK_FALSE(cab.MainSwitchCheck());
close_line_breaker(cab);
CHECK_FALSE(cab.lineBreaker.IsClosed());
+3 -3
View File
@@ -62,11 +62,11 @@ TEST_CASE("handover: sanding the player or the automatic system asked for goes o
TEST_CASE("handover: the departure signal the AI was giving stops") {
auto cab{cab_vehicle()};
cab->signal_departure(true);
REQUIRE(cab->DepartureSignal);
REQUIRE(cab->DepartureSignal());
handover::release_ai_controls(cab.physics(), cab.physics());
CHECK_FALSE(cab->DepartureSignal);
CHECK_FALSE(cab->DepartureSignal());
}
TEST_CASE("handover: the brake releaser the AI was holding lets go") {
@@ -86,7 +86,7 @@ TEST_CASE("handover: nothing the AI didn't latch changes") {
CHECK(cab->WarningSignal() == 0);
CHECK_FALSE(cab->SandDose());
CHECK_FALSE(cab->DepartureSignal);
CHECK_FALSE(cab->DepartureSignal());
CHECK_FALSE(cab->brakes.distributor->Releaser());
}
+10 -10
View File
@@ -89,7 +89,7 @@ TEST_CASE("pullee: a dead Vectron vents the brake pipe of the train hauling it,
CHECK(train.hauled->brakes.emergencyValve.flow == 0.0);
CHECK(train.locomotive->brakePipe.Pressure() > 4.99);
CHECK(train.hauled->brakes.cylinderPressure < 0.1);
CHECK(train.hauled->Fb < 1.0);
CHECK(train.hauled->Fb() < 1.0);
CHECK(train.hauled.speed() > 40.0); // running resistance alone
}
}
@@ -154,11 +154,11 @@ TEST_CASE("pullee: the spring brake of a dead locomotive without air stops the t
// no air came from anywhere: the cylinder of the spring brake is empty either way
REQUIRE(hauled.brakes.spring.pressure < 0.1);
if (pullee) {
CHECK(hauled.Fb < 1.0);
CHECK(hauled.Fb() < 1.0);
CHECK(train.hauled.speed() > 45.0);
}
else {
CHECK(hauled.Fb > 30000.0);
CHECK(hauled.Fb() > 30000.0);
CHECK(std::abs(train.hauled.speed()) < 1.0);
}
}
@@ -178,14 +178,14 @@ TEST_CASE("pullee: a dead EU47 starts to drag once its main reservoir has leaked
train.run(180.0);
// charged and released: nothing holds it yet
CHECK(hauled.brakes.cylinderPressure < 0.1);
CHECK(hauled.Fb < 1.0);
CHECK(hauled.Fb() < 1.0);
train.run(1020.0); // 20 minutes since the start
CHECK(hauled.mainPipe.Pressure() < hauled.brakes.spring.minForcePressure);
if (pullee) {
CHECK(hauled.Fb < 1.0);
CHECK(hauled.Fb() < 1.0);
}
else {
CHECK(hauled.Fb > 5000.0);
CHECK(hauled.Fb() > 5000.0);
}
}
}
@@ -209,11 +209,11 @@ TEST_CASE("pullee: a vehicle prepared for hauling brakes and releases with the t
train.locomotive.hold_brake_pipe(3.5);
train.run(20.0);
CHECK(hauled.brakes.cylinderPressure > 2.0);
CHECK(hauled.Fb > 30000.0);
CHECK(hauled.Fb() > 30000.0);
train.locomotive.hold_brake_pipe(5.0);
train.run(90.0);
CHECK(hauled.brakes.cylinderPressure < 0.1);
CHECK(hauled.Fb < 1.0);
CHECK(hauled.Fb() < 1.0);
CHECK(hauled.brakes.emergencyValve.flow == 0.0);
}
}
@@ -420,7 +420,7 @@ TEST_CASE("pullee: every real vehicle prepared for hauling runs free behind a lo
train.run(60.0);
CHECK(hauled.brakes.emergencyValve.flow == 0.0);
CHECK(hauled.brakes.cylinderPressure < 0.1);
CHECK(hauled.Fb < 1.0);
CHECK(hauled.Fb() < 1.0);
CHECK(train.locomotive->brakePipe.Pressure() > 4.99);
CHECK(train.hauled.speed() > 40.0);
}
@@ -444,6 +444,6 @@ TEST_CASE("pullee: every real vehicle standing braked releases once prepared for
CHECK(hauled.brakes.emergencyValve.flow == 0.0);
CHECK(hauled.brakes.cylinderPressure < 0.1);
// the cylinders of a few are still letting out the last of their air (6Dg, SM42, 810: 15-72 N)
CHECK(hauled.Fb < 500.0);
CHECK(hauled.Fb() < 500.0);
}
}
+1 -1
View File
@@ -731,7 +731,7 @@ TController::determine_consist_state() {
isbraking || bp > 0.4 : // ensure the brakes are sufficiently released when starting to move
// once in motion a brake down to 0.4 bar counts as released (UIC), even if its distributor
// is still in the lap position while the brake pipe recharges
( isbraking && bp > 0.4 ) || vehicle->Fb > 10000.0 ) { // 10 kN
( isbraking && bp > 0.4 ) || vehicle->Fb() > 10000.0 ) { // 10 kN
released = false;
// ready all the same with the power going on against the brake on purpose: at a standstill, and once
// the power holds the train, while the brake releases; otherwise in motion a braking force left
+1 -1
View File
@@ -94,7 +94,7 @@ void TController::Doors( bool const Open, int const Side ) {
if (occupied->Doors.has_warning && !drivingFlags.departureWarned)
{
if (!occupied->DepartureSignal)
if (!occupied->DepartureSignal())
{
// Not warned yet, not warning yet - start the warning signal.
cue_action( driver_hint::departuresignalon ); // załącenie bzyczka
+2 -2
View File
@@ -278,7 +278,7 @@ bool TController::uphill_brake_top_up() {
auto haswagons { false };
for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) {
if( vehicle->physics->Power < 0.01 ) {
trainbrakeforce += vehicle->physics->Fb;
trainbrakeforce += vehicle->physics->Fb();
haswagons = true;
}
}
@@ -368,7 +368,7 @@ void TController::increase_tractive_force() {
// Doors() call can potentially adjust fActionTime
if( fActionTime < 0.0 ) { return; }
}
if( true == occupied->DepartureSignal ) {
if( true == occupied->DepartureSignal() ) {
cue_action( driver_hint::departuresignaloff );
}
+1 -1
View File
@@ -71,7 +71,7 @@ std::string TController::physicslog_line() const {
<< occupied->Couplers[1].CForce << " "
<< occupied->Ft() << " "
<< occupied->Ff << " "
<< occupied->Fb << " "
<< occupied->Fb() << " "
<< occupied->brakes.cylinderPressure << " "
<< occupied->brakePipe.Pressure() << " "
<< mvControlling->Im << " "
+1 -1
View File
@@ -93,7 +93,7 @@ double TController::ESMVelocity(bool Main)
SCPN += 1;
if (mvControlling->RList[MCPN].ScndAct < 255 && mvControlling->ScndCtrlActualPos == 0)
SCPN = mvControlling->RList[MCPN].ScndAct;
double FrictionMax = mvControlling->Mass*9.81*mvControlling->Adhesive(mvControlling->RunningTrack.friction)*fFrictionCoeff;
double FrictionMax = mvControlling->Mass()*9.81*mvControlling->Adhesive(mvControlling->RunningTrack.friction)*fFrictionCoeff;
double IF = mvControlling->Imax;
double MS = 0;
double Fmax = 0;
+1 -1
View File
@@ -212,7 +212,7 @@ void TTrain::OnCommand_departureannounce(TTrain *Train, command_data const &Comm
if (Command.action == GLFW_PRESS)
{
// only reacting to press, so the sound can loop uninterrupted
if (false == Train->occupied->DepartureSignal)
if (false == Train->occupied->DepartureSignal())
{
// turn on
Train->occupied->signal_departure(true);
+2 -2
View File
@@ -113,7 +113,7 @@ void TTrain::OnCommand_doortoggleleft(TTrain *Train, command_data const &Command
if (true == (Train->ggDoorLeftButton.GetDesiredValue() > 0.5 || Train->ggDoorLeftOnButton.GetDesiredValue() > 0.5))
{
// open
if (Train->occupied->Doors.has_autowarning && Train->occupied->DepartureSignal)
if (Train->occupied->Doors.has_autowarning && Train->occupied->DepartureSignal())
{
// complete closing the doors
if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorLeftOffButton.SubModel == nullptr)
@@ -402,7 +402,7 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman
if (true == (Train->ggDoorRightButton.GetDesiredValue() > 0.5 || Train->ggDoorRightOnButton.GetDesiredValue() > 0.5))
{
// open
if (Train->occupied->Doors.has_autowarning && Train->occupied->DepartureSignal)
if (Train->occupied->Doors.has_autowarning && Train->occupied->DepartureSignal())
{
// complete closing the doors
if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorRightOffButton.SubModel == nullptr)
+1 -1
View File
@@ -939,7 +939,7 @@ void TTrain::updateTrainLamps()
btLampkaBlokadaDrzwi.Turn(occupied->Doors.is_locked);
}
btLampkaDoorLockOff.Turn(false == occupied->Doors.lock_enabled);
btLampkaDepartureSignal.Turn(controlled->DepartureSignal);
btLampkaDepartureSignal.Turn(controlled->DepartureSignal());
btLampkaNapNastHam.Turn(controlled->DirActive != 0 && occupied->EpFuse()); // napiecie na nastawniku hamulcowym
// Wylaczanie lampek kierunku gdy jedziemy
+2 -2
View File
@@ -490,7 +490,7 @@ void TDynamicObject::renderDepartureSignalSounds() {
auto const lowvoltagepower { physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable() };
for( auto &doorspeaker : m_doorspeakers ) {
// TBD, TODO: per-location door state triggers?
if( physics->DepartureSignal
if( physics->DepartureSignal()
&& lowvoltagepower
/*
|| ( ( physics->DoorCloseCtrl = control::autonomous )
@@ -1409,7 +1409,7 @@ TDynamicObject::powertrain_sounds::renderTractionMotorSounds( physics::Vehicle c
std::clamp(
motor_momentum
- 1.0 * Deltatime // smooth out decay
+ std::abs( Vehicle.Mm ) / 60.0 * Deltatime,
+ std::abs( Vehicle.Mm() ) / 60.0 * Deltatime,
0.0, 1.25 );
volume *= std::max( 0.25f, motor_momentum );
motor_volume = std::lerp( motor_volume, volume, 0.25 );
+1 -1
View File
@@ -21,7 +21,7 @@ void release_ai_controls(physics::Vehicle &Occupied, physics::Vehicle &Controlli
if (Controlling.SandDose() && false == (Controlling.SandDoseManual || Controlling.SandDoseAuto)) {
Controlling.Sandbox(false);
}
if (Occupied.DepartureSignal) {
if (Occupied.DepartureSignal()) {
Occupied.signal_departure(false);
}
if (Occupied.brakes.distributor->Releaser()) {
+1 -1
View File
@@ -226,7 +226,7 @@ void ui::vehicleparams_panel::render_contents()
vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabActive :
1) +
0.001f,
physics.Fb * 0.001f, physics.Adhesive(physics.RunningTrack.friction), (physics.SlippingWheels() ? " (!)" : ""),
physics.Fb() * 0.001f, physics.Adhesive(physics.RunningTrack.friction), (physics.SlippingWheels() ? " (!)" : ""),
// acceleration
physics.AccSVBased(), physics.AccN() + 0.001f, std::string(std::abs(physics.RunningShape.R) > 10000.0 ? "~0" : to_string(physics.RunningShape.R, 0)).c_str(),
// velocity