16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 16:19:19 +02:00

driving aid panel enhancement, event queue text filter, minor bug fixes

This commit is contained in:
tmj-fstate
2021-03-11 03:27:22 +01:00
parent 98ef06e8fd
commit c216329bfa
10 changed files with 634 additions and 484 deletions

View File

@@ -876,6 +876,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
auto d { 0.0 }; // droga auto d { 0.0 }; // droga
auto d_to_next_sem { 10000.0 }; //ustaiwamy na pewno dalej niż widzi AI auto d_to_next_sem { 10000.0 }; //ustaiwamy na pewno dalej niż widzi AI
auto go { TCommandType::cm_Unknown }; auto go { TCommandType::cm_Unknown };
auto speedlimitiscontinuous { true }; // stays true if potential active speed limit is unbroken to the last (relevant) point in scan table
eSignNext = nullptr; eSignNext = nullptr;
IsAtPassengerStop = false; IsAtPassengerStop = false;
IsScheduledPassengerStopVisible = false; IsScheduledPassengerStopVisible = false;
@@ -903,11 +904,13 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
auto const railwaytrackend { ( true == TestFlag( point.iFlags, spEnd ) ) && ( is_train() ) }; auto const railwaytrackend { ( true == TestFlag( point.iFlags, spEnd ) ) && ( is_train() ) };
if( ( v >= 0.0 ) if( ( v >= 0.0 ) // pozycje z prędkością -1 można spokojnie pomijać
|| ( railwaytrackend ) ) { || ( railwaytrackend ) ) {
// pozycje z prędkością -1 można spokojnie pomijać
d = point.fDist; d = point.fDist;
if( v >= 0.0 ) { if( v >= 0.0 ) {
// points located in front of us can potentially affect our acceleration and target speed
if( ( d > 0.0 ) if( ( d > 0.0 )
&& ( false == TestFlag( point.iFlags, spElapsed ) ) ) { && ( false == TestFlag( point.iFlags, spElapsed ) ) ) {
// sygnał lub ograniczenie z przodu (+32=przejechane) // sygnał lub ograniczenie z przodu (+32=przejechane)
@@ -942,6 +945,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
} }
} }
// points located behind can affect our current speed, but little else
else if ( point.iFlags & spTrack) // jeśli tor else if ( point.iFlags & spTrack) // jeśli tor
{ // tor ogranicza prędkość, dopóki cały skład nie przejedzie, { // tor ogranicza prędkość, dopóki cały skład nie przejedzie,
if( v >= 1.0 ) { // EU06 się zawieszało po dojechaniu na koniec toru postojowego if( v >= 1.0 ) { // EU06 się zawieszało po dojechaniu na koniec toru postojowego
@@ -959,6 +963,9 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
if( v < VelLimitLastDist.first ) { if( v < VelLimitLastDist.first ) {
VelLimitLastDist.second = d + point.trTrack->Length() + fLength; VelLimitLastDist.second = d + point.trTrack->Length() + fLength;
} }
else if( VelLimitLastDist.second > 0 ) { // the speed limit can potentially start afterwards, so don't mark it as broken too soon
speedlimitiscontinuous = false;
}
if( false == railwaytrackend ) { if( false == railwaytrackend ) {
continue; // i tyle wystarczy continue; // i tyle wystarczy
} }
@@ -974,8 +981,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
// track can potentially end, which creates another virtual point of interest with speed limit of 0 at the end of it // track can potentially end, which creates another virtual point of interest with speed limit of 0 at the end of it
// TBD, TODO: when tracing the route create a dedicated table entry for it, to simplify the code? // TBD, TODO: when tracing the route create a dedicated table entry for it, to simplify the code?
if( ( true == TestFlag( point.iFlags, spEnd ) ) if( railwaytrackend ) {
&& ( is_train() ) ) {
// if the railway track ends here set the velnext accordingly as well // if the railway track ends here set the velnext accordingly as well
// TODO: test this with turntables and such // TODO: test this with turntables and such
auto const stopatendacceleration = ( -1.0 * mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * ( d + point.trTrack->Length() ) ); auto const stopatendacceleration = ( -1.0 * mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * ( d + point.trTrack->Length() ) );
@@ -990,27 +996,53 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
} }
} }
if ((a < fAcc) && (v == min_speed(v, fNext))) { if( ( a <= fAcc )
&& ( ( v < fNext ) || ( fNext < 0 ) ) ) { // filter out consecutive, farther out blocks with the same speed limit; they'd make us accelerate slower due to their lower a value
// mniejsze przyspieszenie to mniejsza możliwość rozpędzenia się albo konieczność hamowania // mniejsze przyspieszenie to mniejsza możliwość rozpędzenia się albo konieczność hamowania
// jeśli droga wolna, to może być a>1.0 i się tu nie załapuje // jeśli droga wolna, to może być a>1.0 i się tu nie załapuje
fAcc = a; // zalecane przyspieszenie (nie musi być uwzględniane przez AI) fAcc = a; // zalecane przyspieszenie (nie musi być uwzględniane przez AI)
fNext = v; // istotna jest prędkość na końcu tego odcinka fNext = v; // istotna jest prędkość na końcu tego odcinka
fDist = d; // dlugość odcinka fDist = d; // dlugość odcinka
} }
else if ((fAcc > 0) && (v >= 0) && (v <= fNext)) { /*
else if ((fAcc > 0) && (v >= 0) && (v > fNext)) {
// jeśli nie ma wskazań do hamowania, można podać drogę i prędkość na jej końcu // jeśli nie ma wskazań do hamowania, można podać drogę i prędkość na jej końcu
fNext = v; // istotna jest prędkość na końcu tego odcinka fNext = v; // istotna jest prędkość na końcu tego odcinka
fDist = d; // dlugość odcinka (kolejne pozycje mogą wydłużać drogę, jeśli prędkość jest stała) fDist = d; // dlugość odcinka (kolejne pozycje mogą wydłużać drogę, jeśli prędkość jest stała)
} }
if( ( v < VelLimitLastDist.first ) /* && ( d < VelLimitLastDist.second ) */ ) { */
// if we encounter another speed limit before we can clear current/last registered one, // we'll pick first scanned target speed as our goal
// update our calculation where we'll be able to resume regular speed // farther scan table points can override it through previous clause, if they require lower acceleration or speed reduction
else if( ( a > 0 ) && ( a <= fAcc ) && ( v >= 0 ) && ( fNext < 0 ) ) {
fAcc = a;
fNext = v;
fDist = d;
}
// potentially update our current speed limit
if( ( v < VelLimitLastDist.first )
&& ( ( d < 0 ) // the point counts as part of last speed limit either if it's behind us
|| ( VelLimitLastDist.second > 0 ) ) ) { // or if we already have the last limit ongoing
VelLimitLastDist.second = d + fLength; VelLimitLastDist.second = d + fLength;
if( ( point.iFlags & spTrack ) != 0 ) { if( ( point.iFlags & spTrack ) != 0 ) {
VelLimitLastDist.second += point.trTrack->Length(); VelLimitLastDist.second += point.trTrack->Length();
} }
} }
else {
// if we found a point which isn't part of the current speed limit mark the limit as broken
// NOTE: we exclude switches from this rule, as speed limits generally extend through these
if( ( point.iFlags & ( spSwitch | spPassengerStopPoint ) ) == 0 ) {
speedlimitiscontinuous = false;
}
}
} // if (v>=0.0) } // if (v>=0.0)
// finding a point which doesn't impose speed limit means any potential active speed limit can't extend through entire scan table
// NOTE: we test actual speed value for the given point, as events may receive (v = -1) as a way to disable them in irrelevant modes
if( point.fVelNext < 0 ) {
// NOTE: we exclude switches from this rule, as speed limits generally extend through these
if( ( point.iFlags & ( spSwitch | spPassengerStopPoint ) ) == 0 ) {
speedlimitiscontinuous = false;
}
}
if (fNext >= 0.0) if (fNext >= 0.0)
{ // jeśli ograniczenie { // jeśli ograniczenie
if( ( point.iFlags & ( spEnabled | spEvent ) ) == ( spEnabled | spEvent ) ) { // tylko sygnał przypisujemy if( ( point.iFlags & ( spEnabled | spEvent ) ) == ( spEnabled | spEvent ) ) { // tylko sygnał przypisujemy
@@ -1030,6 +1062,11 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
&& ( true == TestFlag( OrderCurrentGet(), Obey_train ) ) ) { && ( true == TestFlag( OrderCurrentGet(), Obey_train ) ) ) {
VelSignalLast = -1.0; VelSignalLast = -1.0;
} }
// if there's unbroken speed limit through our scan table take a note of it
if( ( VelLimitLastDist.second > 0 )
&& ( speedlimitiscontinuous ) ) {
VelLimitLastDist.second = EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE;
}
// take into account the effect switches have on duration of signal-imposed speed limit, in calculation of speed limit end point // take into account the effect switches have on duration of signal-imposed speed limit, in calculation of speed limit end point
if( ( VelSignalLast >= 0.0 ) && ( SwitchClearDist >= 0.0 ) ) { if( ( VelSignalLast >= 0.0 ) && ( SwitchClearDist >= 0.0 ) ) {
VelLimitLastDist.second = std::max( VelLimitLastDist.second, SwitchClearDist ); VelLimitLastDist.second = std::max( VelLimitLastDist.second, SwitchClearDist );
@@ -1054,7 +1091,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
bool bool
TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, double const Signaldistance ) { TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, double const Signaldistance ) {
// stop points are irrelevant when not in one of the basic modes // stop points are irrelevant when not in one of the basic modes
if( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank ) ) == 0 ) { return true; } if( ( OrderCurrentGet() & ( /*Shunt | Loose_shunt |*/ Obey_train | Bank ) ) == 0 ) { return true; }
// jeśli przystanek, trzeba obsłużyć wg rozkładu // jeśli przystanek, trzeba obsłużyć wg rozkładu
iDrivigFlags |= moveStopPointFound; iDrivigFlags |= moveStopPointFound;
// first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them // first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them
@@ -1498,12 +1535,17 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
// HACK: if so, make it a stop point, to prevent non-signals farther down affect us // HACK: if so, make it a stop point, to prevent non-signals farther down affect us
auto const isforsomeoneelse { ( is_train() ) && ( Obstacle.distance < Point.fDist ) }; auto const isforsomeoneelse { ( is_train() ) && ( Obstacle.distance < Point.fDist ) };
if( Point.fDist <= Signaldistance ) { if( Point.fDist <= Signaldistance ) {
VelSignalNext = ( isforsomeoneelse ? 0.0 : Point.fVelNext );
}
if( isforsomeoneelse ) { if( isforsomeoneelse ) {
VelSignalNext = 0.0;
Velocity = 0.0; Velocity = 0.0;
// VelNext = 0.0; }
// return true; else {
VelSignalNext - Point.fVelNext;
if( Velocity < 0 ) {
Velocity = fVelMax;
VelSignal = fVelMax;
}
}
} }
} }
} }
@@ -6877,29 +6919,33 @@ TController::pick_optimal_speed( double const Range ) {
// if( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank | Connect | Disconnect | Change_direction ) ) == 0 ) { return; } // if( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank | Connect | Disconnect | Change_direction ) ) == 0 ) { return; }
// set initial velocity and acceleration values // set initial velocity and acceleration values
VelDesired = fVelMax; // wstępnie prędkość maksymalna dla pojazdu(-ów), będzie następnie ograniczana
VelNext = VelDesired; // maksymalna prędkość wynikająca z innych czynników niż trajektoria ruchu
SetDriverPsyche(); // ustawia AccPreferred (potrzebne tu?) SetDriverPsyche(); // ustawia AccPreferred (potrzebne tu?)
VelDesired = fVelMax; // wstępnie prędkość maksymalna dla pojazdu(-ów), będzie następnie ograniczana
AccDesired = AccPreferred; // AccPreferred wynika z osobowości mechanika AccDesired = AccPreferred; // AccPreferred wynika z osobowości mechanika
ActualProximityDist = Range; // funkcja Update() może pozostawić wartości bez zmian
VelLimitLastDist = { VelDesired, -1 };
SwitchClearDist = -1;
// if we're idling bail out early // nie przekraczać rozkladowej
if( false == is_active() ) { if( ( ( OrderCurrentGet() & Obey_train ) != 0 )
VelDesired = 0.0; && ( TrainParams.TTVmax > 0.0 ) ) {
VelNext = 0.0; VelDesired =
AccDesired = std::min( AccDesired, EU07_AI_NOACCELERATION ); min_speed(
return; VelDesired,
TrainParams.TTVmax );
} }
// basic velocity and acceleration adjustments // VelNext = VelDesired; // maksymalna prędkość wynikająca z innych czynników niż trajektoria ruchu
// HACK: -1 means we can pick up 0 speed limits in ( point.velnext > velnext ) tests aimed to find highest next speed,
// but also doubles as 'max speed' in min_speed tests, so it shouldn't interfere if we don't find any speed limits
VelNext = -1.0;
// basic velocity and acceleration adjustments
// jeśli manewry, to ograniczamy prędkość // jeśli manewry, to ograniczamy prędkość
if( ( OrderCurrentGet() & ( Obey_train | Bank ) ) == 0 ) { // spokojne manewry if( ( OrderCurrentGet() & ( Obey_train | Bank ) ) == 0 ) { // spokojne manewry
SetVelocity( fShuntVelocity, fShuntVelocity ); SetVelocity( fShuntVelocity, fShuntVelocity );
VelDesired =
min_speed(
VelDesired,
fShuntVelocity );
} }
// uncoupling mode changes velocity/acceleration between stages // uncoupling mode changes velocity/acceleration between stages
if( ( OrderCurrentGet() & Disconnect ) != 0 ) { if( ( OrderCurrentGet() & Disconnect ) != 0 ) {
if( iVehicleCount >= 0 ) { if( iVehicleCount >= 0 ) {
@@ -6920,6 +6966,19 @@ TController::pick_optimal_speed( double const Range ) {
} }
} }
} }
VelLimitLastDist = { VelDesired, -1 };
SwitchClearDist = -1;
ActualProximityDist = Range; // funkcja Update() może pozostawić wartości bez zmian
// if we're idling bail out early
if( false == is_active() ) {
VelDesired = 0.0;
VelNext = 0.0;
AccDesired = std::min( AccDesired, EU07_AI_NOACCELERATION );
return;
}
// Ra: odczyt (ActualProximityDist), (VelNext) i (AccPreferred) z tabelki prędkosci // Ra: odczyt (ActualProximityDist), (VelNext) i (AccPreferred) z tabelki prędkosci
check_route_ahead( Range ); check_route_ahead( Range );
@@ -7087,14 +7146,6 @@ TController::adjust_desired_speed_for_limits() {
VelDesired, VelDesired,
VelSignal ); VelSignal );
} }
if( ( ( OrderCurrentGet() & Obey_train ) != 0 )
&& ( TrainParams.TTVmax > 0.0 ) ) {
// jesli nie spozniony to nie przekraczać rozkladowej
VelDesired =
min_speed(
VelDesired,
TrainParams.TTVmax );
}
if( mvOccupied->RunningTrack.Velmax >= 0 ) { if( mvOccupied->RunningTrack.Velmax >= 0 ) {
// ograniczenie prędkości z trajektorii ruchu // ograniczenie prędkości z trajektorii ruchu
VelDesired = VelDesired =

View File

@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
#include "translation.h" #include "translation.h"
auto const EU07_AI_NOACCELERATION = -0.05; auto const EU07_AI_NOACCELERATION = -0.05;
auto const EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE = 10000.0;
enum TOrders enum TOrders
{ // rozkazy dla AI { // rozkazy dla AI

View File

@@ -43,25 +43,25 @@ global_settings::ConfigParse(cParser &Parser) {
std::string token; std::string token;
do do
{ {
token = ""; token = "";
Parser.getTokens(); Parser.getTokens();
Parser >> token; Parser >> token;
if (token == "sceneryfile") if( ConfigParse_gfx( Parser, token ) ) {
continue;
}
else if (token == "sceneryfile")
{ {
Parser.getTokens(); Parser.getTokens();
Parser >> SceneryFile; Parser >> SceneryFile;
} }
else if (token == "humanctrlvehicle") else if (token == "humanctrlvehicle")
{ {
Parser.getTokens(); Parser.getTokens();
Parser >> local_start_vehicle; Parser >> local_start_vehicle;
} }
else if( token == "fieldofview" ) { else if (token == "fieldofview")
{
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> FieldOfView; Parser >> FieldOfView;
// guard against incorrect values // guard against incorrect values
@@ -69,13 +69,11 @@ global_settings::ConfigParse(cParser &Parser) {
} }
else if (token == "width") else if (token == "width")
{ {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iWindowWidth; Parser >> iWindowWidth;
} }
else if (token == "height") else if (token == "height")
{ {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iWindowHeight; Parser >> iWindowHeight;
} }
@@ -88,7 +86,8 @@ global_settings::ConfigParse(cParser &Parser) {
{ {
Parser.getTokens(1); Parser.getTokens(1);
Parser >> BaseDrawRange; Parser >> BaseDrawRange;
BaseDrawRange = clamp( BaseDrawRange, 500.f, 5000.f ); // arbitrary limits to keep users from hurting themselves BaseDrawRange = clamp(BaseDrawRange, 500.f,
5000.f); // arbitrary limits to keep users from hurting themselves
} }
else if (token == "fullscreen") else if (token == "fullscreen")
{ {
@@ -100,29 +99,25 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> fullscreen_monitor; Parser >> fullscreen_monitor;
} }
else if( token == "fullscreenwindowed" ) { else if (token == "fullscreenwindowed")
{
Parser.getTokens(); Parser.getTokens();
Parser >> fullscreen_windowed; Parser >> fullscreen_windowed;
} }
else if( token == "vsync" ) { else if (token == "vsync")
{
Parser.getTokens(); Parser.getTokens();
Parser >> VSync; Parser >> VSync;
} }
else if (token == "freefly") else if (token == "freefly")
{ // Mczapkie-130302 { // Mczapkie-130302
Parser.getTokens(); Parser.getTokens();
Parser >> FreeFlyModeFlag; Parser >> FreeFlyModeFlag;
Parser.getTokens(3, false); Parser.getTokens(3, false);
Parser >> Parser >> FreeCameraInit[0].x, FreeCameraInit[0].y, FreeCameraInit[0].z;
FreeCameraInit[0].x,
FreeCameraInit[0].y,
FreeCameraInit[0].z;
} }
else if (token == "wireframe") else if (token == "wireframe")
{ {
Parser.getTokens(); Parser.getTokens();
Parser >> bWireFrame; Parser >> bWireFrame;
} }
@@ -139,35 +134,41 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(); Parser.getTokens();
Parser >> bSoundEnabled; Parser >> bSoundEnabled;
} }
else if( token == "sound.openal.renderer" ) { else if (token == "sound.openal.renderer")
{
// selected device for audio renderer // selected device for audio renderer
AudioRenderer = Parser.getToken<std::string>(false); // case-sensitive AudioRenderer = Parser.getToken<std::string>(false); // case-sensitive
} }
else if( token == "sound.volume" ) { else if (token == "sound.volume")
{
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> AudioVolume; Parser >> AudioVolume;
AudioVolume = clamp(AudioVolume, 0.f, 2.f); AudioVolume = clamp(AudioVolume, 0.f, 2.f);
} }
else if( token == "sound.volume.radio" ) { else if (token == "sound.volume.radio")
{
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> RadioVolume; Parser >> RadioVolume;
RadioVolume = clamp(RadioVolume, 0.f, 1.f); RadioVolume = clamp(RadioVolume, 0.f, 1.f);
} }
else if( token == "sound.volume.vehicle" ) { else if (token == "sound.volume.vehicle")
{
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> VehicleVolume; Parser >> VehicleVolume;
VehicleVolume = clamp(VehicleVolume, 0.f, 1.f); VehicleVolume = clamp(VehicleVolume, 0.f, 1.f);
} }
else if( token == "sound.volume.positional" ) { else if (token == "sound.volume.positional")
{
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> EnvironmentPositionalVolume; Parser >> EnvironmentPositionalVolume;
EnvironmentPositionalVolume = clamp(EnvironmentPositionalVolume, 0.f, 1.f); EnvironmentPositionalVolume = clamp(EnvironmentPositionalVolume, 0.f, 1.f);
} }
else if( token == "sound.volume.ambient" ) { else if (token == "sound.volume.ambient")
{
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> EnvironmentAmbientVolume; Parser >> EnvironmentAmbientVolume;
@@ -183,7 +184,6 @@ global_settings::ConfigParse(cParser &Parser) {
} }
else if (token == "fullphysics") else if (token == "fullphysics")
{ // McZapkie-291103 - usypianie fizyki { // McZapkie-291103 - usypianie fizyki
Parser.getTokens(); Parser.getTokens();
Parser >> FullPhysics; Parser >> FullPhysics;
} }
@@ -205,11 +205,13 @@ global_settings::ConfigParse(cParser &Parser) {
iWriteLogEnabled = stol_def(token, 3); iWriteLogEnabled = stol_def(token, 3);
} }
} }
else if( token == "multiplelogs" ) { else if (token == "multiplelogs")
{
Parser.getTokens(); Parser.getTokens();
Parser >> MultipleLogs; Parser >> MultipleLogs;
} }
else if( token == "logs.filter" ) { else if (token == "logs.filter")
{
Parser.getTokens(); Parser.getTokens();
Parser >> DisabledLogTypes; Parser >> DisabledLogTypes;
} }
@@ -219,7 +221,8 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(2, false); Parser.getTokens(2, false);
Parser >> fMouseXScale >> fMouseYScale; Parser >> fMouseXScale >> fMouseYScale;
} }
else if( token == "mousecontrol" ) { else if (token == "mousecontrol")
{
// whether control pick mode can be activated // whether control pick mode can be activated
Parser.getTokens(); Parser.getTokens();
Parser >> InputMouse; Parser >> InputMouse;
@@ -238,7 +241,6 @@ global_settings::ConfigParse(cParser &Parser) {
} }
else if (token == "friction") else if (token == "friction")
{ // mnożnik tarcia - KURS90 { // mnożnik tarcia - KURS90
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> fFriction; Parser >> fFriction;
} }
@@ -266,21 +268,18 @@ global_settings::ConfigParse(cParser &Parser) {
// domyślnie od TGA // domyślnie od TGA
szDefaultExt = szTexturesTGA; szDefaultExt = szTexturesTGA;
} }
else { else
szDefaultExt = {
( token[ 0 ] == '.' ? szDefaultExt = (token[0] == '.' ? token : "." + token);
token :
"." + token );
} }
} }
else if (token == "newaircouplers") else if (token == "newaircouplers")
{ {
Parser.getTokens(); Parser.getTokens();
Parser >> bnewAirCouplers; Parser >> bnewAirCouplers;
} }
else if( token == "anisotropicfiltering" ) { else if (token == "anisotropicfiltering")
{
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> AnisotropicFiltering; Parser >> AnisotropicFiltering;
if (AnisotropicFiltering < 1.0f) if (AnisotropicFiltering < 1.0f)
@@ -288,25 +287,21 @@ global_settings::ConfigParse(cParser &Parser) {
} }
else if (token == "usevbo") else if (token == "usevbo")
{ {
Parser.getTokens(); Parser.getTokens();
Parser >> bUseVBO; Parser >> bUseVBO;
} }
else if (token == "feedbackmode") else if (token == "feedbackmode")
{ {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iFeedbackMode; Parser >> iFeedbackMode;
} }
else if (token == "feedbackport") else if (token == "feedbackport")
{ {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iFeedbackPort; Parser >> iFeedbackPort;
} }
else if (token == "multiplayer") else if (token == "multiplayer")
{ {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iMultiplayer; Parser >> iMultiplayer;
} }
@@ -339,21 +334,25 @@ global_settings::ConfigParse(cParser &Parser) {
} }
simulation::Environment.compute_season(fMoveLight); simulation::Environment.compute_season(fMoveLight);
} }
else if( token == "dynamiclights" ) { else if (token == "dynamiclights")
{
// number of dynamic lights in the scene // number of dynamic lights in the scene
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> DynamicLightCount; Parser >> DynamicLightCount;
// clamp the light number // clamp the light number
// max 8 lights per opengl specs, minus one used for sun. at least one light for controlled vehicle // max 8 lights per opengl specs, minus one used for sun. at least one light for
// controlled vehicle
DynamicLightCount = clamp(DynamicLightCount, 1, 7); DynamicLightCount = clamp(DynamicLightCount, 1, 7);
} }
else if( token == "scenario.time.override" ) { else if (token == "scenario.time.override")
{
// shift (in hours) applied to train timetables // shift (in hours) applied to train timetables
Parser.getTokens(1, false); Parser.getTokens(1, false);
std::string token; std::string token;
Parser >> token; Parser >> token;
std::istringstream stream(token); std::istringstream stream(token);
if (token.find(':') != -1) { if (token.find(':') != -1)
{
float a, b; float a, b;
char s; char s;
stream >> a >> s >> b; stream >> a >> s >> b;
@@ -363,120 +362,91 @@ global_settings::ConfigParse(cParser &Parser) {
stream >> ScenarioTimeOverride; stream >> ScenarioTimeOverride;
ScenarioTimeOverride = clamp(ScenarioTimeOverride, 0.f, 24 * 1439 / 1440.f); ScenarioTimeOverride = clamp(ScenarioTimeOverride, 0.f, 24 * 1439 / 1440.f);
} }
else if( token == "scenario.time.offset" ) { else if (token == "scenario.time.offset")
{
// shift (in hours) applied to train timetables // shift (in hours) applied to train timetables
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> ScenarioTimeOffset; Parser >> ScenarioTimeOffset;
} }
else if( token == "scenario.time.current" ) { else if (token == "scenario.time.current")
{
// sync simulation time with local clock // sync simulation time with local clock
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> ScenarioTimeCurrent; Parser >> ScenarioTimeCurrent;
} }
else if( token == "scenario.weather.temperature" ) { else if (token == "scenario.weather.temperature")
{
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> AirTemperature; Parser >> AirTemperature;
if( false == DebugModeFlag ) { if (false == DebugModeFlag)
{
AirTemperature = clamp(AirTemperature, -15.f, 45.f); AirTemperature = clamp(AirTemperature, -15.f, 45.f);
} }
} }
else if( token == "scalespeculars" ) { else if (token == "scalespeculars")
// whether strength of specular highlights should be adjusted (generally needed for legacy 3d models) {
// whether strength of specular highlights should be adjusted (generally needed for
// legacy 3d models)
Parser.getTokens(); Parser.getTokens();
Parser >> ScaleSpecularValues; Parser >> ScaleSpecularValues;
} }
else if( token == "gfxrenderer" ) { else if (token == "gfxrenderer")
{
// shadow render toggle // shadow render toggle
Parser.getTokens(); Parser.getTokens();
Parser >> GfxRenderer; Parser >> GfxRenderer;
if( GfxRenderer == "full" ) { if (GfxRenderer == "full")
{
GfxRenderer = "default"; GfxRenderer = "default";
} }
BasicRenderer = (GfxRenderer == "simple"); BasicRenderer = (GfxRenderer == "simple");
LegacyRenderer = (GfxRenderer != "default"); LegacyRenderer = (GfxRenderer != "default");
} }
else if( token == "shadows" ) { else if (token == "shadows")
{
// shadow render toggle // shadow render toggle
Parser.getTokens(); Parser.getTokens();
Parser >> RenderShadows; Parser >> RenderShadows;
} }
else if( token == "shadowtune" ) { else if (token == "shadowtune")
{
Parser.getTokens(4, false); Parser.getTokens(4, false);
float discard; float discard;
Parser Parser >> shadowtune.map_size >> discard >> shadowtune.range >> discard;
>> shadowtune.map_size
>> discard
>> shadowtune.range
>> discard;
shadowtune.map_size = clamp_power_of_two<unsigned int>(shadowtune.map_size, 512, 8192); shadowtune.map_size = clamp_power_of_two<unsigned int>(shadowtune.map_size, 512, 8192);
// make sure we actually make effective use of all csm stages // make sure we actually make effective use of all csm stages
shadowtune.range = shadowtune.range =
std::max( std::max((shadowtune.map_size <= 2048 ? 75.f : 75.f * shadowtune.map_size / 2048),
( shadowtune.map_size <= 2048 ?
75.f :
75.f * shadowtune.map_size / 2048 ),
shadowtune.range); shadowtune.range);
} }
else if( token == "gfx.shadows.cab.range" ) { else if (token == "smoothtraction")
// shadow render toggle {
Parser.getTokens();
Parser >> RenderCabShadowsRange;
}
else if( token == "gfx.smoke" ) {
// smoke visualization toggle
Parser.getTokens();
Parser >> Smoke;
}
else if( token == "gfx.smoke.fidelity" ) {
// smoke visualization fidelity
float smokefidelity;
Parser.getTokens();
Parser >> smokefidelity;
SmokeFidelity = clamp( smokefidelity, 1.f, 4.f );
}
else if( token == "smoothtraction" ) {
// podwójna jasność ambient // podwójna jasność ambient
Parser.getTokens(); Parser.getTokens();
Parser >> bSmoothTraction; Parser >> bSmoothTraction;
} }
else if( token == "splinefidelity" ) { else if (token == "splinefidelity")
{
// segment size during spline->geometry conversion // segment size during spline->geometry conversion
float splinefidelity; float splinefidelity;
Parser.getTokens(); Parser.getTokens();
Parser >> splinefidelity; Parser >> splinefidelity;
SplineFidelity = clamp(splinefidelity, 1.f, 4.f); SplineFidelity = clamp(splinefidelity, 1.f, 4.f);
} }
else if (token == "rendercab") { else if (token == "rendercab")
{
Parser.getTokens(); Parser.getTokens();
Parser >> render_cab; Parser >> render_cab;
} }
else if( token == "createswitchtrackbeds" ) { else if (token == "createswitchtrackbeds")
{
// podwójna jasność ambient // podwójna jasność ambient
Parser.getTokens(); Parser.getTokens();
Parser >> CreateSwitchTrackbeds; Parser >> CreateSwitchTrackbeds;
} }
else if( token == "gfx.resource.sweep" ) { else if (token == "timespeed")
{
Parser.getTokens();
Parser >> ResourceSweep;
}
else if( token == "gfx.resource.move" ) {
Parser.getTokens();
Parser >> ResourceMove;
}
else if( token == "gfx.reflections.framerate" ) {
auto const updatespersecond { std::abs( Parser.getToken<double>() ) };
reflectiontune.update_interval = 1.0 / updatespersecond;
}
else if( token == "gfx.reflections.fidelity" ) {
Parser.getTokens( 1, false );
Parser >> reflectiontune.fidelity;
reflectiontune.fidelity = clamp( reflectiontune.fidelity, 0, 2 );
}
else if( token == "timespeed" ) {
// przyspieszenie czasu, zmienna do testów // przyspieszenie czasu, zmienna do testów
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> fTimeSpeed; Parser >> fTimeSpeed;
@@ -500,12 +470,10 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iConvertModels; Parser >> iConvertModels;
// temporary override, to prevent generation of .e3d not compatible with old exe // temporary override, to prevent generation of .e3d not compatible with old exe
iConvertModels = iConvertModels = (iConvertModels > 128 ? iConvertModels - 128 : 0);
( iConvertModels > 128 ?
iConvertModels - 128 :
0 );
} }
else if( token == "file.binary.terrain" ) { else if (token == "file.binary.terrain")
{
// binary terrain (de)serialization // binary terrain (de)serialization
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> file_binary_terrain; Parser >> file_binary_terrain;
@@ -557,8 +525,7 @@ global_settings::ConfigParse(cParser &Parser) {
in = 5; // na ostatni, bo i tak trzeba pominąć wartości in = 5; // na ostatni, bo i tak trzeba pominąć wartości
} }
Parser.getTokens(4, false); Parser.getTokens(4, false);
Parser Parser >> fCalibrateIn[in][0] // wyraz wolny
>> fCalibrateIn[in][0] // wyraz wolny
>> fCalibrateIn[in][1] // mnożnik >> fCalibrateIn[in][1] // mnożnik
>> fCalibrateIn[in][2] // mnożnik dla kwadratu >> fCalibrateIn[in][2] // mnożnik dla kwadratu
>> fCalibrateIn[in][3]; // mnożnik dla sześcianu >> fCalibrateIn[in][3]; // mnożnik dla sześcianu
@@ -623,9 +590,8 @@ global_settings::ConfigParse(cParser &Parser) {
{ {
// maksymalne wartości jakie można wyświetlić na mierniku // maksymalne wartości jakie można wyświetlić na mierniku
Parser.getTokens(7, false); Parser.getTokens(7, false);
Parser >> fCalibrateOutMax[0] >> fCalibrateOutMax[1] >> Parser >> fCalibrateOutMax[0] >> fCalibrateOutMax[1] >> fCalibrateOutMax[2] >>
fCalibrateOutMax[2] >> fCalibrateOutMax[3] >> fCalibrateOutMax[3] >> fCalibrateOutMax[4] >> fCalibrateOutMax[5] >>
fCalibrateOutMax[4] >> fCalibrateOutMax[5] >>
fCalibrateOutMax[6]; fCalibrateOutMax[6];
} }
else if (token == "calibrateoutdebuginfo") else if (token == "calibrateoutdebuginfo")
@@ -659,7 +625,8 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> iHiddenEvents; Parser >> iHiddenEvents;
} }
else if( token == "ai.trainman" ) { else if (token == "ai.trainman")
{
// czy łączyć eventy z torami poprzez nazwę toru // czy łączyć eventy z torami poprzez nazwę toru
Parser.getTokens(1, false); Parser.getTokens(1, false);
Parser >> AITrainman; Parser >> AITrainman;
@@ -683,127 +650,100 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(); Parser.getTokens();
Parser >> token; Parser >> token;
auto const priority{token}; auto const priority{token};
PythonScreenUpdateRate = ( PythonScreenUpdateRate =
priority == "normal" ? 200 : (priority == "normal" ?
priority == "lower" ? 500 : 200 :
priority == "lowest" ? 1000 : priority == "lower" ?
priority == "off" ? 0 : 500 :
stol_def( priority, 200 ) ); priority == "lowest" ? 1000 : priority == "off" ? 0 : stol_def(priority, 200));
} }
else if (token == "python.updatetime") else if (token == "python.updatetime")
{ {
Parser.getTokens(); Parser.getTokens();
Parser >> PythonScreenUpdateRate; Parser >> PythonScreenUpdateRate;
} }
else if( token == "uitextcolor" ) { else if (token == "uitextcolor")
{
// color of the ui text. NOTE: will be obsolete once the real ui is in place // color of the ui text. NOTE: will be obsolete once the real ui is in place
Parser.getTokens(3, false); Parser.getTokens(3, false);
Parser Parser >> UITextColor.r >> UITextColor.g >> UITextColor.b;
>> UITextColor.r
>> UITextColor.g
>> UITextColor.b;
glm::clamp(UITextColor, 0.f, 255.f); glm::clamp(UITextColor, 0.f, 255.f);
UITextColor = UITextColor / 255.f; UITextColor = UITextColor / 255.f;
UITextColor.a = 1.f; UITextColor.a = 1.f;
} }
else if( token == "ui.bg.opacity" ) { else if (token == "ui.bg.opacity")
{
// czy grupować eventy o tych samych nazwach // czy grupować eventy o tych samych nazwach
Parser.getTokens(); Parser.getTokens();
Parser >> UIBgOpacity; Parser >> UIBgOpacity;
UIBgOpacity = clamp(UIBgOpacity, 0.f, 1.f); UIBgOpacity = clamp(UIBgOpacity, 0.f, 1.f);
} }
else if( token == "input.gamepad" ) { else if (token == "input.gamepad")
{
// czy grupować eventy o tych samych nazwach // czy grupować eventy o tych samych nazwach
Parser.getTokens(); Parser.getTokens();
Parser >> InputGamepad; Parser >> InputGamepad;
} }
#ifdef WITH_UART #ifdef WITH_UART
else if( token == "uart" ) { else if (token == "uart")
{
uart_conf.enable = true; uart_conf.enable = true;
Parser.getTokens(3, false); Parser.getTokens(3, false);
Parser Parser >> uart_conf.port >> uart_conf.baud >> uart_conf.updatetime;
>> uart_conf.port
>> uart_conf.baud
>> uart_conf.updatetime;
} }
else if( token == "uarttune" ) { else if (token == "uarttune")
{
Parser.getTokens(16); Parser.getTokens(16);
Parser Parser >> uart_conf.mainbrakemin >> uart_conf.mainbrakemax >> uart_conf.localbrakemin >>
>> uart_conf.mainbrakemin uart_conf.localbrakemax >> uart_conf.tankmax >> uart_conf.tankuart >>
>> uart_conf.mainbrakemax uart_conf.pipemax >> uart_conf.pipeuart >> uart_conf.brakemax >>
>> uart_conf.localbrakemin uart_conf.brakeuart >> uart_conf.hvmax >> uart_conf.hvuart >>
>> uart_conf.localbrakemax uart_conf.currentmax >> uart_conf.currentuart >> uart_conf.lvmax >>
>> uart_conf.tankmax uart_conf.lvuart;
>> uart_conf.tankuart
>> uart_conf.pipemax
>> uart_conf.pipeuart
>> uart_conf.brakemax
>> uart_conf.brakeuart
>> uart_conf.hvmax
>> uart_conf.hvuart
>> uart_conf.currentmax
>> uart_conf.currentuart
>> uart_conf.lvmax
>> uart_conf.lvuart;
} }
else if ( token == "uarttachoscale" ) { else if (token == "uarttachoscale")
{
Parser.getTokens(1); Parser.getTokens(1);
Parser >> uart_conf.tachoscale; Parser >> uart_conf.tachoscale;
} }
else if( token == "uartfeature" ) { else if (token == "uartfeature")
{
Parser.getTokens(4); Parser.getTokens(4);
Parser Parser >> uart_conf.mainenable >> uart_conf.scndenable >> uart_conf.trainenable >>
>> uart_conf.mainenable uart_conf.localenable;
>> uart_conf.scndenable
>> uart_conf.trainenable
>> uart_conf.localenable;
} }
else if( token == "uartdebug" ) { else if (token == "uartdebug")
{
Parser.getTokens(1); Parser.getTokens(1);
Parser >> uart_conf.debug; Parser >> uart_conf.debug;
} }
#endif #endif
#ifdef USE_EXTCAM_CAMERA #ifdef USE_EXTCAM_CAMERA
else if( token == "extcam.cmd" ) { else if (token == "extcam.cmd")
{
Parser.getTokens(1); Parser.getTokens(1);
Parser >> extcam_cmd; Parser >> extcam_cmd;
} }
else if( token == "extcam.rec" ) { else if (token == "extcam.rec")
{
Parser.getTokens(1); Parser.getTokens(1);
Parser >> extcam_rec; Parser >> extcam_rec;
} }
else if( token == "extcam.res" ) { else if (token == "extcam.res")
{
Parser.getTokens(2); Parser.getTokens(2);
Parser >> extcam_res.x >> extcam_res.y; Parser >> extcam_res.x >> extcam_res.y;
} }
#endif #endif
else if (token == "compresstex") { else if (token == "compresstex")
{
Parser.getTokens(1); Parser.getTokens(1);
if( false == gfx_usegles ) { if (false == gfx_usegles)
{
// ogl es use requires compression to be disabled // ogl es use requires compression to be disabled
Parser >> compress_tex; Parser >> compress_tex;
} }
} }
else if (token == "gfx.framebuffer.width")
{
Parser.getTokens(1, false);
Parser >> gfx_framebuffer_width;
}
else if (token == "gfx.framebuffer.height")
{
Parser.getTokens(1, false);
Parser >> gfx_framebuffer_height;
}
else if (token == "gfx.framebuffer.fidelity")
{
Parser.getTokens(1, false);
Parser >> gfx_framebuffer_fidelity;
}
else if (token == "gfx.shadowmap.enabled")
{
Parser.getTokens(1);
Parser >> gfx_shadowmap_enabled;
}
else if (token == "fpslimit") else if (token == "fpslimit")
{ {
Parser.getTokens(1); Parser.getTokens(1);
@@ -816,95 +756,6 @@ global_settings::ConfigParse(cParser &Parser) {
Parser.getTokens(1); Parser.getTokens(1);
Parser >> Global.random_seed; Parser >> Global.random_seed;
} }
else if (token == "gfx.envmap.enabled")
{
Parser.getTokens(1);
Parser >> gfx_envmap_enabled;
}
else if (token == "gfx.postfx.motionblur.enabled")
{
Parser.getTokens(1);
Parser >> gfx_postfx_motionblur_enabled;
}
else if (token == "gfx.postfx.motionblur.shutter")
{
Parser.getTokens(1);
Parser >> gfx_postfx_motionblur_shutter;
}
else if (token == "gfx.postfx.motionblur.format")
{
Parser.getTokens(1);
std::string token;
Parser >> token;
if (token == "rg16f")
gfx_postfx_motionblur_format = GL_RG16F;
else if (token == "rg32f")
gfx_postfx_motionblur_format = GL_RG32F;
}
else if (token == "gfx.postfx.chromaticaberration.enabled")
{
Parser.getTokens(1);
Parser >> gfx_postfx_chromaticaberration_enabled;
}
else if (token == "gfx.format.color")
{
Parser.getTokens(1);
std::string token;
Parser >> token;
if (token == "rgb8")
gfx_format_color = GL_RGB8;
else if (token == "rgb16f")
gfx_format_color = GL_RGB16F;
else if (token == "rgb32f")
gfx_format_color = GL_RGB32F;
else if (token == "r11f_g11f_b10f")
gfx_format_color = GL_R11F_G11F_B10F;
}
else if (token == "gfx.format.depth")
{
Parser.getTokens(1);
std::string token;
Parser >> token;
if (token == "z16")
gfx_format_depth = GL_DEPTH_COMPONENT16;
else if (token == "z24")
gfx_format_depth = GL_DEPTH_COMPONENT24;
else if (token == "z32")
gfx_format_depth = GL_DEPTH_COMPONENT32;
else if (token == "z32f")
gfx_format_depth = GL_DEPTH_COMPONENT32F;
}
else if (token == "gfx.skiprendering")
{
Parser.getTokens(1);
Parser >> gfx_skiprendering;
}
else if (token == "gfx.skippipeline")
{
Parser.getTokens(1);
Parser >> gfx_skippipeline;
}
else if (token == "gfx.extraeffects")
{
Parser.getTokens(1);
Parser >> gfx_extraeffects;
}
/*
else if (token == "gfx.usegles")
{
Parser.getTokens(1);
Parser >> gfx_usegles;
if( true == gfx_usegles ) {
compress_tex = false;
gfx_shadergamma = true;
}
}
else if (token == "gfx.shadergamma")
{
Parser.getTokens(1);
Parser >> gfx_shadergamma;
}
*/
else if (token == "python.enabled") else if (token == "python.enabled")
{ {
Parser.getTokens(1); Parser.getTokens(1);
@@ -943,7 +794,8 @@ global_settings::ConfigParse(cParser &Parser) {
Parser >> network_client->first; Parser >> network_client->first;
Parser >> network_client->second; Parser >> network_client->second;
} }
else if (token == "execonexit") { else if (token == "execonexit")
{
Parser.getTokens(1); Parser.getTokens(1);
Parser >> exec_on_exit; Parser >> exec_on_exit;
std::replace(std::begin(exec_on_exit), std::end(exec_on_exit), '_', ' '); std::replace(std::begin(exec_on_exit), std::end(exec_on_exit), '_', ' ');
@@ -973,9 +825,9 @@ global_settings::ConfigParse(cParser &Parser) {
} }
/* /*
fFpsMin = fFpsAverage - fFpsMin = fFpsAverage -
fFpsDeviation; // dolna granica FPS, przy której promień scenerii będzie zmniejszany fFpsDeviation; // dolna granica FPS, przy której promień scenerii będzie
fFpsMax = fFpsAverage + zmniejszany fFpsMax = fFpsAverage + fFpsDeviation; // górna granica FPS, przy której promień
fFpsDeviation; // górna granica FPS, przy której promień scenerii będzie zwiększany scenerii będzie zwiększany
*/ */
if (iPause) if (iPause)
iTextMode = GLFW_KEY_F1; // jak pauza, to pokazać zegar iTextMode = GLFW_KEY_F1; // jak pauza, to pokazać zegar
@@ -985,6 +837,170 @@ global_settings::ConfigParse(cParser &Parser) {
#endif #endif
} }
bool
global_settings::ConfigParse_gfx( cParser &Parser, std::string_view const Token ) {
// TODO: move other graphics switches here
auto tokenparsed { true };
if (Token == "gfx.shadows.cab.range")
{
// shadow render toggle
Parser.getTokens();
Parser >> RenderCabShadowsRange;
}
else if (Token == "gfx.smoke")
{
// smoke visualization toggle
Parser.getTokens();
Parser >> Smoke;
}
else if (Token == "gfx.smoke.fidelity")
{
// smoke visualization fidelity
float smokefidelity;
Parser.getTokens();
Parser >> smokefidelity;
SmokeFidelity = clamp(smokefidelity, 1.f, 4.f);
}
else if (Token == "gfx.resource.sweep")
{
Parser.getTokens();
Parser >> ResourceSweep;
}
else if (Token == "gfx.resource.move")
{
Parser.getTokens();
Parser >> ResourceMove;
}
else if (Token == "gfx.reflections.framerate")
{
auto const updatespersecond{std::abs(Parser.getToken<double>())};
reflectiontune.update_interval = 1.0 / updatespersecond;
}
else if (Token == "gfx.reflections.fidelity")
{
Parser.getTokens(1, false);
Parser >> reflectiontune.fidelity;
reflectiontune.fidelity = clamp(reflectiontune.fidelity, 0, 2);
}
else if (Token == "gfx.framebuffer.width")
{
Parser.getTokens(1, false);
Parser >> gfx_framebuffer_width;
}
else if (Token == "gfx.framebuffer.height")
{
Parser.getTokens(1, false);
Parser >> gfx_framebuffer_height;
}
else if (Token == "gfx.framebuffer.fidelity")
{
Parser.getTokens(1, false);
Parser >> gfx_framebuffer_fidelity;
}
else if (Token == "gfx.shadowmap.enabled")
{
Parser.getTokens(1);
Parser >> gfx_shadowmap_enabled;
}
else if (Token == "gfx.envmap.enabled")
{
Parser.getTokens(1);
Parser >> gfx_envmap_enabled;
}
else if (Token == "gfx.postfx.motionblur.enabled")
{
Parser.getTokens(1);
Parser >> gfx_postfx_motionblur_enabled;
}
else if (Token == "gfx.postfx.motionblur.shutter")
{
Parser.getTokens(1);
Parser >> gfx_postfx_motionblur_shutter;
}
else if (Token == "gfx.postfx.motionblur.format")
{
Parser.getTokens(1);
std::string value;
Parser >> value;
if (value == "rg16f")
gfx_postfx_motionblur_format = GL_RG16F;
else if (value == "rg32f")
gfx_postfx_motionblur_format = GL_RG32F;
}
else if (Token == "gfx.postfx.chromaticaberration.enabled")
{
Parser.getTokens(1);
Parser >> gfx_postfx_chromaticaberration_enabled;
}
else if (Token == "gfx.format.color")
{
Parser.getTokens(1);
std::string value;
Parser >> value;
if (value == "rgb8")
gfx_format_color = GL_RGB8;
else if (value == "rgb16f")
gfx_format_color = GL_RGB16F;
else if (value == "rgb32f")
gfx_format_color = GL_RGB32F;
else if (value == "r11f_g11f_b10f")
gfx_format_color = GL_R11F_G11F_B10F;
}
else if (Token == "gfx.format.depth")
{
Parser.getTokens(1);
std::string value;
Parser >> value;
if (value == "z16")
gfx_format_depth = GL_DEPTH_COMPONENT16;
else if (value == "z24")
gfx_format_depth = GL_DEPTH_COMPONENT24;
else if (value == "z32")
gfx_format_depth = GL_DEPTH_COMPONENT32;
else if (value == "z32f")
gfx_format_depth = GL_DEPTH_COMPONENT32F;
}
else if (Token == "gfx.skiprendering")
{
Parser.getTokens(1);
Parser >> gfx_skiprendering;
}
else if (Token == "gfx.skippipeline")
{
Parser.getTokens(1);
Parser >> gfx_skippipeline;
}
else if (Token == "gfx.extraeffects")
{
Parser.getTokens(1);
Parser >> gfx_extraeffects;
}
/*
else if (Token == "gfx.usegles")
{
Parser.getTokens(1);
Parser >> gfx_usegles;
if( true == gfx_usegles ) {
compress_tex = false;
gfx_shadergamma = true;
}
}
*/
else if (Token == "gfx.shadergamma")
{
Parser.getTokens(1);
Parser >> gfx_shadergamma;
}
else
{
tokenparsed = false;
}
return tokenparsed;
}
void void
global_settings::export_as_text( std::ostream &Output ) const { global_settings::export_as_text( std::ostream &Output ) const {
@@ -1194,6 +1210,7 @@ global_settings::export_as_text( std::ostream &Output ) const {
export_as_text( Output, "gfx.skiprendering", gfx_skiprendering ); export_as_text( Output, "gfx.skiprendering", gfx_skiprendering );
export_as_text( Output, "gfx.skippipeline", gfx_skippipeline ); export_as_text( Output, "gfx.skippipeline", gfx_skippipeline );
export_as_text( Output, "gfx.extraeffects", gfx_extraeffects ); export_as_text( Output, "gfx.extraeffects", gfx_extraeffects );
export_as_text( Output, "gfx.shadergamma", gfx_shadergamma );
export_as_text( Output, "python.enabled", python_enabled ); export_as_text( Output, "python.enabled", python_enabled );
export_as_text( Output, "python.threadedupload", python_threadedupload ); export_as_text( Output, "python.threadedupload", python_threadedupload );
export_as_text( Output, "python.uploadmain", python_uploadmain ); export_as_text( Output, "python.uploadmain", python_uploadmain );

View File

@@ -237,6 +237,7 @@ struct global_settings {
// methods // methods
void LoadIniFile( std::string asFileName ); void LoadIniFile( std::string asFileName );
void ConfigParse( cParser &parser ); void ConfigParse( cParser &parser );
bool ConfigParse_gfx( cParser &parser, std::string_view const Token );
// sends basic content of the class in legacy (text) format to provided stream // sends basic content of the class in legacy (text) format to provided stream
void void
export_as_text( std::ostream &Output ) const; export_as_text( std::ostream &Output ) const;

View File

@@ -3485,7 +3485,7 @@ void TMoverParameters::MainSwitch_( bool const State ) {
return; return;
} }
bool const initialstate { Mains || dizel_startup }; bool const initialstate { Mains };
if( ( false == State ) if( ( false == State )
|| ( true == MainSwitchCheck() ) ) { || ( true == MainSwitchCheck() ) ) {

View File

@@ -464,7 +464,9 @@ driver_mode::on_key( int const Key, int const Scancode, int const Action, int co
void void
driver_mode::on_char( unsigned int const Char ) { driver_mode::on_char( unsigned int const Char ) {
// TODO: implement
// give the ui first shot at the input processing...
if( true == m_userinterface->on_char( Char ) ) { return; }
} }
void void

View File

@@ -63,23 +63,55 @@ drivingaid_panel::update() {
gradetext = m_buffer.data(); gradetext = m_buffer.data();
} }
// next speed limit // next speed limit
auto const speedlimit { static_cast<int>( std::floor( owner->VelDesired ) ) }; auto const speedlimit { static_cast<int>( owner->VelDesired ) };
auto nextspeedlimit { speedlimit }; auto nextspeedlimit { speedlimit };
auto nextspeedlimitdistance { 0.0 }; auto nextspeedlimitdistance { std::numeric_limits<double>::max() };
if( speedlimit != 0 ) { if( speedlimit != 0 ) { // if we aren't allowed to move then any next speed limit is irrelevant
// if we aren't allowed to move then any next speed limit is irrelevant // nie przekraczać rozkladowej
if( ( owner->VelLimitLastDist.first > 0.0 ) && ( owner->VelLimitLastDist.second > 0.0 ) ) { auto const schedulespeedlimit { (
( ( owner->OrderCurrentGet() & ( Obey_train | Bank ) ) != 0 ) && ( owner->TrainParams.TTVmax > 0.0 ) ? static_cast<int>( owner->TrainParams.TTVmax ) :
( ( owner->OrderCurrentGet() & ( Obey_train | Bank ) ) == 0 ) ? static_cast<int>( owner->fShuntVelocity ) :
-1 ) };
// first take note of any speed change which should occur after passing potential current speed limit // first take note of any speed change which should occur after passing potential current speed limit
nextspeedlimit = static_cast<int>( std::floor( owner->VelLimitLastDist.first ) ); if( owner->VelLimitLastDist.second > 0 ) {
nextspeedlimit = min_speed( schedulespeedlimit, static_cast<int>( owner->VelLimitLastDist.first ) );
nextspeedlimitdistance = owner->VelLimitLastDist.second; nextspeedlimitdistance = owner->VelLimitLastDist.second;
} }
auto const speedatproximitydistance{ static_cast<int>( std::floor( owner->VelNext ) ) }; // then take into account speed change ahead, compare it with speed after potentially clearing last limit
if( ( speedatproximitydistance != speedlimit ) && ( speedatproximitydistance < nextspeedlimit ) ) { // lower of these two takes priority; otherwise limit lasts at least until potential last limit is cleared
// if there's speed reduction down the road then it's more important than any potential speedup auto const noactivespeedlimit { owner->VelLimitLastDist.second < 0 };
auto const speedatproximitydistance { min_speed( schedulespeedlimit, static_cast<int>( owner->VelNext ) ) };
if( speedatproximitydistance == nextspeedlimit ) {
if( noactivespeedlimit ) {
nextspeedlimit = speedatproximitydistance; nextspeedlimit = speedatproximitydistance;
nextspeedlimitdistance = owner->ActualProximityDist; nextspeedlimitdistance = owner->ActualProximityDist;
} }
} }
else if( speedatproximitydistance < nextspeedlimit ) {
// if the speed limit ahead is more strict than our current limit, it's important enough to report
if( speedatproximitydistance < owner->VelDesired ) {
nextspeedlimit = speedatproximitydistance;
nextspeedlimitdistance = owner->ActualProximityDist;
}
// otherwise report it only if it's located after our current (lower) limit ends
else if( owner->ActualProximityDist > nextspeedlimitdistance ) {
nextspeedlimit = speedatproximitydistance;
nextspeedlimitdistance = owner->ActualProximityDist;
}
}
else if( noactivespeedlimit ) { // implicit proximity > last, report only if last limit isn't present
nextspeedlimit = speedatproximitydistance;
nextspeedlimitdistance = owner->ActualProximityDist;
}
// HACK: if our current speed limit extends beyond our scan range don't display potentially misleading information about its length
if( nextspeedlimitdistance >= EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE ) {
nextspeedlimit = speedlimit;
}
// HACK: hide next speed limit if the 'limit' is a vehicle in front of us
else if( owner->ActualProximityDist == std::abs( owner->TrackObstacle() ) ) {
nextspeedlimit = speedlimit;
}
}
std::string nextspeedlimittext; std::string nextspeedlimittext;
if( nextspeedlimit != speedlimit ) { if( nextspeedlimit != speedlimit ) {
std::snprintf( std::snprintf(
@@ -590,10 +622,7 @@ debug_panel::render() {
render_section( "Vehicle AI", m_ailines ); render_section( "Vehicle AI", m_ailines );
render_section( "Vehicle Scan Table", m_scantablelines ); render_section( "Vehicle Scan Table", m_scantablelines );
render_section_scenario(); render_section_scenario();
if( true == render_section( "Scenario Event Queue", m_eventqueuelines ) ) { render_section_eventqueue();
// event queue filter
ImGui::Checkbox( "By This Vehicle Only", &m_eventqueueactivevehicleonly );
}
if( true == render_section( "Power Grid", m_powergridlines ) ) { if( true == render_section( "Power Grid", m_powergridlines ) ) {
// traction state debug // traction state debug
ImGui::Checkbox( "Debug Traction", &DebugTractionFlag ); ImGui::Checkbox( "Debug Traction", &DebugTractionFlag );
@@ -693,6 +722,22 @@ debug_panel::render_section_scenario() {
return true; return true;
} }
bool
debug_panel::render_section_eventqueue() {
if( false == ImGui::CollapsingHeader( "Scenario Event Queue" ) ) { return false; }
// event queue name filter
ImGui::PushItemWidth( -1 );
ImGui::InputTextWithHint( "", "Search event queue", m_eventsearch.data(), m_eventsearch.size() );
ImGui::PopItemWidth();
// event queue
render_section( m_eventqueuelines );
// event queue activator filter
ImGui::Checkbox( "By This Vehicle Only", &m_eventqueueactivevehicleonly );
return true;
}
void void
debug_panel::update_section_vehicle( std::vector<text_line> &Output ) { debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
@@ -1061,6 +1106,15 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
textline = textline =
"Distances:\n proximity: " + to_string( mechanik.ActualProximityDist, 0 ) "Distances:\n proximity: " + to_string( mechanik.ActualProximityDist, 0 )
+ ", braking: " + to_string( mechanik.fBrakeDist, 0 ); + ", braking: " + to_string( mechanik.fBrakeDist, 0 );
if( mechanik.VelLimitLastDist.second > 0 ) {
textline += ", last limit: " + (
mechanik.VelLimitLastDist.second < EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE ?
to_string( mechanik.VelLimitLastDist.second, 0 ) :
"???" );
}
if( mechanik.SwitchClearDist > 0 ) {
textline += ", switches: " + to_string( mechanik.SwitchClearDist, 0 );
}
if( mechanik.Obstacle.distance < 5000 ) { if( mechanik.Obstacle.distance < 5000 ) {
textline += textline +=
@@ -1116,7 +1170,7 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
textline = textline =
"Brakes:\n highest pressure: " + to_string( mechanik.fReady, 2 ) + ( mechanik.Ready ? " (all brakes released)" : "" ) "Brakes:\n highest pressure: " + to_string( mechanik.fReady, 2 ) + ( mechanik.Ready ? " (all brakes released)" : "" )
+ "\n activation threshold: " + to_string( mechanik.fAccThreshold, 2 ) + "\n activation threshold: " + to_string( mechanik.fAccThreshold, 2 )
+ "\n activation delays: " + to_string( mechanik.fBrake_a0[ 0 ], 2 ) + " + " + to_string( mechanik.fBrake_a1[ 0 ], 2 ) + ", delays: " + to_string( mechanik.fBrake_a0[ 0 ], 2 ) + " + " + to_string( mechanik.fBrake_a1[ 0 ], 2 )
+ "\n virtual brake position: " + to_string( mechanik.BrakeCtrlPosition, 2 ); + "\n virtual brake position: " + to_string( mechanik.BrakeCtrlPosition, 2 );
Output.emplace_back( textline, Global.UITextColor ); Output.emplace_back( textline, Global.UITextColor );
@@ -1188,6 +1242,7 @@ debug_panel::update_section_eventqueue( std::vector<text_line> &Output ) {
// current event queue // current event queue
auto const time { Timer::GetTime() }; auto const time { Timer::GetTime() };
auto const *event { simulation::Events.begin() }; auto const *event { simulation::Events.begin() };
auto const searchfilter { std::string( m_eventsearch.data() ) };
Output.emplace_back( "Delay: Event:", Global.UITextColor ); Output.emplace_back( "Delay: Event:", Global.UITextColor );
@@ -1199,18 +1254,29 @@ debug_panel::update_section_eventqueue( std::vector<text_line> &Output ) {
&& ( ( false == m_eventqueueactivevehicleonly ) && ( ( false == m_eventqueueactivevehicleonly )
|| ( event->m_activator == m_input.vehicle ) ) ) { || ( event->m_activator == m_input.vehicle ) ) ) {
if( ( false == searchfilter.empty() )
&& ( event->m_name.find( searchfilter ) == std::string::npos ) ) {
event = event->m_next;
continue;
}
auto const delay { " " + to_string( std::max( 0.0, event->m_launchtime - time ), 1 ) }; auto const delay { " " + to_string( std::max( 0.0, event->m_launchtime - time ), 1 ) };
textline = delay.substr( delay.length() - 6 ) auto const label { event->m_name + ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) };
+ " " + event->m_name textline =
+ ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) delay.substr( delay.length() - 6 )
+ ( event->m_sibling ? " (joint event)" : "" ); + " "
+ label + ( event->m_sibling ? " (joint event)" : "" );
Output.emplace_back( textline, Global.UITextColor ); Output.emplace_back( textline, Global.UITextColor );
} }
event = event->m_next; event = event->m_next;
} }
if( Output.size() == 1 ) { if( Output.size() == 1 ) {
Output.front().data = "(no queued events)"; // event queue can be empty either because no event got through active filters, or because it is genuinely empty
Output.front().data = (
simulation::Events.begin() == nullptr ?
"(no queued events)" :
"(no matching events)" );
} }
} }
@@ -1328,6 +1394,12 @@ debug_panel::render_section( std::string const &Header, std::vector<text_line> c
if( true == Lines.empty() ) { return false; } if( true == Lines.empty() ) { return false; }
if( false == ImGui::CollapsingHeader( Header.c_str() ) ) { return false; } if( false == ImGui::CollapsingHeader( Header.c_str() ) ) { return false; }
return render_section( Lines );
}
bool
debug_panel::render_section( std::vector<text_line> const &Lines ) {
for( auto const &line : Lines ) { for( auto const &line : Lines ) {
ImGui::PushStyleColor( ImGuiCol_Text, { line.color.r, line.color.g, line.color.b, line.color.a } ); ImGui::PushStyleColor( ImGuiCol_Text, { line.color.r, line.color.g, line.color.b, line.color.a } );
ImGui::TextUnformatted( line.data.c_str() ); ImGui::TextUnformatted( line.data.c_str() );

View File

@@ -95,10 +95,13 @@ private:
std::string update_vehicle_brake() const; std::string update_vehicle_brake() const;
// renders provided lines, under specified collapsing header // renders provided lines, under specified collapsing header
bool render_section( std::string const &Header, std::vector<text_line> const &Lines ); bool render_section( std::string const &Header, std::vector<text_line> const &Lines );
bool render_section( std::vector<text_line> const &Lines );
bool render_section_scenario(); bool render_section_scenario();
bool render_section_eventqueue();
bool render_section_settings(); bool render_section_settings();
// members // members
std::array<char, 1024> m_buffer; std::array<char, 1024> m_buffer;
std::array<char, 128> m_eventsearch;
input_data m_input; input_data m_input;
std::vector<text_line> std::vector<text_line>
m_vehiclelines, m_vehiclelines,

View File

@@ -105,7 +105,7 @@ editor_mode::enter() {
m_statebackup = { Global.pCamera, FreeFlyModeFlag, Global.ControlPicking }; m_statebackup = { Global.pCamera, FreeFlyModeFlag, Global.ControlPicking };
Global.pCamera = Camera; Camera = Global.pCamera;
FreeFlyModeFlag = true; FreeFlyModeFlag = true;
Global.ControlPicking = true; Global.ControlPicking = true;
EditorModeFlag = true; EditorModeFlag = true;

View File

@@ -386,31 +386,31 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
vp.msaa_fb->attach(*vp.msaa_rbc, GL_COLOR_ATTACHMENT0); vp.msaa_fb->attach(*vp.msaa_rbc, GL_COLOR_ATTACHMENT0);
vp.msaa_fb->attach(*vp.msaa_rbd, GL_DEPTH_ATTACHMENT); vp.msaa_fb->attach(*vp.msaa_rbd, GL_DEPTH_ATTACHMENT);
if (Global.gfx_postfx_motionblur_enabled)
{
vp.msaa_rbv = std::make_unique<gl::renderbuffer>();
vp.msaa_rbv->alloc(Global.gfx_postfx_motionblur_format, vp.width, vp.height, samples);
vp.msaa_fb->attach(*vp.msaa_rbv, GL_COLOR_ATTACHMENT1);
vp.main_tex = std::make_unique<opengl_texture>(); vp.main_tex = std::make_unique<opengl_texture>();
vp.main_tex->alloc_rendertarget(Global.gfx_format_color, GL_RGB, vp.width, vp.height, 1, 1, GL_CLAMP_TO_EDGE); vp.main_tex->alloc_rendertarget(Global.gfx_format_color, GL_RGB, vp.width, vp.height, 1, 1, GL_CLAMP_TO_EDGE);
vp.main_fb = std::make_unique<gl::framebuffer>(); vp.main_fb = std::make_unique<gl::framebuffer>();
vp.main_fb->attach(*vp.main_tex, GL_COLOR_ATTACHMENT0); vp.main_fb->attach(*vp.main_tex, GL_COLOR_ATTACHMENT0);
if (Global.gfx_postfx_motionblur_enabled)
{
vp.msaa_rbv = std::make_unique<gl::renderbuffer>();
vp.msaa_rbv->alloc(Global.gfx_postfx_motionblur_format, vp.width, vp.height, samples);
vp.msaa_fb->attach(*vp.msaa_rbv, GL_COLOR_ATTACHMENT1);
vp.main_texv = std::make_unique<opengl_texture>(); vp.main_texv = std::make_unique<opengl_texture>();
vp.main_texv->alloc_rendertarget(Global.gfx_postfx_motionblur_format, GL_RG, vp.width, vp.height); vp.main_texv->alloc_rendertarget(Global.gfx_postfx_motionblur_format, GL_RG, vp.width, vp.height);
vp.main_fb->attach(*vp.main_texv, GL_COLOR_ATTACHMENT1); vp.main_fb->attach(*vp.main_texv, GL_COLOR_ATTACHMENT1);
vp.main_fb->setup_drawing(2); vp.main_fb->setup_drawing(2);
WriteLog("motion blur enabled");
}
if( !vp.main_fb->is_complete() ) { if( !vp.main_fb->is_complete() ) {
ErrorLog( "main framebuffer setup failed" ); ErrorLog( "main framebuffer setup failed" );
return false; return false;
} }
WriteLog("motion blur enabled");
}
if( !vp.msaa_fb->is_complete() ) { if( !vp.msaa_fb->is_complete() ) {
ErrorLog( "msaa framebuffer setup failed" ); ErrorLog( "msaa framebuffer setup failed" );
return false; return false;
@@ -789,6 +789,8 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
model_ubs.param[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter); model_ubs.param[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter);
model_ubo->update(model_ubs); model_ubo->update(model_ubs);
m_pfx_motionblur->apply({vp.main_tex.get(), vp.main_texv.get()}, vp.main2_fb.get()); m_pfx_motionblur->apply({vp.main_tex.get(), vp.main_texv.get()}, vp.main2_fb.get());
vp.main_fb->setup_drawing(1); // restore draw buffers after blit operation
} }
else else
{ {
@@ -802,6 +804,7 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glViewport(0, 0, target_size.x, target_size.y); glViewport(0, 0, target_size.x, target_size.y);
if( Global.gfx_postfx_chromaticaberration_enabled ) { if( Global.gfx_postfx_chromaticaberration_enabled ) {
// NOTE: for some unexplained reason need this setup_drawing() call here for the tonemapping effects to show up on the main_tex?
m_pfx_tonemapping->apply( *vp.main2_tex, vp.main_fb.get() ); m_pfx_tonemapping->apply( *vp.main2_tex, vp.main_fb.get() );
m_pfx_chromaticaberration->apply( *vp.main_tex, nullptr ); m_pfx_chromaticaberration->apply( *vp.main_tex, nullptr );
} }
@@ -3844,7 +3847,7 @@ void opengl33_renderer::Render_Alpha(TSubModel *Submodel)
auto lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override auto lightcolor = glm::vec3(Submodel->DiffuseOverride.r < 0.f ? // -1 indicates no override
Submodel->f4Diffuse : Submodel->f4Diffuse :
Submodel->DiffuseOverride); Submodel->DiffuseOverride);
lightcolor = glm::pow( lightcolor, gammacorrection ); // lightcolor = glm::pow( lightcolor, gammacorrection );
m_freespot_shader->bind(); m_freespot_shader->bind();