mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 10:37:07 +01:00
refactor(physics): six more of what the rest only reads are private, under names of their own
The mass of the empty vehicle, the braking force, the outcome of a derailment,
the departure signal, the traction mode of a dual-mode vehicle and the moment
of the motors are private to physics::Vehicle like the 53 before them, read
through Mass(), Fb(), Derailed(), DepartureSignal(), TractionMode() and Mm().
Inside the class they are emptyMass, brakingForce, derailOutcome,
departureSignalOn, tractionModeSetting and motorMoment, as the plain camelCase
names were taken by locals there.
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
@@ -171,7 +171,7 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
|
||||
// the crush, the vehicles coupled to the wall push it on (crush_hit())
|
||||
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
|
||||
auto const wall = [crushing, coupled](physics::Vehicle const &Vehicle) {
|
||||
return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.Derailed == derailment::outcome::none && false == coupled));
|
||||
return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.derailOutcome == derailment::outcome::none && false == coupled));
|
||||
};
|
||||
if (false == wall(*this))
|
||||
{
|
||||
@@ -259,7 +259,7 @@ void physics::Vehicle::derail_in_collision(DerailReason const Reason, std::strin
|
||||
return;
|
||||
}
|
||||
// upright, it slides on the sleepers and keeps passing the forces on
|
||||
Derailed = derailment::outcome::off_rails;
|
||||
derailOutcome = derailment::outcome::off_rails;
|
||||
derailCause = derail_motion::cause::collision;
|
||||
derailAcceleration = 0.0;
|
||||
derailSide = 0;
|
||||
@@ -372,8 +372,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
|
||||
// train. the vehicles coupled to it push it on, as the train behind a derailed vehicle does: a wall to them, it
|
||||
// stopped the whole train at once, and the vehicles behind it crushed by the energy of the train
|
||||
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
|
||||
auto const wall{false == coupled && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none};
|
||||
auto const otherwall{false == coupled && othervehicle->DamageFlag.HasAll(VehicleDamage::derailed) && othervehicle->Derailed == derailment::outcome::none};
|
||||
auto const wall{false == coupled && DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none};
|
||||
auto const otherwall{false == coupled && othervehicle->DamageFlag.HasAll(VehicleDamage::derailed) && othervehicle->derailOutcome == derailment::outcome::none};
|
||||
if (wall && otherwall)
|
||||
{
|
||||
return false;
|
||||
@@ -670,9 +670,9 @@ double physics::Vehicle::centre_of_gravity() const
|
||||
{
|
||||
auto const kind{EngineType == TEngineType::None ? derailment::vehicle_class::unpowered : derailment::vehicle_class::powered};
|
||||
auto const empty{CentreOfGravity > 0.0 ? CentreOfGravity : derailment::default_centre_of_gravity(Dim.H, kind)};
|
||||
auto const loadmass{totalMass - Mass - mred};
|
||||
auto const loadmass{totalMass - emptyMass - mred};
|
||||
auto const loadshare{maxLoad > 0.f ? loadAmount / maxLoad : 1.0};
|
||||
return derailment::loaded_centre_of_gravity(empty, Mass, loadmass, loadshare, Floor, Dim.H);
|
||||
return derailment::loaded_centre_of_gravity(empty, emptyMass, loadmass, loadshare, Floor, Dim.H);
|
||||
}
|
||||
|
||||
void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double const Distance)
|
||||
@@ -734,7 +734,7 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
|
||||
{
|
||||
return;
|
||||
}
|
||||
Derailed = Verdict.result;
|
||||
derailOutcome = Verdict.result;
|
||||
derailCause = Verdict.result == derailment::outcome::overturned ? derail_motion::cause::overturned : derail_motion::cause::off_rails;
|
||||
// out of the curve; a buckle bending the line against the curve more than the curve does throws it into the curve
|
||||
derailAcceleration = std::abs(Track.radius) > 1e-3 && derailment::line_curvature(Track) < 0.0 ? -Verdict.acceleration : Verdict.acceleration;
|
||||
@@ -754,7 +754,7 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
|
||||
void physics::Vehicle::rerail()
|
||||
{
|
||||
DamageFlag.Clear(VehicleDamage::derailed);
|
||||
Derailed = derailment::outcome::none;
|
||||
derailOutcome = derailment::outcome::none;
|
||||
// and back on the track; what derailed it before has no say in how it leaves the track the next time
|
||||
OffTrack.reset();
|
||||
derailCause = derail_motion::cause::off_rails;
|
||||
@@ -821,7 +821,7 @@ void physics::Vehicle::Derail(DerailReason const Reason)
|
||||
// ground as the vehicles the criteria derail do, and its brake hoses tear
|
||||
if (Reason == END_OF_TRACK && Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1))
|
||||
{
|
||||
Derailed = derailment::outcome::off_rails;
|
||||
derailOutcome = derailment::outcome::off_rails;
|
||||
derailCause = derail_motion::cause::end_of_track;
|
||||
derailAcceleration = 0.0;
|
||||
derailSide = 0;
|
||||
@@ -846,7 +846,7 @@ void physics::Vehicle::Derail(DerailReason const Reason)
|
||||
|
||||
bool physics::Vehicle::leaves_track() const
|
||||
{
|
||||
return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed != derailment::outcome::none &&
|
||||
return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome != derailment::outcome::none &&
|
||||
false == OffTrack.active();
|
||||
}
|
||||
|
||||
@@ -857,7 +857,7 @@ void physics::Vehicle::pull_off(int const Side, double const Acceleration, std::
|
||||
return;
|
||||
}
|
||||
// upright, its flange climbs the rail the coupling pulls it over
|
||||
Derailed = derailment::outcome::off_rails;
|
||||
derailOutcome = derailment::outcome::off_rails;
|
||||
derailCause = derail_motion::cause::pulled_off;
|
||||
derailAcceleration = Acceleration;
|
||||
derailSide = Side;
|
||||
|
||||
Reference in New Issue
Block a user