diff --git a/DynObj.h b/DynObj.h index b5ff3e04..e90f60ee 100644 --- a/DynObj.h +++ b/DynObj.h @@ -444,7 +444,7 @@ public: // modele składowe pojazdu { return vUp; }; - inline vector3 VectorLeft() + inline vector3 VectorLeft() const { return vLeft; }; @@ -460,7 +460,7 @@ public: // modele składowe pojazdu { return MoverParameters->Dim.L; }; - inline double GetWidth() + inline double GetWidth() const { return MoverParameters->Dim.W; }; diff --git a/Globals.cpp b/Globals.cpp index 532ace49..fd40e5b1 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -495,7 +495,10 @@ void Global::ConfigParse(cParser &Parser) Parser.getTokens(); Parser >> token; +/* Global::bUseVBO = (token == "yes"); +*/ + Global::bUseVBO = false; // temporarily disabled until render paths are sorted out } else if (token == "feedbackmode") { diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 065df7a5..89c47a26 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -3005,98 +3005,105 @@ void TMoverParameters::UpdatePipePressure(double dt) // if (Hamulec is typeid(TWest)) return 0; - switch (BrakeValve) - { - case W: - { - if (BrakeLocHandle != NoHandle) + switch (BrakeValve) { + + case K: + case W: { + + if( BrakeLocHandle != NoHandle ) { + LocBrakePress = LocHandle->GetCP(); + + //(Hamulec as TWest).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + } + if( MBPM < 2 ) + //(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag]) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + //(Hamulec as TWest).PLC(TotalMass); + Hamulec->PLC( TotalMass ); + break; + } + + case LSt: + case EStED: { + + LocBrakePress = LocHandle->GetCP(); + for( int b = 0; b < 2; b++ ) + if( ( ( TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) && + ( Couplers[ b ].Connected != NULL ) ) // nie podoba mi się to rozwiązanie, chyba trzeba + // dodać jakiś wpis do fizyki na to + if( ( ( Couplers[ b ].Connected->TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) && + ( ( Couplers[ b ].CouplingFlag & 36 ) == 36 ) ) + LocBrakePress = Max0R( Couplers[ b ].Connected->LocHandle->GetCP(), LocBrakePress ); + + //if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor)) + //{ + // //if (Vel > 10) + // // LocBrakePress = 0; + // //else if (Vel > 5) + // // LocBrakePress = (10 - Vel) / 5 * LocBrakePress; + //} + + //(Hamulec as TLSt).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + if( ( BrakeValve == EStED ) ) + if( MBPM < 2 ) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + Hamulec->PLC( TotalMass ); + break; + } + + case CV1_L_TR: { LocBrakePress = LocHandle->GetCP(); - - //(Hamulec as TWest).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); + //(Hamulec as TCV1L_TR).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + break; } - if (MBPM < 2) - //(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag]) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - //(Hamulec as TWest).PLC(TotalMass); - Hamulec->PLC(TotalMass); - break; - } - case LSt: - case EStED: - { - LocBrakePress = LocHandle->GetCP(); - for (int b = 0; b < 2; b++) - if (((TrainType & (dt_ET41 | dt_ET42)) != 0) && - (Couplers[b].Connected != NULL)) // nie podoba mi się to rozwiązanie, chyba trzeba - // dodać jakiś wpis do fizyki na to - if (((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0) && - ((Couplers[b].CouplingFlag & 36) == 36)) - LocBrakePress = Max0R(Couplers[b].Connected->LocHandle->GetCP(), LocBrakePress); - - //if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor)) - //{ - // //if (Vel > 10) - // // LocBrakePress = 0; - // //else if (Vel > 5) - // // LocBrakePress = (10 - Vel) / 5 * LocBrakePress; - //} - - //(Hamulec as TLSt).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - if ((BrakeValve == EStED)) - if (MBPM < 2) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - Hamulec->PLC(TotalMass); - break; - } - - case CV1_L_TR: - { - LocBrakePress = LocHandle->GetCP(); - //(Hamulec as TCV1L_TR).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - break; - } - - case EP2: - { - Hamulec->PLC(TotalMass); - break; - } - case ESt3AL2: - case NESt3: - case ESt4: - case ESt3: - { - if (MBPM < 2) - //(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag]) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - //(Hamulec as TNESt3).PLC(TotalMass); - Hamulec->PLC(TotalMass); - LocBrakePress = LocHandle->GetCP(); - //(Hamulec as TNESt3).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - break; - } - case KE: - { - LocBrakePress = LocHandle->GetCP(); - //(Hamulec as TKE).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - if (MBPM < 2) - //(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag]) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - //(Hamulec as TKE).PLC(TotalMass); - Hamulec->PLC(TotalMass); - break; - } + case EP2: + { + Hamulec->PLC( TotalMass ); + break; + } + case ESt3AL2: + case NESt3: + case ESt4: + case ESt3: + { + if( MBPM < 2 ) + //(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag]) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + //(Hamulec as TNESt3).PLC(TotalMass); + Hamulec->PLC( TotalMass ); + LocBrakePress = LocHandle->GetCP(); + //(Hamulec as TNESt3).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + break; + } + case KE: + { + LocBrakePress = LocHandle->GetCP(); + //(Hamulec as TKE).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + if( MBPM < 2 ) + //(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag]) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + //(Hamulec as TKE).PLC(TotalMass); + Hamulec->PLC( TotalMass ); + break; + } + default: + { + // unsupported brake valve type, we should never land here +// ErrorLog( "Unsupported brake valve type (" + std::to_string( BrakeValve ) + ") in " + TypeName ); +// ::PostQuitMessage( 0 ); + break; + } } // switch if ((BrakeHandle == FVel6) && (ActiveCab != 0)) @@ -7252,8 +7259,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) } if ( ( true == TestFlag( BrakeDelays, bdelay_G ) ) - && ( false == TestFlag(BrakeDelays, bdelay_R) ) - || ( Power > 1.0 ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy + && ( ( false == TestFlag(BrakeDelays, bdelay_R ) ) + || ( Power > 1.0 ) ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy Spg = 0.792; else Spg = 0.507; diff --git a/World.cpp b/World.cpp index 9fd96101..7f986aa4 100644 --- a/World.cpp +++ b/World.cpp @@ -763,7 +763,8 @@ void TWorld::OnKeyDown(int cKey) break; } case VK_F4: { - InOutKey(); + + InOutKey( !Console::Pressed( VK_SHIFT ) ); // distant view with Shift, short distance step out otherwise break; } case VK_F5: { @@ -980,7 +981,7 @@ void TWorld::OnMouseMove(double x, double y) Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor); } -void TWorld::InOutKey() +void TWorld::InOutKey( bool const Near ) { // przełączenie widoku z kabiny na zewnętrzny i odwrotnie FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku if (FreeFlyModeFlag) @@ -990,7 +991,7 @@ void TWorld::InOutKey() { // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0)); Train->Silence(); // wyłączenie dźwięków kabiny Train->Dynamic()->bDisplayCab = false; - DistantView(); + DistantView( Near ); } } else @@ -1010,26 +1011,33 @@ void TWorld::InOutKey() } }; -void TWorld::DistantView() +// places camera outside the controlled vehicle, or nearest if nothing is under control +// depending on provided switch the view is placed right outside, or at medium distance +void TWorld::DistantView( bool const Near ) { // ustawienie widoku pojazdu z zewnątrz - if (Controlled) // jest pojazd do prowadzenia? - { // na prowadzony + + TDynamicObject const *vehicle{ nullptr }; + if( nullptr != Controlled ) { vehicle = Controlled; } + else if( nullptr != pDynamicNearest ) { vehicle = pDynamicNearest; } + else { return; } + + if( true == Near ) { + Camera.Pos = - Controlled->GetPosition() + - (Controlled->MoverParameters->ActiveCab >= 0 ? 30 : -30) * Controlled->VectorFront() + - vector3(0, 5, 0); - Camera.LookAt = Controlled->GetPosition(); - Camera.RaLook(); // jednorazowe przestawienie kamery + vector3( Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z ) + + vehicle->VectorLeft() * vehicle->MoverParameters->ActiveCab * vehicle->GetWidth() + + vector3( 1.25 * vehicle->MoverParameters->ActiveCab, 1.6, 0.0 ); } - else if (pDynamicNearest) // jeśli jest pojazd wykryty blisko - { // patrzenie na najbliższy pojazd - Camera.Pos = pDynamicNearest->GetPosition() + - (pDynamicNearest->MoverParameters->ActiveCab >= 0 ? 30 : -30) * - pDynamicNearest->VectorFront() + - vector3(0, 5, 0); - Camera.LookAt = pDynamicNearest->GetPosition(); - Camera.RaLook(); // jednorazowe przestawienie kamery + else { + + Camera.Pos = + vehicle->GetPosition() + + vehicle->VectorFront() * vehicle->MoverParameters->ActiveCab * 50.0 + + vector3( -10.0, 1.6, 0.0 ); } + + Camera.LookAt = vehicle->GetPosition(); + Camera.RaLook(); // jednorazowe przestawienie kamery }; void TWorld::FollowView(bool wycisz) diff --git a/World.h b/World.h index cfdff5b5..d018041e 100644 --- a/World.h +++ b/World.h @@ -35,9 +35,9 @@ private: class TWorld { - void InOutKey(); + void InOutKey( bool const Near = true ); void FollowView(bool wycisz = true); - void DistantView(); + void DistantView( bool const Near = false ); public: bool Init(HWND NhWnd, HDC hDC);