mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 03:52:52 +01:00
refactor(physics): the motion of the vehicle is private to it
The speed along the couplers, the location, the offsets from the track axis,
the accelerations, the distance counter and the distance moved since the last
check, the flat of the wheels and the truck hunting, the distance of the
derailment check, whether the vehicle is inside a consist and in the coupler
model, the analog demand of the integrated controller and the flow of the pipe
stabiliser are private to physics::Vehicle. TDynamicObject places and moves the
vehicle, the scenery puts road vehicles on their way and the contacts push them
through the operations (SetV(), SetLoc(), SetOffsetTrackH(), ...), and the
jolts of the track are ShakeVertically() and ShakeHorizontally(), the same
additions as before.
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
@@ -806,7 +806,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
||||
physics.LoadType.name.c_str(),
|
||||
physics.EngineDescription( 0 ).c_str(),
|
||||
// TODO: put wheel flat reporting in the enginedescription()
|
||||
std::string( physics.WheelFlat > 0.01 ? " Flat: " + to_string( physics.WheelFlat, 1 ) + " mm" : "" ).c_str(),
|
||||
std::string( physics.WheelFlat() > 0.01 ? " Flat: " + to_string( physics.WheelFlat(), 1 ) + " mm" : "" ).c_str(),
|
||||
update_vehicle_coupler( VehicleEnd::front ).c_str(),
|
||||
update_vehicle_coupler( VehicleEnd::rear ).c_str() );
|
||||
|
||||
@@ -968,11 +968,11 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
||||
physics.SlippingWheels ? " (!)" : "",
|
||||
// acceleration
|
||||
physics.AccSVBased,
|
||||
physics.AccN + 0.001f,
|
||||
physics.AccN() + 0.001f,
|
||||
std::string( std::abs( physics.RunningShape.R ) > 15000.0 ? "~0" : to_string( physics.RunningShape.R, 0 ) ).c_str(),
|
||||
// velocity
|
||||
vehicle.GetVelocity(),
|
||||
physics.DistCounter,
|
||||
physics.DistCounter(),
|
||||
// position
|
||||
vehicle.GetPosition().x,
|
||||
vehicle.GetPosition().y,
|
||||
@@ -1007,11 +1007,11 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
||||
|
||||
if (!std::isnan(last_time)) {
|
||||
double dt = Timer::GetTime() - last_time;
|
||||
AccN_jerk_graph.update(static_cast<float>((physics.AccN - last_AccN) / dt));
|
||||
AccN_acc_graph.update(static_cast<float>(physics.AccN));
|
||||
AccN_jerk_graph.update(static_cast<float>((physics.AccN() - last_AccN) / dt));
|
||||
AccN_acc_graph.update(static_cast<float>(physics.AccN()));
|
||||
}
|
||||
|
||||
last_AccN = static_cast<float>(physics.AccN);
|
||||
last_AccN = static_cast<float>(physics.AccN());
|
||||
last_time = Timer::GetTime();
|
||||
}
|
||||
|
||||
@@ -1123,8 +1123,8 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) const {
|
||||
if( physics.EngineType == TEngineType::DieselEngine ) {
|
||||
|
||||
double fuel_mean = 0.0;
|
||||
if (physics.DistCounter > 0.5) {
|
||||
fuel_mean = 100 * physics.diesel.fuelConsumedTotal / physics.DistCounter;
|
||||
if (physics.DistCounter() > 0.5) {
|
||||
fuel_mean = 100 * physics.diesel.fuelConsumedTotal / physics.DistCounter();
|
||||
}
|
||||
|
||||
std::string parameterstext = "param value";
|
||||
@@ -1629,7 +1629,7 @@ debug_panel::update_section_coupler( std::vector<text_line> &Output ) {
|
||||
"Model: {} (couplerphysics {}, vehicle {}covered), crash damage {}",
|
||||
physics.coupler_physics_at( m_coupler.end ) ? "physical" : "legacy",
|
||||
coupler_physics_setting(),
|
||||
physics.CouplerPhysics ? "" : "not ",
|
||||
physics.CouplerPhysics() ? "" : "not ",
|
||||
Global.crash_damage ? "on" : "off" ),
|
||||
Global.UITextColor );
|
||||
if( neighbour.vehicle != nullptr ) {
|
||||
|
||||
+8
-8
@@ -273,17 +273,17 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle)
|
||||
size_t j = Vehicle->asName.length();
|
||||
r.iPar[0] = i; // ilość danych liczbowych
|
||||
r.fPar[1] = Global.fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba)
|
||||
r.fPar[2] = Vehicle->physics->Loc.X; // pozycja X
|
||||
r.fPar[3] = Vehicle->physics->Loc.Y; // pozycja Y
|
||||
r.fPar[4] = Vehicle->physics->Loc.Z; // pozycja Z
|
||||
r.fPar[5] = Vehicle->physics->V; // prędkość ruchu X
|
||||
r.fPar[2] = Vehicle->physics->Loc().X; // pozycja X
|
||||
r.fPar[3] = Vehicle->physics->Loc().Y; // pozycja Y
|
||||
r.fPar[4] = Vehicle->physics->Loc().Z; // pozycja Z
|
||||
r.fPar[5] = Vehicle->physics->V(); // prędkość ruchu X
|
||||
r.fPar[6] = Vehicle->physics->nrot * M_PI *
|
||||
Vehicle->physics->WheelDiameter; // prędkość obrotowa kóŁ
|
||||
r.fPar[7] = 0; // prędkość ruchu Z
|
||||
r.fPar[8] = Vehicle->physics->AccS; // przyspieszenie X
|
||||
r.fPar[9] = Vehicle->physics->AccN; // przyspieszenie Y //na razie nie
|
||||
r.fPar[10] = Vehicle->physics->AccVert; // przyspieszenie Z
|
||||
r.fPar[11] = Vehicle->physics->DistCounter; // przejechana odległość w km
|
||||
r.fPar[8] = Vehicle->physics->AccS(); // przyspieszenie X
|
||||
r.fPar[9] = Vehicle->physics->AccN(); // przyspieszenie Y //na razie nie
|
||||
r.fPar[10] = Vehicle->physics->AccVert(); // przyspieszenie Z
|
||||
r.fPar[11] = Vehicle->physics->DistCounter(); // przejechana odległość w km
|
||||
r.fPar[12] = Vehicle->physics->brakePipe.Pressure(); // ciśnienie w PG
|
||||
r.fPar[13] = Vehicle->physics->mainPipe.Pressure(); // ciśnienie w PZ
|
||||
r.fPar[14] = Vehicle->physics->brakes.cylinderPressure; // ciśnienie w CH
|
||||
|
||||
+70
-70
@@ -149,7 +149,7 @@ physics::Vehicle::Vehicle(double VelInitial, std::string const &TypeNameInit, st
|
||||
}
|
||||
|
||||
Vel = abs(VelInitial);
|
||||
V = VelInitial / 3.6;
|
||||
travelSpeed = VelInitial / 3.6;
|
||||
|
||||
RunningShape.Len = 1.0;
|
||||
|
||||
@@ -182,7 +182,7 @@ void physics::Vehicle::change_train_velocity(double const Change)
|
||||
continue;
|
||||
}
|
||||
auto const otherdirection{direction * DirPatch(end, coupler.ConnectedEnd())};
|
||||
other->V += Change * otherdirection;
|
||||
other->travelSpeed += Change * otherdirection;
|
||||
train.emplace_back(other, otherdirection);
|
||||
}
|
||||
}
|
||||
@@ -217,56 +217,56 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
}
|
||||
|
||||
if (CategoryFlag == 4)
|
||||
OffsetTrackV = TotalMass / (Dim.L * Dim.W * 1000.0);
|
||||
offsetTrackV = TotalMass / (Dim.L * Dim.W * 1000.0);
|
||||
else if (TestFlag(CategoryFlag, 1) && TestFlag(RunningTrack.CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed))
|
||||
{
|
||||
OffsetTrackV = -0.2;
|
||||
OffsetTrackH = Sign(RunningShape.R) * 0.2;
|
||||
offsetTrackV = -0.2;
|
||||
offsetTrackH = Sign(RunningShape.R) * 0.2;
|
||||
}
|
||||
|
||||
// TODO: investigate, seems supplied NewRot is always 0 although the code here suggests some actual values are expected
|
||||
Loc = NewLoc;
|
||||
location = NewLoc;
|
||||
Rot = NewRot;
|
||||
|
||||
if (dL == 0) // oblicz przesuniecie}
|
||||
{
|
||||
auto const AccSprev{AccS};
|
||||
auto const AccSprev{accS};
|
||||
// przyspieszenie styczne
|
||||
AccS = std::lerp(AccSprev, FTotal / TotalMass, 0.5);
|
||||
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)
|
||||
|
||||
// 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))
|
||||
AccS = -Sign(V) * g * 1; // random(0.0, 0.1)
|
||||
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)) && V == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
auto const stuck{(Derailed != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
if (stuck)
|
||||
AccS = 0.0;
|
||||
accS = 0.0;
|
||||
|
||||
// przyspieszenie normalne
|
||||
if (abs(Shape.R) > 0.01)
|
||||
AccN = square(V) / Shape.R + g * Shape.dHrail / TrackW; // Q: zamieniam SQR() na sqr()
|
||||
accN = square(travelSpeed) / Shape.R + g * Shape.dHrail / TrackW; // Q: zamieniam SQR() na sqr()
|
||||
else
|
||||
AccN = g * Shape.dHrail / TrackW;
|
||||
accN = g * Shape.dHrail / TrackW;
|
||||
|
||||
// velocity change
|
||||
auto const Vprev{V};
|
||||
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
|
||||
auto const Vprev{travelSpeed};
|
||||
travelSpeed += (3.0 * accS - AccSprev) * dt / 2.0; // przyrost predkosci
|
||||
if (stuck)
|
||||
V = 0.0;
|
||||
if (V * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
|
||||
travelSpeed = 0.0;
|
||||
if (travelSpeed * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
|
||||
{
|
||||
// tlumienie predkosci przy hamowaniu
|
||||
// zahamowany
|
||||
V = 0;
|
||||
travelSpeed = 0;
|
||||
}
|
||||
|
||||
// tangential acceleration, from velocity change
|
||||
AccSVBased = std::lerp(AccSVBased, (V - Vprev) / dt, std::clamp(dt * 3.0, 0.0, 1.0));
|
||||
AccSVBased = std::lerp(AccSVBased, (travelSpeed - Vprev) / dt, std::clamp(dt * 3.0, 0.0, 1.0));
|
||||
|
||||
// vertical acceleration
|
||||
AccVert = std::abs(AccVert) < 0.01 ? 0.0 : AccVert * 0.5;
|
||||
accVert = std::abs(accVert) < 0.01 ? 0.0 : accVert * 0.5;
|
||||
// szarpanie
|
||||
/*
|
||||
#ifdef EU07_USE_FUZZYLOGIC
|
||||
@@ -279,7 +279,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
AccV = AccV / 2.0;
|
||||
|
||||
if (AccV > 1.0)
|
||||
AccN += (7.0 - Random(5)) * (100.0 + Track.DamageFlag / 2.0) * AccV / 2000.0;
|
||||
accN += (7.0 - Random(5)) * (100.0 + Track.DamageFlag / 2.0) * AccV / 2000.0;
|
||||
*/
|
||||
// wykolejanie na luku oraz z braku szyn
|
||||
if (TestFlag(CategoryFlag, 1))
|
||||
@@ -288,7 +288,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
Derail(END_OF_TRACK);
|
||||
// too fast in a curve: the legacy draw in every step (physics.derailment old), or the physical criteria
|
||||
// once the step's distance is known, below
|
||||
if ((Global.derailment == global_settings::derailment_model::old || Global.derailment == global_settings::derailment_model::monitor) && FuzzyLogic(AccN / g * (1.0 + 0.1 * (Track.DamageFlag & dtrack_freerail)), TrackW / Dim.H, 1))
|
||||
if ((Global.derailment == global_settings::derailment_model::old || Global.derailment == global_settings::derailment_model::monitor) && FuzzyLogic(accN / g * (1.0 + 0.1 * (Track.DamageFlag & dtrack_freerail)), TrackW / Dim.H, 1))
|
||||
Derail(TOO_HIGH_SPEED);
|
||||
// wykolejanie na poszerzeniu toru
|
||||
if (FuzzyLogic(abs(Track.Width - TrackW), TrackW / 10.0, 1))
|
||||
@@ -300,13 +300,13 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
|
||||
// dL:=(V+AccS*dt/2)*dt;
|
||||
// przyrost dlugosci czyli przesuniecie
|
||||
dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha}
|
||||
dL = (3.0 * travelSpeed - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha}
|
||||
if (Global.derailment == global_settings::derailment_model::physical || Global.derailment == global_settings::derailment_model::monitor)
|
||||
{
|
||||
// over the distance of this step and of the simpler ones of the frame before it
|
||||
check_derailment(Shape, Track, derailment_distance + std::abs(dL));
|
||||
check_derailment(Shape, Track, derailmentDistance + std::abs(dL));
|
||||
}
|
||||
derailment_distance = 0.0;
|
||||
derailmentDistance = 0.0;
|
||||
// ale jesli jest kolizja (zas. zach. pedu) to...}
|
||||
for (auto const b : VehicleEnds)
|
||||
if (Couplers[b].CheckCollision)
|
||||
@@ -318,7 +318,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
auto const d{(EngineType == TEngineType::WheelsDriven ? dL * CabActive : // na chwile dla testu
|
||||
dL)};
|
||||
|
||||
DistCounter += fabs(dL) / 1000.0;
|
||||
distCounter += fabs(dL) / 1000.0;
|
||||
Odometer.run(dL);
|
||||
dL = 0;
|
||||
|
||||
@@ -339,52 +339,52 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh
|
||||
{
|
||||
// physics::Vehicle::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot);
|
||||
|
||||
Loc = NewLoc;
|
||||
location = NewLoc;
|
||||
Rot = NewRot;
|
||||
|
||||
if (dL == 0) // oblicz przesuniecie
|
||||
{
|
||||
auto const AccSprev{AccS};
|
||||
auto const AccSprev{accS};
|
||||
// przyspieszenie styczne
|
||||
AccS = std::lerp(AccSprev, FTotal / TotalMass, 0.5);
|
||||
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))
|
||||
AccS = -Sign(V) * g * 1; // * random(0.0, 0.1)
|
||||
auto const stuck{(Derailed != derailment::outcome::none || legacy_derailed_slides(*this)) && V == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
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)};
|
||||
if (stuck)
|
||||
AccS = 0.0;
|
||||
accS = 0.0;
|
||||
|
||||
// simple mode skips calculation of normal acceleration
|
||||
|
||||
// velocity change
|
||||
auto const Vprev{V};
|
||||
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
|
||||
auto const Vprev{travelSpeed};
|
||||
travelSpeed += (3.0 * accS - AccSprev) * dt / 2.0; // przyrost predkosci
|
||||
if (stuck)
|
||||
V = 0.0;
|
||||
if (V * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
|
||||
travelSpeed = 0.0;
|
||||
if (travelSpeed * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
|
||||
{
|
||||
// tlumienie predkosci przy hamowaniu
|
||||
// zahamowany
|
||||
V = 0;
|
||||
travelSpeed = 0;
|
||||
}
|
||||
|
||||
// simple mode skips calculation of tangential acceleration
|
||||
|
||||
// simple mode skips calculation of vertical acceleration
|
||||
AccVert = 0.0;
|
||||
accVert = 0.0;
|
||||
|
||||
// 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)
|
||||
{
|
||||
V = 0.0;
|
||||
AccS = 0.0;
|
||||
travelSpeed = 0.0;
|
||||
accS = 0.0;
|
||||
}
|
||||
|
||||
dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha
|
||||
dL = (3.0 * travelSpeed - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha
|
||||
// the criteria of derailment go by the distance, checked in the full step which ends the frame
|
||||
derailment_distance += std::abs(dL);
|
||||
derailmentDistance += std::abs(dL);
|
||||
// ale jesli jest kolizja (zas. zach. pedu) to...
|
||||
for (auto const b : VehicleEnds)
|
||||
if (Couplers[b].CheckCollision)
|
||||
@@ -395,7 +395,7 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh
|
||||
auto const d{(EngineType == TEngineType::WheelsDriven ? dL * CabActive : // na chwile dla testu
|
||||
dL)};
|
||||
|
||||
DistCounter += fabs(dL) / 1000.0;
|
||||
distCounter += fabs(dL) / 1000.0;
|
||||
Odometer.run(dL);
|
||||
dL = 0;
|
||||
|
||||
@@ -534,7 +534,7 @@ bool physics::Vehicle::AddPulseForce(int Multipler)
|
||||
DirActive = CabActive;
|
||||
DirAbsolute = DirActive * CabActive;
|
||||
if (Vel > 0)
|
||||
PulseForce = std::min(1000.0 * Power / (abs(V) + 0.1), Ftmax);
|
||||
PulseForce = std::min(1000.0 * Power / (abs(travelSpeed) + 0.1), Ftmax);
|
||||
else
|
||||
PulseForce = Ftmax;
|
||||
if (PulseForceCount > 1000.0)
|
||||
@@ -707,13 +707,13 @@ void physics::Vehicle::ComputeConstans(void)
|
||||
// if (Ft * Ft < 1)
|
||||
// HideModifier = HideModifier - 3;
|
||||
}
|
||||
Ff = TotalMassxg * (BearingF + RollF * V * V / 10.0) / 1000.0;
|
||||
Ff = TotalMassxg * (BearingF + RollF * travelSpeed * travelSpeed / 10.0) / 1000.0;
|
||||
// dorobic liczenie temperatury lozyska!
|
||||
FrictConst1 = TotalMassxg * RollF / 10000.0;
|
||||
// drag calculation
|
||||
{
|
||||
// NOTE: draft effect of previous vehicle is simplified and doesn't have much to do with reality
|
||||
auto const *previousvehicle{Couplers[V >= 0.0 ? VehicleEnd::front : VehicleEnd::rear].Connected};
|
||||
auto const *previousvehicle{Couplers[travelSpeed >= 0.0 ? VehicleEnd::front : VehicleEnd::rear].Connected};
|
||||
auto dragarea{Dim.W * Dim.H};
|
||||
if (previousvehicle)
|
||||
{
|
||||
@@ -776,7 +776,7 @@ void physics::Vehicle::ComputeMass()
|
||||
void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
{
|
||||
|
||||
Vel = std::abs(V) * 3.6; // prędkość w km/h
|
||||
Vel = std::abs(travelSpeed) * 3.6; // prędkość w km/h
|
||||
|
||||
// McZapkie-031103: sprawdzanie czy warto liczyc fizyke i inne updaty
|
||||
// ABu 300105: cos tu mieszalem , dziala teraz troche lepiej, wiec zostawiam
|
||||
@@ -855,51 +855,51 @@ void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
|
||||
Fb = BrakeForce(RunningTrack);
|
||||
// poslizg
|
||||
auto Fwheels{FTrain - Fb * Sign(V)};
|
||||
auto Fwheels{FTrain - Fb * 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))
|
||||
{
|
||||
SlippingWheels = true;
|
||||
}
|
||||
if (true == SlippingWheels && Vel < 0.1 // the same crude trap: (nearly) stopped vehicle...
|
||||
&& std::abs(nrot * M_PI * WheelDiameter - V) < 0.1 / 3.6) // ...with wheels turning at its speed, i.e. locked wheels at the end of a skid
|
||||
&& std::abs(nrot * M_PI * WheelDiameter - travelSpeed) < 0.1 / 3.6) // ...with wheels turning at its speed, i.e. locked wheels at the end of a skid
|
||||
{
|
||||
// locked wheels never pass the rotation speed test below once the vehicle stops, and a skidding vehicle
|
||||
// keeps its braking force capped by the sliding adhesion, so the rest of the consist could push it around
|
||||
SlippingWheels = false;
|
||||
nrot = V / M_PI / WheelDiameter;
|
||||
nrot = travelSpeed / M_PI / WheelDiameter;
|
||||
}
|
||||
double temp_nrot = nrot;
|
||||
if (true == SlippingWheels)
|
||||
{
|
||||
|
||||
temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - V) * Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot);
|
||||
if (Sign(nrot * M_PI * WheelDiameter - V) * Sign(temp_nrot * M_PI * WheelDiameter - V) < 0)
|
||||
temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - travelSpeed) * Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot);
|
||||
if (Sign(nrot * M_PI * WheelDiameter - travelSpeed) * Sign(temp_nrot * M_PI * WheelDiameter - travelSpeed) < 0)
|
||||
{
|
||||
SlippingWheels = false;
|
||||
temp_nrot = V / M_PI / WheelDiameter;
|
||||
temp_nrot = travelSpeed / M_PI / WheelDiameter;
|
||||
}
|
||||
}
|
||||
if (true == SlippingWheels)
|
||||
{
|
||||
Fwheels = Sign(temp_nrot * M_PI * WheelDiameter - V) * TotalMassxg * Adhesive(RunningTrack.friction);
|
||||
if (Fwheels * Sign(V) > 0)
|
||||
Fwheels = Sign(temp_nrot * M_PI * WheelDiameter - travelSpeed) * TotalMassxg * Adhesive(RunningTrack.friction);
|
||||
if (Fwheels * Sign(travelSpeed) > 0)
|
||||
{
|
||||
FTrain = Fwheels + Fb * Sign(V);
|
||||
FTrain = Fwheels + Fb * Sign(travelSpeed);
|
||||
}
|
||||
else if (FTrain * Sign(V) > 0)
|
||||
else if (FTrain * Sign(travelSpeed) > 0)
|
||||
{
|
||||
Fb = FTrain * Sign(V) - Fwheels * Sign(V);
|
||||
Fb = FTrain * Sign(travelSpeed) - Fwheels * Sign(travelSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
double factor = FTrain - Fb * Sign(V) != 0 ? Fwheels / (FTrain - Fb * Sign(V)) : 1.0;
|
||||
double factor = FTrain - Fb * Sign(travelSpeed) != 0 ? Fwheels / (FTrain - Fb * Sign(travelSpeed)) : 1.0;
|
||||
Fb *= factor;
|
||||
FTrain *= factor;
|
||||
}
|
||||
if (std::abs(nrot) < 0.1)
|
||||
{
|
||||
WheelFlat = sqrt(square(WheelFlat) + abs(Fwheels) / NAxles * Vel * 0.000002);
|
||||
wheelFlat = sqrt(square(wheelFlat) + abs(Fwheels) / NAxles * Vel * 0.000002);
|
||||
}
|
||||
|
||||
nrot = temp_nrot;
|
||||
@@ -935,7 +935,7 @@ void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
FTrain /= FT_factor;
|
||||
FTrain += TotalMassxg * RunningShape.dHtrack;
|
||||
//! niejawne przypisanie zmiennej!
|
||||
FTotal = FTrain - Sign(V) * FStand;
|
||||
FTotal = FTrain - Sign(travelSpeed) * FStand;
|
||||
}
|
||||
|
||||
double physics::Vehicle::BrakeForceR(double ratio, double velocity) const
|
||||
@@ -1058,10 +1058,10 @@ double physics::Vehicle::FrictionForce() const
|
||||
{
|
||||
double FF = 0;
|
||||
// ABu 240205: chyba juz ekstremalnie zoptymalizowana funkcja liczaca sily tarcia
|
||||
if (abs(V) > 0.01)
|
||||
FF = FrictConst1 * V * V + FrictConst2d;
|
||||
if (abs(travelSpeed) > 0.01)
|
||||
FF = FrictConst1 * travelSpeed * travelSpeed + FrictConst2d;
|
||||
else
|
||||
FF = FrictConst1 * V * V + FrictConst2s;
|
||||
FF = FrictConst1 * travelSpeed * travelSpeed + FrictConst2s;
|
||||
return FF;
|
||||
}
|
||||
|
||||
@@ -1112,7 +1112,7 @@ double physics::Vehicle::Adhesive(double staticfriction) const
|
||||
*/
|
||||
// wersja3 by youBy - uwzględnia naturalne mikropoślizgi i wpływ piasecznicy, usuwa losowość z pojazdu
|
||||
double Vwheels = nrot * M_PI * WheelDiameter; // predkosc liniowa koła wynikająca z obrotowej
|
||||
double deltaV = V - Vwheels; // poślizg - różnica prędkości w punkcie styku koła i szyny
|
||||
double deltaV = travelSpeed - Vwheels; // poślizg - różnica prędkości w punkcie styku koła i szyny
|
||||
deltaV = std::max(0.0, std::abs(deltaV) - 0.25); // mikropoślizgi do ok. 0,25 m/s nie zrywają przyczepności
|
||||
Vwheels = std::abs(Vwheels);
|
||||
adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((SandDose ? sandfactor : 1) - (1 - adh_factor) * (deltaV / (deltaV + slipfactor)));
|
||||
@@ -1128,7 +1128,7 @@ double physics::Vehicle::ComputeRotatingWheel(double WForce, double dt, double n
|
||||
{
|
||||
double newn = 0;
|
||||
double eps = 0;
|
||||
if (n == 0 && WForce * Sign(V) < 0)
|
||||
if (n == 0 && WForce * Sign(travelSpeed) < 0)
|
||||
newn = 0;
|
||||
else
|
||||
{
|
||||
@@ -1149,9 +1149,9 @@ bool physics::Vehicle::ChangeOffsetH(double DeltaOffset)
|
||||
bool COH = false;
|
||||
if (TestFlag(CategoryFlag, 2) && TestFlag(RunningTrack.CategoryFlag, 2))
|
||||
{
|
||||
OffsetTrackH = OffsetTrackH + DeltaOffset;
|
||||
offsetTrackH = offsetTrackH + DeltaOffset;
|
||||
// if (abs(OffsetTrackH) > (RunningTrack.Width / 1.95 - TrackW / 2.0))
|
||||
if (abs(OffsetTrackH) > 0.5 * (RunningTrack.Width - Dim.W) - 0.05) // Ra: może pół pojazdu od brzegu?
|
||||
if (abs(offsetTrackH) > 0.5 * (RunningTrack.Width - Dim.W) - 0.05) // Ra: może pół pojazdu od brzegu?
|
||||
COH = false; // kola na granicy drogi
|
||||
else
|
||||
COH = true;
|
||||
@@ -1184,7 +1184,7 @@ std::string physics::Vehicle::EngineDescription(int what) const
|
||||
else
|
||||
outstr = "Load shifted";
|
||||
}
|
||||
if (WheelFlat > 5.0 || DamageFlag.HasAll(VehicleDamage::wheelWear))
|
||||
if (wheelFlat > 5.0 || DamageFlag.HasAll(VehicleDamage::wheelWear))
|
||||
{
|
||||
outstr = "Wheel wear";
|
||||
}
|
||||
@@ -1232,7 +1232,7 @@ std::string physics::Vehicle::EngineDescription(int what) const
|
||||
// *************************************************************************************************
|
||||
bool physics::Vehicle::accelerating() const
|
||||
{
|
||||
if (std::abs(AccS) <= 0.0001)
|
||||
if (std::abs(accS) <= 0.0001)
|
||||
return false;
|
||||
// standing still and held by the brakes and the resistance, against the slope and the couplers: the test ComputeMovement()
|
||||
// sets the speed to zero by. the forces are of the last ComputeTotalForce(), the ones the movement went by. a vehicle whose
|
||||
|
||||
@@ -58,7 +58,7 @@ bool physics::Vehicle::ChangeCab(int direction)
|
||||
{
|
||||
BrakeLevelSet(brakes.driverValve->GetPos(bh_NP));
|
||||
brakes.pipeLimiterPressure = brakePipe.Pressure();
|
||||
ActFlowSpeed = 0;
|
||||
actFlowSpeed = 0;
|
||||
}
|
||||
else
|
||||
BrakeLevelSet(brakes.driverValve->GetPos(bh_NP));
|
||||
@@ -150,7 +150,7 @@ bool physics::Vehicle::CabDeactivisation(bool const Enforce)
|
||||
}
|
||||
if (InactiveCabFlag & activation::pantographsup)
|
||||
{
|
||||
InactiveCabPantsCheck = true;
|
||||
inactiveCabPantsCheck = true;
|
||||
}
|
||||
if (InactiveCabFlag & activation::doorpermition)
|
||||
{
|
||||
|
||||
@@ -106,8 +106,8 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
|
||||
// the velocities along this vehicle's axis: the other vehicle's one is turned around when the vehicles face each
|
||||
// other (touch with the same ends), as in CouplerForce()
|
||||
auto const otherdirection{DirPatch(End, otherend)};
|
||||
auto velocity{V};
|
||||
auto othervehiclevelocity{othervehicle->V * otherdirection};
|
||||
auto velocity{travelSpeed};
|
||||
auto othervehiclevelocity{othervehicle->travelSpeed * otherdirection};
|
||||
// calculate collision force and new velocities for involved vehicles
|
||||
auto const VirtualCoupling{(thiscoupler.CouplingFlag == Coupling::none)};
|
||||
auto CCF{0.0};
|
||||
@@ -175,16 +175,16 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
|
||||
};
|
||||
if (false == wall(*this))
|
||||
{
|
||||
auto const accelerationchange{(velocity - V) / dt};
|
||||
AccS += accelerationchange * accelerationspike;
|
||||
V = velocity;
|
||||
auto const accelerationchange{(velocity - travelSpeed) / dt};
|
||||
accS += accelerationchange * accelerationspike;
|
||||
travelSpeed = velocity;
|
||||
}
|
||||
if (false == wall(*othervehicle))
|
||||
{
|
||||
auto const othervehiclenewvelocity{othervehiclevelocity * otherdirection}; // back along the other vehicle's axis
|
||||
auto const othervehicleaccelerationchange{(othervehiclenewvelocity - othervehicle->V) / dt};
|
||||
othervehicle->AccS += othervehicleaccelerationchange * accelerationspike;
|
||||
othervehicle->V = othervehiclenewvelocity;
|
||||
auto const othervehicleaccelerationchange{(othervehiclenewvelocity - othervehicle->travelSpeed) / dt};
|
||||
othervehicle->accS += othervehicleaccelerationchange * accelerationspike;
|
||||
othervehicle->travelSpeed = othervehiclenewvelocity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,11 +462,11 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
|
||||
auto const apart{End == VehicleEnd::front ? -1.0 : 1.0};
|
||||
if (false == wall)
|
||||
{
|
||||
V += apart * hit.impulse / mass;
|
||||
travelSpeed += apart * hit.impulse / mass;
|
||||
}
|
||||
if (false == otherwall)
|
||||
{
|
||||
othervehicle->V -= apart * hit.impulse / othermass * otherdirection;
|
||||
othervehicle->travelSpeed -= apart * hit.impulse / othermass * otherdirection;
|
||||
}
|
||||
record_hit(thiscoupler, hit.force, hit.duration);
|
||||
record_hit(othercoupler, hit.force, hit.duration);
|
||||
@@ -708,7 +708,7 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co
|
||||
track.buckle_curvature = Shape.buckle_curvature;
|
||||
track.damage = Track.DamageFlag;
|
||||
|
||||
auto const verdict{derailment_monitor.update(vehicle, track, V, Distance)};
|
||||
auto const verdict{derailment_monitor.update(vehicle, track, travelSpeed, Distance)};
|
||||
if (verdict.result == derailment::outcome::none)
|
||||
{
|
||||
return;
|
||||
@@ -725,7 +725,7 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co
|
||||
}
|
||||
derailment_reported = Track.Name;
|
||||
++derailment_reports;
|
||||
WriteLog("derailment monitor: " + Name + " " + derailment::report(verdict, vehicle, track, V, Track.Name != nullptr ? *Track.Name : std::string{}));
|
||||
WriteLog("derailment monitor: " + Name + " " + derailment::report(verdict, vehicle, track, travelSpeed, Track.Name != nullptr ? *Track.Name : std::string{}));
|
||||
}
|
||||
|
||||
void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track, std::string const *TrackName)
|
||||
@@ -743,7 +743,7 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
|
||||
MainSwitch(false, range_t::local);
|
||||
// the brake hoses tear: the brake pipe vents and the rest of the train brakes in emergency
|
||||
tear_brake_hoses(*this);
|
||||
ErrorLog("Bad driving: " + Name + " " + derailment::report(Verdict, Vehicle, Track, V, TrackName != nullptr ? *TrackName : std::string{}));
|
||||
ErrorLog("Bad driving: " + Name + " " + derailment::report(Verdict, Vehicle, Track, travelSpeed, TrackName != nullptr ? *TrackName : std::string{}));
|
||||
if (Track.buckle_curvature != 0.0)
|
||||
{
|
||||
ErrorLog(std::format("Bad driving: {} derailed on buckled track, the buckle bending the line by 1/{:.0f} m {} the curve", Name, 1.0 / std::abs(Track.buckle_curvature),
|
||||
@@ -761,7 +761,7 @@ void physics::Vehicle::rerail()
|
||||
DerailAcceleration = 0.0;
|
||||
DerailSide = 0;
|
||||
derailment_monitor.reset();
|
||||
derailment_distance = 0.0;
|
||||
derailmentDistance = 0.0;
|
||||
derailment_reported.reset();
|
||||
// nor derailed in a collision
|
||||
CollisionDerail = NONE;
|
||||
@@ -770,8 +770,8 @@ void physics::Vehicle::rerail()
|
||||
// its place on the road)
|
||||
if (TestFlag(CategoryFlag, 1))
|
||||
{
|
||||
OffsetTrackH = 0.0;
|
||||
OffsetTrackV = 0.0;
|
||||
offsetTrackH = 0.0;
|
||||
offsetTrackV = 0.0;
|
||||
}
|
||||
// a derailed vehicle which stopped sleeps (Global.physics_sleepheld) with the friction of the derailment in FStand and
|
||||
// where the derailment put it, until something wakes it: the physics on, for the friction of the rails and its place on
|
||||
@@ -783,7 +783,7 @@ void physics::Vehicle::repair_damage()
|
||||
{
|
||||
DamageFlag = {};
|
||||
equipmentFaults = {};
|
||||
WheelFlat = 0.0;
|
||||
wheelFlat = 0.0;
|
||||
brakes.alarmChain = false;
|
||||
// the crushed ends rebuilt
|
||||
for (auto &coupler : Couplers)
|
||||
@@ -800,15 +800,15 @@ void physics::Vehicle::Derail(DerailReason const Reason)
|
||||
eventFlag = true;
|
||||
MainSwitch(false, range_t::local);
|
||||
|
||||
auto const velocity{V};
|
||||
AccS *= 0.65;
|
||||
V *= 0.65;
|
||||
auto const velocity{travelSpeed};
|
||||
accS *= 0.65;
|
||||
travelSpeed *= 0.65;
|
||||
// physics.collisions new: the vehicles coupled to it lose the speed with it. the cut in a step stands for the
|
||||
// train coming to a stop with the vehicle; the coupled ones keeping their speed would run into it at a third of
|
||||
// the speed of the train, and crush their ends and ride up onto it for a hit no train had
|
||||
if (Global.collisions == global_settings::collision_model::physical && TestFlag(CategoryFlag, 1))
|
||||
{
|
||||
change_train_velocity(V - velocity);
|
||||
change_train_velocity(travelSpeed - velocity);
|
||||
}
|
||||
RunningShape.R = 0;
|
||||
if (Vel < 5.0)
|
||||
|
||||
@@ -734,7 +734,7 @@ bool physics::Vehicle::RunLoadCommand(VehicleCommand const Command, double CValu
|
||||
{
|
||||
OK = false; // będzie powtarzane aż się załaduje
|
||||
if (Vel < 0.1 // tolerance margin for small vehicle movements in the consist
|
||||
&& maxLoad > 0 && loadAmount < maxLoad * (1.0 + OverLoadFactor) && Distance(Loc, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0))
|
||||
&& maxLoad > 0 && loadAmount < maxLoad * (1.0 + OverLoadFactor) && Distance(location, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0))
|
||||
{ // ten peron/rampa
|
||||
|
||||
auto const loadname{ToLower(std::string{Argument})};
|
||||
@@ -756,7 +756,7 @@ bool physics::Vehicle::RunLoadCommand(VehicleCommand const Command, double CValu
|
||||
OK = false; // będzie powtarzane aż się rozładuje
|
||||
if (Vel < 0.1 // tolerance margin for small vehicle movements in the consist
|
||||
&& loadAmount > 0 // czy jest co rozladowac?
|
||||
&& Distance(Loc, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0))
|
||||
&& Distance(location, CommandIn.Location, Dim, Dim) < (CValue2 > 1.0 ? CValue2 : 10.0))
|
||||
{ // ten peron
|
||||
/*mozna to rozladowac*/
|
||||
OK = LoadingDone(-1.f * LoadSpeed, ToLower(std::string{Argument}));
|
||||
|
||||
@@ -1036,7 +1036,7 @@ void physics::Vehicle::CheckEIMIC(double dt)
|
||||
// the controller (EIMCtrlType 0): the position of the main controller, or the analog one, or the brake asked
|
||||
void physics::Vehicle::EIMICFromController(double const brakeDemand, double const offset, double const multiplier)
|
||||
{
|
||||
eimic = brakeDemand > 0.01 ? -brakeDemand : eimic_analog > 0.01 ? eimic_analog : (double)mainCtrlPos / (double)MainCtrlPosNo;
|
||||
eimic = brakeDemand > 0.01 ? -brakeDemand : eimicAnalog > 0.01 ? eimicAnalog : (double)mainCtrlPos / (double)MainCtrlPosNo;
|
||||
if (EIMCtrlAdditionalZeros || EIMCtrlEmergency)
|
||||
{
|
||||
if (eimic > 0.001)
|
||||
|
||||
@@ -42,7 +42,7 @@ double physics::Vehicle::Distance(const TLocation &Loc1, const TLocation &Loc2,
|
||||
|
||||
double physics::Vehicle::CouplerDist(physics::Vehicle const *Left, physics::Vehicle const *Right)
|
||||
{ // obliczenie odległości pomiędzy sprzęgami (kula!)
|
||||
return Distance(Left->Loc, Right->Loc, Left->Dim, Right->Dim); // odległość pomiędzy sprzęgami (kula!)
|
||||
return Distance(Left->location, Right->location, Left->Dim, Right->Dim); // odległość pomiędzy sprzęgami (kula!)
|
||||
};
|
||||
|
||||
bool physics::Vehicle::Attach(int ConnectNo, int ConnectToNr, physics::Vehicle *ConnectTo, CouplingSet CouplingType, bool Enforce, bool Audible)
|
||||
@@ -194,7 +194,7 @@ double physics::Vehicle::CouplerVelocityDifference(VehicleEnd const End, physics
|
||||
{
|
||||
// V runs along the vehicle's own axis, towards its front; the other vehicle's velocity is turned around when the
|
||||
// vehicles face each other (touch with the same ends)
|
||||
return V - Other.V * DirPatch(End, OtherEnd);
|
||||
return travelSpeed - Other.travelSpeed * DirPatch(End, OtherEnd);
|
||||
}
|
||||
|
||||
bool physics::Vehicle::AutomaticCouplingSafe(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const
|
||||
@@ -271,9 +271,9 @@ double physics::Vehicle::CouplerForce(VehicleEnd const End, double dt)
|
||||
auto const otherend{Neighbours[End].FacingEnd()};
|
||||
auto const &othercoupler{othervehicle->Couplers[otherend]};
|
||||
|
||||
auto const othervehiclemove{(othervehicle->dMoveLen * DirPatch(End, otherend))};
|
||||
auto const othervehiclemove{(othervehicle->moveLength * DirPatch(End, otherend))};
|
||||
auto const initialdistance{Neighbours[End].distance}; // odległość od sprzęgu sąsiada
|
||||
auto const distancedelta{(End == VehicleEnd::front ? othervehiclemove - dMoveLen : dMoveLen - othervehiclemove)};
|
||||
auto const distancedelta{(End == VehicleEnd::front ? othervehiclemove - moveLength : moveLength - othervehiclemove)};
|
||||
|
||||
// the ends crushed for good (physics.collisions new, see collision.h) let the buffers meet that much closer
|
||||
auto const crushed{thiscoupler.crush + othercoupler.crush};
|
||||
@@ -411,13 +411,13 @@ bool physics::Vehicle::coupler_physics_at(VehicleEnd const End) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Global.coupler_physics_all || CouplerPhysics)
|
||||
if (Global.coupler_physics_all || couplerPhysics)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// either vehicle of the pair covered takes the pair in, so both of them compute it the same way
|
||||
auto const *other{Neighbours[End].vehicle};
|
||||
return other != nullptr && other->physics->CouplerPhysics;
|
||||
return other != nullptr && other->physics->couplerPhysics;
|
||||
}
|
||||
|
||||
void physics::Vehicle::automatic_coupling(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd)
|
||||
@@ -499,8 +499,8 @@ double physics::Vehicle::coupler_force_physical(VehicleEnd const End, double con
|
||||
auto &state{thiscoupler.physics_state};
|
||||
|
||||
// the gap as it is now: the distance found at the start of the frame, and the movement of both vehicles since
|
||||
auto const othervehiclemove{othervehicle->dMoveLen * DirPatch(End, otherend)};
|
||||
auto const gap{Neighbours[End].distance + (End == VehicleEnd::front ? othervehiclemove - dMoveLen : dMoveLen - othervehiclemove)};
|
||||
auto const othervehiclemove{othervehicle->moveLength * DirPatch(End, otherend)};
|
||||
auto const gap{Neighbours[End].distance + (End == VehicleEnd::front ? othervehiclemove - moveLength : moveLength - othervehiclemove)};
|
||||
// the gap opens up when the front end falls behind the vehicle ahead of it, or the rear end runs ahead of the one behind
|
||||
auto const gaprate{CouplerVelocityDifference(End, *othervehicle, otherend) * DirF(End)};
|
||||
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
|
||||
|
||||
@@ -586,9 +586,9 @@ double physics::Vehicle::dieselelectric_dynamic_brake_limit() const
|
||||
{
|
||||
auto const &brake{DEDynamicBrake};
|
||||
auto limit{brake.max_force};
|
||||
if (brake.max_power > 0.0 && std::abs(V) > 0.0)
|
||||
if (brake.max_power > 0.0 && std::abs(travelSpeed) > 0.0)
|
||||
{
|
||||
limit = std::min(limit, brake.max_power / std::abs(V));
|
||||
limit = std::min(limit, brake.max_power / std::abs(travelSpeed));
|
||||
}
|
||||
if (brake.fade_high > brake.fade_low)
|
||||
{
|
||||
@@ -632,8 +632,8 @@ void physics::Vehicle::update_dieselelectric_dynamic_brake(double const dt)
|
||||
// would turn round each time the speed crosses zero, and in FTrain it never lets the stop of ComputeMovement() catch it
|
||||
void physics::Vehicle::apply_dieselelectric_dynamic_brake(double const dt)
|
||||
{
|
||||
auto const force{dt > 0.0 ? std::min(DEDynamicBrake.force, TotalMass * std::abs(V) / dt) : DEDynamicBrake.force};
|
||||
Ft = V > 0.0 ? -force : V < 0.0 ? force : 0.0;
|
||||
auto const force{dt > 0.0 ? std::min(DEDynamicBrake.force, TotalMass * std::abs(travelSpeed) / dt) : DEDynamicBrake.force};
|
||||
Ft = travelSpeed > 0.0 ? -force : travelSpeed < 0.0 ? force : 0.0;
|
||||
Fw = Ft / NPoweredAxles;
|
||||
Mw = Fw * WheelDiameter / 2.0;
|
||||
Mm = Mw / Transmision.Ratio;
|
||||
|
||||
@@ -276,7 +276,7 @@ bool physics::Vehicle::RadiostopSwitch(bool Switch)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Switch == false && std::abs(V) < 0.1)
|
||||
if (Switch == false && std::abs(travelSpeed) < 0.1)
|
||||
{
|
||||
// odblokowanie hamulca bezpieczenistwa tylko po zatrzymaniu
|
||||
radioStopFlag = Switch;
|
||||
|
||||
@@ -127,7 +127,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
|
||||
SetBraked();
|
||||
}
|
||||
|
||||
ActFlowSpeed = 0.0;
|
||||
actFlowSpeed = 0.0;
|
||||
brakes.SetHandlePositionReal(brakes.HandlePosition());
|
||||
|
||||
if (brakes.config.independentValveType == TBrakeHandle::Knorr)
|
||||
|
||||
@@ -672,7 +672,7 @@ void physics::Vehicle::DumbTractionForce(double const PosRatio)
|
||||
{
|
||||
if (Vel > 0.1)
|
||||
{
|
||||
Ft = std::min(1000.0 * Power / std::abs(V), Ftmax) * PosRatio;
|
||||
Ft = std::min(1000.0 * Power / std::abs(travelSpeed), Ftmax) * PosRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1197,9 +1197,9 @@ double physics::Vehicle::InductionMotorBrakeRatio(double const ActiveInverters,
|
||||
{
|
||||
double PosRatio;
|
||||
// ustalanie współczynnika blendingu do luzowania hamulca PN
|
||||
if (inductionMotor.state.maxForce * Sign(V) * DirAbsolute < -1)
|
||||
if (inductionMotor.state.maxForce * Sign(travelSpeed) * DirAbsolute < -1)
|
||||
{
|
||||
PosRatio = -Sign(V) * DirAbsolute * inductionMotor.state.force / (inductionMotor.braking.maxForce * std::max(edBCP, std::max(0.01, brakes.distributor->GetEDBCP())) / brakes.config.maxCylinderPressure[0]);
|
||||
PosRatio = -Sign(travelSpeed) * DirAbsolute * inductionMotor.state.force / (inductionMotor.braking.maxForce * std::max(edBCP, std::max(0.01, brakes.distributor->GetEDBCP())) / brakes.config.maxCylinderPressure[0]);
|
||||
PosRatio = std::clamp(PosRatio, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
@@ -1320,11 +1320,11 @@ void physics::Vehicle::InductionMotorForceLimits()
|
||||
if (inductionMotor.forceShare < 0)
|
||||
{
|
||||
inductionMotor.state.fullForce = std::min(inductionMotor.braking.maxPower * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(inductionMotor.braking.maxForce, inductionMotor.state.absoluteMaxForce));
|
||||
inductionMotor.state.maxForce = -Sign(V) * DirAbsolute*std::min(inductionMotor.braking.maxPower * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-inductionMotor.braking.maxForce * inductionMotor.forceShare, inductionMotor.state.absoluteMaxForce));
|
||||
inductionMotor.state.maxForce = -Sign(travelSpeed) * DirAbsolute*std::min(inductionMotor.braking.maxPower * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-inductionMotor.braking.maxForce * inductionMotor.forceShare, inductionMotor.state.absoluteMaxForce));
|
||||
double pr = inductionMotor.forceShare;
|
||||
if (inductionMotor.logForce)
|
||||
pr = -log(1 - 4 * pr) / log(5);
|
||||
inductionMotor.state.force = -Sign(V) * DirAbsolute*std::min(inductionMotor.braking.maxPower * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-inductionMotor.braking.maxForce * pr, inductionMotor.state.absoluteMaxForce));
|
||||
inductionMotor.state.force = -Sign(travelSpeed) * DirAbsolute*std::min(inductionMotor.braking.maxPower * 3.6 / (Vel != 0.0 ? Vel : 0.001), std::min(-inductionMotor.braking.maxForce * pr, inductionMotor.state.absoluteMaxForce));
|
||||
if (inductionMotor.inverterRatio < 1.0)
|
||||
inductionMotor.state.fullForce = 0;
|
||||
//*std::min(1,(Vel-inductionMotor.braking.offSpeed)/(inductionMotor.braking.fullSpeed-inductionMotor.braking.offSpeed))
|
||||
@@ -1512,7 +1512,7 @@ double physics::Vehicle::v2n(void)
|
||||
double n;
|
||||
double deltan = 0;
|
||||
|
||||
n = V / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s]
|
||||
n = travelSpeed / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s]
|
||||
deltan = n - nrot; //"pochodna" prędkości obrotowej
|
||||
/* if (SlippingWheels)
|
||||
if (std::abs(deltan) < 0.001)
|
||||
|
||||
@@ -183,7 +183,7 @@ void physics::ConsistBrakeBlending::ComputeDemand(Step &state, Vehicle &Lead, do
|
||||
// the holding brake lets go once power has been demanded for its delay (SBDReleaseDelay, none by default)
|
||||
auto const holdingbrakereleased { Lead.UpdateStopBrakeRelease( state.eimic, dt1 ) };
|
||||
if (Lead.ShuntMode && false == holdingbrakereleased || state.doorisopen /*||
|
||||
(Lead.V * Lead.DirAbsolute < -0.2)*/)
|
||||
(Lead.V() * Lead.DirAbsolute < -0.2)*/)
|
||||
{
|
||||
auto const sbd { ( Lead.brakes.spring.isActive && Lead.brakes.spring.releasesParking ? 0.0 : Lead.brakes.holding.deceleration ) };
|
||||
state.Fzad = std::max( state.Fzad, sbd * state.masa );
|
||||
|
||||
+58
-17
@@ -622,7 +622,8 @@ class Vehicle
|
||||
public:
|
||||
std::string chkPath;
|
||||
bool reload_FIZ();
|
||||
double dMoveLen = 0.0;
|
||||
double const &MoveLength() const { return moveLength; }
|
||||
void SetMoveLength(double const Value) { moveLength = Value; }
|
||||
/*---opis lokomotywy, wagonu itp*/
|
||||
/*--opis serii--*/
|
||||
int CategoryFlag = 1; /*1 - pociag, 2 - samochod, 4 - statek, 8 - samolot*/
|
||||
@@ -897,14 +898,16 @@ class Vehicle
|
||||
double SpeedCtrlValue = 0; /*wybrana predkosc jazdy na tempomacie*/
|
||||
/*--sekcja zmiennych*/
|
||||
/*--opis konkretnego egzemplarza taboru*/
|
||||
TLocation Loc{0.0, 0.0, 0.0}; // pozycja pojazdów do wyznaczenia odległości pomiędzy sprzęgami
|
||||
TLocation const &Loc() const { return location; } // pozycja pojazdów do wyznaczenia odległości pomiędzy sprzęgami
|
||||
void SetLoc(TLocation const Value) { location = Value; }
|
||||
TRotation Rot{0.0, 0.0, 0.0};
|
||||
glm::vec3 Front{};
|
||||
std::string Name; /*nazwa wlasna*/
|
||||
ByEnd<TCoupling> Couplers; // urzadzenia zderzno-sprzegowe, polaczenia miedzy wagonami
|
||||
// the physical coupler model covers the vehicle: it's in the player's train or in one the player's train closes in on
|
||||
// (vehicle_table::update_coupler_physics()); with couplerphysics all in eu07.ini every vehicle is covered
|
||||
bool CouplerPhysics{false};
|
||||
bool const &CouplerPhysics() const { return couplerPhysics; }
|
||||
void SetCouplerPhysics(bool const Value) { couplerPhysics = Value; }
|
||||
ByEnd<neighbour_data> Neighbours; // potential collision sources
|
||||
// something out of the ordinary happened (the line breaker knocked out, a derailment), for the sounds to follow up
|
||||
bool EventFlag() const { return eventFlag; }
|
||||
@@ -914,26 +917,41 @@ class Vehicle
|
||||
int SoundFlag() const { return soundFlag; }
|
||||
void ClearSoundFlags() { soundFlag = 0; }
|
||||
int AIFlag{0}; // HACK: events of interest for consist owner
|
||||
double DistCounter = 0.0; /*! licznik kilometrow */
|
||||
double const &DistCounter() const { return distCounter; } /*! licznik kilometrow */
|
||||
void SetDistCounter(double const Value) { distCounter = Value; }
|
||||
// the criteria of derailment (physics.derailment new), and the distance travelled since they were checked [m]
|
||||
derailment::monitor derailment_monitor;
|
||||
double derailment_distance = 0.0;
|
||||
double const &DerailmentDistance() const { return derailmentDistance; }
|
||||
void SetDerailmentDistance(double const Value) { derailmentDistance = Value; }
|
||||
// physics.derailment monitor: the name of the track the criteria were last reported on (one report on a track), and
|
||||
// how many reports there were
|
||||
std::optional<std::string const *> derailment_reported;
|
||||
int derailment_reports = 0;
|
||||
odometer::reading Odometer; // total distance run, kept between the sessions (eu07/maszyna#72)
|
||||
std::pair<double, double> EnergyMeter; // energy <drawn, returned> from grid [kWh]
|
||||
double V = 0.0; // predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
|
||||
double const &V() const { return travelSpeed; } // predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
|
||||
void SetV(double const Value) { travelSpeed = Value; }
|
||||
double Vel = 0.0; // moduł prędkości w [km/h], używany przez AI
|
||||
double AccS = 0.0; // efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły)
|
||||
double const &AccS() const { return accS; } // efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły)
|
||||
void SetAccS(double const Value) { accS = Value; }
|
||||
double AccSVBased{}; // tangential acceleration calculated from velocity change
|
||||
double AccN = 0.0; // przyspieszenie normalne w [m/s^2]
|
||||
double AccVert = 0.0; // vertical acceleration
|
||||
double const &AccN() const { return accN; } // przyspieszenie normalne w [m/s^2]
|
||||
void SetAccN(double const Value) { accN = Value; }
|
||||
double const &AccVert() const { return accVert; } // vertical acceleration
|
||||
void SetAccVert(double const Value) { accVert = Value; }
|
||||
// a jolt of the track under the vehicle: up and down, or along and across (a switch)
|
||||
void ShakeVertically(double const Acceleration) { accVert += Acceleration; }
|
||||
void ShakeHorizontally(double const Acceleration)
|
||||
{
|
||||
accS += Acceleration;
|
||||
accN += Acceleration;
|
||||
}
|
||||
double nrot = 0.0; // predkosc obrotowa kol (obrotow na sekunde)
|
||||
double nrot_eps = 0.0; // przyspieszenie kątowe kół (bez kierunku)
|
||||
double WheelFlat = 0.0;
|
||||
bool TruckHunting{true}; // enable/disable truck hunting calculation
|
||||
double const &WheelFlat() const { return wheelFlat; }
|
||||
void SetWheelFlat(double const Value) { wheelFlat = Value; }
|
||||
bool const &TruckHunting() const { return truckHunting; } // enable/disable truck hunting calculation
|
||||
void SetTruckHunting(bool const Value) { truckHunting = Value; }
|
||||
/*! rotacja kol [obr/s]*/
|
||||
double EnginePower = 0.0; /*! chwilowa moc silnikow*/
|
||||
double dL = 0.0;
|
||||
@@ -973,7 +991,8 @@ class Vehicle
|
||||
bool TUHEX_ResChange = false; /*czy zmiana rezystancji hamowania ED - odwzbudzanie*/
|
||||
bool TUHEX_Active = false; /*czy hamowanie ED wywołane z zewnątrz*/
|
||||
// NapUdWsp: integer;
|
||||
double ActFlowSpeed = 0.0; /*szybkosc stabilizatora*/
|
||||
double const &ActFlowSpeed() const { return actFlowSpeed; } /*szybkosc stabilizatora*/
|
||||
void SetActFlowSpeed(double const Value) { actFlowSpeed = Value; }
|
||||
|
||||
DamageSet DamageFlag; // the damage of the vehicle
|
||||
EquipmentFaultSet equipmentFaults; // the faults of the equipment set on the vehicle (SetEquipmentFaults())
|
||||
@@ -986,8 +1005,10 @@ class Vehicle
|
||||
|
||||
TTrackShape RunningShape; /*geometria toru po ktorym jedzie pojazd*/
|
||||
TTrackParam RunningTrack; /*parametry toru po ktorym jedzie pojazd*/
|
||||
double OffsetTrackH = 0.0;
|
||||
double OffsetTrackV = 0.0; /*przesuniecie poz. i pion. w/m osi toru*/
|
||||
double const &OffsetTrackH() const { return offsetTrackH; }
|
||||
void SetOffsetTrackH(double const Value) { offsetTrackH = Value; }
|
||||
double const &OffsetTrackV() const { return offsetTrackV; } /*przesuniecie poz. i pion. w/m osi toru*/
|
||||
void SetOffsetTrackV(double const Value) { offsetTrackV = Value; }
|
||||
|
||||
/*-zmienne dla lokomotyw*/
|
||||
bool ReleaserEnabledOnlyAtNoPowerPos{false};
|
||||
@@ -1013,12 +1034,14 @@ class Vehicle
|
||||
} // czy aktualna kabina jest na pewno tą, z której można sterować
|
||||
bool AutomaticCabActivation = true; // czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny
|
||||
int InactiveCabFlag = 0; // co sie dzieje przy dezaktywacji kabiny
|
||||
bool InactiveCabPantsCheck = false; // niech DynamicObject sprawdzi pantografy
|
||||
bool const &InactiveCabPantsCheck() const { return inactiveCabPantsCheck; } // niech DynamicObject sprawdzi pantografy
|
||||
void SetInactiveCabPantsCheck(bool const Value) { inactiveCabPantsCheck = Value; }
|
||||
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 InsideConsist = false;
|
||||
bool const &InsideConsist() const { return insideConsist; }
|
||||
void SetInsideConsist(bool const Value) { insideConsist = Value; }
|
||||
/*-zmienne dla lokomotywy elektrycznej*/
|
||||
TTractionParam RunningTraction; /*parametry sieci trakcyjnej najblizej lokomotywy*/
|
||||
double enrot = 0.0; // ilosc obrotow silnika
|
||||
@@ -1055,7 +1078,8 @@ class Vehicle
|
||||
|
||||
/*- zmienne dla lokomotyw z silnikami indukcyjnymi -*/
|
||||
double eimic = 0; /*aktualna pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
double eimic_analog = 0; /*pozycja zadajnika analogowa*/
|
||||
double const &EimicAnalog() const { return eimicAnalog; } /*pozycja zadajnika analogowa*/
|
||||
void SetEimicAnalog(double const Value) { eimicAnalog = Value; }
|
||||
double eimic_real = 0; /*faktycznie uzywana pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
double eimic_step_progress{0.0}; // the part of the next UniCtrlValStep the controller has covered so far
|
||||
double eim_localbrake = 0; /*nastawa hamowania dodatkowego pneumatycznego lokomotywy*/
|
||||
@@ -1817,6 +1841,23 @@ class Vehicle
|
||||
|
||||
private:
|
||||
// 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};
|
||||
double offsetTrackH = 0.0;
|
||||
double offsetTrackV = 0.0;
|
||||
double accS = 0.0;
|
||||
double accN = 0.0;
|
||||
double accVert = 0.0;
|
||||
double distCounter = 0.0;
|
||||
double moveLength = 0.0;
|
||||
double wheelFlat = 0.0;
|
||||
bool truckHunting{true};
|
||||
double derailmentDistance = 0.0;
|
||||
bool insideConsist = false;
|
||||
bool couplerPhysics{false};
|
||||
bool inactiveCabPantsCheck = false;
|
||||
double eimicAnalog = 0;
|
||||
double actFlowSpeed = 0.0;
|
||||
float maxLoad = 0.f;
|
||||
bool eventFlag = false;
|
||||
int soundFlag = 0;
|
||||
|
||||
@@ -225,7 +225,7 @@ blackbox::vehicle_state state_of(TDynamicObject const &Vehicle, std::uint32_t co
|
||||
state.position = glm::vec3{Vehicle.GetPosition()};
|
||||
auto const front{Vehicle.VectorFront()};
|
||||
state.heading = static_cast<float>(std::atan2(front.x, front.z));
|
||||
state.speed_kmh = static_cast<float>(Vehicle.physics->V * 3.6);
|
||||
state.speed_kmh = static_cast<float>(Vehicle.physics->V() * 3.6);
|
||||
state.driving = driver_of(Vehicle);
|
||||
return state;
|
||||
}
|
||||
@@ -424,7 +424,7 @@ void blackbox_recorder::write_cab() {
|
||||
sample.time = m_time;
|
||||
sample.vehicle = vehicle_id(vehicle);
|
||||
sample.position = vehicle->GetPosition();
|
||||
sample.speed_kmh = static_cast<float>(occupied->V * 3.6);
|
||||
sample.speed_kmh = static_cast<float>(occupied->V() * 3.6);
|
||||
// of the wheels as they turn, which the speedometer shows: apart from that of the vehicle when they slip or skid.
|
||||
// those of the powered vehicle, as the speedometer has it (TTrain::DynamicSet), which in a unit driven from an
|
||||
// unpowered car is another one, maybe facing the other way: signed as the occupied one's speed
|
||||
@@ -432,8 +432,8 @@ void blackbox_recorder::write_cab() {
|
||||
auto const *powered{train->Dynamic()->FindPowered()};
|
||||
auto const facing{powered->DirectionGet() * vehicle->DirectionGet()};
|
||||
sample.wheel_speed_kmh = static_cast<float>(facing * M_PI * powered->physics->WheelDiameter * powered->physics->nrot * 3.6);
|
||||
sample.acceleration = static_cast<float>(controlling->AccS);
|
||||
sample.lateral_acceleration = static_cast<float>(occupied->AccN);
|
||||
sample.acceleration = static_cast<float>(controlling->AccS());
|
||||
sample.lateral_acceleration = static_cast<float>(occupied->AccN());
|
||||
if (owner != nullptr && owner->is_train()) {
|
||||
auto const order{owner->order_current()};
|
||||
sample.movement = order.HasAny(DriverOrder::obeyTrain) ? blackbox::movements::train :
|
||||
@@ -441,7 +441,7 @@ void blackbox_recorder::write_cab() {
|
||||
sample.light_hint_head = static_cast<std::int16_t>(owner->light_hint(VehicleEnd::front));
|
||||
sample.light_hint_tail = static_cast<std::int16_t>(owner->light_hint(VehicleEnd::rear));
|
||||
}
|
||||
sample.odometer_km = static_cast<float>(occupied->DistCounter);
|
||||
sample.odometer_km = static_cast<float>(occupied->DistCounter());
|
||||
sample.driving = driver_of(*vehicle);
|
||||
sample.flags = (FreeFlyModeFlag ? 0 : blackbox::cab_flags::in_cab) | (owner != nullptr && owner->is_active() ? blackbox::cab_flags::ai_valid : 0) |
|
||||
(controlling->SecuritySystem.is_blinking() ? blackbox::cab_flags::alerter_blinking : 0) |
|
||||
@@ -598,7 +598,7 @@ void blackbox_recorder::look_at_derailments() {
|
||||
state.cause = cause_of(motion.reason());
|
||||
state.position = vehicle->GetPosition();
|
||||
state.heading = static_cast<float>(std::atan2(vehicle->VectorFront().x, vehicle->VectorFront().z));
|
||||
state.speed_kmh = static_cast<float>(vehicle->physics->V * 3.6);
|
||||
state.speed_kmh = static_cast<float>(vehicle->physics->V() * 3.6);
|
||||
state.offset = static_cast<float>(vehicle->off_track_offset());
|
||||
state.roll = static_cast<float>(motion.roll());
|
||||
state.travelled = static_cast<float>(motion.travelled());
|
||||
|
||||
@@ -437,10 +437,10 @@ void state_manager::process_commands() {
|
||||
while (vehicle) {
|
||||
// no damage, back on the rails with the state of the derailment cleared
|
||||
vehicle->physics->repair_damage();
|
||||
vehicle->physics->V = 0.000001; // HACK: force vehicle position re-calculation
|
||||
vehicle->physics->DistCounter = 0.0;
|
||||
vehicle->physics->OffsetTrackH = 0.0;
|
||||
vehicle->physics->OffsetTrackV = 0.0;
|
||||
vehicle->physics->SetV(0.000001); // HACK: force vehicle position re-calculation
|
||||
vehicle->physics->SetDistCounter(0.0);
|
||||
vehicle->physics->SetOffsetTrackH(0.0);
|
||||
vehicle->physics->SetOffsetTrackV(0.0);
|
||||
|
||||
// pantographs
|
||||
for( auto idx = 0; idx < vehicle->iAnimType[ ANIM_PANTS ]; ++idx ) {
|
||||
|
||||
@@ -19,14 +19,14 @@ vehicle &consist::add(definition const &Definition, int Cab, CouplingSet const c
|
||||
if (false == m_vehicles.empty()) {
|
||||
auto &last{m_vehicles.back()->physics()};
|
||||
position = m_positions.back() - 0.5 * (last.Dim.L + physics.Dim.L) - Gap;
|
||||
physics.Loc = TLocation{position, 0.0, 0.0};
|
||||
physics.SetLoc(TLocation{position, 0.0, 0.0});
|
||||
if (false == couplings.Empty()) {
|
||||
last.Attach(VehicleEnd::rear, VehicleEnd::front, &physics, couplings, true, false);
|
||||
physics.Attach(VehicleEnd::front, VehicleEnd::rear, &last, couplings, true, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
physics.Loc = TLocation{position, 0.0, 0.0};
|
||||
physics.SetLoc(TLocation{position, 0.0, 0.0});
|
||||
}
|
||||
m_vehicles.push_back(std::move(added));
|
||||
m_positions.push_back(position);
|
||||
@@ -51,7 +51,7 @@ void consist::update_neighbours() {
|
||||
auto const distance{physics::Vehicle::CouplerDist(&physics, &otherPhysics) - physics.Couplers[end].adapter_length -
|
||||
otherPhysics.Couplers[otherend].adapter_length};
|
||||
// a vehicle not coupled is a collision source when it's within the range the game scans
|
||||
if (physics.Couplers[end].Connected == nullptr && distance > std::max(10.0, std::abs(physics.V)) + 40.0) {
|
||||
if (physics.Couplers[end].Connected == nullptr && distance > std::max(10.0, std::abs(physics.V())) + 40.0) {
|
||||
neighbour = neighbour_data();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,20 +61,20 @@ constexpr double pipe_back{4.9};
|
||||
|
||||
void figures::sample(double Time, physics::Vehicle const &Vehicle) {
|
||||
auto &part{m_parts.back()};
|
||||
auto const speed{Vehicle.V * 3.6};
|
||||
auto const speed{Vehicle.V() * 3.6};
|
||||
auto const pipe{Vehicle.brakePipe.Pressure()};
|
||||
if (false == part.sampled) {
|
||||
part.sampled = true;
|
||||
// from the last step of the part before, so the parts add up to the run
|
||||
part.start = m_last_time < 0.0 ? Time : m_last_time;
|
||||
part.speed_start = m_last_time < 0.0 ? speed : m_last_speed;
|
||||
part.distance_start = m_last_time < 0.0 ? Vehicle.DistCounter : m_last_distance;
|
||||
part.distance_start = m_last_time < 0.0 ? Vehicle.DistCounter() : m_last_distance;
|
||||
part.pipe_lowest = pipe;
|
||||
}
|
||||
part.end = Time;
|
||||
part.speed_end = speed;
|
||||
part.speed_peak = std::max(part.speed_peak, std::abs(speed));
|
||||
part.distance_end = Vehicle.DistCounter;
|
||||
part.distance_end = Vehicle.DistCounter();
|
||||
if (part.stopped < 0.0 && std::abs(part.speed_start) > 1.0 && std::abs(speed) < 0.05) {
|
||||
part.stopped = Time - part.start;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ void figures::sample(double Time, physics::Vehicle const &Vehicle) {
|
||||
|
||||
m_last_time = Time;
|
||||
m_last_speed = speed;
|
||||
m_last_distance = Vehicle.DistCounter;
|
||||
m_last_distance = Vehicle.DistCounter();
|
||||
// which figures the vehicle has, over the whole run, so each part has the same ones
|
||||
m_moved |= std::abs(speed) >= 0.05;
|
||||
m_piped |= pipe >= 0.1;
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace channels {
|
||||
|
||||
std::vector<channel> motion() {
|
||||
return {
|
||||
{"V", [](auto const &M) { return M.V; }},
|
||||
{"DistCounter", [](auto const &M) { return M.DistCounter; }},
|
||||
{"AccS", [](auto const &M) { return M.AccS; }},
|
||||
{"V", [](auto const &M) { return M.V(); }},
|
||||
{"DistCounter", [](auto const &M) { return M.DistCounter(); }},
|
||||
{"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; }},
|
||||
@@ -278,7 +278,7 @@ void trace::sample(double Time, physics::Vehicle const &Vehicle) {
|
||||
m_last_event.empty() ? std::string{} : std::format(", after \"{}\"", m_last_event), invariant.explain(Vehicle)));
|
||||
}
|
||||
}
|
||||
m_before = {Time, Vehicle.V, Vehicle.DistCounter};
|
||||
m_before = {Time, Vehicle.V(), Vehicle.DistCounter()};
|
||||
m_sampled = true;
|
||||
m_figures.sample(Time, Vehicle);
|
||||
|
||||
|
||||
+10
-10
@@ -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()}});
|
||||
}},
|
||||
@@ -103,20 +103,20 @@ std::vector<invariant> const &invariants() {
|
||||
// the speed of the step is between the speeds at its ends, or a bit off it, as the movement is integrated;
|
||||
// through a standstill, down to none
|
||||
auto const dt{Time - Before->time};
|
||||
auto const covered{(M.DistCounter - Before->DistCounter) * 1000.0};
|
||||
auto const lowest{M.V * Before->V > 0.0 ? std::min(std::abs(M.V), std::abs(Before->V)) : 0.0};
|
||||
auto const highest{std::max(std::abs(M.V), std::abs(Before->V))};
|
||||
auto const covered{(M.DistCounter() - Before->distCounter) * 1000.0};
|
||||
auto const lowest{M.V() * Before->v > 0.0 ? std::min(std::abs(M.V()), std::abs(Before->v)) : 0.0};
|
||||
auto const highest{std::max(std::abs(M.V()), std::abs(Before->v))};
|
||||
return covered >= lowest * dt * 0.9 - 0.01 && covered <= highest * dt * 1.1 + 0.01;
|
||||
},
|
||||
[](auto const &M) { return values({{"V", M.V}, {"DistCounter", M.DistCounter}}); }},
|
||||
[](auto const &M) { return values({{"V", M.V()}, {"DistCounter", M.DistCounter()}}); }},
|
||||
{"no acceleration over 5 g",
|
||||
[](auto const &M, double Time, auto const *Before) {
|
||||
return Before == nullptr || std::abs(M.V - Before->V) <= highest_acceleration * (Time - Before->time) + 0.01;
|
||||
return Before == nullptr || std::abs(M.V() - Before->v) <= highest_acceleration * (Time - Before->time) + 0.01;
|
||||
},
|
||||
[](auto const &M) { return values({{"V", M.V}, {"AccS", M.AccS}}); }},
|
||||
[](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;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace test {
|
||||
// what the rules over time need of the step before
|
||||
struct snapshot {
|
||||
double time;
|
||||
double V;
|
||||
double DistCounter;
|
||||
double v;
|
||||
double distCounter;
|
||||
};
|
||||
|
||||
// a rule of physics or of the vehicle's circuits, which holds for every vehicle after every step, whatever
|
||||
|
||||
@@ -195,7 +195,7 @@ TEST_CASE("cab: a road vehicle moved across its road") {
|
||||
bus.step(test::track{0.15, 0.0, 0.0, 2, 1, 7.0});
|
||||
REQUIRE(TestFlag(bus->CategoryFlag, 2));
|
||||
CHECK(bus->ChangeOffsetH(0.5));
|
||||
CHECK(bus->OffsetTrackH == doctest::Approx(0.5));
|
||||
CHECK(bus->OffsetTrackH() == doctest::Approx(0.5));
|
||||
// off the edge of the road
|
||||
CHECK_FALSE(bus->ChangeOffsetH(100.0));
|
||||
vehicle eu07{definition::fiz("4e_v1/4e")};
|
||||
|
||||
@@ -587,7 +587,7 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai
|
||||
locomotive->DirectionForward();
|
||||
}
|
||||
test::drive(driver, line, 10.0);
|
||||
auto const start{empty->DistCounter};
|
||||
auto const start{empty->DistCounter()};
|
||||
auto pushed{0.0};
|
||||
auto worst{0.0};
|
||||
auto const watch = [&]() {
|
||||
@@ -608,7 +608,7 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai
|
||||
test::drive(driver, line, 1.0);
|
||||
watch();
|
||||
}
|
||||
auto const rolled{(empty->DistCounter - start) * 1000.0};
|
||||
auto const rolled{(empty->DistCounter() - start) * 1000.0};
|
||||
MESSAGE(std::format("ST44 pushing at up to {:.0f} kN, the empty 3WL at Y/Q {:.2f}, rolled {:.3f} m", pushed / 1000.0, worst, rolled));
|
||||
REQUIRE(worst >= derailment::climbing_limit);
|
||||
CHECK(rolled < 0.5);
|
||||
@@ -666,10 +666,10 @@ TEST_CASE("collisions: a train propelling an empty wagon into a braked one in a
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
add_loaded(train, consist::full_coupling, 15.0, 0.0);
|
||||
}
|
||||
auto const start{empty->DistCounter};
|
||||
auto const start{empty->DistCounter()};
|
||||
train.run(10.0, curve);
|
||||
MESSAGE(std::format("the empty 3WL: derailed {}, {}, rolled {:.2f} m", derailed(empty.physics()), empty->CollisionDerail == COLLISION_PUSHED_OFF ? "pushed off" : "not pushed off",
|
||||
(empty->DistCounter - start) * 1000.0));
|
||||
(empty->DistCounter() - start) * 1000.0));
|
||||
CHECK(empty->CollisionDerail == COLLISION_PUSHED_OFF);
|
||||
}
|
||||
|
||||
@@ -900,10 +900,10 @@ TEST_CASE("collisions: a vehicle off the rails by the new model stays in the cha
|
||||
auto &locomotive{train.add(definition::fiz("4e_v1/4e"), 0, Coupling::none, 10.0, 0.5)};
|
||||
wagon->derail_in_collision(COLLISION_PUSHED_OFF, "for the test");
|
||||
REQUIRE(derailed(wagon.physics()));
|
||||
auto const before{wagon->TotalMass * wagon->V + locomotive->TotalMass * locomotive->V};
|
||||
auto const before{wagon->TotalMass * wagon->V() + locomotive->TotalMass * locomotive->V()};
|
||||
// the hit is over within a second, the friction of the derailed wagon slows the pair down over it
|
||||
train.run(1.0);
|
||||
auto const after{wagon->TotalMass * wagon->V + locomotive->TotalMass * locomotive->V};
|
||||
auto const after{wagon->TotalMass * wagon->V() + locomotive->TotalMass * locomotive->V()};
|
||||
// pushed along, not a wall the locomotive bounces off
|
||||
CHECK(wagon.speed() > 1.0);
|
||||
CHECK(locomotive.speed() > 0.0);
|
||||
@@ -1346,7 +1346,7 @@ train_damage damage_of(consist &Train) {
|
||||
double kinetic_of(consist &Train) {
|
||||
auto energy{0.0};
|
||||
for (std::size_t i = 0; i < Train.size(); ++i) {
|
||||
energy += 0.5 * Train[i]->TotalMass * Train[i]->V * Train[i]->V;
|
||||
energy += 0.5 * Train[i]->TotalMass * Train[i]->V() * Train[i]->V();
|
||||
}
|
||||
return energy;
|
||||
}
|
||||
@@ -1488,15 +1488,15 @@ TEST_CASE("collisions: a pair parting at the start of the step isn't crushed (l0
|
||||
vehicle->forces(dt);
|
||||
}
|
||||
REQUIRE((front->Couplers[VehicleEnd::rear].closing < 0.0) == parting);
|
||||
back->V = 25.0 * kmh;
|
||||
back->SetV(25.0 * kmh);
|
||||
for (auto *vehicle : {&front, &back}) {
|
||||
vehicle->move({}, dt, (*vehicle)->Loc, 5.0);
|
||||
vehicle->move({}, dt, (*vehicle)->Loc(), 5.0);
|
||||
}
|
||||
auto const crush{front->Couplers[VehicleEnd::rear].crush + back->Couplers[VehicleEnd::front].crush};
|
||||
if (parting) {
|
||||
CHECK(crush == 0.0);
|
||||
// the legacy collision pushed them apart
|
||||
CHECK(back->V < 25.0 * kmh);
|
||||
CHECK(back->V() < 25.0 * kmh);
|
||||
}
|
||||
else {
|
||||
// closing in from a stand, the knock is a hit past the energy of the buffers
|
||||
|
||||
@@ -239,7 +239,7 @@ TEST_CASE("commands: every command run on every real vehicle") {
|
||||
vehicle real{definition::fiz(path), 0.0, "test", 1};
|
||||
// loading takes place where the command was given, which comes with the command (PutCommand). a
|
||||
// vehicle gets none before its first one, TCommand::Location is left uninitialised
|
||||
real->CommandIn.Location = real->Loc;
|
||||
real->CommandIn.Location = real->Loc();
|
||||
auto done{false};
|
||||
auto channels{state()};
|
||||
channels.emplace_back("Done", [&done](auto const &) { return flag(done); });
|
||||
@@ -515,21 +515,21 @@ TEST_CASE("commands: a wagon loaded and unloaded by commands, which repeat until
|
||||
// the game gives the commands of loading through PutCommand, with the place of the platform or the ramp
|
||||
SUBCASE("loading 12 tonnes of coal") {
|
||||
trace.mark("load");
|
||||
wagon->PutCommand("Load=Coal", 12, 0, wagon->Loc);
|
||||
wagon->PutCommand("Load=Coal", 12, 0, wagon->Loc());
|
||||
wagon.run(30.0);
|
||||
CHECK(wagon->LoadAmount() == doctest::Approx(12.0).epsilon(0.1));
|
||||
CHECK(wagon->LoadType.name == "coal");
|
||||
CHECK(wagon->CommandIn.Command == VehicleCommand::none);
|
||||
|
||||
trace.mark("unload");
|
||||
wagon->PutCommand("UnLoad=Coal", 20, 0, wagon->Loc);
|
||||
wagon->PutCommand("UnLoad=Coal", 20, 0, wagon->Loc());
|
||||
wagon.run(200.0);
|
||||
CHECK(wagon->LoadAmount() == doctest::Approx(0.0));
|
||||
CHECK(wagon->LoadType.name.empty());
|
||||
trace.check();
|
||||
}
|
||||
SUBCASE("a load the wagon doesn't take stays a command, not done") {
|
||||
wagon->PutCommand("Load=passengers", 12, 0, wagon->Loc);
|
||||
wagon->PutCommand("Load=passengers", 12, 0, wagon->Loc());
|
||||
wagon.run(10.0);
|
||||
CHECK(wagon->LoadAmount() == doctest::Approx(0.0));
|
||||
CHECK_FALSE(wagon->CommandIn.Command == VehicleCommand::none);
|
||||
@@ -541,7 +541,7 @@ TEST_CASE("commands: a wagon loaded and unloaded by commands, which repeat until
|
||||
CHECK(wagon->LastLoadChangeTime == doctest::Approx(0.0));
|
||||
}
|
||||
SUBCASE("unloading an empty wagon isn't done either") {
|
||||
wagon->PutCommand("UnLoad=Coal", 12, 0, wagon->Loc);
|
||||
wagon->PutCommand("UnLoad=Coal", 12, 0, wagon->Loc());
|
||||
wagon.run(10.0);
|
||||
CHECK_FALSE(wagon->CommandIn.Command == VehicleCommand::none);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ TEST_CASE("consist: every real electric unit driven whole from its front cab") {
|
||||
test::drive_cycle(test::driving(train), test::track{0.15, 0.0, test::catenary_3kv}, *traces.front());
|
||||
// every unit runs off and is braked to a stop, but the EN57, which doesn't get ready (COVERAGE.md)
|
||||
auto const &leading{train[0].physics()};
|
||||
CHECK((leading.DistCounter > 0.2 /* km */) != (std::string{unit.name} == "en57"));
|
||||
CHECK((leading.DistCounter() > 0.2 /* km */) != (std::string{unit.name} == "en57"));
|
||||
CHECK(leading.Vel < 0.5);
|
||||
for (auto const &trace : traces) {
|
||||
trace->check();
|
||||
|
||||
@@ -96,7 +96,7 @@ TEST_CASE("consist braking: with the controller at neutral and the train release
|
||||
unit.step(10.0);
|
||||
REQUIRE(unit.cab().eimic == doctest::Approx(0.0));
|
||||
for (auto *car : unit.cars) {
|
||||
car->V = 10.0; // [m/s], above the speed the holding brake comes in at
|
||||
car->SetV(10.0); // [m/s], above the speed the holding brake comes in at
|
||||
car->Vel = 36.0;
|
||||
}
|
||||
unit.blending.Update(unit.cab(), unit.cars, {}, 0.01);
|
||||
|
||||
@@ -211,7 +211,7 @@ TEST_CASE("controls: reversing and changing the cab of a locomotive") {
|
||||
// the speed along the vehicle, its front ahead
|
||||
notch_up(scenario, 10, 1.5);
|
||||
scenario.wait(10.0);
|
||||
CHECK(cab.V > 3.0);
|
||||
CHECK(cab.V() > 3.0);
|
||||
notch_down(scenario);
|
||||
brake_to_stop(scenario);
|
||||
CHECK(stopped(scenario));
|
||||
@@ -222,7 +222,7 @@ TEST_CASE("controls: reversing and changing the cab of a locomotive") {
|
||||
CHECK(cab.DirActive < 0);
|
||||
notch_up(scenario, 10, 1.5);
|
||||
scenario.wait(10.0);
|
||||
CHECK(cab.V < -3.0);
|
||||
CHECK(cab.V() < -3.0);
|
||||
notch_down(scenario);
|
||||
brake_to_stop(scenario);
|
||||
CHECK(stopped(scenario));
|
||||
@@ -241,7 +241,7 @@ TEST_CASE("controls: reversing and changing the cab of a locomotive") {
|
||||
notch_up(scenario, 10, 1.5);
|
||||
scenario.wait(10.0);
|
||||
// forward from the rear cab is the vehicle's backward
|
||||
CHECK(cab.V < -3.0);
|
||||
CHECK(cab.V() < -3.0);
|
||||
notch_down(scenario);
|
||||
brake_to_stop(scenario);
|
||||
CHECK(stopped(scenario));
|
||||
@@ -515,7 +515,7 @@ TEST_CASE("controls: a locomotive running into a standing wagon") {
|
||||
// the wagon derails where it stands
|
||||
auto const derailed{speed > 30.0};
|
||||
CHECK(wagon.DamageFlag.HasAll(VehicleDamage::derailed) == derailed);
|
||||
CHECK((std::abs(wagon.DistCounter) > 0.0001) != derailed);
|
||||
CHECK((std::abs(wagon.DistCounter()) > 0.0001) != derailed);
|
||||
CHECK(stopped(scenario));
|
||||
scenario.check();
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ TEST_CASE("coupler physics: with couplerphysics yes, only the pairs with a vehic
|
||||
}
|
||||
SUBCASE("one covered: both compute the pair physically") {
|
||||
// as the player's train closing in on the other one
|
||||
moving->CouplerPhysics = true;
|
||||
moving->SetCouplerPhysics(true);
|
||||
pair.run(1.0);
|
||||
CHECK(moving->coupler_physics_at(VehicleEnd::front));
|
||||
CHECK(standing->coupler_physics_at(VehicleEnd::rear));
|
||||
@@ -528,7 +528,7 @@ TEST_CASE("coupler physics: with couplerphysics yes, only the pairs with a vehic
|
||||
}
|
||||
SUBCASE("the setting off: the legacy model, covered or not") {
|
||||
flag_setting const off{Global.coupler_physics, false};
|
||||
moving->CouplerPhysics = true;
|
||||
moving->SetCouplerPhysics(true);
|
||||
CHECK_FALSE(moving->coupler_physics_at(VehicleEnd::front));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,14 +420,14 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n
|
||||
CHECK(eu07vehicle->DerailCause == dm::cause::overturned);
|
||||
CHECK(eu07vehicle->DerailAcceleration > eu07_tipping);
|
||||
CHECK(eu07vehicle->leaves_track());
|
||||
eu07vehicle->OffTrack.begin(leaving(eu07vehicle->V, eu07vehicle->DerailCause, 1, eu07vehicle->DerailAcceleration), eu07(), ballast);
|
||||
eu07vehicle->OffTrack.begin(leaving(eu07vehicle->V(), eu07vehicle->DerailCause, 1, eu07vehicle->DerailAcceleration), eu07(), ballast);
|
||||
CHECK_FALSE(eu07vehicle->leaves_track());
|
||||
// tipping over on its outer wheels it hardly slows down
|
||||
auto const start{eu07vehicle->V};
|
||||
auto const start{eu07vehicle->V()};
|
||||
for (int step = 0; step < 20; ++step) {
|
||||
eu07vehicle.step(curve);
|
||||
}
|
||||
auto const deceleration{(start - eu07vehicle->V) / 0.2};
|
||||
auto const deceleration{(start - eu07vehicle->V()) / 0.2};
|
||||
CHECK(deceleration == doctest::Approx(dm::guided_friction * dr::gravity * 80.0 / 96.0).epsilon(0.1));
|
||||
// back on the rails, not off the track any more, and what derailed it forgotten
|
||||
eu07vehicle->repair_damage();
|
||||
@@ -478,7 +478,7 @@ TEST_CASE("derail motion: with physics.derailment monitor and old the vehicle st
|
||||
CHECK_FALSE(fast->leaves_track());
|
||||
CHECK_FALSE(fast->OffTrack.active());
|
||||
// stopped dead by the legacy model
|
||||
CHECK(fast->V == doctest::Approx(0.0).epsilon(0.01));
|
||||
CHECK(fast->V() == doctest::Approx(0.0).epsilon(0.01));
|
||||
vehicle ending{definition::fiz("4e_v1/4e"), 40.0};
|
||||
ending.damage_track(dtrack_norail);
|
||||
ending.step();
|
||||
|
||||
@@ -61,17 +61,17 @@ TEST_CASE("derailment: a vehicle too fast in a curve") {
|
||||
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};
|
||||
auto const start{eu07vehicle->V()};
|
||||
CHECK(start > 0.95 * (critical + 5.0) * kmh);
|
||||
for (int step = 0; step < 100; ++step) {
|
||||
eu07vehicle.step(curve);
|
||||
}
|
||||
auto const deceleration{(start - eu07vehicle->V) / 1.0};
|
||||
auto const deceleration{(start - eu07vehicle->V()) / 1.0};
|
||||
CHECK(deceleration == doctest::Approx(0.5 * dr::gravity * 80.0 / 96.0).epsilon(0.05));
|
||||
for (int step = 0; step < 2000; ++step) {
|
||||
eu07vehicle.step(curve);
|
||||
}
|
||||
CHECK(eu07vehicle->V == doctest::Approx(0.0));
|
||||
CHECK(eu07vehicle->V() == doctest::Approx(0.0));
|
||||
}
|
||||
SUBCASE("a higher centre of gravity of its definition overturns it slower") {
|
||||
vehicle high{definition::fiz("4e_v1/4e").set("Dimensions", "CoGH", 2.2), critical - 5.0};
|
||||
@@ -127,7 +127,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->V == doctest::Approx(0.0).epsilon(0.01));
|
||||
CHECK(eu07vehicle->V() == doctest::Approx(0.0).epsilon(0.01));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,11 +156,11 @@ TEST_CASE("derailment: a stopped derailed vehicle stays put on a gradient") {
|
||||
eu07vehicle.step(curve);
|
||||
}
|
||||
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
|
||||
REQUIRE(eu07vehicle->V == 0.0);
|
||||
REQUIRE(eu07vehicle->V() == 0.0);
|
||||
auto still{true};
|
||||
for (int step = 0; step < 500; ++step) {
|
||||
eu07vehicle.step(curve);
|
||||
still = still && eu07vehicle->V == 0.0 && eu07vehicle->AccS == 0.0;
|
||||
still = still && eu07vehicle->V() == 0.0 && eu07vehicle->AccS() == 0.0;
|
||||
}
|
||||
CHECK(still);
|
||||
}
|
||||
@@ -178,23 +178,23 @@ TEST_CASE("derailment: a repaired vehicle is back on the rails") {
|
||||
repaired.step(curve);
|
||||
}
|
||||
REQUIRE(repaired->Derailed == dr::outcome::overturned);
|
||||
REQUIRE(repaired->V == 0.0);
|
||||
REQUIRE(repaired->V() == 0.0);
|
||||
repaired->repair_damage();
|
||||
CHECK(repaired->DamageFlag.Empty());
|
||||
CHECK(repaired->Derailed == dr::outcome::none);
|
||||
CHECK(repaired->derailment_distance == 0.0);
|
||||
CHECK(repaired->OffsetTrackH == 0.0);
|
||||
CHECK(repaired->OffsetTrackV == 0.0);
|
||||
CHECK(repaired->DerailmentDistance() == 0.0);
|
||||
CHECK(repaired->OffsetTrackH() == 0.0);
|
||||
CHECK(repaired->OffsetTrackV() == 0.0);
|
||||
|
||||
SUBCASE("a derailment of the legacy kind stops it dead, as one never derailed") {
|
||||
test::track straight;
|
||||
vehicle fresh{definition::fiz("4e_v1/4e"), 60.0};
|
||||
repaired->V = fresh->V;
|
||||
repaired->AccS = 0.0;
|
||||
repaired->SetV(fresh->V());
|
||||
repaired->SetAccS(0.0);
|
||||
repaired->Derail(TOO_HIGH_SPEED);
|
||||
fresh->Derail(TOO_HIGH_SPEED);
|
||||
REQUIRE(repaired->Derailed == dr::outcome::none);
|
||||
auto const start{fresh->V};
|
||||
auto const start{fresh->V()};
|
||||
REQUIRE(start > 10.0);
|
||||
for (int step = 0; step < 150; ++step) {
|
||||
repaired.step(straight);
|
||||
@@ -202,8 +202,8 @@ TEST_CASE("derailment: a repaired vehicle is back on the rails") {
|
||||
}
|
||||
// the legacy model takes g off a derailed vehicle and holds it with a friction 1e20 times its own: 1.1 s from
|
||||
// 39 km/h. with the friction of the overturned one (half of g on 80 of 96 t) it would still go at 23 km/h
|
||||
CHECK(fresh->V == doctest::Approx(0.0).epsilon(0.01));
|
||||
CHECK(repaired->V == doctest::Approx(fresh->V).epsilon(0.01));
|
||||
CHECK(fresh->V() == doctest::Approx(0.0).epsilon(0.01));
|
||||
CHECK(repaired->V() == doctest::Approx(fresh->V()).epsilon(0.01));
|
||||
}
|
||||
SUBCASE("the friction of the ballast doesn't hold it any more") {
|
||||
// unbraked on the gradient of 20 per mille it rolls away, at g / 50 less the running resistance
|
||||
@@ -212,11 +212,11 @@ TEST_CASE("derailment: a repaired vehicle is back on the rails") {
|
||||
for (int step = 0; step < 300; ++step) {
|
||||
repaired.step(straight);
|
||||
}
|
||||
CHECK(std::abs(repaired->V) > 0.4);
|
||||
CHECK(std::abs(repaired->V) < 3.0 * 0.02 * dr::gravity);
|
||||
CHECK(std::abs(repaired->V()) > 0.4);
|
||||
CHECK(std::abs(repaired->V()) < 3.0 * 0.02 * dr::gravity);
|
||||
}
|
||||
SUBCASE("too fast in a curve again it derails again, by the criteria") {
|
||||
repaired->V = 150.0 * kmh;
|
||||
repaired->SetV(150.0 * kmh);
|
||||
curve.gradient = 0.0;
|
||||
for (int step = 0; step < 20; ++step) {
|
||||
repaired.step(curve);
|
||||
@@ -303,7 +303,7 @@ TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what t
|
||||
}
|
||||
CHECK(faster->DamageFlag.HasAll(VehicleDamage::derailed));
|
||||
CHECK(faster->Derailed == dr::outcome::none);
|
||||
CHECK(faster->V == doctest::Approx(0.0).epsilon(0.01));
|
||||
CHECK(faster->V() == doctest::Approx(0.0).epsilon(0.01));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ definition st44_braking() {
|
||||
|
||||
// the force of the brakes above at full effort at the speed of the vehicle
|
||||
double br285_limit(physics::Vehicle const &Vehicle) {
|
||||
return std::min(150000.0, 2000000.0 / std::abs(Vehicle.V)) * std::clamp((Vehicle.Vel - 2.0) / 4.0, 0.0, 1.0);
|
||||
return std::min(150000.0, 2000000.0 / std::abs(Vehicle.V())) * std::clamp((Vehicle.Vel - 2.0) / 4.0, 0.0, 1.0);
|
||||
}
|
||||
double st44_limit(physics::Vehicle const &Vehicle) {
|
||||
return std::min(120000.0, 1200000.0 / std::abs(Vehicle.V)) * std::clamp(Vehicle.Vel / 40.0, 0.0, 1.0);
|
||||
return std::min(120000.0, 1200000.0 / std::abs(Vehicle.V())) * std::clamp(Vehicle.Vel / 40.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
// the controller of the BR285 down to the given position, a step a time
|
||||
@@ -249,14 +249,14 @@ TEST_CASE("diesel-electric dynamic brake: without a fade it brings the vehicle t
|
||||
|
||||
scenario.act("EB+ to the stop");
|
||||
controller_to(locomotive, 0);
|
||||
for (int i = 0; i < 120 && locomotive.V != 0.0; ++i) {
|
||||
for (int i = 0; i < 120 && locomotive.V() != 0.0; ++i) {
|
||||
scenario.wait(1.0);
|
||||
}
|
||||
CHECK(locomotive.brakes.cylinderPressure < 0.1);
|
||||
// at rest, and staying there: no speed either way, no force
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
scenario.wait(1.0);
|
||||
CHECK(locomotive.V == 0.0);
|
||||
CHECK(locomotive.V() == 0.0);
|
||||
CHECK(locomotive.Ft == doctest::Approx(0.0));
|
||||
}
|
||||
CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(1.0));
|
||||
|
||||
@@ -16,14 +16,14 @@ TEST_CASE("figures: a run split into parts by the events, each from the last ste
|
||||
vehicle eu07{definition::fiz("4e_v1/4e")};
|
||||
test::figures figures;
|
||||
auto &physics{eu07.physics()};
|
||||
physics.V = 10.0;
|
||||
physics.SetV(10.0);
|
||||
physics.brakePipe.SetPressure(5.0);
|
||||
figures.sample(0.0, physics);
|
||||
figures.mark("brake");
|
||||
figures.mark("hard");
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
physics.V = 10.0 - i;
|
||||
physics.DistCounter += 0.005;
|
||||
physics.SetV(10.0 - i);
|
||||
physics.SetDistCounter(physics.DistCounter() + 0.005);
|
||||
physics.brakePipe.SetPressure(3.5);
|
||||
physics.brakes.cylinderPressure = 0.4 * i;
|
||||
figures.sample(i, physics);
|
||||
|
||||
@@ -111,7 +111,7 @@ void notch_up(physics::Vehicle &Cab) {
|
||||
|
||||
// the power at the wheels [kW]
|
||||
double wheel_power(physics::Vehicle const &Vehicle) {
|
||||
return std::abs(Vehicle.Ft * Vehicle.V) / 1000.0;
|
||||
return std::abs(Vehicle.Ft * Vehicle.V()) / 1000.0;
|
||||
}
|
||||
|
||||
// one step of 0.01 s, acknowledging the vigilance once a second
|
||||
@@ -342,7 +342,7 @@ TEST_CASE("genset: running from the catenary is the same with the keys") {
|
||||
auto const record = [](values &Values) {
|
||||
return std::vector<test::channel>{
|
||||
{"Ft", [&Values](physics::Vehicle const &Vehicle) { Values.force.push_back(Vehicle.Ft); return Vehicle.Ft; }},
|
||||
{"V", [&Values](physics::Vehicle const &Vehicle) { Values.speed.push_back(Vehicle.V); return Vehicle.V; }},
|
||||
{"V", [&Values](physics::Vehicle const &Vehicle) { Values.speed.push_back(Vehicle.V()); return Vehicle.V(); }},
|
||||
{"EngineVoltage", [&Values](physics::Vehicle const &Vehicle) { Values.voltage.push_back(Vehicle.EngineVoltage); return Vehicle.EngineVoltage; }},
|
||||
{"Itot", [&Values](physics::Vehicle const &Vehicle) { Values.current.push_back(Vehicle.Itot); return Vehicle.Itot; }},
|
||||
{"eimv_pr", [&Values](physics::Vehicle const &Vehicle) { Values.demand.push_back(Vehicle.inductionMotor.forceShare); return Vehicle.inductionMotor.forceShare; }},
|
||||
@@ -645,16 +645,16 @@ TEST_CASE("genset: a scenery command reaches the selector") {
|
||||
auto &cab{dragon6.physics()};
|
||||
wake(cab);
|
||||
// as a scenery's PutValues event gives it, one at a time
|
||||
cab.PutCommand("TractionMode", 1, 0, cab.Loc);
|
||||
cab.PutCommand("TractionMode", 1, 0, cab.Loc());
|
||||
dragon6.step(no_wire);
|
||||
CHECK(cab.GensetSelected());
|
||||
CHECK(cab.CommandIn.Command == VehicleCommand::none);
|
||||
cab.PutCommand("GensetSwitch", 1, 0, cab.Loc);
|
||||
cab.PutCommand("GensetSwitch", 1, 0, cab.Loc());
|
||||
dragon6.step(no_wire);
|
||||
CHECK(cab.Genset.is_enabled);
|
||||
run(dragon6, 10.0);
|
||||
CHECK(cab.Genset.is_active);
|
||||
cab.PutCommand("TractionMode", 0, 0, cab.Loc);
|
||||
cab.PutCommand("TractionMode", 0, 0, cab.Loc());
|
||||
dragon6.step(no_wire);
|
||||
CHECK_FALSE(cab.GensetSelected());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ TEST_CASE("invariants: a vehicle in an impossible state, reported once with its
|
||||
CHECK(violation.find("BrakePress=50") != std::string::npos);
|
||||
|
||||
eu07->brakes.cylinderPressure = 0.0;
|
||||
eu07->V = std::nan("");
|
||||
eu07->SetV(std::nan(""));
|
||||
trace.sample(0.03, eu07.physics());
|
||||
CHECK(trace.violations().size() > 1);
|
||||
CHECK(trace.violations()[1].find("every value a number") != std::string::npos);
|
||||
|
||||
@@ -68,8 +68,8 @@ TEST_CASE("odometer: a vehicle counts the distance it runs either way, as the se
|
||||
test::vehicle vehicle{test::definition::load("wagon"), velocity};
|
||||
vehicle->Odometer.begin(123456.0, odometer::origin::saved);
|
||||
vehicle.run(10.0);
|
||||
CHECK(vehicle->DistCounter > 0.05);
|
||||
CHECK(vehicle->Odometer.km - 123456.0 == doctest::Approx(vehicle->DistCounter));
|
||||
CHECK(vehicle->DistCounter() > 0.05);
|
||||
CHECK(vehicle->Odometer.km - 123456.0 == doctest::Approx(vehicle->DistCounter()));
|
||||
CHECK(vehicle->Odometer.start == 123456.0);
|
||||
CHECK(vehicle->Odometer.moved());
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ TEST_CASE("queries: the damage of a vehicle as the driver's panel describes it")
|
||||
}
|
||||
// flat wheels count as worn ones
|
||||
wagon->DamageFlag = {};
|
||||
wagon->WheelFlat = 6.0;
|
||||
wagon->SetWheelFlat(6.0);
|
||||
CHECK(wagon->EngineDescription(0) == "Wheel wear");
|
||||
// nothing else is described
|
||||
CHECK(wagon->EngineDescription(1) == "Invalid qualifier");
|
||||
|
||||
@@ -35,7 +35,7 @@ TEST_CASE("traction: every real powered vehicle started up, driven to full power
|
||||
// barely move (COVERAGE.md); the cars of a unit taking their power from another car don't start alone
|
||||
if (real->lineBreaker.IsClosed()) {
|
||||
auto const crawls{path == "sm31_v1/411d" || path == "tem2_v2/tem2a"};
|
||||
CHECK((real->DistCounter > 0.2 /* km */) != crawls);
|
||||
CHECK((real->DistCounter() > 0.2 /* km */) != crawls);
|
||||
// but the road vehicle, which a minute of full service only slows down
|
||||
CHECK((real->Vel < 0.5) != (path == "road/man/nl293"));
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ pair::~pair() {
|
||||
void pair::find_neighbours() {
|
||||
// as TDynamicObject::update_neighbours()
|
||||
for (auto const &placed : m_vehicles) {
|
||||
placed.owner->physics().Loc = TLocation{placed.position, 0.0, 0.0};
|
||||
placed.owner->physics().SetLoc(TLocation{placed.position, 0.0, 0.0});
|
||||
}
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
auto const &self{m_vehicles[i]};
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
double move(track const &Track, double Dt, TLocation const &Location, double Trainpipe);
|
||||
|
||||
// vehicle speed in kilometres per hour, negative when moving backwards
|
||||
double speed() const { return m_physics->V * 3.6; }
|
||||
double speed() const { return m_physics->V() * 3.6; }
|
||||
|
||||
private:
|
||||
std::unique_ptr<physics::Vehicle> m_physics;
|
||||
|
||||
@@ -93,9 +93,9 @@ void motiontelemetry::update()
|
||||
if (conf.latposbased)
|
||||
local_acc.x -= glm::dot(acc, leftvector);
|
||||
else
|
||||
local_acc.x -= t->Occupied()->AccN;
|
||||
local_acc.x -= t->Occupied()->AccN();
|
||||
|
||||
local_acc.y += glm::dot(acc, up) + t->Occupied()->AccVert * conf.axlebumpscale;
|
||||
local_acc.y += glm::dot(acc, up) + t->Occupied()->AccVert() * conf.axlebumpscale;
|
||||
|
||||
if (conf.fwdposbased)
|
||||
local_acc.z += glm::dot(acc, frontvector);
|
||||
@@ -130,7 +130,7 @@ void motiontelemetry::update()
|
||||
|
||||
glm::dvec3 rot(asin(-frontvector.y), atan2(frontvector.x, frontvector.z), asin(sinroll));
|
||||
|
||||
double velocity = t->Occupied()->V;
|
||||
double velocity = t->Occupied()->V();
|
||||
double yaw_vel = (rot.y - last_yaw) / dt;
|
||||
|
||||
last_yaw = rot.y;
|
||||
|
||||
+1
-1
@@ -452,7 +452,7 @@ void uart_input::poll()
|
||||
GLFW_PRESS,
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
0);
|
||||
simulation::Train->Occupied()->eimic_analog = desiredpercent;
|
||||
simulation::Train->Occupied()->SetEimicAnalog(desiredpercent);
|
||||
}
|
||||
}
|
||||
if( true == conf.scndenable ) {
|
||||
|
||||
@@ -108,7 +108,7 @@ void TController::Activation()
|
||||
&& ( BrakeSystem == TBrakeSystem::Pneumatic
|
||||
|| BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) {
|
||||
occupied->brakes.pipeLimiterPressure = occupied->brakePipe.Pressure();
|
||||
occupied->ActFlowSpeed = 0;
|
||||
occupied->SetActFlowSpeed(0);
|
||||
}
|
||||
BrakeLevelSet( occupied->brakes.HandlePosition() );
|
||||
}
|
||||
@@ -508,8 +508,8 @@ void TController::DirectionInitial()
|
||||
if (occupied->Vel > EU07_AI_NOMOVEMENT)
|
||||
{ // jeśli na starcie jedzie
|
||||
iDirection = iDirectionOrder =
|
||||
occupied->V > 0 ? 1 : -1; // początkowa prędkość wymusza kierunek jazdy
|
||||
DirectionForward(occupied->V * occupied->CabActive >= 0.0); // a dalej ustawienie nawrotnika
|
||||
occupied->V() > 0 ? 1 : -1; // początkowa prędkość wymusza kierunek jazdy
|
||||
DirectionForward(occupied->V() * occupied->CabActive >= 0.0); // a dalej ustawienie nawrotnika
|
||||
}
|
||||
CheckVehicles(); // sprawdzenie świateł oraz skrajnych pojazdów do skanowania
|
||||
};
|
||||
@@ -717,7 +717,7 @@ TController::determine_consist_state() {
|
||||
{ // sprawdzenie odhamowania wszystkich połączonych pojazdów
|
||||
auto *vehicle { p->physics };
|
||||
auto const bp { std::max( 0.0, vehicle->brakes.cylinderPressure - ( vehicle->SpeedCtrlUnit.Parking ? vehicle->brakes.config.maxCylinderPressure[ 0 ] * vehicle->brakes.holding.deceleration : 0.0 ) ) };
|
||||
momentum += vehicle->TotalMass * vehicle->V * ( p->DirectionGet() == iDirection ? 1 : -1 );
|
||||
momentum += vehicle->TotalMass * vehicle->V() * ( p->DirectionGet() == iDirection ? 1 : -1 );
|
||||
mostapplied = std::max( bp, mostapplied );
|
||||
if( ( vehicle->brakes.config.kind != TBrakeSystem::Individual )
|
||||
&& ( vehicle->brakes.config.maxCylinderPressure[ 3 ] > 0.0 )
|
||||
@@ -837,7 +837,7 @@ TController::determine_consist_state() {
|
||||
absaccs = 0;
|
||||
auto *d = pVehicles[ VehicleEnd::front ]; // pojazd na czele składu
|
||||
while( d ) {
|
||||
absaccs += d->physics->TotalMass * d->physics->AccS * ( d->DirectionGet() == iDirection ? 1 : -1 );
|
||||
absaccs += d->physics->TotalMass * d->physics->AccS() * ( d->DirectionGet() == iDirection ? 1 : -1 );
|
||||
d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła)
|
||||
}
|
||||
absaccs *= iDirection >= 0 ? 1 : -1;
|
||||
|
||||
@@ -334,7 +334,7 @@ TController::Update( double const Timedelta ) {
|
||||
if( occupied->Vel > 1.0 ) {
|
||||
// przy prowadzeniu samochodu trzeba każdą oś odsuwać oddzielnie, inaczej kicha wychodzi
|
||||
if (occupied->CategoryFlag & 2) // jeśli samochód
|
||||
// if (fabs(occupied->OffsetTrackH)<occupied->Dim.W) //Ra: szerokość drogi tu powinna być?
|
||||
// if (fabs(occupied->OffsetTrackH())<occupied->Dim.W) //Ra: szerokość drogi tu powinna być?
|
||||
if (!occupied->ChangeOffsetH(-0.01 * occupied->Vel * dt)) // ruch w poprzek drogi
|
||||
occupied->ChangeOffsetH(0.01 * occupied->Vel * dt); // Ra: co to miało być, to nie wiem
|
||||
}
|
||||
@@ -578,7 +578,7 @@ bool TController::has_diesel_engine() const {
|
||||
return mvControlling->EngineType == TEngineType::DieselElectric || mvControlling->EngineType == TEngineType::DieselEngine; }
|
||||
|
||||
double TController::DirectionalVel() const {
|
||||
return occupied->Vel * sign( iDirection * occupied->V ); }
|
||||
return occupied->Vel * sign( iDirection * occupied->V() ); }
|
||||
|
||||
std::vector<std::string_view> DrivingFlags::ActiveNames() const {
|
||||
std::vector<std::pair<bool, std::string_view>> const flags {
|
||||
|
||||
@@ -437,7 +437,7 @@ TController::PrepareDirection() {
|
||||
}
|
||||
else {
|
||||
// ustalenie kierunku, gdy jedzie
|
||||
iDirection = occupied->V >= 0 ? 1 : // jazda w kierunku sprzęgu 0
|
||||
iDirection = occupied->V() >= 0 ? 1 : // jazda w kierunku sprzęgu 0
|
||||
-1; // jazda w kierunku sprzęgu 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,12 +373,12 @@ TController::scan_obstacles( double const Range ) {
|
||||
// HACK: vehicle order in the consist is based on intended travel direction
|
||||
// if our actual travel direction doesn't match that, we should be scanning from the other end of the consist
|
||||
// we cast to int to avoid getting confused by microstutters
|
||||
auto *frontvehicle { pVehicles[ ( static_cast<int>( occupied->V ) * iDirection >= 0 ? VehicleEnd::front : VehicleEnd::rear ) ] };
|
||||
auto *frontvehicle { pVehicles[ ( static_cast<int>( occupied->V() ) * iDirection >= 0 ? VehicleEnd::front : VehicleEnd::rear ) ] };
|
||||
|
||||
int routescandirection;
|
||||
// for moving vehicle determine heading from velocity; for standing fall back on the set direction
|
||||
if( std::abs(frontvehicle->physics->V) > 0.5 ? // ignore potential micro-stutters in oposite direction during "almost stop"
|
||||
frontvehicle->physics->V > 0.0 :
|
||||
if( std::abs(frontvehicle->physics->V()) > 0.5 ? // ignore potential micro-stutters in oposite direction during "almost stop"
|
||||
frontvehicle->physics->V() > 0.0 :
|
||||
pVehicle->DirectionGet() == frontvehicle->DirectionGet() ? iDirection >= 0 : iDirection <= 0 ) {
|
||||
// towards coupler 0
|
||||
routescandirection = NumberOf( VehicleEnd::front );
|
||||
|
||||
@@ -176,7 +176,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
|
||||
{ // SHP wyzwalane jest przez człon z obsadą, ale obsługiwane przez silnikowy
|
||||
// nie jest to najlepiej zrobione, ale bez symulacji obwodów lepiej nie będzie
|
||||
// Ra 2014-04: jednak przeniosłem do rozrządczego
|
||||
occupied->PutCommand(NewCommand, NewValue1, NewValue2, occupied->Loc);
|
||||
occupied->PutCommand(NewCommand, NewValue1, NewValue2, occupied->Loc());
|
||||
occupied->RunInternalCommand(); // rozpoznaj komende bo lokomotywa jej nie rozpoznaje
|
||||
return true; // załatwione
|
||||
}
|
||||
@@ -192,7 +192,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
|
||||
if (NewCommand == "Emergency_brake") // wymuszenie zatrzymania, niezależnie kto prowadzi
|
||||
{ // Ra: no nadal nie jest zbyt pięknie
|
||||
// SetVelocity(0, 0, reason);
|
||||
occupied->PutCommand("Emergency_brake", 1.0, 1.0, occupied->Loc);
|
||||
occupied->PutCommand("Emergency_brake", 1.0, 1.0, occupied->Loc());
|
||||
return true; // załatwione
|
||||
}
|
||||
|
||||
@@ -301,8 +301,8 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
|
||||
else
|
||||
if (!iDirectionOrder)
|
||||
{//jeśli nie ma kierunku, trzeba ustalić
|
||||
if (occupied->V!=0.0)
|
||||
iDirectionOrder=occupied->V>0?1:-1;
|
||||
if (occupied->V()!=0.0)
|
||||
iDirectionOrder=occupied->V()>0?1:-1;
|
||||
else
|
||||
iDirectionOrder=occupied->CabOccupied();
|
||||
if (!iDirectionOrder) iDirectionOrder=1;
|
||||
@@ -310,7 +310,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
|
||||
*/
|
||||
// jeśli wysyłane z Trainset, to wszystko jest już odpowiednio ustawione
|
||||
// if (!NewLocation) //jeśli wysyłane z Trainset
|
||||
// if (occupied->CabActive*occupied->V*NewValue1<0) //jeśli zadana prędkość niezgodna z
|
||||
// if (occupied->CabActive*occupied->V()*NewValue1<0) //jeśli zadana prędkość niezgodna z
|
||||
// aktualnym kierunkiem jazdy
|
||||
// DirectionForward(false); //jedziemy do tyłu (nawrotnik do tyłu)
|
||||
// CheckVehicles(); //sprawdzenie składu, AI zapali światła
|
||||
|
||||
@@ -66,7 +66,7 @@ std::string TController::physicslog_line() const {
|
||||
line << std::fixed << std::setprecision( 4 )
|
||||
<< ElapsedTime << " "
|
||||
<< fabs(11.31 * occupied->WheelDiameter * occupied->nrot) << " "
|
||||
<< mvControlling->AccS << " "
|
||||
<< mvControlling->AccS() << " "
|
||||
<< occupied->Couplers[1].Dist << " "
|
||||
<< occupied->Couplers[1].CForce << " "
|
||||
<< occupied->Ft << " "
|
||||
@@ -90,7 +90,7 @@ std::string TController::physicslog_line() const {
|
||||
<< mvControlling->diesel.heat.temperatura1 << " "
|
||||
<< mvControlling->diesel.heat.temperatura2 << " "
|
||||
// vehicle speed [km/h], the second column is the wheel speed, which stays at 0 while the wheels are locked in a skid
|
||||
<< occupied->V * 3.6
|
||||
<< occupied->V() * 3.6
|
||||
<< "\r\n";
|
||||
return line.str();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ void TController::PhysicsLog()
|
||||
std::ostringstream line;
|
||||
line << ElapsedTime << "\t" << fabs(11.31 * occupied->WheelDiameter * occupied->nrot)
|
||||
<< "\t";
|
||||
line << mvControlling->AccS << "\t";
|
||||
line << mvControlling->AccS() << "\t";
|
||||
line << occupied->brakePipe.Pressure() << "\t" << occupied->brakes.controlReservoirPressure << "\t"
|
||||
<< occupied->brakes.cylinderPressure << "\t";
|
||||
line << occupied->brakes.reservoirAir << "\t" << occupied->brakes.distributor->GetCRP() << "\n";
|
||||
|
||||
@@ -211,7 +211,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
|
||||
fTrackLength -= glm::length(
|
||||
pVehicle->AxlePositionGet()
|
||||
- pVehicle->RearPosition()
|
||||
+ pVehicle->VectorLeft() * pVehicle->physics->OffsetTrackH );
|
||||
+ pVehicle->VectorLeft() * pVehicle->physics->OffsetTrackH() );
|
||||
// aktualna odległość ma być ujemna gdyż jesteśmy na końcu składu
|
||||
fCurrentDistance = -fLength - fTrackLength;
|
||||
fTrackLength = pTrack->Length(); //skasowanie zmian w zmiennej żeby poprawnie liczyło w dalszych krokach
|
||||
|
||||
@@ -566,7 +566,7 @@ void
|
||||
TController::UpdateNextStop() {
|
||||
|
||||
if( fLastStopExpDist > 0.0
|
||||
&& occupied->DistCounter > fLastStopExpDist ) {
|
||||
&& occupied->DistCounter() > fLastStopExpDist ) {
|
||||
// zaktualizować wyświetlanie rozkładu
|
||||
TrainParams.StationStart = TrainParams.StationIndex;
|
||||
fLastStopExpDist = -1.0; // usunąć licznik
|
||||
|
||||
@@ -350,7 +350,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
|
||||
pVehicle->asName, TrainParams.TrainName, simulation::Time.data().wHour, simulation::Time.data().wMinute, asNextStop)); // informacja
|
||||
#endif
|
||||
// przy jakim dystansie (stanie licznika) ma przesunąć na następny postój
|
||||
fLastStopExpDist = occupied->DistCounter + 0.250 + 0.001 * fLength;
|
||||
fLastStopExpDist = occupied->DistCounter() + 0.250 + 0.001 * fLength;
|
||||
TrainParams.UpdateMTable( simulation::Time, asNextStop );
|
||||
record_station( Point, blackbox::station_kinds::passed );
|
||||
UpdateDelayFlag();
|
||||
@@ -517,7 +517,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
|
||||
IsAtPassengerStop = false;
|
||||
record_station( Point, blackbox::station_kinds::ready );
|
||||
// przy jakim dystansie (stanie licznika) ma przesunąć na następny postój
|
||||
fLastStopExpDist = occupied->DistCounter + 0.050 + 0.001 * fLength;
|
||||
fLastStopExpDist = occupied->DistCounter() + 0.050 + 0.001 * fLength;
|
||||
TrainParams.StationIndexInc(); // przejście do następnej
|
||||
asNextStop = TrainParams.NextStop(); // pobranie kolejnego miejsca zatrzymania
|
||||
#if LOGSTOPS
|
||||
|
||||
@@ -638,13 +638,13 @@ void TTrain::OnCommand_vehicleboost(TTrain *Train, const command_data &Command)
|
||||
auto *vehicle{Train->DynamicObject};
|
||||
while (vehicle)
|
||||
{
|
||||
vehicle->physics->V += vehicle->DirectionGet() * boost;
|
||||
vehicle->physics->SetV(vehicle->physics->V() + vehicle->DirectionGet() * boost);
|
||||
vehicle = vehicle->Next(); // pozostałe też
|
||||
}
|
||||
vehicle = Train->DynamicObject->Prev();
|
||||
while (vehicle)
|
||||
{
|
||||
vehicle->physics->V += vehicle->DirectionGet() * boost;
|
||||
vehicle->physics->SetV(vehicle->physics->V() + vehicle->DirectionGet() * boost);
|
||||
vehicle = vehicle->Prev(); // w drugą stronę też
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ std::shared_ptr<dictionary_source> TTrain::GetTrainState(dictionary_source const
|
||||
dict->insert("tractionforce", std::abs(occupied->Ft));
|
||||
dict->insert("slipping_wheels", occupied->SlippingWheels);
|
||||
dict->insert("sanding", occupied->SandDose);
|
||||
dict->insert("odometer", occupied->DistCounter); // distance run in the session, km
|
||||
dict->insert("odometer", occupied->DistCounter()); // distance run in the session, km
|
||||
dict->insert("odometer_total", occupied->Odometer.km); // the vehicle's odometer, kept between the sessions
|
||||
// electric current data
|
||||
dict->insert("traction_voltage", std::abs(pantographUnit->pantographCircuit.SupplyVoltage()));
|
||||
@@ -418,7 +418,7 @@ TTrain::state_t TTrain::get_state() const
|
||||
fHVoltage,
|
||||
{fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]},
|
||||
ggLVoltage.GetValue(),
|
||||
occupied->DistCounter,
|
||||
occupied->DistCounter(),
|
||||
static_cast<std::uint8_t>(RadioChannel()),
|
||||
btLampkaSpringBrakeActive.GetValue(),
|
||||
btLampkaNapNastHam.GetValue(),
|
||||
|
||||
@@ -1208,7 +1208,7 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower)
|
||||
{
|
||||
|
||||
set_master_controller(Console::AnalogCalibrateGet(2) * occupied->MainCtrlPosNo);
|
||||
occupied->eimic_analog = Console::AnalogCalibrateGet(2);
|
||||
occupied->SetEimicAnalog(Console::AnalogCalibrateGet(2));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ TDynamicObject::update_neighbours() {
|
||||
// NOTE: we perform a new scan on each update to ensure we always locate the nearest potential source
|
||||
neighbour = neighbour_data();
|
||||
// 10m ~= 140 km/h at 4 fps + safety margin, potential distance between outer axles of involved vehicles
|
||||
auto const scanrange { std::max( 10.0, std::abs( physics->V ) ) + 40.0 };
|
||||
auto const scanrange { std::max( 10.0, std::abs( physics->V() ) ) + 40.0 };
|
||||
// physics.derailment new: a vehicle off the track beside the other one doesn't run into it, the scan goes on
|
||||
// past it to the vehicles beyond
|
||||
auto const lookup { find_vehicle( NumberOf( end ), scanrange, true ) };
|
||||
@@ -519,9 +519,9 @@ TDynamicObject *TDynamicObject::PrevConnected() const { return physics->Neighbou
|
||||
int TDynamicObject::NextConnectedNo() const { return physics->Neighbours[ VehicleEnd::rear ].vehicle_end; }
|
||||
int TDynamicObject::PrevConnectedNo() const { return physics->Neighbours[ VehicleEnd::front ].vehicle_end; }
|
||||
|
||||
void TDynamicObject::SetdMoveLen( double dMoveLen ) { physics->dMoveLen = dMoveLen; }
|
||||
void TDynamicObject::ResetdMoveLen() { physics->dMoveLen = 0; }
|
||||
double TDynamicObject::GetdMoveLen() { return physics->dMoveLen; }
|
||||
void TDynamicObject::SetdMoveLen( double dMoveLen ) { physics->SetMoveLength(dMoveLen); }
|
||||
void TDynamicObject::ResetdMoveLen() { physics->SetMoveLength(0); }
|
||||
double TDynamicObject::GetdMoveLen() { return physics->MoveLength(); }
|
||||
|
||||
double TDynamicObject::GetVelocity() const { return physics->Vel; }
|
||||
double TDynamicObject::GetLength() const { return physics->Dim.L; }
|
||||
|
||||
@@ -321,10 +321,10 @@ void TDynamicObject::AttachNext(TDynamicObject *Object, int iType)
|
||||
|
||||
Object->Move( physics->Neighbours[ vehicleend ].distance * Object->DirectionGet() );
|
||||
// HACK: manually update vehicle position as it's used by neighbour distance update we do next
|
||||
Object->physics->Loc = {
|
||||
Object->physics->SetLoc({
|
||||
-Object->vPosition.x,
|
||||
Object->vPosition.z,
|
||||
Object->vPosition.y };
|
||||
Object->vPosition.y });
|
||||
// update neighbour distance data after moving our vehicle
|
||||
update_neighbours();
|
||||
Object->update_neighbours();
|
||||
|
||||
@@ -169,7 +169,7 @@ void TDynamicObject::place_on_track(TTrack *Track, double fDist, bool Reversed)
|
||||
}
|
||||
// the stretches the criteria of derailment held over were on the track the vehicle left (consistteleport)
|
||||
physics->derailment_monitor.reset();
|
||||
physics->derailment_distance = 0.0;
|
||||
physics->SetDerailmentDistance(0.0);
|
||||
// potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy pozycji
|
||||
// teraz jeszcze trzeba przypisać pojazdy do nowego toru, bo przesuwanie początkowe osi nie
|
||||
// zrobiło tego
|
||||
@@ -454,7 +454,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
auto const indexstart { 1 };
|
||||
auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) };
|
||||
auto const huntingchance { std::atoi( ActPar.substr( indexstart, indexend ).c_str() ) };
|
||||
physics->TruckHunting = Random(0, 100) < huntingchance;
|
||||
physics->SetTruckHunting(Random(0, 100) < huntingchance);
|
||||
ActPar.erase( 0, indexend );
|
||||
break;
|
||||
}
|
||||
@@ -466,7 +466,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
}
|
||||
}
|
||||
if( Random( 0, 100 ) <= flatchance ) {
|
||||
physics->WheelFlat += fixedflatsize + Random( 0, randomflatsize );
|
||||
physics->SetWheelFlat( physics->WheelFlat() + ( fixedflatsize + Random( 0, randomflatsize ) ) );
|
||||
}
|
||||
} // wheel
|
||||
else if( ActPar.size() >= 2
|
||||
@@ -534,23 +534,22 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
{ // ustawianie samochodow na poboczu albo na środku drogi
|
||||
if( Track->fTrackWidth < 3.5 // jeśli droga wąska
|
||||
|| Track->m_road != nullptr ) // a lane of a road node is one-way, the vehicle keeps to its middle
|
||||
physics->OffsetTrackH = 0.0; // to stawiamy na środku, niezależnie od stanu
|
||||
physics->SetOffsetTrackH(0.0); // to stawiamy na środku, niezależnie od stanu
|
||||
// ruchu
|
||||
else if( driveractive ) {// od 3.5m do 8.0m jedzie po środku pasa, dla
|
||||
// szerszych w odległości
|
||||
// 1.5m
|
||||
auto const lanefreespace = 0.5 * Track->fTrackWidth - physics->Dim.W;
|
||||
physics->OffsetTrackH = lanefreespace > 1.5 ?
|
||||
physics->SetOffsetTrackH(lanefreespace > 1.5 ?
|
||||
-0.5 * physics->Dim.W - 0.75 : // wide road, keep near centre with safe margin
|
||||
lanefreespace > 0.1 ?
|
||||
-0.25 * Track->fTrackWidth : // narrow fit, stay on the middle
|
||||
-0.5 * physics->Dim.W - 0.075; // too narrow, just keep some minimal clearance
|
||||
-0.5 * physics->Dim.W - 0.075); // too narrow, just keep some minimal clearance
|
||||
}
|
||||
else // jak stoi, to kołem na poboczu i pobieramy szerokość razem z
|
||||
// poboczem, ale nie z
|
||||
// chodnikiem
|
||||
physics->OffsetTrackH =
|
||||
-0.5 * (Track->WidthTotal() - physics->Dim.W) + 0.05;
|
||||
physics->SetOffsetTrackH(-0.5 * (Track->WidthTotal() - physics->Dim.W) + 0.05);
|
||||
iHornWarning = 0; // nie będzie trąbienia po podaniu zezwolenia na jazdę
|
||||
if (fDist < 0.0) //-0.5*physics->Dim.L) //jeśli jest przesunięcie do tyłu
|
||||
if (!Track->CurrentPrev()) // a nie ma tam odcinka i trzeba by coś
|
||||
@@ -754,10 +753,10 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
Move( 0.0001 );
|
||||
ABuCheckMyTrack(); // zmiana toru na ten, co oś Axle0 (oś z przodu)
|
||||
// Ra: ustawienie pozycji do obliczania sprzęgów
|
||||
physics->Loc = {
|
||||
physics->SetLoc({
|
||||
-vPosition.x,
|
||||
vPosition.z,
|
||||
vPosition.y }; // normalnie przesuwa ComputeMovement() w Update()
|
||||
vPosition.y }); // normalnie przesuwa ComputeMovement() w Update()
|
||||
// ABuWozki 060504
|
||||
if (mdModel) // jeśli ma w czym szukać
|
||||
{
|
||||
@@ -869,7 +868,7 @@ TDynamicObject::create_controller( std::string const Type, bool const Trainset )
|
||||
// tryb pociągowy z ustaloną prędkością (względem sprzęgów)
|
||||
Mechanik->PutCommand(
|
||||
"Timetable:",
|
||||
physics->V * 3.6 * ( iDirection ? -1.0 : 1.0 ),
|
||||
physics->V() * 3.6 * ( iDirection ? -1.0 : 1.0 ),
|
||||
0,
|
||||
nullptr );
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ TDimension const &TDynamicObject::Dimensions() const {
|
||||
}
|
||||
|
||||
double TDynamicObject::Speed() const {
|
||||
return physics->V;
|
||||
return physics->V();
|
||||
}
|
||||
|
||||
int TDynamicObject::ActiveCab() const {
|
||||
|
||||
@@ -60,7 +60,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
void TDynamicObject::FastMove(double fDistance)
|
||||
{
|
||||
physics->dMoveLen = physics->dMoveLen + fDistance;
|
||||
physics->SetMoveLength(physics->MoveLength() + fDistance);
|
||||
}
|
||||
|
||||
void TDynamicObject::Move(double fDistance)
|
||||
@@ -90,7 +90,7 @@ void TDynamicObject::move_axles(double fDistance)
|
||||
// na tym samym torze
|
||||
if (physics->Vel >
|
||||
2) //|[km/h]| nie ma sensu zmiana osi, jesli pojazd drga na postoju
|
||||
iAxleFirst = physics->V >= 0.0 ?
|
||||
iAxleFirst = physics->V() >= 0.0 ?
|
||||
1 :
|
||||
0; //[m/s] ?1:0 - aktywna druga oś w kierunku jazdy
|
||||
// aktualnie eventy aktywuje druga oś, żeby AI nie wyłączało sobie semafora
|
||||
@@ -148,10 +148,10 @@ void TDynamicObject::place_by_axles()
|
||||
mMatrix = glm::inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna tylko do wyświetlania?)
|
||||
// if (physics->CategoryFlag&2)
|
||||
{ // przesunięcia są używane po wyrzuceniu pociągu z toru
|
||||
vPosition.x += physics->OffsetTrackH * vLeft.x; // dodanie przesunięcia w bok
|
||||
vPosition.z += physics->OffsetTrackH * vLeft.z; // vLeft jest wektorem poprzecznym
|
||||
vPosition.x += physics->OffsetTrackH() * vLeft.x; // dodanie przesunięcia w bok
|
||||
vPosition.z += physics->OffsetTrackH() * vLeft.z; // vLeft jest wektorem poprzecznym
|
||||
// if () na przechyłce będzie dodatkowo zmiana wysokości samochodu
|
||||
vPosition.y += physics->OffsetTrackV; // te offsety są liczone przez the physics
|
||||
vPosition.y += physics->OffsetTrackV(); // te offsety są liczone przez the physics
|
||||
}
|
||||
// obliczanie pozycji sprzęgów do liczenia zderzeń
|
||||
auto dir = 0.5 * physics->Dim.L * vFront; // wektor sprzęgu
|
||||
|
||||
@@ -293,10 +293,10 @@ TDynamicObject::ABuFindObject( int &Foundcoupler, double &Distance, TTrack const
|
||||
double relativeoffset; // wzajemna odległość poprzeczna
|
||||
if( Foundcoupler != Mycoupler ) {
|
||||
// facing the same direction
|
||||
relativeoffset = std::abs( physics->OffsetTrackH - dynamic->physics->OffsetTrackH );
|
||||
relativeoffset = std::abs( physics->OffsetTrackH() - dynamic->physics->OffsetTrackH() );
|
||||
}
|
||||
else {
|
||||
relativeoffset = std::abs( physics->OffsetTrackH + dynamic->physics->OffsetTrackH );
|
||||
relativeoffset = std::abs( physics->OffsetTrackH() + dynamic->physics->OffsetTrackH() );
|
||||
}
|
||||
if( relativeoffset + relativeoffset > physics->Dim.W + dynamic->physics->Dim.W ) {
|
||||
// odległość większa od połowy sumy szerokości - kolizji nie będzie
|
||||
|
||||
@@ -246,7 +246,7 @@ void TDynamicObject::gather_off_track_terrain() {
|
||||
|
||||
auto const &position { physics->OffTrack.active() ? physics->OffTrack.current().position : vPosition };
|
||||
// as far as it may slide, and some
|
||||
auto const slide { derail_motion::stopping_distance( physics->V, derailment::off_rails_friction ).value_or( 0.0 ) };
|
||||
auto const slide { derail_motion::stopping_distance( physics->V(), derailment::off_rails_friction ).value_or( 0.0 ) };
|
||||
auto const reach { std::min( slide + physics->Dim.L + 50.0, 600.0 ) };
|
||||
m_offtrackgathered = m_offtracktotal;
|
||||
m_offtrackcropped = false;
|
||||
@@ -257,7 +257,7 @@ void TDynamicObject::gather_off_track_terrain() {
|
||||
heading = physics->OffTrack.heading();
|
||||
}
|
||||
auto const length { glm::length( heading ) };
|
||||
auto const stop { length > 1e-6 ? position + heading * ( std::copysign( std::max( reach - physics->Dim.L - 50.0, 0.0 ), physics->V ) / length ) : position };
|
||||
auto const stop { length > 1e-6 ? position + heading * ( std::copysign( std::max( reach - physics->Dim.L - 50.0, 0.0 ), physics->V() ) / length ) : position };
|
||||
auto const margin { physics->Dim.L + 30.0 };
|
||||
if( auto shared { simulation::Vehicles.off_track_terrain(
|
||||
glm::dvec2 { std::min( position.x, stop.x ) - margin, std::min( position.z, stop.z ) - margin },
|
||||
@@ -334,7 +334,7 @@ void TDynamicObject::begin_off_track() {
|
||||
start.position = vPosition;
|
||||
start.front = vFront;
|
||||
start.line = track_front();
|
||||
start.speed = physics->V;
|
||||
start.speed = physics->V();
|
||||
start.reason = physics->DerailCause;
|
||||
start.outward = ( physics->DerailSide != 0 ? physics->DerailSide : outward_side() );
|
||||
start.acceleration = physics->DerailAcceleration;
|
||||
@@ -361,7 +361,7 @@ void TDynamicObject::begin_off_track() {
|
||||
}
|
||||
WriteLog( std::format(
|
||||
"derailment: {} leaves the track at {:.0f} km/h on track {}, heading turned {:.1f} deg to the {}, the outside of the curve to the {}; {} around it",
|
||||
physics->Name, std::abs( physics->V ) * 3.6, MyTrack != nullptr ? MyTrack->name() : std::string { "(none)" },
|
||||
physics->Name, std::abs( physics->V() ) * 3.6, MyTrack != nullptr ? MyTrack->name() : std::string { "(none)" },
|
||||
std::abs( glm::degrees( turn ) ), side_name( turn >= 0.0 ? 1 : -1 ), side_name( start.outward ), terrain ) );
|
||||
WriteLog( std::format(
|
||||
"derailment: {} scattered by {:+.2f} deg of departure, {:+.2f} deg of yaw at {:+.3f} rad/s, the friction under its ends x{:.2f} / x{:.2f}{}",
|
||||
@@ -397,10 +397,10 @@ void TDynamicObject::move_off_track( double const Distance ) {
|
||||
derail_motion::meet( end_point_of( *this, end ), end_point_of( *neighbour, physics->Neighbours[ end ].FacingEnd() ) ), compression );
|
||||
}
|
||||
auto const reversals { motion.reversals() };
|
||||
motion.step( time, Distance, physics->V, m_offtracksite, ends );
|
||||
motion.step( time, Distance, physics->V(), m_offtracksite, ends );
|
||||
if( ( motion.reversals() - reversals ) % 2 != 0 ) {
|
||||
// the body turned about against the way it goes: the vehicle goes rear first, its speed the other way along it
|
||||
physics->V = -physics->V;
|
||||
physics->SetV(-physics->V());
|
||||
}
|
||||
auto const &pose { motion.current() };
|
||||
// the axles go along the track as far as the vehicle went along it, for the track nearest to it: the vehicles on it
|
||||
@@ -497,6 +497,6 @@ void TDynamicObject::update_off_track( double const Deltatime ) {
|
||||
m_offtracklogdue = ( resting ? -1.0 : 1.0 );
|
||||
WriteLog( std::format(
|
||||
"derailment: {} {} {:.1f} m from where it left the rails, {:.1f} m from the axis of the track, at {:.1f} km/h, sliding sideways at {:.1f} m/s, tipped {:.0f} deg, roll {:.0f} deg, yaw {:+.1f} deg turning at {:+.1f} deg/s{}",
|
||||
physics->Name, resting ? "came to rest" : "off the track", motion.travelled(), off_track_offset(), std::abs( physics->V ) * 3.6, motion.sideways(),
|
||||
physics->Name, resting ? "came to rest" : "off the track", motion.travelled(), off_track_offset(), std::abs( physics->V() ) * 3.6, motion.sideways(),
|
||||
glm::degrees( motion.tipping() ), glm::degrees( motion.roll() ), glm::degrees( motion.yaw() ), glm::degrees( motion.yaw_rate() ), motion.lying() ? ", lying on its side" : "" ) );
|
||||
}
|
||||
|
||||
@@ -763,10 +763,10 @@ void TDynamicObject::renderWheelFlatSound() {
|
||||
if( physics->CategoryFlag == 1 ) {
|
||||
// trains only
|
||||
if( GetVelocity() > 1.0
|
||||
&& physics->WheelFlat > 5.0 ) {
|
||||
&& physics->WheelFlat() > 5.0 ) {
|
||||
m_wheelflat
|
||||
.pitch( m_wheelflat.m_frequencyoffset + std::abs( physics->nrot ) * m_wheelflat.m_frequencyfactor )
|
||||
.gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + physics->Vel / physics->Vmax + std::clamp( physics->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) )
|
||||
.gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + physics->Vel / physics->Vmax + std::clamp( physics->WheelFlat() / 60.0, 0.0, 1.0 ) ) / 3.0 ) )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
}
|
||||
else {
|
||||
@@ -786,7 +786,7 @@ void TDynamicObject::renderCurveSound() {
|
||||
&& std::abs(ts.R) < 15000.0 ) {
|
||||
// scale volume with curve radius and vehicle speed
|
||||
volume =
|
||||
std::abs( physics->AccN ) // * physics->AccN
|
||||
std::abs( physics->AccN() ) // * physics->AccN()
|
||||
* std::lerp(
|
||||
0.5, 1.0,
|
||||
std::clamp(
|
||||
@@ -817,7 +817,7 @@ void TDynamicObject::renderStartJoltSound() {
|
||||
// movement start jolt
|
||||
if( false == m_startjoltplayed ) {
|
||||
auto const velocity { GetVelocity() };
|
||||
if( ( physics->V > 0.0 ? physics->AccSVBased > 0.1 : physics->AccSVBased < 0.1 )
|
||||
if( ( physics->V() > 0.0 ? physics->AccSVBased > 0.1 : physics->AccSVBased < 0.1 )
|
||||
&& velocity > 1.0
|
||||
&& velocity < 15.0 ) {
|
||||
m_startjolt.play( sound_flags::exclusive );
|
||||
|
||||
+10
-11
@@ -170,10 +170,10 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
toggle_lights();
|
||||
}
|
||||
|
||||
if (physics->InactiveCabPantsCheck)
|
||||
if (physics->InactiveCabPantsCheck())
|
||||
{
|
||||
pants_up();
|
||||
physics->InactiveCabPantsCheck = false;
|
||||
physics->SetInactiveCabPantsCheck(false);
|
||||
}
|
||||
|
||||
if( physics->LoadStatus() ) {
|
||||
@@ -237,10 +237,10 @@ void TDynamicObject::updateCouplingState()
|
||||
// couplers
|
||||
if( physics->Couplers[0].CouplingFlag != Coupling::none
|
||||
&& physics->Couplers[1].CouplingFlag != Coupling::none ) {
|
||||
physics->InsideConsist = true;
|
||||
physics->SetInsideConsist(true);
|
||||
}
|
||||
else {
|
||||
physics->InsideConsist = false;
|
||||
physics->SetInsideConsist(false);
|
||||
}
|
||||
if( TestFlag( physics->AIFlag, sound::attachcoupler ) ) {
|
||||
auto *driver{ ctOwner ? ctOwner : Mechanik };
|
||||
@@ -478,7 +478,7 @@ void TDynamicObject::applyJointJolt( int const axleindex )
|
||||
{
|
||||
// crude bump simulation, drop down on even axles, move back up on
|
||||
// the odd ones
|
||||
// physics->AccVert += (physics->Vel*0.1f) *
|
||||
// physics->AccVert() += (physics->Vel*0.1f) *
|
||||
// the arguments keep the order they had up to 26.05.1, 0 in place of the value and the figure in place of the
|
||||
// upper limit, so they work out as the old clamp worked them out up to 26.05.1: the headroom is
|
||||
// Vmax - (Vel + 0.32 Vmax) whatever its sign, and the bump is capped from above only
|
||||
@@ -486,14 +486,13 @@ void TDynamicObject::applyJointJolt( int const axleindex )
|
||||
double const jolt = headroom * .05f * ( MyTrack->iDamageFlag * 0.25f );
|
||||
if (MyTrack->eType == tt_Normal)
|
||||
{
|
||||
physics->AccVert += safe_clamp( 0.0, 4.0, jolt );
|
||||
physics->ShakeVertically( safe_clamp( 0.0, 4.0, jolt ) );
|
||||
}
|
||||
else if (MyTrack->eType == tt_Switch)
|
||||
{
|
||||
double const accHorizontal = safe_clamp( 0.0, 1.0, jolt ) * ((axleindex % 2) != 0 ? 1 : -1);
|
||||
physics->AccS += accHorizontal;
|
||||
physics->AccN += accHorizontal;
|
||||
physics->AccVert += safe_clamp( 0.0, 2.0, jolt );
|
||||
physics->ShakeHorizontally( accHorizontal );
|
||||
physics->ShakeVertically( safe_clamp( 0.0, 2.0, jolt ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,10 +503,10 @@ void TDynamicObject::updateWheelAngles( double const dt1 )
|
||||
{ // McZapkie-050402: krecenie kolami:
|
||||
glm::dvec3 old_wheels = glm::dvec3(dWheelAngle[0], dWheelAngle[1], dWheelAngle[2]);
|
||||
|
||||
dWheelAngle[0] += 114.59155902616464175359630962821 * physics->V * dt1 /
|
||||
dWheelAngle[0] += 114.59155902616464175359630962821 * physics->V() * dt1 /
|
||||
physics->WheelDiameterL; // przednie toczne
|
||||
dWheelAngle[1] += physics->nrot * dt1 * 360.0; // napędne
|
||||
dWheelAngle[2] += 114.59155902616464175359630962821 * physics->V * dt1 /
|
||||
dWheelAngle[2] += 114.59155902616464175359630962821 * physics->V() * dt1 /
|
||||
physics->WheelDiameterT; // tylne toczne
|
||||
|
||||
|
||||
|
||||
@@ -147,10 +147,10 @@ vehicle_table::update_coupler_physics() const {
|
||||
std::unordered_set<TDynamicObject *> checked;
|
||||
for( auto *vehicle : m_items ) {
|
||||
if( covered.contains( vehicle ) ) {
|
||||
vehicle->physics->CouplerPhysics = true;
|
||||
vehicle->physics->SetCouplerPhysics(true);
|
||||
continue;
|
||||
}
|
||||
if( false == vehicle->physics->CouplerPhysics
|
||||
if( false == vehicle->physics->CouplerPhysics()
|
||||
|| checked.contains( vehicle ) ) {
|
||||
continue;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ vehicle_table::update_coupler_physics() const {
|
||||
checked.insert( other.begin(), other.end() );
|
||||
if( false == trains_within( other, train, coupler_physics_release ) ) {
|
||||
for( auto *othervehicle : other ) {
|
||||
othervehicle->physics->CouplerPhysics = false;
|
||||
othervehicle->physics->SetCouplerPhysics(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,7 @@ derail_motion::contact_body contact_body_of( TDynamicObject const &Vehicle ) {
|
||||
body.guided = true;
|
||||
body.guide = length > 1e-6 ? front / length : glm::dvec3 { 0.0, 0.0, 1.0 };
|
||||
body.base = Vehicle.GetPosition();
|
||||
body.velocity = body.guide * physics.V;
|
||||
body.velocity = body.guide * physics.V();
|
||||
}
|
||||
return body;
|
||||
}
|
||||
@@ -471,7 +471,7 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) {
|
||||
auto const correction { derail_motion::contact_correction * std::max( 0.0, hit->depth - derail_motion::contact_slop ) };
|
||||
if( glm::length( impulse ) > 0.0 ) {
|
||||
motion.kick( velocity, yawrate );
|
||||
vehicle->physics->V = motion.speed();
|
||||
vehicle->physics->SetV(motion.speed());
|
||||
}
|
||||
if( correction > 0.0 ) {
|
||||
motion.nudge( -hit->normal * ( share * correction ) );
|
||||
@@ -482,7 +482,7 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) {
|
||||
auto &othermotion { other->physics->OffTrack };
|
||||
if( glm::length( impulse ) > 0.0 ) {
|
||||
othermotion.kick( othervelocity, otheryawrate );
|
||||
other->physics->V = othermotion.speed();
|
||||
other->physics->SetV(othermotion.speed());
|
||||
}
|
||||
if( correction > 0.0 ) {
|
||||
othermotion.nudge( hit->normal * ( share * correction ) );
|
||||
@@ -492,7 +492,7 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) {
|
||||
}
|
||||
// one on the rails: along them into its speed, across them on its wheels, as a coupling pulls them off
|
||||
auto &otherPhysics { *other->physics };
|
||||
otherPhysics.V += glm::dot( impulse, otherbody.guide ) / std::max( otherPhysics.TotalMass, 1.0 );
|
||||
otherPhysics.SetV( otherPhysics.V() + glm::dot( impulse, otherbody.guide ) / std::max( otherPhysics.TotalMass, 1.0 ) );
|
||||
if( otherPhysics.DamageFlag.HasAll(VehicleDamage::derailed) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
||||
}
|
||||
|
||||
if( HuntingShake.fadein_begin > 0.f
|
||||
&& true == physics->TruckHunting ) {
|
||||
&& true == physics->TruckHunting() ) {
|
||||
// hunting oscillation
|
||||
HuntingAngle = clamp_circular( HuntingAngle + 4.0 * HuntingShake.frequency * Timedelta * physics->Vel, 360.0 );
|
||||
auto const huntingamount =
|
||||
@@ -695,11 +695,11 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
||||
if( iVel > 0.5 ) {
|
||||
// acceleration-driven base shake
|
||||
shakevector += glm::dvec3(
|
||||
replaced.sway ? 0.0 : -physics->AccN * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway
|
||||
-physics->AccVert * Timedelta * Global.ShakingMultiplierUD,
|
||||
replaced.sway ? 0.0 : -physics->AccN() * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway
|
||||
-physics->AccVert() * Timedelta * Global.ShakingMultiplierUD,
|
||||
-physics->AccSVBased * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration
|
||||
// unevenness of the track under the outer axles
|
||||
auto const ride { 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ) * ( physics->V * physics->V ) };
|
||||
auto const ride { 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ) * ( physics->V() * physics->V() ) };
|
||||
shakevector += glm::dvec3(
|
||||
-glm::dot( ride, vLeft ) * Timedelta * 5.0 * Global.ShakingMultiplierRL,
|
||||
-ride.y * Timedelta * Global.ShakingMultiplierUD,
|
||||
|
||||
@@ -179,7 +179,7 @@ void trainingcard_panel::render_contents()
|
||||
{
|
||||
state.store(2);
|
||||
if (simulation::Trains.sequence().size() > 0)
|
||||
distance = static_cast<float>(simulation::Trains.sequence()[0]->Dynamic()->physics->DistCounter);
|
||||
distance = static_cast<float>(simulation::Trains.sequence()[0]->Dynamic()->physics->DistCounter());
|
||||
|
||||
if (save_thread.joinable())
|
||||
save_thread.join();
|
||||
|
||||
@@ -228,9 +228,9 @@ void ui::vehicleparams_panel::render_contents()
|
||||
0.001f,
|
||||
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(),
|
||||
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
|
||||
vehicle.GetVelocity(), physics.DistCounter,
|
||||
vehicle.GetVelocity(), physics.DistCounter(),
|
||||
// position
|
||||
vehicle.GetPosition().x, vehicle.GetPosition().y, vehicle.GetPosition().z);
|
||||
|
||||
@@ -293,7 +293,7 @@ void ui::vehicleparams_panel::render_contents()
|
||||
if (ImGui::IsItemDeactivated())
|
||||
m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_RELEASE, 0, glm::vec3(0.0f), &vehicle_ptr->name());
|
||||
|
||||
if (vehicle_ptr->physics->V < 0.01)
|
||||
if (vehicle_ptr->physics->V() < 0.01)
|
||||
{
|
||||
if (ImGui::Button(STR_C("Move +500m")))
|
||||
m_relay.post(user_command::dynamicmove, 500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
|
||||
|
||||
+1
-1
@@ -3161,7 +3161,7 @@ void junction_node::update(double const Deltatime)
|
||||
if (first != nullptr)
|
||||
{
|
||||
gate.distance = nearest;
|
||||
gate.speed = std::abs(first->physics->V);
|
||||
gate.speed = std::abs(first->physics->V());
|
||||
gate.halflength = 0.5 * first->physics->Dim.L;
|
||||
gate.taken = ways_of(gate, first);
|
||||
gate.active = gate.distance < std::max(gate_zone, gate.speed * gate_gap) + gate.halflength;
|
||||
|
||||
+3
-3
@@ -860,7 +860,7 @@ void roadpoint_node::prepare()
|
||||
}
|
||||
pooled_vehicle entry;
|
||||
entry.vehicle = vehicle;
|
||||
entry.velocity = vehicle->physics->V;
|
||||
entry.velocity = vehicle->physics->V();
|
||||
m_pool.emplace_back(entry);
|
||||
// ...which is taken off the road right away, the way the vehicles leaving the scenery are, to wait for its turn
|
||||
if (vehicle->MyTrack != nullptr)
|
||||
@@ -998,7 +998,7 @@ void roadpoint_node::update_spawn(double const Deltatime)
|
||||
entry.standing = 0.0;
|
||||
continue;
|
||||
}
|
||||
auto const speed{vehicle->physics->V};
|
||||
auto const speed{vehicle->physics->V()};
|
||||
// forward is the way it went when it was put on the road
|
||||
auto const backwards{speed * entry.velocity < 0.0 && std::abs(speed) > reverse_speed};
|
||||
if (std::abs(speed) > stuck_speed || simulation::Roadpoints.holds(*vehicle))
|
||||
@@ -1062,7 +1062,7 @@ void roadpoint_node::update_spawn(double const Deltatime)
|
||||
// it comes back the way it was made: whole, at speed, with the driver told to drive on
|
||||
vehicle->bEnabled = true;
|
||||
vehicle->physics->repair_damage();
|
||||
vehicle->physics->V = entry.velocity;
|
||||
vehicle->physics->SetV(entry.velocity);
|
||||
vehicle->place_on_track(m_lanes.front(), m_offset + 0.5 * vehicle->physics->Dim.L, false);
|
||||
if (vehicle->Mechanik != nullptr)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user