mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 14:29:18 +02:00
reverted pantograph control changes, removed some of the type conversion warnings
This commit is contained in:
32
Camera.cpp
32
Camera.cpp
@@ -379,35 +379,9 @@ void TCamera::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector3 TCamera::GetDirection()
|
vector3 TCamera::GetDirection() {
|
||||||
{
|
|
||||||
matrix4x4 mat;
|
|
||||||
vector3 Vec;
|
|
||||||
Vec = vector3(0, 0, 1);
|
|
||||||
Vec.RotateY(Yaw);
|
|
||||||
|
|
||||||
return (Normalize(Vec));
|
return glm::normalize( glm::rotateY<float>( glm::vec3{ 0.f, 0.f, 1.f }, Yaw ) );
|
||||||
}
|
|
||||||
|
|
||||||
bool TCamera::SetMatrix()
|
|
||||||
{
|
|
||||||
glRotated( -Roll * 180.0 / M_PI, 0.0, 0.0, 1.0 ); // po wyłączeniu tego kręci się pojazd, a sceneria nie
|
|
||||||
glRotated( -Pitch * 180.0 / M_PI, 1.0, 0.0, 0.0 );
|
|
||||||
glRotated( -Yaw * 180.0 / M_PI, 0.0, 1.0, 0.0 ); // w zewnętrznym widoku: kierunek patrzenia
|
|
||||||
|
|
||||||
if( Type == tp_Follow )
|
|
||||||
{
|
|
||||||
gluLookAt(
|
|
||||||
Pos.x, Pos.y, Pos.z,
|
|
||||||
LookAt.x, LookAt.y, LookAt.z,
|
|
||||||
vUp.x, vUp.y, vUp.z); // Ra: pOffset is zero
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
glTranslated( -Pos.x, -Pos.y, -Pos.z ); // nie zmienia kierunku patrzenia
|
|
||||||
}
|
|
||||||
|
|
||||||
Global::SetCameraPosition(Pos); // było +pOffset
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
||||||
@@ -427,7 +401,6 @@ bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
|||||||
Matrix = glm::translate( Matrix, glm::dvec3{ -Pos } ); // nie zmienia kierunku patrzenia
|
Matrix = glm::translate( Matrix, glm::dvec3{ -Pos } ); // nie zmienia kierunku patrzenia
|
||||||
}
|
}
|
||||||
|
|
||||||
Global::SetCameraPosition( Pos ); // było +pOffset
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,4 +419,3 @@ void TCamera::Stop()
|
|||||||
Type = tp_Follow;
|
Type = tp_Follow;
|
||||||
Velocity = vector3(0, 0, 0);
|
Velocity = vector3(0, 0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
1
Camera.h
1
Camera.h
@@ -57,7 +57,6 @@ class TCamera
|
|||||||
void OnCommand( command_data const &Command );
|
void OnCommand( command_data const &Command );
|
||||||
void Update();
|
void Update();
|
||||||
vector3 GetDirection();
|
vector3 GetDirection();
|
||||||
bool SetMatrix();
|
|
||||||
bool SetMatrix(glm::dmat4 &Matrix);
|
bool SetMatrix(glm::dmat4 &Matrix);
|
||||||
void RaLook();
|
void RaLook();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
|
|||||||
fCurrentDistance = lastspeedpoint.fDist;
|
fCurrentDistance = lastspeedpoint.fDist;
|
||||||
// nie doliczac dlugosci gdy: miniety początek lub jazda do konca toru
|
// nie doliczac dlugosci gdy: miniety początek lub jazda do konca toru
|
||||||
fTrackLength = (
|
fTrackLength = (
|
||||||
( lastspeedpoint.iFlags & ( spElapsed | spEnd ) != 0 ) ?
|
( ( lastspeedpoint.iFlags & ( spElapsed | spEnd ) ) != 0 ) ?
|
||||||
0.0 :
|
0.0 :
|
||||||
pTrack->Length() );
|
pTrack->Length() );
|
||||||
}
|
}
|
||||||
@@ -1331,7 +1331,7 @@ void TController::TablePurger()
|
|||||||
for( std::size_t idx = 0; idx < sSpeedTable.size() - 1; ++idx ) {
|
for( std::size_t idx = 0; idx < sSpeedTable.size() - 1; ++idx ) {
|
||||||
auto const &speedpoint = sSpeedTable[ idx ];
|
auto const &speedpoint = sSpeedTable[ idx ];
|
||||||
if( ( 0 == ( speedpoint.iFlags & spEnabled ) )
|
if( ( 0 == ( speedpoint.iFlags & spEnabled ) )
|
||||||
|| ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) == ( spElapsed | spTrack | spCurve ) )
|
|| ( ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) ) == ( spElapsed | spTrack | spCurve ) )
|
||||||
&& ( speedpoint.fVelNext < 0.0 ) ) ) {
|
&& ( speedpoint.fVelNext < 0.0 ) ) ) {
|
||||||
// NOTE: we could break out early here, but running through entire thing gives us exact size needed for new table
|
// NOTE: we could break out early here, but running through entire thing gives us exact size needed for new table
|
||||||
++trimcount;
|
++trimcount;
|
||||||
@@ -1353,7 +1353,7 @@ void TController::TablePurger()
|
|||||||
}
|
}
|
||||||
auto const &speedpoint = sSpeedTable[ idx ];
|
auto const &speedpoint = sSpeedTable[ idx ];
|
||||||
if( ( 0 == ( speedpoint.iFlags & spEnabled ) )
|
if( ( 0 == ( speedpoint.iFlags & spEnabled ) )
|
||||||
|| ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) == ( spElapsed | spTrack | spCurve ) )
|
|| ( ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) ) == ( spElapsed | spTrack | spCurve ) )
|
||||||
&& ( speedpoint.fVelNext < 0.0 ) ) ) {
|
&& ( speedpoint.fVelNext < 0.0 ) ) ) {
|
||||||
// if the trimmed point happens to be currently active semaphor we need to invalidate their placements
|
// if the trimmed point happens to be currently active semaphor we need to invalidate their placements
|
||||||
if( idx == SemNextIndex ) {
|
if( idx == SemNextIndex ) {
|
||||||
|
|||||||
126
DynObj.cpp
126
DynObj.cpp
@@ -185,9 +185,10 @@ float TDynamicObject::GetEPP()
|
|||||||
// od strony sprzegu (coupler_nr) obiektu (start)
|
// od strony sprzegu (coupler_nr) obiektu (start)
|
||||||
TDynamicObject *temp = this;
|
TDynamicObject *temp = this;
|
||||||
int coupler_nr = 0;
|
int coupler_nr = 0;
|
||||||
float eq = 0, am = 0;
|
double eq = 0.0;
|
||||||
|
double am = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < 300; i++) // ograniczenie do 300 na wypadek zapętlenia składu
|
for (int i = 0; i < 300; ++i) // ograniczenie do 300 na wypadek zapętlenia składu
|
||||||
{
|
{
|
||||||
if (!temp)
|
if (!temp)
|
||||||
break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów
|
break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów
|
||||||
@@ -2732,26 +2733,20 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
if (Mechanik)
|
if (Mechanik)
|
||||||
{ // Ra 2F3F: do Driver.cpp to przenieść?
|
{ // Ra 2F3F: do Driver.cpp to przenieść?
|
||||||
MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG
|
MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG
|
||||||
if ((Mechanik->Primary()) &&
|
if( ( Mechanik->Primary() )
|
||||||
(MoverParameters->EngineType == ElectricInductionMotor)) // jesli glowny i z
|
&& ( MoverParameters->EngineType == ElectricInductionMotor ) ) {
|
||||||
// asynchronami, to
|
// jesli glowny i z asynchronami, to niech steruje hamulcem lacznie dla calego pociagu/ezt
|
||||||
// niech steruje
|
auto const kier = (DirectionGet() * MoverParameters->ActiveCab > 0);
|
||||||
{ // hamulcem lacznie dla calego pociagu/ezt
|
auto FED { 0.0 };
|
||||||
bool kier = (DirectionGet() * MoverParameters->ActiveCab > 0);
|
auto np { 0 };
|
||||||
float FED = 0;
|
auto masa { 0.0 };
|
||||||
int np = 0;
|
auto FrED { 0.0 };
|
||||||
float masa = 0;
|
auto masamax { 0.0 };
|
||||||
float FrED = 0;
|
auto FmaxPN { 0.0 };
|
||||||
float masamax = 0;
|
auto FfulED { 0.0 };
|
||||||
float FmaxPN = 0;
|
auto FmaxED { 0.0 };
|
||||||
float FfulED = 0;
|
auto Frj { 0.0 };
|
||||||
float FmaxED = 0;
|
auto osie { 0 };
|
||||||
float Fzad = 0;
|
|
||||||
float FzadED = 0;
|
|
||||||
float FzadPN = 0;
|
|
||||||
float Frj = 0;
|
|
||||||
float amax = 0;
|
|
||||||
float osie = 0;
|
|
||||||
// 1. ustal wymagana sile hamowania calego pociagu
|
// 1. ustal wymagana sile hamowania calego pociagu
|
||||||
// - opoznienie moze byc ustalane na podstawie charakterystyki
|
// - opoznienie moze byc ustalane na podstawie charakterystyki
|
||||||
// - opoznienie moze byc ustalane na podstawie mas i cisnien granicznych
|
// - opoznienie moze byc ustalane na podstawie mas i cisnien granicznych
|
||||||
@@ -2762,11 +2757,14 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
|
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
|
||||||
(kier ? p = p->NextC(4) : p = p->PrevC(4)))
|
(kier ? p = p->NextC(4) : p = p->PrevC(4)))
|
||||||
{
|
{
|
||||||
np++;
|
++np;
|
||||||
masamax += p->MoverParameters->MBPM +
|
masamax +=
|
||||||
(p->MoverParameters->MBPM > 1 ? 0 : p->MoverParameters->Mass) +
|
p->MoverParameters->MBPM
|
||||||
p->MoverParameters->Mred;
|
+ ( p->MoverParameters->MBPM > 1.0 ?
|
||||||
float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
|
0.0 :
|
||||||
|
p->MoverParameters->Mass )
|
||||||
|
+ p->MoverParameters->Mred;
|
||||||
|
auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
|
||||||
p->MoverParameters->BrakeCylSpring) *
|
p->MoverParameters->BrakeCylSpring) *
|
||||||
p->MoverParameters->BrakeCylMult[0] -
|
p->MoverParameters->BrakeCylMult[0] -
|
||||||
p->MoverParameters->BrakeSlckAdj) *
|
p->MoverParameters->BrakeSlckAdj) *
|
||||||
@@ -2780,18 +2778,19 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
0) ?
|
0) ?
|
||||||
p->MoverParameters->eimc[eimc_p_Fh] * 1000 :
|
p->MoverParameters->eimc[eimc_p_Fh] * 1000 :
|
||||||
0); // chwilowy max ED -> do rozdzialu sil
|
0); // chwilowy max ED -> do rozdzialu sil
|
||||||
FED -= Min0R(p->MoverParameters->eimv[eimv_Fmax], 0) *
|
FED -= std::min(p->MoverParameters->eimv[eimv_Fmax], 0.0) *
|
||||||
1000; // chwilowy max ED -> do rozdzialu sil
|
1000; // chwilowy max ED -> do rozdzialu sil
|
||||||
FfulED = Min0R(p->MoverParameters->eimv[eimv_Fful], 0) *
|
FfulED = std::min(p->MoverParameters->eimv[eimv_Fful], 0.0) *
|
||||||
1000; // chwilowy max ED -> do rozdzialu sil
|
1000; // chwilowy max ED -> do rozdzialu sil
|
||||||
FrED -= Min0R(p->MoverParameters->eimv[eimv_Fr], 0) *
|
FrED -= std::min(p->MoverParameters->eimv[eimv_Fr], 0.0) *
|
||||||
1000; // chwilowo realizowane ED -> do pneumatyki
|
1000; // chwilowo realizowane ED -> do pneumatyki
|
||||||
Frj += Max0R(p->MoverParameters->eimv[eimv_Fr], 0) *
|
Frj += std::max(p->MoverParameters->eimv[eimv_Fr], 0.0) *
|
||||||
1000;// chwilowo realizowany napęd -> do utrzymującego
|
1000;// chwilowo realizowany napęd -> do utrzymującego
|
||||||
masa += p->MoverParameters->TotalMass;
|
masa += p->MoverParameters->TotalMass;
|
||||||
osie += p->MoverParameters->NAxles;
|
osie += p->MoverParameters->NAxles;
|
||||||
}
|
}
|
||||||
amax = FmaxPN / masamax;
|
|
||||||
|
auto const amax = FmaxPN / masamax;
|
||||||
if ((MoverParameters->Vel < 0.5) && (MoverParameters->BrakePress > 0.2) ||
|
if ((MoverParameters->Vel < 0.5) && (MoverParameters->BrakePress > 0.2) ||
|
||||||
(dDoorMoveL > 0.001) || (dDoorMoveR > 0.001))
|
(dDoorMoveL > 0.001) || (dDoorMoveR > 0.001))
|
||||||
{
|
{
|
||||||
@@ -2808,24 +2807,28 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
MoverParameters->ShuntModeAllow = (MoverParameters->BrakePress > 0.2) &&
|
MoverParameters->ShuntModeAllow = (MoverParameters->BrakePress > 0.2) &&
|
||||||
(MoverParameters->LocalBrakeRatio() < 0.01);
|
(MoverParameters->LocalBrakeRatio() < 0.01);
|
||||||
}
|
}
|
||||||
Fzad = amax * MoverParameters->LocalBrakeRatio() * masa;
|
auto Fzad = amax * MoverParameters->LocalBrakeRatio() * masa;
|
||||||
if ((MoverParameters->ScndS) &&
|
if ((MoverParameters->ScndS) &&
|
||||||
(MoverParameters->Vel > MoverParameters->eimc[eimc_p_Vh1]) && (FmaxED > 0))
|
(MoverParameters->Vel > MoverParameters->eimc[eimc_p_Vh1]) && (FmaxED > 0))
|
||||||
{
|
{
|
||||||
Fzad = Min0R(MoverParameters->LocalBrakeRatio() * FmaxED, FfulED);
|
Fzad = std::min(MoverParameters->LocalBrakeRatio() * FmaxED, FfulED);
|
||||||
}
|
}
|
||||||
if (((MoverParameters->ShuntMode) && (Frj < 0.0015 * masa)) ||
|
if (((MoverParameters->ShuntMode) && (Frj < 0.0015 * masa)) ||
|
||||||
(MoverParameters->V * MoverParameters->DirAbsolute < -0.2))
|
(MoverParameters->V * MoverParameters->DirAbsolute < -0.2))
|
||||||
{
|
{
|
||||||
Fzad = Max0R(MoverParameters->StopBrakeDecc * masa, Fzad);
|
Fzad = std::max(MoverParameters->StopBrakeDecc * masa, Fzad);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MoverParameters->BrakeHandle == MHZ_EN57?MoverParameters->BrakeOpModeFlag & bom_MED:MoverParameters->EpFuse)
|
auto FzadED { 0.0 };
|
||||||
FzadED = Min0R(Fzad, FmaxED);
|
if( ( MoverParameters->EpFuse )
|
||||||
else
|
|| ( ( MoverParameters->BrakeHandle == MHZ_EN57 )
|
||||||
FzadED = 0;
|
&& ( MoverParameters->BrakeOpModeFlag & bom_MED ) ) ) {
|
||||||
FzadPN = Fzad - FrED;
|
FzadED = std::min( Fzad, FmaxED );
|
||||||
|
}
|
||||||
|
auto const FzadPN = Fzad - FrED;
|
||||||
//np = 0;
|
//np = 0;
|
||||||
|
// BUG: likely memory leak, allocation per inner loop, deleted only once outside
|
||||||
|
// TODO: sort this shit out
|
||||||
bool* PrzekrF = new bool[np];
|
bool* PrzekrF = new bool[np];
|
||||||
float nPrzekrF = 0;
|
float nPrzekrF = 0;
|
||||||
bool test = true;
|
bool test = true;
|
||||||
@@ -2849,7 +2852,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
|
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p;
|
||||||
p = (kier == true ? p->NextC(4) : p->PrevC(4)) )
|
p = (kier == true ? p->NextC(4) : p->PrevC(4)) )
|
||||||
{
|
{
|
||||||
float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
|
auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
|
||||||
p->MoverParameters->BrakeCylSpring) *
|
p->MoverParameters->BrakeCylSpring) *
|
||||||
p->MoverParameters->BrakeCylMult[0] -
|
p->MoverParameters->BrakeCylMult[0] -
|
||||||
p->MoverParameters->BrakeSlckAdj) *
|
p->MoverParameters->BrakeSlckAdj) *
|
||||||
@@ -2864,8 +2867,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
FzED[i] = (FmaxED > 0 ? FzadED / FmaxED : 0);
|
FzED[i] = (FmaxED > 0 ? FzadED / FmaxED : 0);
|
||||||
p->MoverParameters->AnPos =
|
p->MoverParameters->AnPos =
|
||||||
(MoverParameters->ScndS ? MoverParameters->LocalBrakeRatio() : FzED[i]);
|
(MoverParameters->ScndS ? MoverParameters->LocalBrakeRatio() : FzED[i]);
|
||||||
FzEP[i] = FzadPN * p->MoverParameters->NAxles / osie;
|
FzEP[ i ] = static_cast<float>( FzadPN * p->MoverParameters->NAxles ) / static_cast<float>( osie );
|
||||||
i++;
|
++i;
|
||||||
p->MoverParameters->ShuntMode = MoverParameters->ShuntMode;
|
p->MoverParameters->ShuntMode = MoverParameters->ShuntMode;
|
||||||
p->MoverParameters->ShuntModeAllow = MoverParameters->ShuntModeAllow;
|
p->MoverParameters->ShuntModeAllow = MoverParameters->ShuntModeAllow;
|
||||||
}
|
}
|
||||||
@@ -2896,7 +2899,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
FzEP[i] = 0;
|
FzEP[i] = 0;
|
||||||
przek += przek1;
|
przek += przek1;
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
przek = przek / (np - nPrzekrF);
|
przek = przek / (np - nPrzekrF);
|
||||||
@@ -2907,7 +2910,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
{
|
{
|
||||||
FzEP[i] += przek;
|
FzEP[i] += przek;
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -2938,31 +2941,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
p->MoverParameters->LocalBrakePosA = p->MoverParameters->LocalBrakePosA;
|
p->MoverParameters->LocalBrakePosA = p->MoverParameters->LocalBrakePosA;
|
||||||
else
|
else
|
||||||
p->MoverParameters->LocalBrakePosA = 0;
|
p->MoverParameters->LocalBrakePosA = 0;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
/* ////ALGORYTM 1 - KAZDEMU PO ROWNO
|
|
||||||
for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0); p;
|
|
||||||
(iDirection > 0 ? p = p->NextC(4) : p = p->PrevC(4)))
|
|
||||||
{
|
|
||||||
|
|
||||||
float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] -
|
|
||||||
p->MoverParameters->BrakeCylSpring) *
|
|
||||||
p->MoverParameters->BrakeCylMult[0] -
|
|
||||||
p->MoverParameters->BrakeSlckAdj) *
|
|
||||||
p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff;
|
|
||||||
float FmaxPoj = Nmax *
|
|
||||||
p->MoverParameters->Hamulec->GetFC(
|
|
||||||
Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA),
|
|
||||||
p->MoverParameters->Vel) *
|
|
||||||
1000; // sila hamowania pn
|
|
||||||
// Fpoj=(FED>0?-FzadED*p->MoverParameters->eimv[eimv_Fmax]*1000/FED:0);
|
|
||||||
// p->MoverParameters->AnPos=(p->MoverParameters->eimc[eimc_p_Fh]>1?0.001f*Fpoj/(p->MoverParameters->eimc[eimc_p_Fh]):0);
|
|
||||||
p->MoverParameters->AnPos = (FmaxED > 0 ? FzadED / FmaxED : 0);
|
|
||||||
// Fpoj = FzadPN * Min0R(p->MoverParameters->TotalMass / masa, 1);
|
|
||||||
// p->MoverParameters->LocalBrakePosA =
|
|
||||||
// (p->MoverParameters->SlippingWheels ? 0 : Min0R(Max0R(Fpoj / FmaxPoj, 0), 1));
|
|
||||||
p->MoverParameters->LocalBrakePosA = (p->MoverParameters->SlippingWheels ? 0 : FzadPN / FmaxPN);
|
|
||||||
} */
|
|
||||||
|
|
||||||
MED[0][0] = masa*0.001;
|
MED[0][0] = masa*0.001;
|
||||||
MED[0][1] = amax;
|
MED[0][1] = amax;
|
||||||
@@ -2979,14 +2959,6 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
delete[] FmaxEP;
|
delete[] FmaxEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// yB: cos (AI) tu jest nie kompatybilne z czyms (hamulce)
|
|
||||||
// if (Controller!=Humandriver)
|
|
||||||
// if (Mechanik->LastReactionTime>0.5)
|
|
||||||
// {
|
|
||||||
// MoverParameters->BrakeCtrlPos=0;
|
|
||||||
// Mechanik->LastReactionTime=0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
Mechanik->UpdateSituation(dt1); // przebłyski świadomości AI
|
Mechanik->UpdateSituation(dt1); // przebłyski świadomości AI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
Float3d.h
34
Float3d.h
@@ -241,7 +241,7 @@ public:
|
|||||||
e[i + 2] = f; // zamiana Y i Z
|
e[i + 2] = f; // zamiana Y i Z
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
inline float4x4 &Rotation(double angle, float3 axis);
|
inline float4x4 &Rotation(float const angle, float3 const &axis);
|
||||||
inline bool IdentityIs()
|
inline bool IdentityIs()
|
||||||
{ // sprawdzenie jednostkowości
|
{ // sprawdzenie jednostkowości
|
||||||
for (int i = 0; i < 16; ++i)
|
for (int i = 0; i < 16; ++i)
|
||||||
@@ -270,34 +270,30 @@ inline glm::vec3 operator*( const float4x4 &m, const glm::vec3 &v ) { // mnożen
|
|||||||
v.x * m[ 0 ][ 2 ] + v.y * m[ 1 ][ 2 ] + v.z * m[ 2 ][ 2 ] + m[ 3 ][ 2 ] );
|
v.x * m[ 0 ][ 2 ] + v.y * m[ 1 ][ 2 ] + v.z * m[ 2 ][ 2 ] + m[ 3 ][ 2 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float4x4 &float4x4::Rotation(double angle, float3 axis)
|
inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis)
|
||||||
{
|
{
|
||||||
double c = cos(angle);
|
auto const c = std::cos(Angle);
|
||||||
double s = sin(angle);
|
auto const s = std::sin(Angle);
|
||||||
// One minus c (short name for legibility of formulai)
|
// One minus c (short name for legibility of formulai)
|
||||||
double omc = (1 - c);
|
auto const omc = (1.f - c);
|
||||||
if (axis.Length() != 1.0f)
|
auto const axis = SafeNormalize(Axis);
|
||||||
axis = SafeNormalize(axis);
|
auto const xs = axis.x * s;
|
||||||
double x = axis.x;
|
auto const ys = axis.y * s;
|
||||||
double y = axis.y;
|
auto const zs = axis.z * s;
|
||||||
double z = axis.z;
|
auto const xyomc = axis.x * axis.y * omc;
|
||||||
double xs = x * s;
|
auto const xzomc = axis.x * axis.z * omc;
|
||||||
double ys = y * s;
|
auto const yzomc = axis.y * axis.z * omc;
|
||||||
double zs = z * s;
|
e[0] = axis.x * axis.x * omc + c;
|
||||||
double xyomc = x * y * omc;
|
|
||||||
double xzomc = x * z * omc;
|
|
||||||
double yzomc = y * z * omc;
|
|
||||||
e[0] = x * x * omc + c;
|
|
||||||
e[1] = xyomc + zs;
|
e[1] = xyomc + zs;
|
||||||
e[2] = xzomc - ys;
|
e[2] = xzomc - ys;
|
||||||
e[3] = 0;
|
e[3] = 0;
|
||||||
e[4] = xyomc - zs;
|
e[4] = xyomc - zs;
|
||||||
e[5] = y * y * omc + c;
|
e[5] = axis.y * axis.y * omc + c;
|
||||||
e[6] = yzomc + xs;
|
e[6] = yzomc + xs;
|
||||||
e[7] = 0;
|
e[7] = 0;
|
||||||
e[8] = xzomc + ys;
|
e[8] = xzomc + ys;
|
||||||
e[9] = yzomc - xs;
|
e[9] = yzomc - xs;
|
||||||
e[10] = z * z * omc + c;
|
e[10] = axis.z * axis.z * omc + c;
|
||||||
e[11] = 0;
|
e[11] = 0;
|
||||||
e[12] = 0;
|
e[12] = 0;
|
||||||
e[13] = 0;
|
e[13] = 0;
|
||||||
|
|||||||
18
Ground.cpp
18
Ground.cpp
@@ -1352,12 +1352,12 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
|||||||
>> vertex.normal.z
|
>> vertex.normal.z
|
||||||
>> vertex.texture.s
|
>> vertex.texture.s
|
||||||
>> vertex.texture.t;
|
>> vertex.texture.t;
|
||||||
vertex.position = glm::rotateZ( vertex.position, aRotate.z / 180 * M_PI );
|
vertex.position = glm::rotateZ( vertex.position, glm::radians( aRotate.z ) );
|
||||||
vertex.position = glm::rotateX( vertex.position, aRotate.x / 180 * M_PI );
|
vertex.position = glm::rotateX( vertex.position, glm::radians( aRotate.x ) );
|
||||||
vertex.position = glm::rotateY( vertex.position, aRotate.y / 180 * M_PI );
|
vertex.position = glm::rotateY( vertex.position, glm::radians( aRotate.y ) );
|
||||||
vertex.normal = glm::rotateZ( vertex.normal, static_cast<float>( aRotate.z / 180 * M_PI ) );
|
vertex.normal = glm::rotateZ( vertex.normal, glm::radians<float>( aRotate.z ) );
|
||||||
vertex.normal = glm::rotateX( vertex.normal, static_cast<float>( aRotate.x / 180 * M_PI ) );
|
vertex.normal = glm::rotateX( vertex.normal, glm::radians<float>( aRotate.x ) );
|
||||||
vertex.normal = glm::rotateY( vertex.normal, static_cast<float>( aRotate.y / 180 * M_PI ) );
|
vertex.normal = glm::rotateY( vertex.normal, glm::radians<float>( aRotate.y ) );
|
||||||
vertex.position += glm::dvec3{ pOrigin };
|
vertex.position += glm::dvec3{ pOrigin };
|
||||||
if( true == clamps ) { vertex.texture.s = clamp( vertex.texture.s, 0.001f, 0.999f ); }
|
if( true == clamps ) { vertex.texture.s = clamp( vertex.texture.s, 0.001f, 0.999f ); }
|
||||||
if( true == clampt ) { vertex.texture.t = clamp( vertex.texture.t, 0.001f, 0.999f ); }
|
if( true == clampt ) { vertex.texture.t = clamp( vertex.texture.t, 0.001f, 0.999f ); }
|
||||||
@@ -1486,9 +1486,9 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
|||||||
*parser
|
*parser
|
||||||
>> vertex.position.y
|
>> vertex.position.y
|
||||||
>> vertex.position.z;
|
>> vertex.position.z;
|
||||||
vertex.position = glm::rotateZ( vertex.position, aRotate.z / 180 * M_PI );
|
vertex.position = glm::rotateZ( vertex.position, glm::radians( aRotate.z ) );
|
||||||
vertex.position = glm::rotateX( vertex.position, aRotate.x / 180 * M_PI );
|
vertex.position = glm::rotateX( vertex.position, glm::radians( aRotate.x ) );
|
||||||
vertex.position = glm::rotateY( vertex.position, aRotate.y / 180 * M_PI );
|
vertex.position = glm::rotateY( vertex.position, glm::radians( aRotate.y ) );
|
||||||
|
|
||||||
vertex.position += glm::dvec3{ pOrigin };
|
vertex.position += glm::dvec3{ pOrigin };
|
||||||
// convert all data to gl_lines to allow data merge for matching nodes
|
// convert all data to gl_lines to allow data merge for matching nodes
|
||||||
|
|||||||
@@ -624,14 +624,14 @@ public:
|
|||||||
bool Signalling = false; /*Czy jest zalaczona sygnalizacja hamowania ostatniego wagonu*/
|
bool Signalling = false; /*Czy jest zalaczona sygnalizacja hamowania ostatniego wagonu*/
|
||||||
bool DoorSignalling = false; /*Czy jest zalaczona sygnalizacja blokady drzwi*/
|
bool DoorSignalling = false; /*Czy jest zalaczona sygnalizacja blokady drzwi*/
|
||||||
bool Radio = true; /*Czy jest zalaczony radiotelefon*/
|
bool Radio = true; /*Czy jest zalaczony radiotelefon*/
|
||||||
double NominalBatteryVoltage = 0.0; /*Winger - baterie w elektrykach*/
|
float NominalBatteryVoltage = 0.f; /*Winger - baterie w elektrykach*/
|
||||||
TDimension Dim; /*wymiary*/
|
TDimension Dim; /*wymiary*/
|
||||||
double Cx = 0.0; /*wsp. op. aerodyn.*/
|
double Cx = 0.0; /*wsp. op. aerodyn.*/
|
||||||
double Floor = 0.96; //poziom podłogi dla ładunków
|
float Floor = 0.96f; //poziom podłogi dla ładunków
|
||||||
double WheelDiameter = 1.0; /*srednica kol napednych*/
|
float WheelDiameter = 1.f; /*srednica kol napednych*/
|
||||||
double WheelDiameterL = 0.9; //Ra: srednica kol tocznych przednich
|
float WheelDiameterL = 0.9f; //Ra: srednica kol tocznych przednich
|
||||||
double WheelDiameterT = 0.9; //Ra: srednica kol tocznych tylnych
|
float WheelDiameterT = 0.9f; //Ra: srednica kol tocznych tylnych
|
||||||
double TrackW = 1.435; /*nominalna szerokosc toru [m]*/
|
float TrackW = 1.435f; /*nominalna szerokosc toru [m]*/
|
||||||
double AxleInertialMoment = 0.0; /*moment bezwladnosci zestawu kolowego*/
|
double AxleInertialMoment = 0.0; /*moment bezwladnosci zestawu kolowego*/
|
||||||
std::string AxleArangement; /*uklad osi np. Bo'Bo' albo 1'C*/
|
std::string AxleArangement; /*uklad osi np. Bo'Bo' albo 1'C*/
|
||||||
int NPoweredAxles = 0; /*ilosc osi napednych liczona z powyzszego*/
|
int NPoweredAxles = 0; /*ilosc osi napednych liczona z powyzszego*/
|
||||||
|
|||||||
@@ -8178,7 +8178,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
|||||||
else if (Command == "PantRear") /*Winger 160204, ABu 310105 i 030305*/
|
else if (Command == "PantRear") /*Winger 160204, ABu 310105 i 030305*/
|
||||||
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
|
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
|
||||||
if ((TrainType == dt_EZT))
|
if ((TrainType == dt_EZT))
|
||||||
{ /*'ezt'*/
|
{ //'ezt'
|
||||||
if ((CValue1 == 1))
|
if ((CValue1 == 1))
|
||||||
{
|
{
|
||||||
PantRearUp = true;
|
PantRearUp = true;
|
||||||
@@ -8191,9 +8191,9 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /*nie 'ezt'*/
|
{ //nie 'ezt'
|
||||||
if ((CValue1 == 1))
|
if ((CValue1 == 1))
|
||||||
/*if ostatni polaczony sprz. sterowania*/
|
//if ostatni polaczony sprz. sterowania
|
||||||
if ((TestFlag(Couplers[1].CouplingFlag, ctrain_controll) && (CValue2 == 1)) ||
|
if ((TestFlag(Couplers[1].CouplingFlag, ctrain_controll) && (CValue2 == 1)) ||
|
||||||
(TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1)))
|
(TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1667,6 +1667,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
pName = "";
|
pName = "";
|
||||||
if (iTexture > 0)
|
if (iTexture > 0)
|
||||||
{ // obsługa stałej tekstury
|
{ // obsługa stałej tekstury
|
||||||
|
if( iTexture < t->size() ) {
|
||||||
pTexture = t->at( iTexture );
|
pTexture = t->at( iTexture );
|
||||||
if( pTexture.find_last_of( "/\\" ) == std::string::npos )
|
if( pTexture.find_last_of( "/\\" ) == std::string::npos )
|
||||||
pTexture.insert( 0, Global::asCurrentTexturePath );
|
pTexture.insert( 0, Global::asCurrentTexturePath );
|
||||||
@@ -1678,6 +1679,11 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
0x20 :
|
0x20 :
|
||||||
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ErrorLog( "Bad model: reference to non-existent texture index in sub-model" + ( pName.empty() ? "" : " \"" + pName + "\"" ) );
|
||||||
|
TextureID = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TextureID = iTexture;
|
TextureID = iTexture;
|
||||||
|
|||||||
185
Train.cpp
185
Train.cpp
@@ -1361,14 +1361,6 @@ void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command
|
|||||||
|
|
||||||
void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
return (
|
|
||||||
Train->mvControlled->ActiveCab < 0 ?
|
|
||||||
pantographtogglerear( Train, Command ) :
|
|
||||||
pantographtogglefront( Train, Command ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||||
if( false == Train->mvControlled->PantFrontUp ) {
|
if( false == Train->mvControlled->PantFrontUp ) {
|
||||||
@@ -1377,22 +1369,6 @@ void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command )
|
|||||||
if( Train->mvControlled->PantFront( true ) ) {
|
if( Train->mvControlled->PantFront( true ) ) {
|
||||||
if( Train->mvControlled->PantFrontStart != 1 ) {
|
if( Train->mvControlled->PantFrontStart != 1 ) {
|
||||||
// visual feedback
|
// visual feedback
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
if( Train->ggPantRearButton.SubModel )
|
|
||||||
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedButton.SubModel )
|
|
||||||
Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
// pantograph control can have two-button setup
|
|
||||||
if( Train->ggPantRearButtonOff.SubModel )
|
|
||||||
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedDownButton.SubModel )
|
|
||||||
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
|
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1409,20 +1385,9 @@ void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// ...or turn off
|
// ...or turn off
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
|
|
||||||
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
|
||||||
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
|
||||||
// then another control has to be used (like pantographlowerall)
|
|
||||||
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
|
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
|
||||||
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
||||||
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
||||||
@@ -1431,30 +1396,11 @@ void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Train->mvControlled->PantFrontSP = false;
|
Train->mvControlled->PantFrontSP = false;
|
||||||
if( false == Train->mvControlled->PantFront( false ) ) {
|
if( false == Train->mvControlled->PantFront( false ) ) {
|
||||||
if( Train->mvControlled->PantFrontStart != 0 ) {
|
if( Train->mvControlled->PantFrontStart != 0 ) {
|
||||||
// visual feedback
|
// visual feedback
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
// in rear cab switch functions are swapped
|
|
||||||
if( Train->ggPantRearButton.SubModel )
|
|
||||||
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedButton.SubModel )
|
|
||||||
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// pantograph control can have two-button setup
|
|
||||||
if( Train->ggPantRearButtonOff.SubModel )
|
|
||||||
Train->ggPantRearButtonOff.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedDownButton.SubModel )
|
|
||||||
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// in front cab switches map normally
|
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1472,27 +1418,9 @@ void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
// impulse switches return automatically to neutral position
|
// impulse switches return automatically to neutral position
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
if( Train->ggPantRearButton.SubModel )
|
|
||||||
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedButton.SubModel )
|
|
||||||
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// also the switch off button, in cabs which have it
|
|
||||||
if( Train->ggPantRearButtonOff.SubModel )
|
|
||||||
Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
if( Train->ggPantSelectedDownButton.SubModel ) {
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
if( Train->ggPantFrontButton.SubModel )
|
||||||
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1510,18 +1438,9 @@ void TTrain::pantographtogglefront( TTrain *Train, command_data const &Command )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
return (
|
|
||||||
Train->mvControlled->ActiveCab < 0 ?
|
|
||||||
pantographtogglefront( Train, Command ) :
|
|
||||||
pantographtogglerear( Train, Command ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command ) {
|
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||||
if( false == Train->mvControlled->PantRearUp ) {
|
if( false == Train->mvControlled->PantRearUp ) {
|
||||||
@@ -1530,23 +1449,6 @@ void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command )
|
|||||||
if( Train->mvControlled->PantRear( true ) ) {
|
if( Train->mvControlled->PantRear( true ) ) {
|
||||||
if( Train->mvControlled->PantRearStart != 1 ) {
|
if( Train->mvControlled->PantRearStart != 1 ) {
|
||||||
// visual feedback
|
// visual feedback
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
// in rear cab switch functions are swapped
|
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
|
||||||
Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedButton.SubModel )
|
|
||||||
Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
// pantograph control can have two-button setup
|
|
||||||
if( Train->ggPantFrontButtonOff.SubModel )
|
|
||||||
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedDownButton.SubModel )
|
|
||||||
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( Train->ggPantRearButton.SubModel )
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1563,21 +1465,9 @@ void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// ...or turn off
|
// ...or turn off
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
// in rear cab switch functions are swapped
|
|
||||||
if( ( Train->ggPantFrontButtonOff.SubModel == nullptr )
|
|
||||||
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
|
||||||
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
|
||||||
// then another control has to be used (like pantographlowerall)
|
|
||||||
// TODO: we should have a way to define presense of cab controls without having to bind these to 3d submodels
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
|
if( ( Train->ggPantRearButtonOff.SubModel == nullptr )
|
||||||
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
&& ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) {
|
||||||
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
// with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it
|
||||||
@@ -1586,29 +1476,11 @@ void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Train->mvControlled->PantRearSP = false;
|
Train->mvControlled->PantRearSP = false;
|
||||||
if( false == Train->mvControlled->PantRear( false ) ) {
|
if( false == Train->mvControlled->PantRear( false ) ) {
|
||||||
if( Train->mvControlled->PantRearStart != 0 ) {
|
if( Train->mvControlled->PantRearStart != 0 ) {
|
||||||
// visual feedback
|
// visual feedback
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
// in rear cab switch functions are swapped
|
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
|
||||||
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedButton.SubModel )
|
|
||||||
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// pantograph control can have two-button setup
|
|
||||||
if( Train->ggPantFrontButtonOff.SubModel )
|
|
||||||
Train->ggPantFrontButtonOff.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedDownButton.SubModel )
|
|
||||||
Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( Train->ggPantRearButton.SubModel )
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1626,28 +1498,9 @@ void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
// impulse switches return automatically to neutral position
|
// impulse switches return automatically to neutral position
|
||||||
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
if( Train->mvOccupied->PantSwitchType == "impulse" ) {
|
||||||
if( Train->mvControlled->ActiveCab < 0 ) {
|
|
||||||
// in rear cab switch functions are swapped
|
|
||||||
if( Train->ggPantFrontButton.SubModel )
|
|
||||||
Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
if( Train->ggPantSelectedButton.SubModel )
|
|
||||||
Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
// also the switch off button, in cabs which have it
|
|
||||||
if( Train->ggPantFrontButtonOff.SubModel )
|
|
||||||
Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
if( Train->ggPantSelectedDownButton.SubModel ) {
|
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
|
||||||
Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( Train->ggPantRearButton.SubModel )
|
if( Train->ggPantRearButton.SubModel )
|
||||||
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
// NOTE: currently we animate the selectable pantograph control based on standard key presses
|
||||||
@@ -1665,7 +1518,6 @@ void TTrain::pantographtogglerear( TTrain *Train, command_data const &Command )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
@@ -6441,21 +6293,12 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
|| ( mvControlled->ConverterFlag ) ) {
|
|| ( mvControlled->ConverterFlag ) ) {
|
||||||
if( ggPantAllDownButton.GetValue() == 0.0 ) {
|
if( ggPantAllDownButton.GetValue() == 0.0 ) {
|
||||||
// the 'lower all' button overrides state of switches, while active itself
|
// the 'lower all' button overrides state of switches, while active itself
|
||||||
// when in rear cab we treat switches as reversed, i.e. front controls physical rear
|
|
||||||
auto const frontpantographswitch = (
|
|
||||||
mvControlled->ActiveCab < 0 ?
|
|
||||||
ggPantRearButton.GetValue() >= 1.0 :
|
|
||||||
ggPantFrontButton.GetValue() >= 1.0 );
|
|
||||||
auto const rearpantographswitch = (
|
|
||||||
mvControlled->ActiveCab < 0 ?
|
|
||||||
ggPantFrontButton.GetValue() >= 1.0 :
|
|
||||||
ggPantRearButton.GetValue() >= 1.0 );
|
|
||||||
if( ( false == mvControlled->PantFrontUp )
|
if( ( false == mvControlled->PantFrontUp )
|
||||||
&& ( frontpantographswitch ) ) {
|
&& ( ggPantFrontButton.GetValue() >= 1.0 ) ) {
|
||||||
mvControlled->PantFront( true );
|
mvControlled->PantFront( true );
|
||||||
}
|
}
|
||||||
if( ( false == mvControlled->PantRearUp )
|
if( ( false == mvControlled->PantRearUp )
|
||||||
&& ( rearpantographswitch ) ) {
|
&& ( ggPantRearButton.GetValue() >= 1.0 ) ) {
|
||||||
mvControlled->PantRear( true );
|
mvControlled->PantRear( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7326,50 +7169,42 @@ void TTrain::set_cab_controls() {
|
|||||||
}
|
}
|
||||||
// pantographs
|
// pantographs
|
||||||
if( mvOccupied->PantSwitchType != "impulse" ) {
|
if( mvOccupied->PantSwitchType != "impulse" ) {
|
||||||
auto const pantograph = (
|
|
||||||
mvControlled->ActiveCab < 0 ?
|
|
||||||
mvControlled->PantRearUp :
|
|
||||||
mvControlled->PantFrontUp );
|
|
||||||
ggPantFrontButton.PutValue(
|
ggPantFrontButton.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantFrontUp ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantFrontButtonOff.PutValue(
|
ggPantFrontButtonOff.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantFrontUp ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
ggPantSelectedButton.PutValue(
|
ggPantSelectedButton.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantFrontUp ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantSelectedDownButton.PutValue(
|
ggPantSelectedDownButton.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantFrontUp ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
}
|
}
|
||||||
if( mvOccupied->PantSwitchType != "impulse" ) {
|
if( mvOccupied->PantSwitchType != "impulse" ) {
|
||||||
auto const pantograph = (
|
|
||||||
mvControlled->ActiveCab < 0 ?
|
|
||||||
mvControlled->PantFrontUp :
|
|
||||||
mvControlled->PantRearUp );
|
|
||||||
ggPantRearButton.PutValue(
|
ggPantRearButton.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantRearUp ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantRearButtonOff.PutValue(
|
ggPantRearButtonOff.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantRearUp ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
// NOTE: currently we animate the selectable pantograph control for both pantographs
|
||||||
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
// TODO: implement actual selection control, and refactor handling this control setup in a separate method
|
||||||
ggPantSelectedButton.PutValue(
|
ggPantSelectedButton.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantRearUp ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 ) );
|
0.0 ) );
|
||||||
ggPantSelectedDownButton.PutValue(
|
ggPantSelectedDownButton.PutValue(
|
||||||
( pantograph ?
|
( mvControlled->PantRearUp ?
|
||||||
0.0 :
|
0.0 :
|
||||||
1.0 ) );
|
1.0 ) );
|
||||||
}
|
}
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -155,9 +155,7 @@ class TTrain
|
|||||||
static void OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_pantographcompressoractivate( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographcompressoractivate( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command );
|
||||||
static void pantographtogglefront( TTrain *Train, command_data const &Command );
|
|
||||||
static void OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command );
|
||||||
static void pantographtogglerear( TTrain *Train, command_data const &Command );
|
|
||||||
static void OnCommand_pantographlowerall( TTrain *Train, command_data const &Command );
|
static void OnCommand_pantographlowerall( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command );
|
static void OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_convertertoggle( TTrain *Train, command_data const &Command );
|
static void OnCommand_convertertoggle( TTrain *Train, command_data const &Command );
|
||||||
|
|||||||
6
moon.cpp
6
moon.cpp
@@ -36,9 +36,9 @@ void
|
|||||||
cMoon::update() {
|
cMoon::update() {
|
||||||
|
|
||||||
move();
|
move();
|
||||||
glm::vec3 position( 0.0f, 0.0f, -2000.0f * Global::fDistanceFactor );
|
glm::vec3 position( 0.f, 0.f, -2000.f * Global::fDistanceFactor );
|
||||||
position = glm::rotateX( position, (float)( m_body.elevref * ( M_PI / 180.0 ) ) );
|
position = glm::rotateX( position, glm::radians<float>( m_body.elevref ) );
|
||||||
position = glm::rotateY( position, (float)( -m_body.hrang * ( M_PI / 180.0 ) ) );
|
position = glm::rotateY( position, glm::radians<float>( -m_body.hrang ) );
|
||||||
|
|
||||||
m_position = position;
|
m_position = position;
|
||||||
}
|
}
|
||||||
|
|||||||
6
sun.cpp
6
sun.cpp
@@ -33,9 +33,9 @@ void
|
|||||||
cSun::update() {
|
cSun::update() {
|
||||||
|
|
||||||
move();
|
move();
|
||||||
glm::vec3 position( 0.0f, 0.0f, -2000.0f * Global::fDistanceFactor );
|
glm::vec3 position( 0.f, 0.f, -2000.f * Global::fDistanceFactor );
|
||||||
position = glm::rotateX( position, (float)( m_body.elevref * ( M_PI / 180.0 ) ) );
|
position = glm::rotateX( position, glm::radians<float>( m_body.elevref ) );
|
||||||
position = glm::rotateY( position, (float)( -m_body.hrang * ( M_PI / 180.0 ) ) );
|
position = glm::rotateY( position, glm::radians<float>( -m_body.hrang ) );
|
||||||
|
|
||||||
m_position = position;
|
m_position = position;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ static std::unordered_map<std::string, std::string> m_cabcontrols = {
|
|||||||
{ "converteroff_sw:", "converter" },
|
{ "converteroff_sw:", "converter" },
|
||||||
{ "main_sw:", "line breaker" },
|
{ "main_sw:", "line breaker" },
|
||||||
{ "radio_sw:", "radio" },
|
{ "radio_sw:", "radio" },
|
||||||
{ "pantfront_sw:", "front pantograph" },
|
{ "pantfront_sw:", "pantograph A" },
|
||||||
{ "pantrear_sw:", "rear pantograph" },
|
{ "pantrear_sw:", "pantograph B" },
|
||||||
{ "pantfrontoff_sw:", "front pantograph" },
|
{ "pantfrontoff_sw:", "pantograph A" },
|
||||||
{ "pantrearoff_sw:", "rear pantograph" },
|
{ "pantrearoff_sw:", "pantograph B" },
|
||||||
{ "pantalloff_sw:", "all pantographs" },
|
{ "pantalloff_sw:", "all pantographs" },
|
||||||
{ "pantselected_sw:", "selected pantograph" },
|
{ "pantselected_sw:", "selected pantograph" },
|
||||||
{ "pantselectedoff_sw:", "selected pantograph" },
|
{ "pantselectedoff_sw:", "selected pantograph" },
|
||||||
|
|||||||
Reference in New Issue
Block a user