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

partial support for cab switch types, basic precipitation level texture selection

This commit is contained in:
tmj-fstate
2018-09-29 20:14:28 +02:00
parent 226ddb6291
commit 467d46eba2
7 changed files with 389 additions and 138 deletions

View File

@@ -28,11 +28,11 @@ TGauge::TGauge( sound_source const &Soundtemplate ) :
m_soundfxdecrease = m_soundtemplate; m_soundfxdecrease = m_soundtemplate;
} }
void TGauge::Init(TSubModel *Submodel, TGaugeType Type, float Scale, float Offset, float Friction, float Value, float const Endvalue, float const Endscale, bool const Interpolatescale ) void TGauge::Init(TSubModel *Submodel, TGaugeAnimation Type, float Scale, float Offset, float Friction, float Value, float const Endvalue, float const Endscale, bool const Interpolatescale )
{ // ustawienie parametrów animacji submodelu { // ustawienie parametrów animacji submodelu
SubModel = Submodel; SubModel = Submodel;
m_value = Value; m_value = Value;
m_type = Type; m_animation = Type;
m_scale = Scale; m_scale = Scale;
m_offset = Offset; m_offset = Offset;
m_friction = Friction; m_friction = Friction;
@@ -45,7 +45,7 @@ void TGauge::Init(TSubModel *Submodel, TGaugeType Type, float Scale, float Offse
return; return;
} }
if( m_type == TGaugeType::gt_Digital ) { if( m_animation == TGaugeAnimation::gt_Digital ) {
TSubModel *sm = SubModel->ChildGet(); TSubModel *sm = SubModel->ChildGet();
do { do {
@@ -147,19 +147,19 @@ bool TGauge::Load( cParser &Parser, TDynamicObject const *Owner, TModel3d *md1,
ErrorLog( "Bad model: failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\"", logtype::model ); ErrorLog( "Bad model: failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\"", logtype::model );
} }
std::map<std::string, TGaugeType> gaugetypes { std::map<std::string, TGaugeAnimation> gaugetypes {
{ "rot", TGaugeType::gt_Rotate }, { "rot", TGaugeAnimation::gt_Rotate },
{ "rotvar", TGaugeType::gt_Rotate }, { "rotvar", TGaugeAnimation::gt_Rotate },
{ "mov", TGaugeType::gt_Move }, { "mov", TGaugeAnimation::gt_Move },
{ "movvar", TGaugeType::gt_Move }, { "movvar", TGaugeAnimation::gt_Move },
{ "wip", TGaugeType::gt_Wiper }, { "wip", TGaugeAnimation::gt_Wiper },
{ "dgt", TGaugeType::gt_Digital } { "dgt", TGaugeAnimation::gt_Digital }
}; };
auto lookup = gaugetypes.find( gaugetypename ); auto lookup = gaugetypes.find( gaugetypename );
auto const type = ( auto const type = (
lookup != gaugetypes.end() ? lookup != gaugetypes.end() ?
lookup->second : lookup->second :
TGaugeType::gt_Unknown ); TGaugeAnimation::gt_Unknown );
Init( submodel, type, scale, offset, friction, 0, endvalue, endscale, interpolatescale ); Init( submodel, type, scale, offset, friction, 0, endvalue, endscale, interpolatescale );
@@ -170,10 +170,17 @@ bool
TGauge::Load_mapping( cParser &Input ) { TGauge::Load_mapping( cParser &Input ) {
// token can be a key or block end // token can be a key or block end
std::string const key { Input.getToken<std::string>( true, "\n\r\t ,;" ) }; auto const key { Input.getToken<std::string>( true, "\n\r\t ,;" ) };
if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
// if not block end then the key is followed by assigned value or sub-block // if not block end then the key is followed by assigned value or sub-block
if( key == "soundinc:" ) { if( key == "type:" ) {
auto const gaugetype { Input.getToken<std::string>( true, "\n\r\t ,;" ) };
m_type = (
gaugetype == "impulse" ? TGaugeType::push :
gaugetype == "return" ? TGaugeType::push :
TGaugeType::toggle ); // default
}
else if( key == "soundinc:" ) {
m_soundfxincrease.deserialize( Input, sound_type::single ); m_soundfxincrease.deserialize( Input, sound_type::single );
} }
else if( key == "sounddec:" ) { else if( key == "sounddec:" ) {
@@ -281,16 +288,16 @@ void TGauge::Update() {
} }
if( SubModel ) if( SubModel )
{ // warunek na wszelki wypadek, gdyby się submodel nie podłączył { // warunek na wszelki wypadek, gdyby się submodel nie podłączył
switch (m_type) { switch (m_animation) {
case TGaugeType::gt_Rotate: { case TGaugeAnimation::gt_Rotate: {
SubModel->SetRotate( float3( 0, 1, 0 ), GetScaledValue() * 360.0 ); SubModel->SetRotate( float3( 0, 1, 0 ), GetScaledValue() * 360.0 );
break; break;
} }
case TGaugeType::gt_Move: { case TGaugeAnimation::gt_Move: {
SubModel->SetTranslate( float3( 0, 0, GetScaledValue() ) ); SubModel->SetTranslate( float3( 0, 0, GetScaledValue() ) );
break; break;
} }
case TGaugeType::gt_Wiper: { case TGaugeAnimation::gt_Wiper: {
auto const scaledvalue { GetScaledValue() }; auto const scaledvalue { GetScaledValue() };
SubModel->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); SubModel->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 );
auto *sm = SubModel->ChildGet(); auto *sm = SubModel->ChildGet();
@@ -302,7 +309,7 @@ void TGauge::Update() {
} }
break; break;
} }
case TGaugeType::gt_Digital: { case TGaugeAnimation::gt_Digital: {
// Ra 2014-07: licznik cyfrowy // Ra 2014-07: licznik cyfrowy
auto *sm = SubModel->ChildGet(); auto *sm = SubModel->ChildGet();
/* std::string n = FormatFloat( "0000000000", floor( fValue ) ); // na razie tak trochę bez sensu /* std::string n = FormatFloat( "0000000000", floor( fValue ) ); // na razie tak trochę bez sensu
@@ -390,4 +397,8 @@ TGauge::model_offset() const {
glm::vec3() ); glm::vec3() );
} }
TGaugeType
TGauge::type() const {
return m_type;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

13
Gauge.h
View File

@@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/.
#include "Classes.h" #include "Classes.h"
#include "sound.h" #include "sound.h"
enum class TGaugeType { enum class TGaugeAnimation {
// typ ruchu // typ ruchu
gt_Unknown, // na razie nie znany gt_Unknown, // na razie nie znany
gt_Rotate, // obrót gt_Rotate, // obrót
@@ -21,6 +21,11 @@ enum class TGaugeType {
gt_Digital // licznik cyfrowy, np. kilometrów gt_Digital // licznik cyfrowy, np. kilometrów
}; };
enum class TGaugeType {
toggle,
push
};
// animowany wskaźnik, mogący przyjmować wiele stanów pośrednich // animowany wskaźnik, mogący przyjmować wiele stanów pośrednich
class TGauge { class TGauge {
@@ -32,7 +37,7 @@ public:
inline inline
void Clear() { void Clear() {
*this = TGauge(); } *this = TGauge(); }
void Init(TSubModel *Submodel, TGaugeType Type, float Scale = 1, float Offset = 0, float Friction = 0, float Value = 0, float const Endvalue = -1.0, float const Endscale = -1.0, bool const Interpolate = false ); void Init(TSubModel *Submodel, TGaugeAnimation Type, float Scale = 1, float Offset = 0, float Friction = 0, float Value = 0, float const Endvalue = -1.0, float const Endscale = -1.0, bool const Interpolate = false );
bool Load(cParser &Parser, TDynamicObject const *Owner, TModel3d *md1, TModel3d *md2 = nullptr, double mul = 1.0); bool Load(cParser &Parser, TDynamicObject const *Owner, TModel3d *md1, TModel3d *md2 = nullptr, double mul = 1.0);
void UpdateValue( float fNewDesired ); void UpdateValue( float fNewDesired );
void UpdateValue( float fNewDesired, sound_source &Fallbacksound ); void UpdateValue( float fNewDesired, sound_source &Fallbacksound );
@@ -46,6 +51,7 @@ public:
void UpdateValue(); void UpdateValue();
// returns offset of submodel associated with the button from the model centre // returns offset of submodel associated with the button from the model centre
glm::vec3 model_offset() const; glm::vec3 model_offset() const;
TGaugeType type() const;
// members // members
TSubModel *SubModel { nullptr }; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie TSubModel *SubModel { nullptr }; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie
@@ -60,7 +66,8 @@ private:
GetScaledValue() const; GetScaledValue() const;
// members // members
TGaugeType m_type { TGaugeType::gt_Unknown }; // typ ruchu TGaugeAnimation m_animation { TGaugeAnimation::gt_Unknown }; // typ ruchu
TGaugeType m_type { TGaugeType::toggle }; // switch type
float m_friction { 0.f }; // hamowanie przy zliżaniu się do zadanej wartości float m_friction { 0.f }; // hamowanie przy zliżaniu się do zadanej wartości
float m_targetvalue { 0.f }; // wartość docelowa float m_targetvalue { 0.f }; // wartość docelowa
float m_value { 0.f }; // wartość obecna float m_value { 0.f }; // wartość obecna

View File

@@ -624,6 +624,7 @@ struct TCoupling {
struct fuel_pump { struct fuel_pump {
bool is_enabled { false }; // device is allowed/requested to operate bool is_enabled { false }; // device is allowed/requested to operate
bool is_disabled { false }; // device is requested to stop
bool is_active { false }; // device is working bool is_active { false }; // device is working
start_t start_type { start_t::manual }; start_t start_type { start_t::manual };
}; };
@@ -633,6 +634,7 @@ struct fuel_pump {
struct oil_pump { struct oil_pump {
bool is_enabled { false }; // device is allowed/requested to operate bool is_enabled { false }; // device is allowed/requested to operate
bool is_disabled { false }; // device is requested to stop
bool is_active { false }; // device is working bool is_active { false }; // device is working
start_t start_type { start_t::manual }; start_t start_type { start_t::manual };
float resource_amount { 1.f }; float resource_amount { 1.f };
@@ -646,6 +648,7 @@ struct water_pump {
bool breaker { true }; // device is allowed to operate bool breaker { true }; // device is allowed to operate
bool is_enabled { false }; // device is requested to operate bool is_enabled { false }; // device is requested to operate
bool is_disabled { false }; // device is requested to stop
bool is_active { false }; // device is working bool is_active { false }; // device is working
start_t start_type { start_t::manual }; start_t start_type { start_t::manual };
}; };
@@ -1332,11 +1335,14 @@ public:
bool DirectionBackward(void);/*! kierunek ruchu*/ bool DirectionBackward(void);/*! kierunek ruchu*/
bool WaterPumpBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water pump breaker state toggle bool WaterPumpBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water pump breaker state toggle
bool WaterPumpSwitch( bool State, range_t const Notify = range_t::consist ); // water pump state toggle bool WaterPumpSwitch( bool State, range_t const Notify = range_t::consist ); // water pump state toggle
bool WaterPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // water pump state toggle
bool WaterHeaterBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water heater breaker state toggle bool WaterHeaterBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water heater breaker state toggle
bool WaterHeaterSwitch( bool State, range_t const Notify = range_t::consist ); // water heater state toggle bool WaterHeaterSwitch( bool State, range_t const Notify = range_t::consist ); // water heater state toggle
bool WaterCircuitsLinkSwitch( bool State, range_t const Notify = range_t::consist ); // water circuits link state toggle bool WaterCircuitsLinkSwitch( bool State, range_t const Notify = range_t::consist ); // water circuits link state toggle
bool FuelPumpSwitch( bool State, range_t const Notify = range_t::consist ); // fuel pump state toggle bool FuelPumpSwitch( bool State, range_t const Notify = range_t::consist ); // fuel pump state toggle
bool FuelPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // fuel pump state toggle
bool OilPumpSwitch( bool State, range_t const Notify = range_t::consist ); // oil pump state toggle bool OilPumpSwitch( bool State, range_t const Notify = range_t::consist ); // oil pump state toggle
bool OilPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // oil pump state toggle
bool MainSwitch( bool const State, range_t const Notify = range_t::consist );/*! wylacznik glowny*/ bool MainSwitch( bool const State, range_t const Notify = range_t::consist );/*! wylacznik glowny*/
bool ConverterSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl przetwornicy*/ bool ConverterSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl przetwornicy*/
bool CompressorSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl sprezarki*/ bool CompressorSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl sprezarki*/
@@ -1366,7 +1372,8 @@ public:
bool MaxCurrentSwitch(bool State); //przelacznik pradu wysokiego rozruchu bool MaxCurrentSwitch(bool State); //przelacznik pradu wysokiego rozruchu
bool MinCurrentSwitch(bool State); //przelacznik pradu automatycznego rozruchu bool MinCurrentSwitch(bool State); //przelacznik pradu automatycznego rozruchu
bool AutoRelaySwitch(bool State); //przelacznik automatycznego rozruchu bool AutoRelaySwitch(bool State); //przelacznik automatycznego rozruchu
bool AutoRelayCheck(void);//symulacja automatycznego rozruchu bool AutoRelayCheck();//symulacja automatycznego rozruchu
bool MotorConnectorsCheck();
bool ResistorsFlagCheck(void) const; //sprawdzenie kontrolki oporow rozruchowych NBMX bool ResistorsFlagCheck(void) const; //sprawdzenie kontrolki oporow rozruchowych NBMX
bool PantFront( bool const State, range_t const Notify = range_t::consist ); //obsluga pantografou przedniego bool PantFront( bool const State, range_t const Notify = range_t::consist ); //obsluga pantografou przedniego
@@ -1441,4 +1448,4 @@ private:
void BrakeSubsystemDecode(); //Q 20160719 void BrakeSubsystemDecode(); //Q 20160719
}; };
extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); //double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);

View File

@@ -144,22 +144,6 @@ double TMoverParameters::Current(double n, double U)
Mn = RList[ MainCtrlActualPos ].Mn * RList[ MainCtrlActualPos ].Bn; Mn = RList[ MainCtrlActualPos ].Mn * RList[ MainCtrlActualPos ].Bn;
} }
// writepaslog("#",
// "C++-----------------------------------------------------------------------------");
// writepaslog("MCAP ", IntToStr(MainCtrlActualPos));
// writepaslog("SCAP ", IntToStr(ScndCtrlActualPos));
// writepaslog("n ", FloatToStr(n));
// writepaslog("StLinFlag ", BoolToYN(StLinFlag));
// writepaslog("DelayCtrlFlag ", booltoYN(DelayCtrlFlag));
// writepaslog("Bn ", FloatToStr(Bn));
// writepaslog("R ", FloatToStr(R));
// writepaslog("Mn ", IntToStr(Mn));
// writepaslog("RList[MCAP].Bn ", FloatToStr(RList[MainCtrlActualPos].Bn));
// writepaslog("RList[MCAP].Mn ", FloatToStr(RList[MainCtrlActualPos].Mn));
// writepaslog("RList[MCAP].R ", FloatToStr(RList[MainCtrlActualPos].R));
// z Megapacka ... bylo tutaj zakomentowane Q: no to usuwam...
if (DynamicBrakeFlag && (!FuseFlag) && (DynamicBrakeType == dbrake_automatic) && if (DynamicBrakeFlag && (!FuseFlag) && (DynamicBrakeType == dbrake_automatic) &&
ConverterFlag && Mains) // hamowanie EP09 //TUHEX ConverterFlag && Mains) // hamowanie EP09 //TUHEX
{ {
@@ -1300,7 +1284,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (SetFlag(DamageFlag, dtrain_out)) if (SetFlag(DamageFlag, dtrain_out))
{ {
EventFlag = true; EventFlag = true;
Mains = false; MainSwitch( false, range_t::local );
RunningShape.R = 0; RunningShape.R = 0;
if (TestFlag(Track.DamageFlag, dtrack_norail)) if (TestFlag(Track.DamageFlag, dtrack_norail))
DerailReason = 1; // Ra: powód wykolejenia: brak szyn DerailReason = 1; // Ra: powód wykolejenia: brak szyn
@@ -1312,7 +1296,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (SetFlag(DamageFlag, dtrain_out)) if (SetFlag(DamageFlag, dtrain_out))
{ {
EventFlag = true; EventFlag = true;
Mains = false; MainSwitch( false, range_t::local );
RunningShape.R = 0; RunningShape.R = 0;
DerailReason = 3; // Ra: powód wykolejenia: za szeroki tor DerailReason = 3; // Ra: powód wykolejenia: za szeroki tor
} }
@@ -1322,7 +1306,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (SetFlag(DamageFlag, dtrain_out)) if (SetFlag(DamageFlag, dtrain_out))
{ {
EventFlag = true; EventFlag = true;
Mains = false; MainSwitch( false, range_t::local );
DerailReason = 4; // Ra: powód wykolejenia: nieodpowiednia trajektoria DerailReason = 4; // Ra: powód wykolejenia: nieodpowiednia trajektoria
} }
if( ( true == TestFlag( DamageFlag, dtrain_out ) ) if( ( true == TestFlag( DamageFlag, dtrain_out ) )
@@ -1542,7 +1526,9 @@ void TMoverParameters::WaterPumpCheck( double const Timestep ) {
WaterPump.is_active = ( WaterPump.is_active = (
( true == Battery ) ( true == Battery )
&& ( true == WaterPump.breaker ) && ( true == WaterPump.breaker )
&& ( ( true == WaterPump.is_enabled ) || ( WaterPump.start_type == start_t::battery ) ) ); && ( false == WaterPump.is_disabled )
&& ( ( true == WaterPump.is_active )
|| ( true == WaterPump.is_enabled ) || ( WaterPump.start_type == start_t::battery ) ) );
} }
// water heater status check // water heater status check
@@ -1571,10 +1557,12 @@ void TMoverParameters::FuelPumpCheck( double const Timestep ) {
FuelPump.is_active = ( FuelPump.is_active = (
( true == Battery ) ( true == Battery )
&& ( FuelPump.start_type == start_t::manual ? ( FuelPump.is_enabled ) : && ( false == FuelPump.is_disabled )
FuelPump.start_type == start_t::automatic ? ( dizel_startup || Mains ) : && ( ( FuelPump.is_active )
FuelPump.start_type == start_t::manualwithautofallback ? ( FuelPump.is_enabled || dizel_startup || Mains ) : || ( FuelPump.start_type == start_t::manual ? ( FuelPump.is_enabled ) :
false ) ); // shouldn't ever get this far but, eh FuelPump.start_type == start_t::automatic ? ( dizel_startup || Mains ) :
FuelPump.start_type == start_t::manualwithautofallback ? ( FuelPump.is_enabled || dizel_startup || Mains ) :
false ) ) ); // shouldn't ever get this far but, eh
} }
// oil pump status update // oil pump status update
@@ -1582,10 +1570,12 @@ void TMoverParameters::OilPumpCheck( double const Timestep ) {
OilPump.is_active = ( OilPump.is_active = (
( true == Battery ) ( true == Battery )
&& ( OilPump.start_type == start_t::manual ? ( OilPump.is_enabled ) : && ( false == OilPump.is_disabled )
OilPump.start_type == start_t::automatic ? ( dizel_startup || Mains ) : && ( ( OilPump.is_active )
OilPump.start_type == start_t::manualwithautofallback ? ( OilPump.is_enabled || dizel_startup || Mains ) : || ( OilPump.start_type == start_t::manual ? ( OilPump.is_enabled ) :
false ) ); // shouldn't ever get this far but, eh OilPump.start_type == start_t::automatic ? ( dizel_startup || Mains ) :
OilPump.start_type == start_t::manualwithautofallback ? ( OilPump.is_enabled || dizel_startup || Mains ) :
false ) ) ); // shouldn't ever get this far but, eh
auto const maxrevolutions { auto const maxrevolutions {
EngineType == TEngineType::DieselEngine ? EngineType == TEngineType::DieselEngine ?
@@ -2419,6 +2409,31 @@ bool TMoverParameters::WaterPumpSwitch( bool State, range_t const Notify ) {
return ( WaterPump.is_enabled != initialstate ); return ( WaterPump.is_enabled != initialstate );
} }
// water pump state toggle
bool TMoverParameters::WaterPumpSwitchOff( bool State, range_t const Notify ) {
if( WaterPump.start_type == start_t::battery ) {
// automatic fuel pump ignores 'manual' state commands
return false;
}
bool const initialstate { WaterPump.is_disabled };
WaterPump.is_disabled = State;
if( Notify != range_t::local ) {
SendCtrlToNext(
"WaterPumpSwitchOff",
( WaterPump.is_disabled ? 1 : 0 ),
CabNo,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return ( WaterPump.is_disabled != initialstate );
}
// water heater breaker state toggle // water heater breaker state toggle
bool TMoverParameters::WaterHeaterBreakerSwitch( bool State, range_t const Notify ) { bool TMoverParameters::WaterHeaterBreakerSwitch( bool State, range_t const Notify ) {
/* /*
@@ -2519,6 +2534,30 @@ bool TMoverParameters::FuelPumpSwitch( bool State, range_t const Notify ) {
return ( FuelPump.is_enabled != initialstate ); return ( FuelPump.is_enabled != initialstate );
} }
bool TMoverParameters::FuelPumpSwitchOff( bool State, range_t const Notify ) {
if( FuelPump.start_type == start_t::automatic ) {
// automatic fuel pump ignores 'manual' state commands
return false;
}
bool const initialstate { FuelPump.is_disabled };
FuelPump.is_disabled = State;
if( Notify != range_t::local ) {
SendCtrlToNext(
"FuelPumpSwitchOff",
( FuelPump.is_disabled ? 1 : 0 ),
CabNo,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return ( FuelPump.is_disabled != initialstate );
}
// oil pump state toggle // oil pump state toggle
bool TMoverParameters::OilPumpSwitch( bool State, range_t const Notify ) { bool TMoverParameters::OilPumpSwitch( bool State, range_t const Notify ) {
@@ -2544,6 +2583,30 @@ bool TMoverParameters::OilPumpSwitch( bool State, range_t const Notify ) {
return ( OilPump.is_enabled != initialstate ); return ( OilPump.is_enabled != initialstate );
} }
bool TMoverParameters::OilPumpSwitchOff( bool State, range_t const Notify ) {
if( OilPump.start_type == start_t::automatic ) {
// automatic pump ignores 'manual' state commands
return false;
}
bool const initialstate { OilPump.is_disabled };
OilPump.is_disabled = State;
if( Notify != range_t::local ) {
SendCtrlToNext(
"OilPumpSwitchOff",
( OilPump.is_disabled ? 1 : 0 ),
CabNo,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return ( OilPump.is_disabled != initialstate );
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160713 // Q: 20160713
// włączenie / wyłączenie obwodu głownego // włączenie / wyłączenie obwodu głownego
@@ -2577,6 +2640,10 @@ bool TMoverParameters::MainSwitch( bool const State, range_t const Notify )
} }
else { else {
Mains = false; Mains = false;
// potentially knock out the pumps if their switch doesn't force them on
WaterPump.is_active &= WaterPump.is_enabled;
OilPump.is_active &= OilPump.is_enabled;
FuelPump.is_active &= FuelPump.is_enabled;
} }
if( ( TrainType == dt_EZT ) if( ( TrainType == dt_EZT )
@@ -4449,6 +4516,13 @@ double TMoverParameters::TractionForce( double dt ) {
&& ( MainSwitch( false, ( TrainType == dt_EZT ? range_t::unit : range_t::local ) ) ) ); // TODO: check whether we need to send this EMU-wide && ( MainSwitch( false, ( TrainType == dt_EZT ? range_t::unit : range_t::local ) ) ) ); // TODO: check whether we need to send this EMU-wide
break; break;
} }
case TEngineType::DieselElectric: {
// TODO: move this to the auto relay check when the electric engine code paths are unified
StLinFlag = MotorConnectorsCheck();
break;
}
default: { default: {
break; break;
} }
@@ -5393,19 +5467,14 @@ bool TMoverParameters::AutoRelayCheck(void)
bool OK = false; // b:int; bool OK = false; // b:int;
bool ARC = false; bool ARC = false;
auto const motorconnectors { MotorConnectorsCheck() };
// Ra 2014-06: dla SN61 nie działa prawidłowo // Ra 2014-06: dla SN61 nie działa prawidłowo
// rozlaczanie stycznikow liniowych // yBARC - rozlaczenie stycznikow liniowych
if( ( false == Mains ) if( false == motorconnectors ) {
|| ( true == FuseFlag ) StLinFlag = false;
|| ( true == StLinSwitchOff )
|| ( MainCtrlPos == 0 )
|| ( ( TrainType != dt_EZT ) && ( BrakePress > 2.1 ) )
|| ( ActiveDir == 0 ) ) // hunter-111211: wylacznik cisnieniowy
{
StLinFlag = false; // yBARC - rozlaczenie stycznikow liniowych
OK = false; OK = false;
if (!DynamicBrakeFlag) if( false == DynamicBrakeFlag ) {
{
Im = 0; Im = 0;
Itot = 0; Itot = 0;
ResistorsFlag = false; ResistorsFlag = false;
@@ -5580,17 +5649,11 @@ bool TMoverParameters::AutoRelayCheck(void)
else // not StLinFlag else // not StLinFlag
{ {
OK = false; OK = false;
// ybARC - tutaj sa wszystkie warunki, jakie musza byc spelnione, zeby mozna byla // ybARC - zalaczenie stycznikow liniowych
// zalaczyc styczniki liniowe if( true == motorconnectors ) {
if (((MainCtrlPos == 1) || ((TrainType == dt_EZT) && (MainCtrlPos > 0))) &&
(!FuseFlag) && (Mains) && ((BrakePress < 1.0) || (TrainType == dt_EZT)) &&
(MainCtrlActualPos == 0) && (ActiveDir != 0))
{ //^^ TODO: sprawdzic BUG, prawdopodobnie w CreateBrakeSys()
DelayCtrlFlag = true; DelayCtrlFlag = true;
if( (LastRelayTime >= InitialCtrlDelay) if( LastRelayTime >= InitialCtrlDelay ) {
&& ( false == StLinSwitchOff ) ) StLinFlag = true;
{
StLinFlag = true; // ybARC - zalaczenie stycznikow liniowych
MainCtrlActualPos = 1; MainCtrlActualPos = 1;
DelayCtrlFlag = false; DelayCtrlFlag = false;
SetFlag(SoundFlag, sound::relay | sound::loud); SetFlag(SoundFlag, sound::relay | sound::loud);
@@ -5663,6 +5726,34 @@ bool TMoverParameters::AutoRelayCheck(void)
} }
} }
bool TMoverParameters::MotorConnectorsCheck() {
// hunter-111211: wylacznik cisnieniowy
auto const pressureswitch {
( TrainType != dt_EZT )
&& ( ( BrakePress > 2.0 )
|| ( PipePress < 3.6 ) ) };
if( pressureswitch ) { return false; }
auto const connectorsoff {
( false == Mains )
|| ( true == FuseFlag )
|| ( true == StLinSwitchOff )
|| ( MainCtrlPos == 0 )
|| ( ActiveDir == 0 ) };
if( connectorsoff ) { return false; }
auto const connectorson {
( true == StLinFlag )
|| ( ( MainCtrlActualPos == 0 )
&& ( ( MainCtrlPos == 1 )
|| ( ( TrainType == dt_EZT ) && ( MainCtrlPos > 0 ) ) ) ) };
return connectorson;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160713 // Q: 20160713
// Podnosi / opuszcza przedni pantograf. Returns: state of the pantograph after the operation // Podnosi / opuszcza przedni pantograf. Returns: state of the pantograph after the operation
@@ -9133,6 +9224,14 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
} }
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }
else if( Command == "WaterPumpSwitchOff" ) {
if( WaterPump.start_type != start_t::battery ) {
// automatic fuel pump ignores 'manual' state commands
WaterPump.is_disabled = ( CValue1 == 1 );
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if( Command == "WaterHeaterBreakerSwitch" ) { else if( Command == "WaterHeaterBreakerSwitch" ) {
/* /*
if( FuelPump.start_type != start::automatic ) { if( FuelPump.start_type != start::automatic ) {
@@ -9169,6 +9268,13 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
} }
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }
else if (Command == "FuelPumpSwitchOff") {
if( FuelPump.start_type != start_t::automatic ) {
// automatic fuel pump ignores 'manual' state commands
FuelPump.is_disabled = ( CValue1 == 1 );
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "OilPumpSwitch") { else if (Command == "OilPumpSwitch") {
if( OilPump.start_type != start_t::automatic ) { if( OilPump.start_type != start_t::automatic ) {
// automatic pump ignores 'manual' state commands // automatic pump ignores 'manual' state commands
@@ -9176,6 +9282,13 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
} }
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }
else if (Command == "OilPumpSwitchOff") {
if( OilPump.start_type != start_t::automatic ) {
// automatic pump ignores 'manual' state commands
OilPump.is_disabled = ( CValue1 == 1 );
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "MainSwitch") else if (Command == "MainSwitch")
{ {
if (CValue1 == 1) { if (CValue1 == 1) {
@@ -9190,6 +9303,10 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
} }
else { else {
Mains = false; Mains = false;
// potentially knock out the pumps if their switch doesn't force them on
WaterPump.is_active &= WaterPump.is_enabled;
OilPump.is_active &= OilPump.is_enabled;
FuelPump.is_active &= FuelPump.is_enabled;
} }
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }

View File

@@ -397,7 +397,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Ori
float m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera) float m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera)
step = fStep; step = fStep;
tv1 = 1.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej tv1 = 0.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej
s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć
int i = iSkip; // domyślnie 0 int i = iSkip; // domyślnie 0
t = fTsBuffer[ i ]; // tabela wattości t dla segmentów t = fTsBuffer[ i ]; // tabela wattości t dla segmentów
@@ -435,7 +435,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Ori
while( tv1 < 0.0 ) { while( tv1 < 0.0 ) {
tv1 += 1.0; tv1 += 1.0;
} }
tv2 = tv1 - step / texturelength; // mapowanie na końcu segmentu tv2 = tv1 + step / texturelength; // mapowanie na końcu segmentu
t = fTsBuffer[ i ]; // szybsze od GetTFromS(s); t = fTsBuffer[ i ]; // szybsze od GetTFromS(s);
pos2 = glm::dvec3{ FastGetPoint( t ) - Origin }; pos2 = glm::dvec3{ FastGetPoint( t ) - Origin };

226
Train.cpp
View File

@@ -2117,8 +2117,17 @@ void TTrain::OnCommand_linebreakerclose( TTrain *Train, command_data const &Comm
void TTrain::OnCommand_fuelpumptoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_fuelpumptoggle( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Train->ggFuelPumpButton.type() == TGaugeType::push ) {
// impulse switch
// currently there's no off button so we always try to turn it on
OnCommand_fuelpumpenable( Train, Command );
}
else {
// two-state switch
if( Command.action == GLFW_RELEASE ) { return; }
if( false == Train->mvControlled->FuelPump.is_enabled ) { if( false == Train->mvControlled->FuelPump.is_enabled ) {
// turn on // turn on
OnCommand_fuelpumpenable( Train, Command ); OnCommand_fuelpumpenable( Train, Command );
@@ -2132,32 +2141,65 @@ void TTrain::OnCommand_fuelpumptoggle( TTrain *Train, command_data const &Comman
void TTrain::OnCommand_fuelpumpenable( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_fuelpumpenable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// visual feedback
Train->ggFuelPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
if( true == Train->mvControlled->FuelPump.is_enabled ) { return; } // already enabled if( Train->ggFuelPumpButton.type() == TGaugeType::push ) {
// impulse switch
Train->mvControlled->FuelPumpSwitch( true ); if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggFuelPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->FuelPumpSwitch( true );
}
else if( Command.action == GLFW_RELEASE ) {
// visual feedback
Train->ggFuelPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->mvControlled->FuelPumpSwitch( false );
}
}
else {
// two-state switch, only cares about press events
if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggFuelPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->FuelPumpSwitch( true );
Train->mvControlled->FuelPumpSwitchOff( false );
}
} }
} }
void TTrain::OnCommand_fuelpumpdisable( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_fuelpumpdisable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// visual feedback
Train->ggFuelPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
if( false == Train->mvControlled->FuelPump.is_enabled ) { return; } // already disabled if( Train->ggFuelPumpButton.type() == TGaugeType::push ) {
// impulse switch
Train->mvControlled->FuelPumpSwitch( false ); // currently there's no disable return type switch
return;
}
else {
// two-state switch, only cares about press events
if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggFuelPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->mvControlled->FuelPumpSwitch( false );
Train->mvControlled->FuelPumpSwitchOff( true );
}
} }
} }
void TTrain::OnCommand_oilpumptoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_oilpumptoggle( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Train->ggOilPumpButton.type() == TGaugeType::push ) {
// impulse switch
// currently there's no off button so we always try to turn it on
OnCommand_oilpumpenable( Train, Command );
}
else {
// two-state switch
if( Command.action == GLFW_RELEASE ) { return; }
if( false == Train->mvControlled->OilPump.is_enabled ) { if( false == Train->mvControlled->OilPump.is_enabled ) {
// turn on // turn on
OnCommand_oilpumpenable( Train, Command ); OnCommand_oilpumpenable( Train, Command );
@@ -2171,25 +2213,49 @@ void TTrain::OnCommand_oilpumptoggle( TTrain *Train, command_data const &Command
void TTrain::OnCommand_oilpumpenable( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_oilpumpenable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// visual feedback
Train->ggOilPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
if( true == Train->mvControlled->OilPump.is_enabled ) { return; } // already enabled if( Train->ggOilPumpButton.type() == TGaugeType::push ) {
// impulse switch
Train->mvControlled->OilPumpSwitch( true ); if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggOilPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->OilPumpSwitch( true );
}
else if( Command.action == GLFW_RELEASE ) {
// visual feedback
Train->ggOilPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->mvControlled->OilPumpSwitch( false );
}
}
else {
// two-state switch, only cares about press events
if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggOilPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->OilPumpSwitch( true );
Train->mvControlled->OilPumpSwitchOff( false );
}
} }
} }
void TTrain::OnCommand_oilpumpdisable( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_oilpumpdisable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// visual feedback
Train->ggOilPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
if( false == Train->mvControlled->OilPump.is_enabled ) { return; } // already disabled if( Train->ggOilPumpButton.type() == TGaugeType::push ) {
// impulse switch
Train->mvControlled->OilPumpSwitch( false ); // currently there's no disable return type switch
return;
}
else {
// two-state switch, only cares about press events
if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggOilPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->mvControlled->OilPumpSwitch( false );
Train->mvControlled->OilPumpSwitchOff( true );
}
} }
} }
@@ -2312,8 +2378,17 @@ void TTrain::OnCommand_waterpumpbreakeropen( TTrain *Train, command_data const &
void TTrain::OnCommand_waterpumptoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_waterpumptoggle( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Train->ggWaterPumpButton.type() == TGaugeType::push ) {
// impulse switch
// currently there's no off button so we always try to turn it on
OnCommand_waterpumpenable( Train, Command );
}
else {
// two-state switch
if( Command.action == GLFW_RELEASE ) { return; }
if( false == Train->mvControlled->WaterPump.is_enabled ) { if( false == Train->mvControlled->WaterPump.is_enabled ) {
// turn on // turn on
OnCommand_waterpumpenable( Train, Command ); OnCommand_waterpumpenable( Train, Command );
@@ -2327,25 +2402,49 @@ void TTrain::OnCommand_waterpumptoggle( TTrain *Train, command_data const &Comma
void TTrain::OnCommand_waterpumpenable( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_waterpumpenable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// visual feedback
Train->ggWaterPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
if( true == Train->mvControlled->WaterPump.is_enabled ) { return; } // already enabled if( Train->ggWaterPumpButton.type() == TGaugeType::push ) {
// impulse switch
Train->mvControlled->WaterPumpSwitch( true ); if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggWaterPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->WaterPumpSwitch( true );
}
else if( Command.action == GLFW_RELEASE ) {
// visual feedback
Train->ggWaterPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->mvControlled->WaterPumpSwitch( false );
}
}
else {
// two-state switch, only cares about press events
if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggWaterPumpButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->WaterPumpSwitch( true );
Train->mvControlled->WaterPumpSwitchOff( false );
}
} }
} }
void TTrain::OnCommand_waterpumpdisable( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_waterpumpdisable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_REPEAT ) { return; }
// visual feedback
Train->ggWaterPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
if( false == Train->mvControlled->WaterPump.is_enabled ) { return; } // already disabled if( Train->ggWaterPumpButton.type() == TGaugeType::push ) {
// impulse switch
Train->mvControlled->WaterPumpSwitch( false ); // currently there's no disable return type switch
return;
}
else {
// two-state switch, only cares about press events
if( Command.action == GLFW_PRESS ) {
// visual feedback
Train->ggWaterPumpButton.UpdateValue( 0.0, Train->dsbSwitch );
Train->mvControlled->WaterPumpSwitch( false );
Train->mvControlled->WaterPumpSwitchOff( true );
}
} }
} }
@@ -5122,14 +5221,13 @@ bool TTrain::Update( double const Deltatime )
( true == mvControlled->ResistorsFlagCheck() ) ( true == mvControlled->ResistorsFlagCheck() )
|| ( mvControlled->MainCtrlActualPos == 0 ) ); // do EU04 || ( mvControlled->MainCtrlActualPos == 0 ) ); // do EU04
if( ( mvControlled->StLinFlag ) if( mvControlled->StLinFlag ) {
|| ( mvOccupied->BrakePress > 2.0 )
|| ( mvOccupied->PipePress < 3.6 ) ) {
// Ra: czy to jest udawanie działania styczników liniowych?
btLampkaStyczn.Turn( false ); btLampkaStyczn.Turn( false );
} }
else if( mvOccupied->BrakePress < 1.0 ) else {
btLampkaStyczn.Turn( true ); // mozna prowadzic rozruch // mozna prowadzic rozruch
btLampkaStyczn.Turn( mvOccupied->BrakePress < 1.0 );
}
if( ( ( TestFlag( mvControlled->Couplers[ side::rear ].CouplingFlag, coupling::control ) ) && ( mvControlled->CabNo == 1 ) ) if( ( ( TestFlag( mvControlled->Couplers[ side::rear ].CouplingFlag, coupling::control ) ) && ( mvControlled->CabNo == 1 ) )
|| ( ( TestFlag( mvControlled->Couplers[ side::front ].CouplingFlag, coupling::control ) ) && ( mvControlled->CabNo == -1 ) ) ) || ( ( TestFlag( mvControlled->Couplers[ side::front ].CouplingFlag, coupling::control ) ) && ( mvControlled->CabNo == -1 ) ) )
btLampkaUkrotnienie.Turn( true ); btLampkaUkrotnienie.Turn( true );
@@ -7140,10 +7238,12 @@ void TTrain::set_cab_controls() {
mvControlled->WaterPump.breaker ? mvControlled->WaterPump.breaker ?
1.0 : 1.0 :
0.0 ); 0.0 );
ggWaterPumpButton.PutValue( if( ggWaterPumpButton.type() != TGaugeType::push ) {
mvControlled->WaterPump.is_enabled ? ggWaterPumpButton.PutValue(
1.0 : mvControlled->WaterPump.is_enabled ?
0.0 ); 1.0 :
0.0 );
}
// water heater // water heater
ggWaterHeaterBreakerButton.PutValue( ggWaterHeaterBreakerButton.PutValue(
mvControlled->WaterHeater.breaker ? mvControlled->WaterHeater.breaker ?
@@ -7158,15 +7258,19 @@ void TTrain::set_cab_controls() {
1.0 : 1.0 :
0.0 ); 0.0 );
// fuel pump // fuel pump
ggFuelPumpButton.PutValue( if( ggFuelPumpButton.type() != TGaugeType::push ) {
mvControlled->FuelPump.is_enabled ? ggFuelPumpButton.PutValue(
1.0 : mvControlled->FuelPump.is_enabled ?
0.0 ); 1.0 :
0.0 );
}
// oil pump // oil pump
ggOilPumpButton.PutValue( if( ggOilPumpButton.type() != TGaugeType::push ) {
mvControlled->OilPump.is_enabled ? ggOilPumpButton.PutValue(
mvControlled->OilPump.is_enabled ?
1.0 : 1.0 :
0.0 ); 0.0 );
}
// we reset all indicators, as they're set during the update pass // we reset all indicators, as they're set during the update pass
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it // TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
@@ -7574,9 +7678,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
if (Parser.getToken<std::string>() == "analog") if (Parser.getToken<std::string>() == "analog")
{ {
// McZapkie-300302: zegarek // McZapkie-300302: zegarek
ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), TGaugeType::gt_Rotate, 1.0/60.0); ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), TGaugeAnimation::gt_Rotate, 1.0/60.0);
ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), TGaugeType::gt_Rotate, 1.0/60.0); ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), TGaugeAnimation::gt_Rotate, 1.0/60.0);
ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), TGaugeType::gt_Rotate, 1.0/12.0); ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), TGaugeAnimation::gt_Rotate, 1.0/12.0);
} }
} }
else if (Label == "evoltage:") else if (Label == "evoltage:")

View File

@@ -91,13 +91,18 @@ basic_precipitation::init() {
create( 18 ); create( 18 );
// TODO: select texture based on current overcast level // TODO: select texture based on current overcast level
// TODO: when the overcast level dynamic change is in check the current level during render and pick the appropriate texture on the fly
std::string const densitysuffix { (
Global.Overcast < 1.35 ?
"_light" :
"_medium" ) };
if( Global.Weather == "rain:" ) { if( Global.Weather == "rain:" ) {
m_texture = GfxRenderer.Fetch_Texture( "fx/rain_medium" );
m_moverateweathertypefactor = 2.f; m_moverateweathertypefactor = 2.f;
m_texture = GfxRenderer.Fetch_Texture( "fx/rain" + densitysuffix );
} }
else if( Global.Weather == "snow:" ) { else if( Global.Weather == "snow:" ) {
m_texture = GfxRenderer.Fetch_Texture( "fx/snow_medium" );
m_moverateweathertypefactor = 1.25f; m_moverateweathertypefactor = 1.25f;
m_texture = GfxRenderer.Fetch_Texture( "fx/snow" + densitysuffix );
} }
return true; return true;
@@ -111,7 +116,7 @@ basic_precipitation::update() {
if( timedelta == 0.0 ) { return; } if( timedelta == 0.0 ) { return; }
m_textureoffset += m_moverate * m_moverateweathertypefactor * timedelta; m_textureoffset += m_moverate * m_moverateweathertypefactor * timedelta;
m_textureoffset = clamp_circular( m_textureoffset, 1.f ); m_textureoffset = clamp_circular( m_textureoffset, 10.f );
auto cameramove { glm::dvec3{ Global.pCamera.Pos - m_camerapos} }; auto cameramove { glm::dvec3{ Global.pCamera.Pos - m_camerapos} };
cameramove.y = 0.0; // vertical movement messes up vector calculation cameramove.y = 0.0; // vertical movement messes up vector calculation