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

Merge branch 'tmj-dev'

This commit is contained in:
milek7
2017-12-26 20:06:07 +01:00
8 changed files with 140 additions and 226 deletions

View File

@@ -1889,21 +1889,10 @@ bool TController::CheckVehicles(TOrders user)
fMass += p->MoverParameters->TotalMass; // dodanie masy łącznie z ładunkiem fMass += p->MoverParameters->TotalMass; // dodanie masy łącznie z ładunkiem
if (fVelMax < 0 ? true : p->MoverParameters->Vmax < fVelMax) if (fVelMax < 0 ? true : p->MoverParameters->Vmax < fVelMax)
fVelMax = p->MoverParameters->Vmax; // ustalenie maksymalnej prędkości dla składu fVelMax = p->MoverParameters->Vmax; // ustalenie maksymalnej prędkości dla składu
/* //youBy: bez przesady, to jest proteza, napelniac mozna, a nawet trzeba, ale z umiarem!
//uwzględnić jeszcze wyłączenie hamulca
if
((p->MoverParameters->BrakeSystem!=Pneumatic)&&(p->MoverParameters->BrakeSystem!=ElectroPneumatic))
iDrivigFlags&=~moveOerlikons; //no jednak nie
else if (p->MoverParameters->BrakeSubsystem!=Oerlikon)
iDrivigFlags&=~moveOerlikons; //wtedy też nie */
p = p->Neightbour(dir); // pojazd podłączony od wskazanej strony p = p->Neightbour(dir); // pojazd podłączony od wskazanej strony
} }
if (main) if (main)
iDrivigFlags |= movePrimary; // nie znaleziono innego, można się porządzić iDrivigFlags |= movePrimary; // nie znaleziono innego, można się porządzić
/* //tabelka z listą pojazdów jest na razie nie potrzebna
delete[] pVehicles;
pVehicles=new TDynamicObject*[iVehicles];
*/
ControllingSet(); // ustalenie członu do sterowania (może być inny niż zasiedziany) ControllingSet(); // ustalenie członu do sterowania (może być inny niż zasiedziany)
int pantmask = 1; int pantmask = 1;
if (iDrivigFlags & movePrimary) if (iDrivigFlags & movePrimary)
@@ -2190,42 +2179,19 @@ bool TController::PrepareEngine()
LastReactionTime = 0.0; LastReactionTime = 0.0;
ReactionTime = PrepareTime; ReactionTime = PrepareTime;
iDrivigFlags |= moveActive; // może skanować sygnały i reagować na komendy iDrivigFlags |= moveActive; // może skanować sygnały i reagować na komendy
// with Controlling do
if ( mvControlling->EnginePowerSource.SourceType == CurrentCollector ) if ( mvControlling->EnginePowerSource.SourceType == CurrentCollector ) {
/*
|| ( (mvOccupied->TrainType==dt_EZT)
&& (mvControlling->GetTrainsetVoltage() > 0.0 ) ) ) // sprawdzanie, czy zasilanie jest może w innym członie
*/
{
voltfront = true; voltfront = true;
voltrear = true; voltrear = true;
} }
// begin else {
// if Couplers[0].Connected<>nil) if( mvOccupied->TrainType != dt_EZT ) {
// begin // Ra 2014-06: to jest wirtualny prąd dla spalinowych???
// if Couplers[0].Connected^.PantFrontVolt or Couplers[0].Connected^.PantRearVolt) voltfront = true;
// voltfront:=true }
// else }
// voltfront:=false; if (AIControllFlag) {
// end // część wykonawcza dla sterowania przez komputer
// else
// voltfront:=false;
// if Couplers[1].Connected<>nil)
// begin
// if Couplers[1].Connected^.PantFrontVolt or Couplers[1].Connected^.PantRearVolt)
// voltrear:=true
// else
// voltrear:=false;
// end
// else
// voltrear:=false;
// end
else
// if EnginePowerSource.SourceType<>CurrentCollector)
if (mvOccupied->TrainType != dt_EZT)
voltfront = true; // Ra 2014-06: to jest wirtualny prąd dla spalinowych???
if (AIControllFlag) // jeśli prowadzi komputer
{ // część wykonawcza dla sterowania przez komputer
mvOccupied->BatterySwitch(true); mvOccupied->BatterySwitch(true);
if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) if (mvControlling->EnginePowerSource.SourceType == CurrentCollector)
{ // jeśli silnikowy jest pantografującym { // jeśli silnikowy jest pantografującym
@@ -2247,39 +2213,42 @@ bool TController::PrepareEngine()
mvControlling->PantCompFlag = false; // sprężarkę pantografów można już wyłączyć mvControlling->PantCompFlag = false; // sprężarkę pantografów można już wyłączyć
} }
} }
// if (mvOccupied->TrainType==dt_EZT)
//{//Ra 2014-12: po co to tutaj?
// mvControlling->PantFront(true);
// mvControlling->PantRear(true);
//}
// if (mvControlling->EngineType==DieselElectric)
// mvControlling->Battery=true; //Ra: to musi być tak?
} }
if (mvControlling->PantFrontVolt || mvControlling->PantRearVolt || voltfront || voltrear) if (mvControlling->PantFrontVolt || mvControlling->PantRearVolt || voltfront || voltrear)
{ // najpierw ustalamy kierunek, jeśli nie został ustalony { // najpierw ustalamy kierunek, jeśli nie został ustalony
if (!iDirection) // jeśli nie ma ustalonego kierunku if( !iDirection ) {
if (mvOccupied->V == 0) // jeśli nie ma ustalonego kierunku
{ // ustalenie kierunku, gdy stoi if( mvOccupied->V == 0 ) { // ustalenie kierunku, gdy stoi
iDirection = mvOccupied->CabNo; // wg wybranej kabiny iDirection = mvOccupied->CabNo; // wg wybranej kabiny
if (!iDirection) // jeśli nie ma ustalonego kierunku if( !iDirection ) {
if ((mvControlling->PantFrontVolt != 0.0) || // jeśli nie ma ustalonego kierunku
(mvControlling->PantRearVolt != 0.0) || voltfront || voltrear) if( ( mvControlling->PantFrontVolt != 0.0 ) || ( mvControlling->PantRearVolt != 0.0 ) || voltfront || voltrear ) {
{ if( mvOccupied->Couplers[ 1 ].CouplingFlag == ctrain_virtual ) {
if (mvOccupied->Couplers[1].CouplingFlag == // jeśli z tyłu nie ma nic
ctrain_virtual) // jeśli z tyłu nie ma nic
iDirection = -1; // jazda w kierunku sprzęgu 1 iDirection = -1; // jazda w kierunku sprzęgu 1
if (mvOccupied->Couplers[0].CouplingFlag == }
ctrain_virtual) // jeśli z przodu nie ma nic if( mvOccupied->Couplers[ 0 ].CouplingFlag == ctrain_virtual ) {
// jeśli z przodu nie ma nic
iDirection = 1; // jazda w kierunku sprzęgu 0 iDirection = 1; // jazda w kierunku sprzęgu 0
}
} }
}
} }
else // ustalenie kierunku, gdy jedzie else {
if ((mvControlling->PantFrontVolt != 0.0) || (mvControlling->PantRearVolt != 0.0) || // ustalenie kierunku, gdy jedzie
voltfront || voltrear) if( ( mvControlling->PantFrontVolt != 0.0 ) || ( mvControlling->PantRearVolt != 0.0 ) || voltfront || voltrear ) {
if (mvOccupied->V < 0) // jedzie do tyłu if( mvOccupied->V < 0 ) {
iDirection = -1; // jazda w kierunku sprzęgu 1 // jedzie do tyłu
else // jak nie do tyłu, to do przodu iDirection = -1; // jazda w kierunku sprzęgu 1
iDirection = 1; // jazda w kierunku sprzęgu 0 }
else {
// jak nie do tyłu, to do przodu
iDirection = 1; // jazda w kierunku sprzęgu 0
}
}
}
}
if (AIControllFlag) // jeśli prowadzi komputer if (AIControllFlag) // jeśli prowadzi komputer
{ // część wykonawcza dla sterowania przez komputer { // część wykonawcza dla sterowania przez komputer
if (mvControlling->ConvOvldFlag) if (mvControlling->ConvOvldFlag)
@@ -2288,38 +2257,48 @@ bool TController::PrepareEngine()
; // zerowanie napędu ; // zerowanie napędu
mvControlling->ConvOvldFlag = false; // reset nadmiarowego mvControlling->ConvOvldFlag = false; // reset nadmiarowego
} }
else if (!mvControlling->Mains) else if (false == mvControlling->Mains) {
{
// if TrainType=dt_SN61)
// begin
// OK:=(OrderDirectionChange(ChangeDir,Controlling)=-1);
// OK:=IncMainCtrl(1);
// end;
while (DecSpeed(true)) while (DecSpeed(true))
; // zerowanie napędu ; // zerowanie napędu
OK = mvControlling->MainSwitch(true);
if (mvControlling->EngineType == DieselEngine) if( ( mvOccupied->EngineType == DieselEngine )
{ // Ra 2014-06: dla SN61 trzeba wrzucić pierwszą pozycję - nie wiem, czy tutaj... || ( mvOccupied->EngineType == DieselElectric ) ) {
// kiedyś działało... // start helper devices before spinning up the engine
if (!mvControlling->MainCtrlPos) // TODO: replace with dedicated diesel engine subsystems
{ mvOccupied->ConverterSwitch( true );
if (mvControlling->RList[0].R == mvOccupied->CompressorSwitch( true );
0.0) // gdy na pozycji 0 dawka paliwa jest zerowa, to zgaśnie }
mvControlling->IncMainCtrl(1); // dlatego trzeba zwiększyć pozycję if( mvOccupied->TrainType == dt_SN61 ) {
if (!mvControlling->ScndCtrlPos) // jeśli bieg nie został ustawiony // specjalnie dla SN61 żeby nie zgasł
if (!mvControlling->MotorParam[0].AutoSwitch) // gdy biegi ręczne if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) {
if (mvControlling->MotorParam[0].mIsat == 0.0) // bl,mIsat,fi,mfi mvControlling->IncMainCtrl( 1 );
mvControlling->IncScndCtrl(1); // pierwszy bieg
} }
} }
OK = mvControlling->MainSwitch(true);
/*
if (mvControlling->EngineType == DieselEngine) {
// Ra 2014-06: dla SN61 trzeba wrzucić pierwszą pozycję - nie wiem, czy tutaj...
// kiedyś działało...
if (!mvControlling->MainCtrlPos) {
if( mvControlling->RList[ 0 ].R == 0.0 ) {
// gdy na pozycji 0 dawka paliwa jest zerowa, to zgaśnie dlatego trzeba zwiększyć pozycję
mvControlling->IncMainCtrl( 1 );
}
if( ( !mvControlling->ScndCtrlPos ) // jeśli bieg nie został ustawiony
&& ( !mvControlling->MotorParam[ 0 ].AutoSwitch ) // gdy biegi ręczne
&& ( mvControlling->MotorParam[ 0 ].mIsat == 0.0 ) ) { // bl,mIsat,fi,mfi
// pierwszy bieg
mvControlling->IncScndCtrl( 1 );
}
}
}
*/
} }
else else {
{ // Ra: iDirection określa, w którą stronę jedzie skład względem sprzęgów pojazdu z AI OK = ( OrderDirectionChange( iDirection, mvOccupied ) == -1 );
OK = (OrderDirectionChange(iDirection, mvOccupied) == -1); mvOccupied->ConverterSwitch( true );
// w EN57 sprężarka w ra jest zasilana z silnikowego // w EN57 sprężarka w ra jest zasilana z silnikowego
mvControlling->CompressorSwitch(true); mvControlling->CompressorSwitch( true );
mvControlling->ConverterSwitch(true);
mvControlling->CompressorSwitch(true);
} }
} }
else else
@@ -2718,20 +2697,22 @@ bool TController::IncSpeed()
break; break;
case DieselEngine: case DieselEngine:
if (mvControlling->ShuntModeAllow) if (mvControlling->ShuntModeAllow)
{ // dla 2Ls150 można zmienić tryb pracy, jeśli jest w liniowym i nie daje rady (wymaga { // dla 2Ls150 można zmienić tryb pracy, jeśli jest w liniowym i nie daje rady (wymaga zerowania kierunku)
// zerowania kierunku)
// mvControlling->ShuntMode=(OrderList[OrderPos]&Shunt)||(fMass>224000.0); // mvControlling->ShuntMode=(OrderList[OrderPos]&Shunt)||(fMass>224000.0);
} }
if ((mvControlling->Vel > mvControlling->dizel_minVelfullengage) && if( true == Ready ) {
(mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0)) if( ( mvControlling->Vel > mvControlling->dizel_minVelfullengage )
OK = mvControlling->IncMainCtrl(1); && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 ) ) {
if (mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0) OK = mvControlling->IncMainCtrl( 1 );
OK = mvControlling->IncMainCtrl(1); }
if (!mvControlling->Mains) if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) {
{ OK = mvControlling->IncMainCtrl( 1 );
mvControlling->MainSwitch(true); }
mvControlling->ConverterSwitch(true); }
mvControlling->CompressorSwitch(true); if( false == mvControlling->Mains ) {
mvControlling->MainSwitch( true );
mvControlling->ConverterSwitch( true );
mvControlling->CompressorSwitch( true );
} }
break; break;
} }
@@ -3173,12 +3154,11 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
vCommandLocation = *NewLocation; vCommandLocation = *NewLocation;
if ((NewValue1 != 0.0) && (OrderList[OrderPos] != Obey_train)) if ((NewValue1 != 0.0) && (OrderList[OrderPos] != Obey_train))
{ // o ile jazda { // o ile jazda
if (!iEngineActive) if( iEngineActive == 0 ) {
OrderNext(Prepare_engine); // trzeba odpalić silnik najpierw, światła ustawi // trzeba odpalić silnik najpierw, światła ustawi
// JumpToNextOrder() OrderNext( Prepare_engine );
// if (OrderList[OrderPos]!=Obey_train) //jeśli nie pociągowa }
OrderNext(Obey_train); // to uruchomić jazdę pociągową (od razu albo po odpaleniu OrderNext(Obey_train); // to uruchomić jazdę pociągową (od razu albo po odpaleniu silnika
// silnika
OrderCheck(); // jeśli jazda pociągowa teraz, to wykonać niezbędne operacje OrderCheck(); // jeśli jazda pociągowa teraz, to wykonać niezbędne operacje
} }
if (NewValue1 != 0.0) // jeśli jechać if (NewValue1 != 0.0) // jeśli jechać
@@ -3481,6 +3461,7 @@ TController::UpdateSituation(double dt) {
index = std::min(BrakeAccTableSize, std::max(1, index)); index = std::min(BrakeAccTableSize, std::max(1, index));
fBrake_a0[0] = fBrake_a0[index]; fBrake_a0[0] = fBrake_a0[index];
fBrake_a1[0] = fBrake_a1[index]; fBrake_a1[0] = fBrake_a1[index];
Ready = true; // wstępnie gotowy Ready = true; // wstępnie gotowy
fReady = 0.0; // założenie, że odhamowany fReady = 0.0; // założenie, że odhamowany
fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia
@@ -3489,8 +3470,8 @@ TController::UpdateSituation(double dt) {
TDynamicObject *p = pVehicles[0]; // pojazd na czole składu TDynamicObject *p = pVehicles[0]; // pojazd na czole składu
while (p) while (p)
{ // sprawdzenie odhamowania wszystkich połączonych pojazdów { // sprawdzenie odhamowania wszystkich połączonych pojazdów
if (Ready) // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać if (Ready) {
// if (p->MoverParameters->BrakePress>=0.03*p->MoverParameters->MaxBrakePress) // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać
if (p->MoverParameters->BrakePress >= 0.4) // wg UIC określone sztywno na 0.04 if (p->MoverParameters->BrakePress >= 0.4) // wg UIC określone sztywno na 0.04
{ {
Ready = false; // nie gotowy Ready = false; // nie gotowy
@@ -3508,6 +3489,7 @@ TController::UpdateSituation(double dt) {
Need_TryAgain = true; // reset jak przy wywaleniu nadmiarowego Need_TryAgain = true; // reset jak przy wywaleniu nadmiarowego
} }
} }
}
if (fReady < p->MoverParameters->BrakePress) if (fReady < p->MoverParameters->BrakePress)
fReady = p->MoverParameters->BrakePress; // szukanie najbardziej zahamowanego fReady = p->MoverParameters->BrakePress; // szukanie najbardziej zahamowanego
if( ( dy = p->VectorFront().y ) != 0.0 ) { if( ( dy = p->VectorFront().y ) != 0.0 ) {
@@ -3526,6 +3508,25 @@ TController::UpdateSituation(double dt) {
// if (mvOccupied->BrakePress<0.08) //to wystarczy, że zadziałają liniowe (nie ma ich jeszcze!!!) // if (mvOccupied->BrakePress<0.08) //to wystarczy, że zadziałają liniowe (nie ma ich jeszcze!!!)
if (fReady < 0.8) // delikatniejszy warunek, obejmuje wszystkie wagony if (fReady < 0.8) // delikatniejszy warunek, obejmuje wszystkie wagony
Ready = true; //żeby uznać za odhamowany Ready = true; //żeby uznać za odhamowany
// second pass, for diesel engines verify the engines are fully started
// TODO: cache presence of diesel engines in the consist, to skip this test if there isn't any
p = pVehicles[ 0 ]; // pojazd na czole składu
while( ( true == Ready )
&& ( p != nullptr ) ) {
auto const *vehicle { p->MoverParameters };
if( ( vehicle->EngineType == DieselEngine )
|| ( vehicle->EngineType == DieselElectric ) ) {
Ready = (
vehicle->enrot > 0.9 * (
vehicle->EngineType == DieselEngine ?
vehicle->dizel_nmin :
vehicle->DElist[ 0 ].RPM / 60.0 ) );
}
p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła)
}
// crude way to deal with automatic door opening on W4 preventing further ride // crude way to deal with automatic door opening on W4 preventing further ride
// for human-controlled vehicles with no door control and dynamic brake auto-activating with door open // for human-controlled vehicles with no door control and dynamic brake auto-activating with door open
@@ -5660,10 +5661,12 @@ void TController::DirectionForward(bool forward)
else else
while (mvOccupied->ActiveDir >= 0) while (mvOccupied->ActiveDir >= 0)
mvOccupied->DirectionBackward(); // do tyłu w obecnej kabinie mvOccupied->DirectionBackward(); // do tyłu w obecnej kabinie
if (mvOccupied->EngineType == DieselEngine) // specjalnie dla SN61 if( mvOccupied->TrainType == dt_SN61 ) {
if (iDrivigFlags & moveActive) // jeśli był już odpalony // specjalnie dla SN61 żeby nie zgasł
if (mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0) if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) {
mvControlling->IncMainCtrl(1); //żeby nie zgasł mvControlling->IncMainCtrl( 1 );
}
}
}; };
std::string TController::Relation() std::string TController::Relation()

View File

@@ -3533,7 +3533,7 @@ void TDynamicObject::RenderSounds() {
} }
m_lastbrakepressure = MoverParameters->BrakePress; m_lastbrakepressure = MoverParameters->BrakePress;
// ensure some basic level of volume and scale it up depending on pressure in the cylinder; scale this by the leak rate // ensure some basic level of volume and scale it up depending on pressure in the cylinder; scale this by the leak rate
volume = 20 * m_brakepressurechange * ( 0.25 + 0.75 * ( std::max( MoverParameters->BrakePress, 0.0 ) / MoverParameters->MaxBrakePress[ 3 ] ) ); volume = 20 * m_brakepressurechange * ( 0.25 + 0.75 * ( std::max( 0.0, MoverParameters->BrakePress ) / std::max( 1.0, MoverParameters->MaxBrakePress[ 3 ] ) ) );
if( volume > 0.075f ) { if( volume > 0.075f ) {
rsUnbrake rsUnbrake
.gain( volume ) .gain( volume )
@@ -3591,7 +3591,7 @@ void TDynamicObject::RenderSounds() {
brakeforceratio = brakeforceratio =
clamp( clamp(
MoverParameters->UnitBrakeForce / ( MoverParameters->BrakeForceR( 1.0, MoverParameters->Vel ) / ( MoverParameters->NAxles * std::max( 1, MoverParameters->NBpA ) ) ), MoverParameters->UnitBrakeForce / std::max( 1.0, MoverParameters->BrakeForceR( 1.0, MoverParameters->Vel ) / ( MoverParameters->NAxles * std::max( 1, MoverParameters->NBpA ) ) ),
0.0, 1.0 ); 0.0, 1.0 );
rsBrake rsBrake
.pitch( rsBrake.m_frequencyoffset + MoverParameters->Vel * rsBrake.m_frequencyfactor ) .pitch( rsBrake.m_frequencyoffset + MoverParameters->Vel * rsBrake.m_frequencyfactor )

View File

@@ -46,7 +46,7 @@ public:
// 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;
// members // members
TSubModel *SubModel; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie TSubModel *SubModel { nullptr }; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie
private: private:
// methods // methods

View File

@@ -8262,10 +8262,9 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
// end // end
else if (Command == "CompressorSwitch") /*NBMX*/ else if (Command == "CompressorSwitch") /*NBMX*/
{ {
if ((CValue1 == 1)) if( CompressorPower < 2 ) {
CompressorAllow = true; CompressorAllow = ( CValue1 == 1 );
else if ((CValue1 == 0)) }
CompressorAllow = false;
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }
else if (Command == "DoorOpen") /*NBMX*/ else if (Command == "DoorOpen") /*NBMX*/

View File

@@ -247,10 +247,6 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
NBpA = i_nbpa; NBpA = i_nbpa;
BrakeDelays = i_BD; BrakeDelays = i_BD;
BrakeDelayFlag = bdelay_P; BrakeDelayFlag = bdelay_P;
DCV = false;
ASBP = 0.0;
BrakeStatus = b_hld;
SoundFlag = 0;
// 210.88 // 210.88
// SizeBR:=i_bcn*i_bcr*i_bcr*i_bcd*40.17*MaxBP/(5-MaxBP); //objetosc ZP w stosunku do cylindra // SizeBR:=i_bcn*i_bcr*i_bcr*i_bcd*40.17*MaxBP/(5-MaxBP); //objetosc ZP w stosunku do cylindra
// 14" i cisnienia 4.2 atm // 14" i cisnienia 4.2 atm
@@ -258,7 +254,6 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
SizeBC = i_bcn * i_bcr * i_bcr * i_bcd * 210.88 * MaxBP / SizeBC = i_bcn * i_bcr * i_bcr * i_bcd * 210.88 * MaxBP /
4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm 4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm
// BrakeCyl:=TReservoir.Create;
BrakeCyl = std::make_shared<TBrakeCyl>(); BrakeCyl = std::make_shared<TBrakeCyl>();
BrakeRes = std::make_shared<TReservoir>(); BrakeRes = std::make_shared<TReservoir>();
ValveRes = std::make_shared<TReservoir>(); ValveRes = std::make_shared<TReservoir>();
@@ -268,7 +263,6 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
BrakeRes->CreateCap(i_brc); BrakeRes->CreateCap(i_brc);
ValveRes->CreateCap(0.25); ValveRes->CreateCap(0.25);
// FM.Free;
// materialy cierne // materialy cierne
i_mat = i_mat & (255 - bp_MHS); i_mat = i_mat & (255 - bp_MHS);
switch (i_mat) switch (i_mat)

View File

@@ -1388,7 +1388,7 @@ TWorld::Update_UI() {
uitextline2 += ( vehicle->MoverParameters->PantPressLockActive ? "!" : ( vehicle->MoverParameters->PantPressSwitchActive ? "*" : "." ) ); uitextline2 += ( vehicle->MoverParameters->PantPressLockActive ? "!" : ( vehicle->MoverParameters->PantPressSwitchActive ? "*" : "." ) );
uitextline2 += ( false == vehicle->MoverParameters->ConverterAllowLocal ? "-" : ( vehicle->MoverParameters->ConverterAllow ? ( vehicle->MoverParameters->ConverterFlag ? "X" : "x" ) : "." ) ); uitextline2 += ( false == vehicle->MoverParameters->ConverterAllowLocal ? "-" : ( vehicle->MoverParameters->ConverterAllow ? ( vehicle->MoverParameters->ConverterFlag ? "X" : "x" ) : "." ) );
uitextline2 += ( vehicle->MoverParameters->ConvOvldFlag ? "!" : "." ); uitextline2 += ( vehicle->MoverParameters->ConvOvldFlag ? "!" : "." );
uitextline2 += ( false == vehicle->MoverParameters->CompressorAllowLocal ? "-" : ( vehicle->MoverParameters->CompressorAllow ? ( vehicle->MoverParameters->CompressorFlag ? "C" : "c" ) : "." ) ); uitextline2 += ( false == vehicle->MoverParameters->CompressorAllowLocal ? "-" : ( ( vehicle->MoverParameters->CompressorAllow || vehicle->MoverParameters->CompressorPower > 1 ) ? ( vehicle->MoverParameters->CompressorFlag ? "C" : "c" ) : "." ) );
uitextline2 += ( vehicle->MoverParameters->CompressorGovernorLock ? "!" : "." ); uitextline2 += ( vehicle->MoverParameters->CompressorGovernorLock ? "!" : "." );
/* /*
uitextline2 += uitextline2 +=

View File

@@ -22,8 +22,6 @@ http://mozilla.org/MPL/2.0/.
#include "Logs.h" #include "Logs.h"
#include "usefull.h" #include "usefull.h"
#define EU07_NEW_CAB_RENDERCODE
opengl_renderer GfxRenderer; opengl_renderer GfxRenderer;
extern TWorld World; extern TWorld World;
@@ -111,7 +109,7 @@ opengl_renderer::Init( GLFWwindow *Window ) {
::glDepthFunc( GL_LEQUAL ); ::glDepthFunc( GL_LEQUAL );
glEnable( GL_DEPTH_TEST ); glEnable( GL_DEPTH_TEST );
glAlphaFunc( GL_GREATER, 0.04f ); glAlphaFunc( GL_GREATER, 0.f );
glEnable( GL_ALPHA_TEST ); glEnable( GL_ALPHA_TEST );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_BLEND ); glEnable( GL_BLEND );
@@ -431,13 +429,11 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
::glEnable( GL_TEXTURE_2D ); ::glEnable( GL_TEXTURE_2D );
} }
#endif #endif
#ifdef EU07_NEW_CAB_RENDERCODE
if( World.Train != nullptr ) { if( World.Train != nullptr ) {
// cab render is performed without shadows, due to low resolution and number of models without windows :| // cab render is performed without shadows, due to low resolution and number of models without windows :|
switch_units( true, false, false ); switch_units( true, false, false );
Render_cab( World.Train->Dynamic(), false ); Render_cab( World.Train->Dynamic(), false );
} }
#endif
switch_units( true, true, true ); switch_units( true, true, true );
Render( simulation::Region ); Render( simulation::Region );
/* /*
@@ -832,7 +828,7 @@ opengl_renderer::setup_drawing( bool const Alpha ) {
} }
else { else {
::glDisable( GL_BLEND ); ::glDisable( GL_BLEND );
::glAlphaFunc( GL_GREATER, 0.50f ); ::glAlphaFunc( GL_GREATER, 0.5f );
} }
switch( m_renderpass.draw_mode ) { switch( m_renderpass.draw_mode ) {
@@ -909,7 +905,7 @@ opengl_renderer::setup_units( bool const Diffuse, bool const Shadows, bool const
if( ( true == Global::RenderShadows ) && ( true == Shadows ) && ( false == Global::bWireFrame ) ) { if( ( true == Global::RenderShadows ) && ( true == Shadows ) && ( false == Global::bWireFrame ) ) {
::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
::glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, glm::value_ptr( m_shadowcolor ) ); // TODO: dynamically calculated shadow colour, based on sun height ::glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, glm::value_ptr( m_shadowcolor ) );
::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE ); // darken the previous stage ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE ); // darken the previous stage
::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS ); ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS );
@@ -1393,17 +1389,6 @@ opengl_renderer::Render( scene::basic_region *Region ) {
m_sectionqueue.clear(); m_sectionqueue.clear();
m_cellqueue.clear(); m_cellqueue.clear();
/*
for( auto *section : Region->sections( m_renderpass.camera.position(), m_renderpass.draw_range * Global::fDistanceFactor ) ) {
#ifdef EU07_USE_DEBUG_CULLING
if( m_worldcamera.camera.visible( section->m_area ) ) {
#else
if( m_renderpass.camera.visible( section->m_area ) ) {
#endif
m_sectionqueue.emplace_back( section );
}
}
*/
// build a list of region sections to render // build a list of region sections to render
glm::vec3 const cameraposition { m_renderpass.camera.position() }; glm::vec3 const cameraposition { m_renderpass.camera.position() };
auto const camerax = static_cast<int>( std::floor( cameraposition.x / scene::EU07_SECTIONSIZE + scene::EU07_REGIONSIDESECTIONCOUNT / 2 ) ); auto const camerax = static_cast<int>( std::floor( cameraposition.x / scene::EU07_SECTIONSIZE + scene::EU07_REGIONSIDESECTIONCOUNT / 2 ) );
@@ -1420,11 +1405,7 @@ opengl_renderer::Render( scene::basic_region *Region ) {
if( column >= scene::EU07_REGIONSIDESECTIONCOUNT ) { break; } if( column >= scene::EU07_REGIONSIDESECTIONCOUNT ) { break; }
auto *section { Region->m_sections[ row * scene::EU07_REGIONSIDESECTIONCOUNT + column ] }; auto *section { Region->m_sections[ row * scene::EU07_REGIONSIDESECTIONCOUNT + column ] };
if( ( section != nullptr ) if( ( section != nullptr )
#ifdef EU07_USE_DEBUG_CULLING
&& ( m_worldcamera.camera.visible( section->m_area ) ) ) {
#else
&& ( m_renderpass.camera.visible( section->m_area ) ) ) { && ( m_renderpass.camera.visible( section->m_area ) ) ) {
#endif
m_sectionqueue.emplace_back( section ); m_sectionqueue.emplace_back( section );
} }
} }
@@ -1501,38 +1482,6 @@ opengl_renderer::Render( section_sequence::iterator First, section_sequence::ite
auto const originoffset { section->m_area.center - m_renderpass.camera.position() }; auto const originoffset { section->m_area.center - m_renderpass.camera.position() };
::glTranslated( originoffset.x, originoffset.y, originoffset.z ); ::glTranslated( originoffset.x, originoffset.y, originoffset.z );
// render // render
#ifdef EU07_USE_DEBUG_CULLING
// debug
::glLineWidth( 2.f );
float const width = section->m_area.radius;
float const height = section->m_area.radius * 0.2f;
glDisable( GL_LIGHTING );
glDisable( GL_TEXTURE_2D );
glColor3ub( 255, 128, 128 );
glBegin( GL_LINE_LOOP );
glVertex3f( -width, height, width );
glVertex3f( -width, height, -width );
glVertex3f( width, height, -width );
glVertex3f( width, height, width );
glEnd();
glBegin( GL_LINE_LOOP );
glVertex3f( -width, 0, width );
glVertex3f( -width, 0, -width );
glVertex3f( width, 0, -width );
glVertex3f( width, 0, width );
glEnd();
glBegin( GL_LINES );
glVertex3f( -width, height, width ); glVertex3f( -width, 0, width );
glVertex3f( -width, height, -width ); glVertex3f( -width, 0, -width );
glVertex3f( width, height, -width ); glVertex3f( width, 0, -width );
glVertex3f( width, height, width ); glVertex3f( width, 0, width );
glEnd();
glColor3ub( 255, 255, 255 );
glEnable( GL_TEXTURE_2D );
glEnable( GL_LIGHTING );
glLineWidth( 1.f );
#endif
// shapes
for( auto const &shape : section->m_shapes ) { Render( shape, true ); } for( auto const &shape : section->m_shapes ) { Render( shape, true ); }
// post-render cleanup // post-render cleanup
::glPopMatrix(); ::glPopMatrix();
@@ -1552,11 +1501,7 @@ opengl_renderer::Render( section_sequence::iterator First, section_sequence::ite
case rendermode::pickscenery: { case rendermode::pickscenery: {
for( auto &cell : section->m_cells ) { for( auto &cell : section->m_cells ) {
if( ( true == cell.m_active ) if( ( true == cell.m_active )
#ifdef EU07_USE_DEBUG_CULLING
&& ( m_worldcamera.camera.visible( cell.m_area ) ) ) {
#else
&& ( m_renderpass.camera.visible( cell.m_area ) ) ) { && ( m_renderpass.camera.visible( cell.m_area ) ) ) {
#endif
// store visible cells with content as well as their current distance, for sorting later // store visible cells with content as well as their current distance, for sorting later
m_cellqueue.emplace_back( m_cellqueue.emplace_back(
glm::length2( m_renderpass.camera.position() - cell.m_area.center ), glm::length2( m_renderpass.camera.position() - cell.m_area.center ),
@@ -1605,35 +1550,6 @@ opengl_renderer::Render( cell_sequence::iterator First, cell_sequence::iterator
::glTranslated( originoffset.x, originoffset.y, originoffset.z ); ::glTranslated( originoffset.x, originoffset.y, originoffset.z );
// render // render
#ifdef EU07_USE_DEBUG_CULLING
// debug
float const width = cell->m_area.radius;
float const height = cell->m_area.radius * 0.15f;
glDisable( GL_LIGHTING );
glDisable( GL_TEXTURE_2D );
glColor3ub( 255, 255, 0 );
glBegin( GL_LINE_LOOP );
glVertex3f( -width, height, width );
glVertex3f( -width, height, -width );
glVertex3f( width, height, -width );
glVertex3f( width, height, width );
glEnd();
glBegin( GL_LINE_LOOP );
glVertex3f( -width, 0, width );
glVertex3f( -width, 0, -width );
glVertex3f( width, 0, -width );
glVertex3f( width, 0, width );
glEnd();
glBegin( GL_LINES );
glVertex3f( -width, height, width ); glVertex3f( -width, 0, width );
glVertex3f( -width, height, -width ); glVertex3f( -width, 0, -width );
glVertex3f( width, height, -width ); glVertex3f( width, 0, -width );
glVertex3f( width, height, width ); glVertex3f( width, 0, width );
glEnd();
glColor3ub( 255, 255, 255 );
glEnable( GL_TEXTURE_2D );
glEnable( GL_LIGHTING );
#endif
// opaque non-instanced shapes // opaque non-instanced shapes
for( auto const &shape : cell->m_shapesopaque ) { Render( shape, false ); } for( auto const &shape : cell->m_shapesopaque ) { Render( shape, false ); }
// tracks // tracks
@@ -1805,6 +1721,10 @@ opengl_renderer::Render( scene::shape_node const &Shape, bool const Ignorerange
void void
opengl_renderer::Render( TAnimModel *Instance ) { opengl_renderer::Render( TAnimModel *Instance ) {
if( false == Instance->m_visible ) {
return;
}
double distancesquared; double distancesquared;
switch( m_renderpass.draw_mode ) { switch( m_renderpass.draw_mode ) {
case rendermode::shadows: { case rendermode::shadows: {
@@ -1988,7 +1908,6 @@ opengl_renderer::Render_cab( TDynamicObject *Dynamic, bool const Alpha ) {
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) ); ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) );
} }
// render // render
#ifdef EU07_NEW_CAB_RENDERCODE
if( true == Alpha ) { if( true == Alpha ) {
// translucent parts // translucent parts
Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
@@ -1997,10 +1916,6 @@ opengl_renderer::Render_cab( TDynamicObject *Dynamic, bool const Alpha ) {
// opaque parts // opaque parts
Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
} }
#else
Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 );
#endif
// post-render restore // post-render restore
if( Dynamic->fShade > 0.0f ) { if( Dynamic->fShade > 0.0f ) {
// change light level based on light level of the occupied track // change light level based on light level of the occupied track
@@ -2632,6 +2547,10 @@ opengl_renderer::Render_Alpha( cell_sequence::reverse_iterator First, cell_seque
void void
opengl_renderer::Render_Alpha( TAnimModel *Instance ) { opengl_renderer::Render_Alpha( TAnimModel *Instance ) {
if( false == Instance->m_visible ) {
return;
}
double distancesquared; double distancesquared;
switch( m_renderpass.draw_mode ) { switch( m_renderpass.draw_mode ) {
case rendermode::shadows: { case rendermode::shadows: {

View File

@@ -22,7 +22,6 @@ http://mozilla.org/MPL/2.0/.
#define EU07_USE_PICKING_FRAMEBUFFER #define EU07_USE_PICKING_FRAMEBUFFER
//#define EU07_USE_DEBUG_SHADOWMAP //#define EU07_USE_DEBUG_SHADOWMAP
//#define EU07_USE_DEBUG_CAMERA //#define EU07_USE_DEBUG_CAMERA
//#define EU07_USE_DEBUG_CULLING
struct opengl_light { struct opengl_light {