mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 02:42:46 +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:
+18
-18
@@ -46,7 +46,7 @@ namespace
|
||||
bool legacy_derailed_slides(physics::Vehicle const &Vehicle)
|
||||
{
|
||||
return Global.collisions == global_settings::collision_model::physical && TestFlag(Vehicle.CategoryFlag, 1) && Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) &&
|
||||
Vehicle.Derailed == derailment::outcome::none;
|
||||
Vehicle.Derailed() == derailment::outcome::none;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -237,10 +237,10 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
|
||||
// a vehicle derailed by the physical criteria slides on with the friction of ComputeTotalForce(), and so does one
|
||||
// derailed the legacy way with physics.collisions new
|
||||
if (DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this))
|
||||
if (DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none && false == legacy_derailed_slides(*this))
|
||||
accS = -Sign(travelSpeed) * g * 1; // random(0.0, 0.1)
|
||||
// stuck in the ballast: the friction holds a derailed vehicle once it stopped, until the forces on it are larger
|
||||
auto const stuck{(Derailed != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
auto const stuck{(derailOutcome != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
if (stuck)
|
||||
accS = 0.0;
|
||||
|
||||
@@ -270,7 +270,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
// szarpanie
|
||||
/*
|
||||
#ifdef EU07_USE_FUZZYLOGIC
|
||||
if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / vmax, 500000.0, p_accn ) ) {
|
||||
if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * emptyMass * Vel / vmax, 500000.0, p_accn ) ) {
|
||||
// Ra: czemu tu masa bez ładunku?
|
||||
AccV /= ( 2.0 * 0.95 + 2.0 * Random() * 0.1 ); // 95-105% of base modifier (2.0)
|
||||
}
|
||||
@@ -349,9 +349,9 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh
|
||||
accS = std::lerp(AccSprev, FTotal / totalMass, 0.5);
|
||||
// std::clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim)
|
||||
|
||||
if (DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this))
|
||||
if (DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none && false == legacy_derailed_slides(*this))
|
||||
accS = -Sign(travelSpeed) * g * 1; // * random(0.0, 0.1)
|
||||
auto const stuck{(Derailed != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
auto const stuck{(derailOutcome != derailment::outcome::none || legacy_derailed_slides(*this)) && travelSpeed == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
if (stuck)
|
||||
accS = 0.0;
|
||||
|
||||
@@ -376,7 +376,7 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh
|
||||
|
||||
// a vehicle derailed by the physical criteria slides on with the friction of ComputeTotalForce(), and so does one
|
||||
// derailed the legacy way with physics.collisions new
|
||||
if (true == DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this) && Vel < 1.0)
|
||||
if (true == DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none && false == legacy_derailed_slides(*this) && Vel < 1.0)
|
||||
{
|
||||
travelSpeed = 0.0;
|
||||
accS = 0.0;
|
||||
@@ -745,7 +745,7 @@ void physics::Vehicle::ComputeConstans(void)
|
||||
void physics::Vehicle::ComputeMass()
|
||||
{
|
||||
// Ra: na razie tak, ale nie wszędzie masy wirujące się wliczają
|
||||
totalMass = Mass + mred;
|
||||
totalMass = emptyMass + mred;
|
||||
|
||||
if (loadAmount == 0)
|
||||
{
|
||||
@@ -812,11 +812,11 @@ void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
FStand = FrictionForce(); // siła oporów ruchu
|
||||
if (true == DamageFlag.HasAll(VehicleDamage::derailed))
|
||||
{
|
||||
if (Derailed != derailment::outcome::none)
|
||||
if (derailOutcome != derailment::outcome::none)
|
||||
{
|
||||
// off the rails by the physical criteria: the vehicle slides on the sleepers and the ballast, or on its side;
|
||||
// off the track on the ground, as far as it tipped over (physics.derailment new)
|
||||
auto const friction{OffTrack.active() ? OffTrack.friction() : derailment::sliding_friction(Derailed)};
|
||||
auto const friction{OffTrack.active() ? OffTrack.friction() : derailment::sliding_friction(derailOutcome)};
|
||||
FStand = friction * (totalMass - mred) * g;
|
||||
}
|
||||
else if (legacy_derailed_slides(*this))
|
||||
@@ -853,9 +853,9 @@ void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
FTrain *= FT_factor;
|
||||
}
|
||||
|
||||
Fb = BrakeForce(RunningTrack);
|
||||
brakingForce = BrakeForce(RunningTrack);
|
||||
// poslizg
|
||||
auto Fwheels{FTrain - Fb * Sign(travelSpeed)};
|
||||
auto Fwheels{FTrain - brakingForce * Sign(travelSpeed)};
|
||||
if (Vel > 0.1 // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
|
||||
&& std::abs(Fwheels) > TotalMassxg * Adhesive(RunningTrack.friction))
|
||||
{
|
||||
@@ -885,16 +885,16 @@ void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
Fwheels = Sign(temp_nrot * M_PI * wheelDiameter - travelSpeed) * TotalMassxg * Adhesive(RunningTrack.friction);
|
||||
if (Fwheels * Sign(travelSpeed) > 0)
|
||||
{
|
||||
FTrain = Fwheels + Fb * Sign(travelSpeed);
|
||||
FTrain = Fwheels + brakingForce * Sign(travelSpeed);
|
||||
}
|
||||
else if (FTrain * Sign(travelSpeed) > 0)
|
||||
{
|
||||
Fb = FTrain * Sign(travelSpeed) - Fwheels * Sign(travelSpeed);
|
||||
brakingForce = FTrain * Sign(travelSpeed) - Fwheels * Sign(travelSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
double factor = FTrain - Fb * Sign(travelSpeed) != 0 ? Fwheels / (FTrain - Fb * Sign(travelSpeed)) : 1.0;
|
||||
Fb *= factor;
|
||||
double factor = FTrain - brakingForce * Sign(travelSpeed) != 0 ? Fwheels / (FTrain - brakingForce * Sign(travelSpeed)) : 1.0;
|
||||
brakingForce *= factor;
|
||||
FTrain *= factor;
|
||||
}
|
||||
if (std::abs(nrotValue) < 0.1)
|
||||
@@ -930,7 +930,7 @@ void physics::Vehicle::ComputeTotalForce(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
FStand += Fb;
|
||||
FStand += brakingForce;
|
||||
// doliczenie składowej stycznej grawitacji
|
||||
FTrain /= FT_factor;
|
||||
FTrain += TotalMassxg * RunningShape.dHtrack;
|
||||
@@ -944,7 +944,7 @@ double physics::Vehicle::BrakeForceR(double ratio, double velocity) const
|
||||
ratio = brakes.distributor->GetBrakeRatio(ratio);
|
||||
if (brakes.config.maxPressureMass > 2)
|
||||
{
|
||||
press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (totalMass - Mass) / (brakes.config.maxPressureMass - Mass));
|
||||
press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (totalMass - emptyMass) / (brakes.config.maxPressureMass - emptyMass));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user