mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 00:29:19 +02:00
work
This commit is contained in:
18
DynObj.cpp
18
DynObj.cpp
@@ -1087,9 +1087,9 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
|||||||
}
|
}
|
||||||
// ABu 29.01.05 koniec przeklejenia *************************************
|
// ABu 29.01.05 koniec przeklejenia *************************************
|
||||||
|
|
||||||
TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, TDynamicObject *MyPointer, int &CouplNr)
|
TDynamicObject * TDynamicObject::ABuFindNearestObject(glm::vec3 pos, TTrack *Track, TDynamicObject *MyPointer, int &CouplNr)
|
||||||
{
|
{
|
||||||
// zwraca wskaznik do obiektu znajdujacego sie na torze (Track), którego sprzęg jest najblizszy kamerze
|
// zwraca wskaznik do obiektu znajdujacego sie na torze (Track), którego sprzęg jest najblizszy punktowi
|
||||||
// służy np. do łączenia i rozpinania sprzęgów
|
// służy np. do łączenia i rozpinania sprzęgów
|
||||||
// WE: Track - tor, na ktorym odbywa sie poszukiwanie
|
// WE: Track - tor, na ktorym odbywa sie poszukiwanie
|
||||||
// MyPointer - wskaznik do obiektu szukajacego
|
// MyPointer - wskaznik do obiektu szukajacego
|
||||||
@@ -1100,19 +1100,19 @@ TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, TDynamicObj
|
|||||||
|
|
||||||
if( CouplNr == -2 ) {
|
if( CouplNr == -2 ) {
|
||||||
// wektor [kamera-obiekt] - poszukiwanie obiektu
|
// wektor [kamera-obiekt] - poszukiwanie obiektu
|
||||||
if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vPosition ) < 100.0 ) {
|
if( Math3D::LengthSquared3( pos - dynamic->vPosition ) < 100.0 ) {
|
||||||
// 10 metrów
|
// 10 metrów
|
||||||
return dynamic;
|
return dynamic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// jeśli (CouplNr) inne niz -2, szukamy sprzęgu
|
// jeśli (CouplNr) inne niz -2, szukamy sprzęgu
|
||||||
if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vCoulpler[ 0 ] ) < 25.0 ) {
|
if( Math3D::LengthSquared3( pos - dynamic->vCoulpler[ 0 ] ) < 25.0 ) {
|
||||||
// 5 metrów
|
// 5 metrów
|
||||||
CouplNr = 0;
|
CouplNr = 0;
|
||||||
return dynamic;
|
return dynamic;
|
||||||
}
|
}
|
||||||
if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vCoulpler[ 1 ] ) < 25.0 ) {
|
if( Math3D::LengthSquared3( pos - dynamic->vCoulpler[ 1 ] ) < 25.0 ) {
|
||||||
// 5 metrów
|
// 5 metrów
|
||||||
CouplNr = 1;
|
CouplNr = 1;
|
||||||
return dynamic;
|
return dynamic;
|
||||||
@@ -1123,13 +1123,13 @@ TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, TDynamicObj
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDynamicObject * TDynamicObject::ABuScanNearestObject(TTrack *Track, double ScanDir, double ScanDist, int &CouplNr)
|
TDynamicObject * TDynamicObject::ABuScanNearestObject(glm::vec3 pos, TTrack *Track, double ScanDir, double ScanDist, int &CouplNr)
|
||||||
{ // skanowanie toru w poszukiwaniu obiektu najblizszego kamerze
|
{ // skanowanie toru w poszukiwaniu obiektu najblizszego punktowi
|
||||||
if (ABuGetDirection() < 0)
|
if (ABuGetDirection() < 0)
|
||||||
ScanDir = -ScanDir;
|
ScanDir = -ScanDir;
|
||||||
TDynamicObject *FoundedObj;
|
TDynamicObject *FoundedObj;
|
||||||
FoundedObj =
|
FoundedObj =
|
||||||
ABuFindNearestObject(Track, this, CouplNr); // zwraca numer sprzęgu znalezionego pojazdu
|
ABuFindNearestObject(pos, Track, this, CouplNr); // zwraca numer sprzęgu znalezionego pojazdu
|
||||||
if (FoundedObj == NULL)
|
if (FoundedObj == NULL)
|
||||||
{
|
{
|
||||||
double ActDist; // Przeskanowana odleglosc.
|
double ActDist; // Przeskanowana odleglosc.
|
||||||
@@ -1165,7 +1165,7 @@ TDynamicObject * TDynamicObject::ABuScanNearestObject(TTrack *Track, double Scan
|
|||||||
if (Track != NULL)
|
if (Track != NULL)
|
||||||
{ // jesli jest kolejny odcinek toru
|
{ // jesli jest kolejny odcinek toru
|
||||||
CurrDist = Track->Length();
|
CurrDist = Track->Length();
|
||||||
FoundedObj = ABuFindNearestObject(Track, this, CouplNr);
|
FoundedObj = ABuFindNearestObject(pos, Track, this, CouplNr);
|
||||||
if (FoundedObj != NULL)
|
if (FoundedObj != NULL)
|
||||||
ActDist = ScanDist;
|
ActDist = ScanDist;
|
||||||
}
|
}
|
||||||
|
|||||||
4
DynObj.h
4
DynObj.h
@@ -176,7 +176,7 @@ private: // położenie pojazdu w świecie oraz parametry ruchu
|
|||||||
int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca eventy)
|
int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca eventy)
|
||||||
float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia
|
float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia
|
||||||
Math3D::vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!!
|
Math3D::vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!!
|
||||||
TDynamicObject * ABuFindNearestObject( TTrack *Track, TDynamicObject *MyPointer, int &CouplNr );
|
TDynamicObject * ABuFindNearestObject(glm::vec3 pos, TTrack *Track, TDynamicObject *MyPointer, int &CouplNr );
|
||||||
|
|
||||||
glm::dvec3 m_future_movement;
|
glm::dvec3 m_future_movement;
|
||||||
glm::dvec3 m_future_wheels_angle;
|
glm::dvec3 m_future_wheels_angle;
|
||||||
@@ -498,7 +498,7 @@ private:
|
|||||||
// float EmR;
|
// float EmR;
|
||||||
// vector3 smokeoffset;
|
// vector3 smokeoffset;
|
||||||
|
|
||||||
TDynamicObject * ABuScanNearestObject(TTrack *Track, double ScanDir, double ScanDist,
|
TDynamicObject * ABuScanNearestObject(glm::vec3 pos, TTrack *Track, double ScanDir, double ScanDist,
|
||||||
int &CouplNr);
|
int &CouplNr);
|
||||||
TDynamicObject * GetFirstDynamic(int cpl_type, int cf = 1);
|
TDynamicObject * GetFirstDynamic(int cpl_type, int cf = 1);
|
||||||
void ABuSetModelShake( Math3D::vector3 mShake);
|
void ABuSetModelShake( Math3D::vector3 mShake);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Timer {
|
|||||||
|
|
||||||
subsystem_stopwatches subsystem;
|
subsystem_stopwatches subsystem;
|
||||||
|
|
||||||
double DeltaTime, DeltaRenderTime;
|
double DeltaTime = 0.0, DeltaRenderTime = 0.0;
|
||||||
double fFPS{ 0.0f };
|
double fFPS{ 0.0f };
|
||||||
double fLastTime{ 0.0f };
|
double fLastTime{ 0.0f };
|
||||||
DWORD dwFrames{ 0 };
|
DWORD dwFrames{ 0 };
|
||||||
@@ -48,7 +48,7 @@ void set_delta_override(double t)
|
|||||||
void ResetTimers()
|
void ResetTimers()
|
||||||
{
|
{
|
||||||
UpdateTimers( Global.iPause != 0 );
|
UpdateTimers( Global.iPause != 0 );
|
||||||
DeltaTime = 0.1;
|
DeltaTime = 0.0;
|
||||||
DeltaRenderTime = 0.0;
|
DeltaRenderTime = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
45
Train.cpp
45
Train.cpp
@@ -719,15 +719,14 @@ void TTrain::set_paired_open_motor_connectors_button( bool const State ) {
|
|||||||
|
|
||||||
// locates nearest vehicle belonging to the consist
|
// locates nearest vehicle belonging to the consist
|
||||||
TDynamicObject *
|
TDynamicObject *
|
||||||
TTrain::find_nearest_consist_vehicle() const {
|
TTrain::find_nearest_consist_vehicle(bool freefly, glm::vec3 pos) const {
|
||||||
|
if (!freefly)
|
||||||
if( false == FreeFlyModeFlag ) {
|
|
||||||
return DynamicObject;
|
return DynamicObject;
|
||||||
}
|
|
||||||
auto coupler { -2 }; // scan for vehicle, not any specific coupler
|
auto coupler { -2 }; // scan for vehicle, not any specific coupler
|
||||||
auto *vehicle{ DynamicObject->ABuScanNearestObject( DynamicObject->GetTrack(), 1, 1500, coupler ) };
|
auto *vehicle{ DynamicObject->ABuScanNearestObject( pos, DynamicObject->GetTrack(), 1, 1500, coupler ) };
|
||||||
if( vehicle == nullptr )
|
if( vehicle == nullptr )
|
||||||
vehicle = DynamicObject->ABuScanNearestObject( DynamicObject->GetTrack(), -1, 1500, coupler );
|
vehicle = DynamicObject->ABuScanNearestObject( pos, DynamicObject->GetTrack(), -1, 1500, coupler );
|
||||||
// TBD, TODO: perform owner test for the located vehicle
|
// TBD, TODO: perform owner test for the located vehicle
|
||||||
return vehicle;
|
return vehicle;
|
||||||
}
|
}
|
||||||
@@ -1029,7 +1028,7 @@ void TTrain::OnCommand_independentbrakebailoff( TTrain *Train, command_data cons
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// car brake handling, while in walk mode
|
// car brake handling, while in walk mode
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle != nullptr ) {
|
if( vehicle != nullptr ) {
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// press or hold
|
// press or hold
|
||||||
@@ -1212,7 +1211,7 @@ void TTrain::OnCommand_trainbrakeoperationtoggle( TTrain *Train, command_data co
|
|||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
vehicle->MoverParameters->Hamulec->SetBrakeStatus( vehicle->MoverParameters->Hamulec->GetBrakeStatus() ^ b_dmg );
|
vehicle->MoverParameters->Hamulec->SetBrakeStatus( vehicle->MoverParameters->Hamulec->GetBrakeStatus() ^ b_dmg );
|
||||||
@@ -1223,7 +1222,7 @@ void TTrain::OnCommand_manualbrakeincrease( TTrain *Train, command_data const &C
|
|||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
if( ( vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake )
|
if( ( vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake )
|
||||||
@@ -1238,7 +1237,7 @@ void TTrain::OnCommand_manualbrakedecrease( TTrain *Train, command_data const &C
|
|||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
if( ( vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake )
|
if( ( vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake )
|
||||||
@@ -1398,7 +1397,7 @@ void TTrain::OnCommand_brakeactingspeedincrease( TTrain *Train, command_data con
|
|||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
if( ( vehicle->MoverParameters->BrakeDelayFlag & bdelay_M ) != 0 ) {
|
if( ( vehicle->MoverParameters->BrakeDelayFlag & bdelay_M ) != 0 ) {
|
||||||
@@ -1418,7 +1417,7 @@ void TTrain::OnCommand_brakeactingspeeddecrease( TTrain *Train, command_data con
|
|||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
if( vehicle->MoverParameters->BrakeDelayFlag == bdelay_G ) {
|
if( vehicle->MoverParameters->BrakeDelayFlag == bdelay_G ) {
|
||||||
@@ -1438,7 +1437,7 @@ void TTrain::OnCommand_brakeactingspeedsetcargo( TTrain *Train, command_data con
|
|||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
Train->set_train_brake_speed( vehicle, bdelay_G );
|
Train->set_train_brake_speed( vehicle, bdelay_G );
|
||||||
@@ -1449,7 +1448,7 @@ void TTrain::OnCommand_brakeactingspeedsetpassenger( TTrain *Train, command_data
|
|||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
Train->set_train_brake_speed( vehicle, bdelay_P );
|
Train->set_train_brake_speed( vehicle, bdelay_P );
|
||||||
@@ -1460,7 +1459,7 @@ void TTrain::OnCommand_brakeactingspeedsetrapid( TTrain *Train, command_data con
|
|||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto *vehicle{ Train->find_nearest_consist_vehicle() };
|
auto *vehicle{ Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
Train->set_train_brake_speed( vehicle, bdelay_R );
|
Train->set_train_brake_speed( vehicle, bdelay_R );
|
||||||
@@ -1471,7 +1470,7 @@ void TTrain::OnCommand_brakeloadcompensationincrease( TTrain *Train, command_dat
|
|||||||
|
|
||||||
if( ( true == FreeFlyModeFlag )
|
if( ( true == FreeFlyModeFlag )
|
||||||
&& ( Command.action == GLFW_PRESS ) ) {
|
&& ( Command.action == GLFW_PRESS ) ) {
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle != nullptr ) {
|
if( vehicle != nullptr ) {
|
||||||
vehicle->MoverParameters->IncBrakeMult();
|
vehicle->MoverParameters->IncBrakeMult();
|
||||||
}
|
}
|
||||||
@@ -1482,7 +1481,7 @@ void TTrain::OnCommand_brakeloadcompensationdecrease( TTrain *Train, command_dat
|
|||||||
|
|
||||||
if( ( true == FreeFlyModeFlag )
|
if( ( true == FreeFlyModeFlag )
|
||||||
&& ( Command.action == GLFW_PRESS ) ) {
|
&& ( Command.action == GLFW_PRESS ) ) {
|
||||||
auto *vehicle { Train->find_nearest_consist_vehicle() };
|
auto *vehicle { Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
|
||||||
if( vehicle != nullptr ) {
|
if( vehicle != nullptr ) {
|
||||||
vehicle->MoverParameters->DecBrakeMult();
|
vehicle->MoverParameters->DecBrakeMult();
|
||||||
}
|
}
|
||||||
@@ -4485,13 +4484,13 @@ void TTrain::OnCommand_doorcloseall( TTrain *Train, command_data const &Command
|
|||||||
|
|
||||||
void TTrain::OnCommand_carcouplingincrease( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_carcouplingincrease( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( ( true == FreeFlyModeFlag )
|
if( ( true == Command.freefly )
|
||||||
&& ( Command.action == GLFW_PRESS ) ) {
|
&& ( Command.action == GLFW_PRESS ) ) {
|
||||||
// tryb freefly, press only
|
// tryb freefly, press only
|
||||||
auto coupler { -1 };
|
auto coupler { -1 };
|
||||||
auto *vehicle { Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), 1, 1500, coupler ) };
|
auto *vehicle { Train->DynamicObject->ABuScanNearestObject( Command.location, Train->DynamicObject->GetTrack(), 1, 1500, coupler ) };
|
||||||
if( vehicle == nullptr )
|
if( vehicle == nullptr )
|
||||||
vehicle = Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), -1, 1500, coupler );
|
vehicle = Train->DynamicObject->ABuScanNearestObject( Command.location, Train->DynamicObject->GetTrack(), -1, 1500, coupler );
|
||||||
|
|
||||||
if( ( coupler != -1 )
|
if( ( coupler != -1 )
|
||||||
&& ( vehicle != nullptr ) ) {
|
&& ( vehicle != nullptr ) ) {
|
||||||
@@ -4507,13 +4506,13 @@ void TTrain::OnCommand_carcouplingincrease( TTrain *Train, command_data const &C
|
|||||||
|
|
||||||
void TTrain::OnCommand_carcouplingdisconnect( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_carcouplingdisconnect( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( ( true == FreeFlyModeFlag )
|
if( ( true == Command.freefly )
|
||||||
&& ( Command.action == GLFW_PRESS ) ) {
|
&& ( Command.action == GLFW_PRESS ) ) {
|
||||||
// tryb freefly, press only
|
// tryb freefly, press only
|
||||||
auto coupler { -1 };
|
auto coupler { -1 };
|
||||||
auto *vehicle { Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), 1, 1500, coupler ) };
|
auto *vehicle { Train->DynamicObject->ABuScanNearestObject( Command.location, Train->DynamicObject->GetTrack(), 1, 1500, coupler ) };
|
||||||
if( vehicle == nullptr )
|
if( vehicle == nullptr )
|
||||||
vehicle = Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), -1, 1500, coupler );
|
vehicle = Train->DynamicObject->ABuScanNearestObject( Command.location, Train->DynamicObject->GetTrack(), -1, 1500, coupler );
|
||||||
|
|
||||||
if( ( coupler != -1 )
|
if( ( coupler != -1 )
|
||||||
&& ( vehicle != nullptr ) ) {
|
&& ( vehicle != nullptr ) ) {
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -136,7 +136,7 @@ class TTrain
|
|||||||
// helper, returns true for EMU with oerlikon brake
|
// helper, returns true for EMU with oerlikon brake
|
||||||
bool is_eztoer() const;
|
bool is_eztoer() const;
|
||||||
// locates nearest vehicle belonging to the consist
|
// locates nearest vehicle belonging to the consist
|
||||||
TDynamicObject *find_nearest_consist_vehicle() const;
|
TDynamicObject *find_nearest_consist_vehicle(bool freefly, glm::vec3 pos) const;
|
||||||
// mover master controller to specified position
|
// mover master controller to specified position
|
||||||
void set_master_controller( double const Position );
|
void set_master_controller( double const Position );
|
||||||
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
// moves train brake lever to specified position, potentially emits switch sound if conditions are met
|
||||||
|
|||||||
@@ -138,9 +138,6 @@ eu07_application::init( int Argc, char *Argv[] ) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Global.random_seed = std::time(nullptr);
|
|
||||||
//Global.random_engine.seed(Global.random_seed);
|
|
||||||
|
|
||||||
if (!init_network())
|
if (!init_network())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ commanddescription_sequence Commands_descriptions = {
|
|||||||
{ "vehiclemoveforwards", command_target::vehicle, command_mode::oneoff },
|
{ "vehiclemoveforwards", command_target::vehicle, command_mode::oneoff },
|
||||||
{ "vehiclemovebackwards", command_target::vehicle, command_mode::oneoff },
|
{ "vehiclemovebackwards", command_target::vehicle, command_mode::oneoff },
|
||||||
{ "vehicleboost", command_target::vehicle, command_mode::oneoff },
|
{ "vehicleboost", command_target::vehicle, command_mode::oneoff },
|
||||||
|
{ "debugtoggle", command_target::simulation, command_mode::oneoff },
|
||||||
};
|
};
|
||||||
|
|
||||||
} // simulation
|
} // simulation
|
||||||
@@ -238,7 +239,7 @@ void command_queue::update()
|
|||||||
double delta = Timer::GetDeltaTime();
|
double delta = Timer::GetDeltaTime();
|
||||||
for (auto c : m_active_continuous)
|
for (auto c : m_active_continuous)
|
||||||
{
|
{
|
||||||
command_data data({c.first, GLFW_REPEAT, 0.0, 0.0, delta});
|
command_data data({c.first, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
|
||||||
auto lookup = m_commands.emplace( c.second, commanddata_sequence() );
|
auto lookup = m_commands.emplace( c.second, commanddata_sequence() );
|
||||||
// recipient stack was either located or created, so we can add to it quite safely
|
// recipient stack was either located or created, so we can add to it quite safely
|
||||||
lookup.first->second.emplace_back( data );
|
lookup.first->second.emplace_back( data );
|
||||||
@@ -365,7 +366,7 @@ command_relay::post( user_command const Command, double const Param1, double con
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t combined_recipient = static_cast<uint32_t>( command.target ) | Recipient;
|
uint32_t combined_recipient = static_cast<uint32_t>( command.target ) | Recipient;
|
||||||
command_data commanddata({Command, Action, Param1, Param2, Timer::GetDeltaTime() });
|
command_data commanddata({Command, Action, Param1, Param2, Timer::GetDeltaTime(), FreeFlyModeFlag, Global.pCamera.Pos });
|
||||||
|
|
||||||
simulation::Commands->push(commanddata, combined_recipient);
|
simulation::Commands->push(commanddata, combined_recipient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ enum class user_command {
|
|||||||
vehiclemoveforwards,
|
vehiclemoveforwards,
|
||||||
vehiclemovebackwards,
|
vehiclemovebackwards,
|
||||||
vehicleboost,
|
vehicleboost,
|
||||||
|
debugtoggle,
|
||||||
|
|
||||||
none = -1
|
none = -1
|
||||||
};
|
};
|
||||||
@@ -257,6 +258,9 @@ struct command_data {
|
|||||||
double param1;
|
double param1;
|
||||||
double param2;
|
double param2;
|
||||||
double time_delta;
|
double time_delta;
|
||||||
|
|
||||||
|
bool freefly;
|
||||||
|
glm::vec3 location;
|
||||||
};
|
};
|
||||||
|
|
||||||
// command_queues: collects and holds commands from input sources, for processing by their intended recipients
|
// command_queues: collects and holds commands from input sources, for processing by their intended recipients
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ driverkeyboard_input::default_bindings() {
|
|||||||
{ user_command::vehiclemoveforwards, GLFW_KEY_LEFT_BRACKET | keymodifier::control },
|
{ user_command::vehiclemoveforwards, GLFW_KEY_LEFT_BRACKET | keymodifier::control },
|
||||||
{ user_command::vehiclemovebackwards, GLFW_KEY_RIGHT_BRACKET | keymodifier::control },
|
{ user_command::vehiclemovebackwards, GLFW_KEY_RIGHT_BRACKET | keymodifier::control },
|
||||||
{ user_command::vehicleboost, GLFW_KEY_TAB | keymodifier::control },
|
{ user_command::vehicleboost, GLFW_KEY_TAB | keymodifier::control },
|
||||||
|
{ user_command::debugtoggle, GLFW_KEY_F12 | keymodifier::control | keymodifier::shift },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,13 +107,6 @@ driver_mode::update() {
|
|||||||
|
|
||||||
if (deltatime != 0.0)
|
if (deltatime != 0.0)
|
||||||
{
|
{
|
||||||
static uint32_t fcount = 0;
|
|
||||||
fcount ++;
|
|
||||||
if (fcount > 500) {
|
|
||||||
fcount = 0;
|
|
||||||
WriteLog(std::to_string(Random(1.0, 100.0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// jak pauza, to nie ma po co tego przeliczać
|
// jak pauza, to nie ma po co tego przeliczać
|
||||||
simulation::Time.update( deltatime );
|
simulation::Time.update( deltatime );
|
||||||
|
|
||||||
@@ -785,15 +778,6 @@ driver_mode::OnKeyDown(int cKey) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GLFW_KEY_F12: {
|
|
||||||
// quick debug mode toggle
|
|
||||||
if( Global.ctrlState
|
|
||||||
&& Global.shiftState ) {
|
|
||||||
DebugModeFlag = !DebugModeFlag;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ void::network::command_message::serialize(std::ostream &stream)
|
|||||||
sn_utils::ls_float64(stream, data.param1);
|
sn_utils::ls_float64(stream, data.param1);
|
||||||
sn_utils::ls_float64(stream, data.param2);
|
sn_utils::ls_float64(stream, data.param2);
|
||||||
sn_utils::ls_float64(stream, data.time_delta);
|
sn_utils::ls_float64(stream, data.time_delta);
|
||||||
|
|
||||||
|
sn_utils::s_bool(stream, data.freefly);
|
||||||
|
sn_utils::s_vec3(stream, data.location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +61,9 @@ void network::command_message::deserialize(std::istream &stream)
|
|||||||
data.param2 = sn_utils::ld_float64(stream);
|
data.param2 = sn_utils::ld_float64(stream);
|
||||||
data.time_delta = sn_utils::ld_float64(stream);
|
data.time_delta = sn_utils::ld_float64(stream);
|
||||||
|
|
||||||
|
data.freefly = sn_utils::d_bool(stream);
|
||||||
|
data.location = sn_utils::d_vec3(stream);
|
||||||
|
|
||||||
sequence.emplace_back(data);
|
sequence.emplace_back(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +78,7 @@ size_t network::command_message::get_size()
|
|||||||
for (auto const &kv : commands) {
|
for (auto const &kv : commands) {
|
||||||
cmd_size += 8;
|
cmd_size += 8;
|
||||||
for (command_data const &data : kv.second) {
|
for (command_data const &data : kv.second) {
|
||||||
cmd_size += 8 + 3 * 8;
|
cmd_size += 8 + 3 * 8 + 2 + 4 * 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ void network::connection::message_received(std::shared_ptr<message> &msg)
|
|||||||
else if (msg->type == message::CONNECT_ACCEPT)
|
else if (msg->type == message::CONNECT_ACCEPT)
|
||||||
{
|
{
|
||||||
auto cmd = std::dynamic_pointer_cast<accept_message>(msg);
|
auto cmd = std::dynamic_pointer_cast<accept_message>(msg);
|
||||||
|
|
||||||
WriteLog("accept received", logtype::net);
|
WriteLog("accept received", logtype::net);
|
||||||
//Global.random_engine.seed(cmd->seed);
|
Global.random_seed = cmd->seed;
|
||||||
|
Global.random_engine.seed(Global.random_seed);
|
||||||
}
|
}
|
||||||
else if (msg->type == message::CLIENT_COMMAND)
|
else if (msg->type == message::CLIENT_COMMAND)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ scenarioloader_mode::update() {
|
|||||||
if( true == simulation::State.deserialize( Global.SceneryFile ) ) {
|
if( true == simulation::State.deserialize( Global.SceneryFile ) ) {
|
||||||
WriteLog( "Scenario loading time: " + std::to_string( std::chrono::duration_cast<std::chrono::seconds>( ( std::chrono::system_clock::now() - timestart ) ).count() ) + " seconds" );
|
WriteLog( "Scenario loading time: " + std::to_string( std::chrono::duration_cast<std::chrono::seconds>( ( std::chrono::system_clock::now() - timestart ) ).count() ) + " seconds" );
|
||||||
// TODO: implement and use next mode cue
|
// TODO: implement and use next mode cue
|
||||||
|
Global.random_seed = std::random_device{}();
|
||||||
|
Global.random_engine.seed(Global.random_seed);
|
||||||
Application.pop_mode();
|
Application.pop_mode();
|
||||||
Application.push_mode( eu07_application::mode::driver );
|
Application.push_mode( eu07_application::mode::driver );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ void state_manager::process_commands() {
|
|||||||
if (commanddata.action == GLFW_RELEASE)
|
if (commanddata.action == GLFW_RELEASE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (commanddata.command == user_command::debugtoggle)
|
||||||
|
DebugModeFlag = !DebugModeFlag;
|
||||||
|
|
||||||
if (DebugModeFlag) {
|
if (DebugModeFlag) {
|
||||||
if (commanddata.command == user_command::timejump) {
|
if (commanddata.command == user_command::timejump) {
|
||||||
Time.update(commanddata.param1);
|
Time.update(commanddata.param1);
|
||||||
|
|||||||
15
sn_utils.cpp
15
sn_utils.cpp
@@ -88,6 +88,14 @@ glm::dvec3 sn_utils::d_dvec3(std::istream& s)
|
|||||||
ld_float64(s) };
|
ld_float64(s) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 sn_utils::d_vec3( std::istream& s)
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
ld_float32(s),
|
||||||
|
ld_float32(s),
|
||||||
|
ld_float32(s) };
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec4 sn_utils::d_vec4( std::istream& s)
|
glm::vec4 sn_utils::d_vec4( std::istream& s)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@@ -173,6 +181,13 @@ void sn_utils::s_dvec3(std::ostream &s, glm::dvec3 const &v)
|
|||||||
ls_float64(s, v.z);
|
ls_float64(s, v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sn_utils::s_vec3(std::ostream &s, glm::vec3 const &v)
|
||||||
|
{
|
||||||
|
ls_float32(s, v.x);
|
||||||
|
ls_float32(s, v.y);
|
||||||
|
ls_float32(s, v.z);
|
||||||
|
}
|
||||||
|
|
||||||
void sn_utils::s_vec4(std::ostream &s, glm::vec4 const &v)
|
void sn_utils::s_vec4(std::ostream &s, glm::vec4 const &v)
|
||||||
{
|
{
|
||||||
ls_float32(s, v.x);
|
ls_float32(s, v.x);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
static std::string d_str(std::istream&);
|
static std::string d_str(std::istream&);
|
||||||
static bool d_bool(std::istream&);
|
static bool d_bool(std::istream&);
|
||||||
static glm::dvec3 d_dvec3(std::istream&);
|
static glm::dvec3 d_dvec3(std::istream&);
|
||||||
|
static glm::vec3 d_vec3(std::istream&);
|
||||||
static glm::vec4 d_vec4(std::istream&);
|
static glm::vec4 d_vec4(std::istream&);
|
||||||
|
|
||||||
static void ls_uint16(std::ostream&, uint16_t);
|
static void ls_uint16(std::ostream&, uint16_t);
|
||||||
@@ -25,5 +26,6 @@ public:
|
|||||||
static void s_str(std::ostream&, std::string);
|
static void s_str(std::ostream&, std::string);
|
||||||
static void s_bool(std::ostream&, bool);
|
static void s_bool(std::ostream&, bool);
|
||||||
static void s_dvec3(std::ostream&, glm::dvec3 const &);
|
static void s_dvec3(std::ostream&, glm::dvec3 const &);
|
||||||
|
static void s_vec3(std::ostream&, glm::vec3 const &);
|
||||||
static void s_vec4(std::ostream&, glm::vec4 const &);
|
static void s_vec4(std::ostream&, glm::vec4 const &);
|
||||||
};
|
};
|
||||||
@@ -105,14 +105,14 @@ bool ClearFlag( int &Flag, int const Value ) {
|
|||||||
|
|
||||||
double Random(double a, double b)
|
double Random(double a, double b)
|
||||||
{
|
{
|
||||||
std::uniform_real_distribution<> dis(a, b);
|
uint32_t val = Global.random_engine();
|
||||||
return dis(Global.random_engine);
|
return interpolate(a, b, (double)val / Global.random_engine.max());
|
||||||
}
|
}
|
||||||
|
|
||||||
double LocalRandom(double a, double b)
|
double LocalRandom(double a, double b)
|
||||||
{
|
{
|
||||||
std::uniform_real_distribution<> dis(a, b);
|
uint32_t val = Global.local_random_engine();
|
||||||
return dis(Global.local_random_engine);
|
return interpolate(a, b, (double)val / Global.random_engine.max());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FuzzyLogic(double Test, double Threshold, double Probability)
|
bool FuzzyLogic(double Test, double Threshold, double Probability)
|
||||||
|
|||||||
Reference in New Issue
Block a user