mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 23:19:19 +02:00
build 180718. ai slope logic tweaks, track grade ui indicator, minor bug fixes
This commit is contained in:
81
Driver.cpp
81
Driver.cpp
@@ -1410,16 +1410,24 @@ TController::braking_distance_multiplier( float const Targetvelocity ) const {
|
|||||||
|
|
||||||
if( Targetvelocity > 65.f ) { return 1.f; }
|
if( Targetvelocity > 65.f ) { return 1.f; }
|
||||||
if( Targetvelocity < 5.f ) {
|
if( Targetvelocity < 5.f ) {
|
||||||
|
// HACK: engaged automatic transmission means extra/earlier braking effort is needed for the last leg before full stop
|
||||||
if( ( mvOccupied->TrainType == dt_DMU )
|
if( ( mvOccupied->TrainType == dt_DMU )
|
||||||
&& ( mvOccupied->Vel < 40.0 )
|
&& ( mvOccupied->Vel < 40.0 )
|
||||||
&& ( Targetvelocity == 0.f ) ) {
|
&& ( Targetvelocity == 0.f ) ) {
|
||||||
// HACK: engaged automatic transmission means extra/earlier braking effort is needed for the last leg before full stop
|
|
||||||
return interpolate( 2.f, 1.f, static_cast<float>( mvOccupied->Vel / 40.0 ) );
|
return interpolate( 2.f, 1.f, static_cast<float>( mvOccupied->Vel / 40.0 ) );
|
||||||
}
|
}
|
||||||
else {
|
// HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop
|
||||||
return 1.f;
|
if( ( fBrake_a0[ 0 ] > 0.2 )
|
||||||
|
&& ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 )
|
||||||
|
|| ( fAccGravity > 0.025 ) ) {
|
||||||
|
return interpolate(
|
||||||
|
1.f, 3.f,
|
||||||
|
clamp(
|
||||||
|
( fBrake_a0[ 0 ] - 0.2 ) / 0.2,
|
||||||
|
0.0, 1.0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1.f;
|
||||||
}
|
}
|
||||||
// stretch the braking distance up to 3 times; the lower the speed, the greater the stretch
|
// stretch the braking distance up to 3 times; the lower the speed, the greater the stretch
|
||||||
return interpolate( 3.f, 1.f, ( Targetvelocity - 5.f ) / 60.f );
|
return interpolate( 3.f, 1.f, ( Targetvelocity - 5.f ) / 60.f );
|
||||||
@@ -1546,7 +1554,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
|
|||||||
// fAccThreshold może podlegać uczeniu się - hamowanie powinno być rejestrowane, a potem analizowane
|
// fAccThreshold może podlegać uczeniu się - hamowanie powinno być rejestrowane, a potem analizowane
|
||||||
// próg opóźnienia dla zadziałania hamulca
|
// próg opóźnienia dla zadziałania hamulca
|
||||||
fAccThreshold = (
|
fAccThreshold = (
|
||||||
mvOccupied->TrainType == dt_EZT ? -0.6 :
|
mvOccupied->TrainType == dt_EZT ? -0.55 :
|
||||||
mvOccupied->TrainType == dt_DMU ? -0.45 :
|
mvOccupied->TrainType == dt_DMU ? -0.45 :
|
||||||
-0.2 );
|
-0.2 );
|
||||||
}
|
}
|
||||||
@@ -1868,7 +1876,7 @@ void TController::AutoRewident()
|
|||||||
fBrake_a1[i+1] /= (12*fMass);
|
fBrake_a1[i+1] /= (12*fMass);
|
||||||
}
|
}
|
||||||
if( mvOccupied->TrainType == dt_EZT ) {
|
if( mvOccupied->TrainType == dt_EZT ) {
|
||||||
fAccThreshold = std::max(-fBrake_a0[BrakeAccTableSize] - 8 * fBrake_a1[BrakeAccTableSize], -0.6);
|
fAccThreshold = std::max(-fBrake_a0[BrakeAccTableSize] - 8 * fBrake_a1[BrakeAccTableSize], -0.55);
|
||||||
fBrakeReaction = 0.25;
|
fBrakeReaction = 0.25;
|
||||||
}
|
}
|
||||||
else if( mvOccupied->TrainType == dt_DMU ) {
|
else if( mvOccupied->TrainType == dt_DMU ) {
|
||||||
@@ -2744,12 +2752,12 @@ bool TController::IncSpeed()
|
|||||||
// na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag)
|
// na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag)
|
||||||
if (Ready || (iDrivigFlags & movePress)) {
|
if (Ready || (iDrivigFlags & movePress)) {
|
||||||
// use series mode:
|
// use series mode:
|
||||||
// to build up speed to 30/40 km/h for passenger/cargo train,
|
// to build up speed to 30/40 km/h for passenger/cargo train (less if going uphill, more if downhill)
|
||||||
// if high threshold is set for motor overload relay,
|
// if high threshold is set for motor overload relay,
|
||||||
// if the power station is heavily burdened
|
// if the power station is heavily burdened
|
||||||
auto const useseriesmodevoltage { 0.80 * mvControlling->EnginePowerSource.CollectorParameters.MaxV };
|
auto const useseriesmodevoltage { 0.80 * mvControlling->EnginePowerSource.CollectorParameters.MaxV };
|
||||||
auto const useseriesmode = (
|
auto const useseriesmode = (
|
||||||
( mvOccupied->Vel <= ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 ? 35 : 25 ) + ( mvControlling->ScndCtrlPos == 0 ? 0 : 5 ) )
|
( mvOccupied->Vel <= ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 ? 35 : 25 ) + ( mvControlling->ScndCtrlPos == 0 ? 0 : 5 ) + ( fAccGravity * 100 ) )
|
||||||
|| ( mvControlling->Imax > mvControlling->ImaxLo )
|
|| ( mvControlling->Imax > mvControlling->ImaxLo )
|
||||||
|| ( fVoltage < useseriesmodevoltage ) );
|
|| ( fVoltage < useseriesmodevoltage ) );
|
||||||
// when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train
|
// when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train
|
||||||
@@ -3731,13 +3739,14 @@ TController::UpdateSituation(double dt) {
|
|||||||
if( ( dy = p->VectorFront().y ) != 0.0 ) {
|
if( ( dy = p->VectorFront().y ) != 0.0 ) {
|
||||||
// istotne tylko dla pojazdów na pochyleniu
|
// istotne tylko dla pojazdów na pochyleniu
|
||||||
// ciężar razy składowa styczna grawitacji
|
// ciężar razy składowa styczna grawitacji
|
||||||
fAccGravity -= p->DirectionGet() * p->MoverParameters->TotalMassxg * dy;
|
fAccGravity -= p->MoverParameters->TotalMassxg * dy * ( p->DirectionGet() == iDirection ? 1 : -1 );
|
||||||
}
|
}
|
||||||
p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła)
|
p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła)
|
||||||
}
|
}
|
||||||
if( iDirection ) {
|
if( iDirection ) {
|
||||||
// siłę generują pojazdy na pochyleniu ale działa ona całość składu, więc a=F/m
|
// siłę generują pojazdy na pochyleniu ale działa ona całość składu, więc a=F/m
|
||||||
fAccGravity /= iDirection * fMass;
|
fAccGravity *= iDirection;
|
||||||
|
fAccGravity /= fMass;
|
||||||
}
|
}
|
||||||
if (!Ready) // v367: jeśli wg powyższych warunków skład nie jest odhamowany
|
if (!Ready) // v367: jeśli wg powyższych warunków skład nie jest odhamowany
|
||||||
if (fAccGravity < -0.05) // jeśli ma pod górę na tyle, by się stoczyć
|
if (fAccGravity < -0.05) // jeśli ma pod górę na tyle, by się stoczyć
|
||||||
@@ -4924,8 +4933,7 @@ TController::UpdateSituation(double dt) {
|
|||||||
// decisions based on current speed
|
// decisions based on current speed
|
||||||
if( mvOccupied->CategoryFlag == 1 ) {
|
if( mvOccupied->CategoryFlag == 1 ) {
|
||||||
|
|
||||||
if( fAccGravity < 0.025 ) {
|
// on flats or uphill we can be less careful
|
||||||
// on flats on uphill we can be less careful
|
|
||||||
if( vel > VelDesired ) {
|
if( vel > VelDesired ) {
|
||||||
// jesli jedzie za szybko do AKTUALNEGO
|
// jesli jedzie za szybko do AKTUALNEGO
|
||||||
if( VelDesired == 0.0 ) {
|
if( VelDesired == 0.0 ) {
|
||||||
@@ -4946,8 +4954,8 @@ TController::UpdateSituation(double dt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
if( fAccGravity > 0.025 ) {
|
||||||
// going sharply downhill we may need to start braking sooner than usual
|
// going sharply downhill we may need to start braking sooner than usual
|
||||||
// try to estimate increase of current velocity before engaged brakes start working
|
// try to estimate increase of current velocity before engaged brakes start working
|
||||||
auto const speedestimate = vel + ( 1.0 - fBrake_a0[ 0 ] ) * 30.0 * AbsAccS;
|
auto const speedestimate = vel + ( 1.0 - fBrake_a0[ 0 ] ) * 30.0 * AbsAccS;
|
||||||
@@ -4958,19 +4966,38 @@ TController::UpdateSituation(double dt) {
|
|||||||
AccDesired = std::min( AccDesired, -0.85 ); // hamuj solidnie
|
AccDesired = std::min( AccDesired, -0.85 ); // hamuj solidnie
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( speedestimate > ( VelDesired + fVelPlus ) ) {
|
// if it looks like we'll exceed maximum speed start thinking about slight slowing down
|
||||||
// if it looks like we'll exceed maximum allowed speed start thinking about slight slowing down
|
|
||||||
AccDesired = std::min( AccDesired, -0.25 );
|
AccDesired = std::min( AccDesired, -0.25 );
|
||||||
|
// HACK: for cargo trains with high braking threshold ensure we cross that threshold
|
||||||
|
if( ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 )
|
||||||
|
&& ( fBrake_a0[ 0 ] > 0.2 ) ) {
|
||||||
|
AccDesired -= clamp( fBrake_a0[ 0 ] - 0.2, 0.0, 0.15 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// close enough to target to stop accelerating
|
// stop accelerating when close enough to target speed
|
||||||
AccDesired = std::min(
|
AccDesired = std::min(
|
||||||
AccDesired, // but don't override decceleration for VelNext
|
AccDesired, // but don't override decceleration for VelNext
|
||||||
interpolate( // ease off as you close to the target velocity
|
interpolate( // ease off as you close to the target velocity
|
||||||
-0.06, AccPreferred,
|
-0.06, AccPreferred,
|
||||||
clamp( speedestimate - vel, 0.0, fVelPlus ) / fVelPlus ) );
|
clamp( VelDesired - speedestimate, 0.0, fVelMinus ) / fVelMinus ) );
|
||||||
}
|
}
|
||||||
|
// final tweaks
|
||||||
|
if( vel > 0.1 ) {
|
||||||
|
// going downhill also take into account impact of gravity
|
||||||
|
AccDesired -= fAccGravity;
|
||||||
|
// HACK: if the max allowed speed was exceeded something went wrong; brake harder
|
||||||
|
AccDesired -= 0.15 * clamp( vel - VelDesired, 0.0, 5.0 );
|
||||||
|
/*
|
||||||
|
if( ( vel > VelDesired )
|
||||||
|
&& ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 )
|
||||||
|
&& ( fBrake_a0[ 0 ] > 0.2 ) ) {
|
||||||
|
AccDesired = clamp(
|
||||||
|
AccDesired - clamp( fBrake_a0[ 0 ] - 0.2, 0.0, 0.15 ),
|
||||||
|
-0.9, 0.9 );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5001,14 +5028,7 @@ TController::UpdateSituation(double dt) {
|
|||||||
|
|
||||||
// last step sanity check, until the whole calculation is straightened out
|
// last step sanity check, until the whole calculation is straightened out
|
||||||
AccDesired = std::min( AccDesired, AccPreferred );
|
AccDesired = std::min( AccDesired, AccPreferred );
|
||||||
|
AccDesired = clamp( AccDesired, -0.9, 0.9 );
|
||||||
if( ( mvOccupied->CategoryFlag == 1 )
|
|
||||||
&& ( fAccGravity > 0.025 ) ) {
|
|
||||||
// going downhill also take into account impact of gravity
|
|
||||||
AccDesired = clamp( AccDesired - fAccGravity, -0.9, 0.9 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (AIControllFlag) {
|
if (AIControllFlag) {
|
||||||
// część wykonawcza tylko dla AI, dla człowieka jedynie napisy
|
// część wykonawcza tylko dla AI, dla człowieka jedynie napisy
|
||||||
@@ -5214,7 +5234,12 @@ TController::UpdateSituation(double dt) {
|
|||||||
if( mvOccupied->TrainType == dt_EZT ) {
|
if( mvOccupied->TrainType == dt_EZT ) {
|
||||||
// właściwie, to warunek powinien być na działający EP
|
// właściwie, to warunek powinien być na działający EP
|
||||||
// Ra: to dobrze hamuje EP w EZT
|
// Ra: to dobrze hamuje EP w EZT
|
||||||
if( ( AccDesired <= fAccThreshold ) // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold
|
// HACK: when going downhill be more responsive to desired deceleration
|
||||||
|
auto const accthreshold { (
|
||||||
|
fAccGravity < 0.025 ?
|
||||||
|
fAccThreshold :
|
||||||
|
std::max( -0.2, fAccThreshold ) ) };
|
||||||
|
if( ( AccDesired <= accthreshold ) // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold
|
||||||
&& ( ( AbsAccS > AccDesired )
|
&& ( ( AbsAccS > AccDesired )
|
||||||
|| ( mvOccupied->BrakeCtrlPos < 0 ) ) ) {
|
|| ( mvOccupied->BrakeCtrlPos < 0 ) ) ) {
|
||||||
// hamować bardziej, gdy aktualne opóźnienie hamowania mniejsze niż (AccDesired)
|
// hamować bardziej, gdy aktualne opóźnienie hamowania mniejsze niż (AccDesired)
|
||||||
@@ -5242,7 +5267,7 @@ TController::UpdateSituation(double dt) {
|
|||||||
} // type & dt_ezt
|
} // type & dt_ezt
|
||||||
else {
|
else {
|
||||||
// a stara wersja w miarę dobrze działa na składy wagonowe
|
// a stara wersja w miarę dobrze działa na składy wagonowe
|
||||||
if( ( ( fAccGravity < -0.05 ) && ( vel < 0.0 ) )
|
if( ( ( fAccGravity < -0.05 ) && ( vel < -0.1 ) ) // brake if uphill and slipping back
|
||||||
|| ( ( AccDesired < fAccGravity - 0.1 ) && ( AbsAccS > AccDesired + fBrake_a1[ 0 ] ) ) ) {
|
|| ( ( AccDesired < fAccGravity - 0.1 ) && ( AbsAccS > AccDesired + fBrake_a1[ 0 ] ) ) ) {
|
||||||
// u góry ustawia się hamowanie na fAccThreshold
|
// u góry ustawia się hamowanie na fAccThreshold
|
||||||
if( ( fBrakeTime < 0.0 )
|
if( ( fBrakeTime < 0.0 )
|
||||||
|
|||||||
4
DynObj.h
4
DynObj.h
@@ -564,12 +564,12 @@ private:
|
|||||||
inline double ABuGetDirection() const { // ABu.
|
inline double ABuGetDirection() const { // ABu.
|
||||||
return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection()); };
|
return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection()); };
|
||||||
// zwraca kierunek pojazdu na torze z aktywną osą
|
// zwraca kierunek pojazdu na torze z aktywną osą
|
||||||
inline double RaDirectionGet() {
|
inline double RaDirectionGet() const {
|
||||||
return iAxleFirst ?
|
return iAxleFirst ?
|
||||||
Axle1.GetDirection() :
|
Axle1.GetDirection() :
|
||||||
Axle0.GetDirection(); };
|
Axle0.GetDirection(); };
|
||||||
// zwraca przesunięcie wózka względem Point1 toru z aktywną osią
|
// zwraca przesunięcie wózka względem Point1 toru z aktywną osią
|
||||||
inline double RaTranslationGet() {
|
inline double RaTranslationGet() const {
|
||||||
return iAxleFirst ?
|
return iAxleFirst ?
|
||||||
Axle1.GetTranslation() :
|
Axle1.GetTranslation() :
|
||||||
Axle0.GetTranslation(); };
|
Axle0.GetTranslation(); };
|
||||||
|
|||||||
49
Train.cpp
49
Train.cpp
@@ -606,6 +606,28 @@ bool TTrain::is_eztoer() const {
|
|||||||
&& ( mvControlled->ActiveDir != 0 ) ); // od yB
|
&& ( mvControlled->ActiveDir != 0 ) ); // od yB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mover master controller to specified position
|
||||||
|
void TTrain::set_master_controller( double const Position ) {
|
||||||
|
|
||||||
|
auto positionchange {
|
||||||
|
std::min<int>(
|
||||||
|
Position,
|
||||||
|
( mvControlled->CoupledCtrl ?
|
||||||
|
mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo :
|
||||||
|
mvControlled->MainCtrlPosNo ) )
|
||||||
|
- ( mvControlled->CoupledCtrl ?
|
||||||
|
mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos :
|
||||||
|
mvControlled->MainCtrlPos ) };
|
||||||
|
while( ( positionchange < 0 )
|
||||||
|
&& ( true == mvControlled->DecMainCtrl( 1 ) ) ) {
|
||||||
|
++positionchange;
|
||||||
|
}
|
||||||
|
while( ( positionchange > 0 )
|
||||||
|
&& ( true == mvControlled->IncMainCtrl( 1 ) ) ) {
|
||||||
|
--positionchange;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
||||||
void TTrain::set_train_brake( double const Position ) {
|
void TTrain::set_train_brake( double const Position ) {
|
||||||
|
|
||||||
@@ -746,22 +768,9 @@ void TTrain::OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data
|
|||||||
|
|
||||||
void TTrain::OnCommand_mastercontrollerset( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_mastercontrollerset( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
auto positionchange {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
std::min<int>(
|
// on press or hold
|
||||||
Command.param1,
|
Train->set_master_controller( Command.param1 );
|
||||||
( Train->mvControlled->CoupledCtrl ?
|
|
||||||
Train->mvControlled->MainCtrlPosNo + Train->mvControlled->ScndCtrlPosNo :
|
|
||||||
Train->mvControlled->MainCtrlPosNo ) )
|
|
||||||
- ( Train->mvControlled->CoupledCtrl ?
|
|
||||||
Train->mvControlled->MainCtrlPos + Train->mvControlled->ScndCtrlPos :
|
|
||||||
Train->mvControlled->MainCtrlPos ) };
|
|
||||||
while( ( positionchange < 0 )
|
|
||||||
&& ( true == Train->mvControlled->DecMainCtrl( 1 ) ) ) {
|
|
||||||
++positionchange;
|
|
||||||
}
|
|
||||||
while( ( positionchange > 0 )
|
|
||||||
&& ( true == Train->mvControlled->IncMainCtrl( 1 ) ) ) {
|
|
||||||
--positionchange;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5103,12 +5112,8 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
&& ( false == DynamicObject->Mechanik->AIControllFlag ) // nie blokujemy AI
|
&& ( false == DynamicObject->Mechanik->AIControllFlag ) // nie blokujemy AI
|
||||||
&& ( Global.iFeedbackMode == 4 )
|
&& ( Global.iFeedbackMode == 4 )
|
||||||
&& ( Global.fCalibrateIn[ 2 ][ 1 ] != 0.0 ) ) {
|
&& ( Global.fCalibrateIn[ 2 ][ 1 ] != 0.0 ) ) {
|
||||||
auto const b = clamp<double>(
|
|
||||||
Console::AnalogCalibrateGet(2) * mvOccupied->MainCtrlPosNo,
|
set_master_controller( Console::AnalogCalibrateGet( 2 ) * mvOccupied->MainCtrlPosNo );
|
||||||
0.0,
|
|
||||||
mvOccupied->MainCtrlPosNo);
|
|
||||||
while (mvOccupied->MainCtrlPos < b) { mvOccupied->MainCtrlPos = b - 1; mvOccupied->IncMainCtrl(1); }
|
|
||||||
while (mvOccupied->MainCtrlPos > b) { mvOccupied->MainCtrlPos = b + 1; mvOccupied->DecMainCtrl(1); }
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -132,6 +132,8 @@ class TTrain
|
|||||||
bool is_eztoer() const;
|
bool is_eztoer() const;
|
||||||
// locates nearest vehicle belonging to the consist
|
// locates nearest vehicle belonging to the consist
|
||||||
TDynamicObject *find_nearest_consist_vehicle() const;
|
TDynamicObject *find_nearest_consist_vehicle() const;
|
||||||
|
// mover master controller to specified position
|
||||||
|
void set_master_controller( double const Position );
|
||||||
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
||||||
void set_train_brake( double const Position );
|
void set_train_brake( double const Position );
|
||||||
// sets specified brake acting speed for specified vehicle, potentially updating state of cab controls to match
|
// sets specified brake acting speed for specified vehicle, potentially updating state of cab controls to match
|
||||||
|
|||||||
11
uilayer.cpp
11
uilayer.cpp
@@ -293,13 +293,18 @@ ui_layer::update() {
|
|||||||
uitextline2 +=
|
uitextline2 +=
|
||||||
" Speed: " + std::to_string( static_cast<int>( std::floor( mover->Vel ) ) ) + " km/h"
|
" Speed: " + std::to_string( static_cast<int>( std::floor( mover->Vel ) ) ) + " km/h"
|
||||||
+ " (limit: " + std::to_string( speedlimit ) + " km/h";
|
+ " (limit: " + std::to_string( speedlimit ) + " km/h";
|
||||||
auto const nextspeedlimit { static_cast<int>( std::floor( controlled->Mechanik->VelNext ) ) };
|
auto const nextspeedlimit { static_cast<int>( std::floor( driver->VelNext ) ) };
|
||||||
if( nextspeedlimit != speedlimit ) {
|
if( nextspeedlimit != speedlimit ) {
|
||||||
uitextline2 +=
|
uitextline2 +=
|
||||||
", new limit: " + std::to_string( nextspeedlimit ) + " km/h"
|
", new limit: " + std::to_string( nextspeedlimit ) + " km/h"
|
||||||
+ " in " + to_string( controlled->Mechanik->ActualProximityDist * 0.001, 1 ) + " km";
|
+ " in " + to_string( driver->ActualProximityDist * 0.001, 1 ) + " km";
|
||||||
}
|
}
|
||||||
uitextline2 += ")";
|
uitextline2 += ")";
|
||||||
|
auto const reverser { ( mover->ActiveDir > 0 ? 1 : -1 ) };
|
||||||
|
auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser };
|
||||||
|
if( std::abs( grade ) >= 0.25 ) {
|
||||||
|
uitextline2 += " Grade: " + to_string( grade, 1 ) + "%";
|
||||||
|
}
|
||||||
uitextline3 +=
|
uitextline3 +=
|
||||||
" Pressure: " + to_string( mover->BrakePress * 100.0, 2 ) + " kPa"
|
" Pressure: " + to_string( mover->BrakePress * 100.0, 2 ) + " kPa"
|
||||||
+ " (train pipe: " + to_string( mover->PipePress * 100.0, 2 ) + " kPa)";
|
+ " (train pipe: " + to_string( mover->PipePress * 100.0, 2 ) + " kPa)";
|
||||||
@@ -513,7 +518,7 @@ ui_layer::update() {
|
|||||||
+ ( vehicle->MoverParameters->SlippingWheels ? " (!)" : "" );
|
+ ( vehicle->MoverParameters->SlippingWheels ? " (!)" : "" );
|
||||||
|
|
||||||
if( vehicle->Mechanik ) {
|
if( vehicle->Mechanik ) {
|
||||||
uitextline2 += "; Ag: " + to_string( vehicle->Mechanik->fAccGravity, 2 );
|
uitextline2 += "; Ag: " + to_string( vehicle->Mechanik->fAccGravity, 2 ) + " (" + ( vehicle->Mechanik->fAccGravity > 0.01 ? "\\" : ( vehicle->Mechanik->fAccGravity < -0.01 ? "/" : "-" ) ) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
uitextline2 +=
|
uitextline2 +=
|
||||||
|
|||||||
@@ -254,14 +254,14 @@ template <typename Type_>
|
|||||||
Type_
|
Type_
|
||||||
interpolate( Type_ const &First, Type_ const &Second, float const Factor ) {
|
interpolate( Type_ const &First, Type_ const &Second, float const Factor ) {
|
||||||
|
|
||||||
return ( First * ( 1.0f - Factor ) ) + ( Second * Factor );
|
return static_cast<Type_>( ( First * ( 1.0f - Factor ) ) + ( Second * Factor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type_>
|
template <typename Type_>
|
||||||
Type_
|
Type_
|
||||||
interpolate( Type_ const &First, Type_ const &Second, double const Factor ) {
|
interpolate( Type_ const &First, Type_ const &Second, double const Factor ) {
|
||||||
|
|
||||||
return ( First * ( 1.0 - Factor ) ) + ( Second * Factor );
|
return static_cast<Type_>( ( First * ( 1.0 - Factor ) ) + ( Second * Factor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// tests whether provided points form a degenerate triangle
|
// tests whether provided points form a degenerate triangle
|
||||||
|
|||||||
Reference in New Issue
Block a user