mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 00:29:19 +02:00
Merge branch 'tmj-dev' into lua
This commit is contained in:
118
Driver.cpp
118
Driver.cpp
@@ -1355,7 +1355,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
|
||||
// modifies brake distance for low target speeds, to ease braking rate in such situations
|
||||
float
|
||||
TController::braking_distance_multiplier( float const Targetvelocity ) {
|
||||
TController::braking_distance_multiplier( float const Targetvelocity ) const {
|
||||
|
||||
if( Targetvelocity > 65.f ) { return 1.f; }
|
||||
if( Targetvelocity < 5.f ) { return 1.f; }
|
||||
@@ -1422,11 +1422,15 @@ void TController::TablePurger()
|
||||
iLast = sSpeedTable.size() - 1;
|
||||
};
|
||||
|
||||
void TController::TableSort()
|
||||
{
|
||||
void TController::TableSort() {
|
||||
|
||||
if( sSpeedTable.size() < 3 ) {
|
||||
// we skip last slot and no point in checking if there's only one other entry
|
||||
return;
|
||||
}
|
||||
TSpeedPos sp_temp = TSpeedPos(); // uzywany do przenoszenia
|
||||
for (std::size_t i = 0; i < (iLast - 1) && iLast > 1 && iLast != -1; ++i)
|
||||
{ // pętla tylko do dwóch pozycji od końca bo ostatniej nie modyfikujemy
|
||||
for( std::size_t i = 0; i < ( iLast - 1 ); ++i ) {
|
||||
// pętla tylko do dwóch pozycji od końca bo ostatniej nie modyfikujemy
|
||||
if (sSpeedTable[i].fDist > sSpeedTable[i + 1].fDist)
|
||||
{ // jesli pozycja wcześniejsza jest dalej to źle
|
||||
sp_temp = sSpeedTable[i + 1];
|
||||
@@ -3992,6 +3996,11 @@ TController::UpdateSituation(double dt) {
|
||||
// bottom margin raised to 2 km/h to give the AI more leeway at low speed limits
|
||||
fVelPlus = clamp( std::ceil( 0.05 * VelDesired ), 2.0, 5.0 );
|
||||
}
|
||||
if( mvOccupied->BrakeDelayFlag == bdelay_G ) {
|
||||
// increase distances for cargo trains to take into account slower reaction to brakes
|
||||
fMinProximityDist += 10.0;
|
||||
fMaxProximityDist += 10.0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// samochod (sokista też)
|
||||
@@ -4302,6 +4311,12 @@ TController::UpdateSituation(double dt) {
|
||||
if( vehicle->fTrackBlock <= fMinProximityDist ) {
|
||||
VelDesired = 0.0;
|
||||
}
|
||||
|
||||
if( ( mvOccupied->CategoryFlag & 1 )
|
||||
&& ( OrderCurrentGet() & Obey_train ) ) {
|
||||
// trains which move normally should try to stop at safe margin
|
||||
ActualProximityDist -= fDriverDist;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -4455,8 +4470,8 @@ TController::UpdateSituation(double dt) {
|
||||
// przeciwnie do zadanego kierunku jazdy
|
||||
//(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS)
|
||||
if( ( VelNext >= 0.0 )
|
||||
&& ( ActualProximityDist <= routescanrange )
|
||||
&& ( vel >= VelNext ) ) {
|
||||
&& ( ActualProximityDist <= routescanrange )
|
||||
&& ( vel >= VelNext ) ) {
|
||||
// gdy zbliża się i jest za szybki do nowej prędkości, albo stoi na zatrzymaniu
|
||||
if (vel > 0.0) {
|
||||
// jeśli jedzie
|
||||
@@ -4563,23 +4578,52 @@ TController::UpdateSituation(double dt) {
|
||||
}
|
||||
// koniec predkosci nastepnej
|
||||
|
||||
if( vel > VelDesired ) {
|
||||
// jesli jedzie za szybko do AKTUALNEGO
|
||||
if( VelDesired == 0.0 ) {
|
||||
// jesli stoj, to hamuj, ale i tak juz za pozno :)
|
||||
AccDesired = std::min( AccDesired, -0.9 ); // hamuj solidnie
|
||||
}
|
||||
else {
|
||||
// slow down, not full stop
|
||||
if( vel > ( VelDesired + fVelPlus ) ) {
|
||||
// hamuj tak średnio
|
||||
AccDesired = std::min( AccDesired, -fBrake_a0[ 0 ] * 0.5 );
|
||||
// decisions based on current speed
|
||||
if( mvOccupied->CategoryFlag == 1 ) {
|
||||
// try to estimate increase of current velocity before engaged brakes start working
|
||||
auto const speedestimate = vel + vel * ( 1.0 - fBrake_a0[ 0 ] ) * AbsAccS;
|
||||
if( speedestimate > VelDesired ) {
|
||||
// jesli jedzie za szybko do AKTUALNEGO
|
||||
if( VelDesired == 0.0 ) {
|
||||
// jesli stoj, to hamuj, ale i tak juz za pozno :)
|
||||
AccDesired = std::min( AccDesired, -0.85 ); // hamuj solidnie
|
||||
}
|
||||
else {
|
||||
// o 5 km/h to olej (zacznij luzować)
|
||||
AccDesired = std::min(
|
||||
AccDesired, // but don't override decceleration for VelNext
|
||||
std::max( 0.0, AccPreferred ) );
|
||||
if( speedestimate > ( VelDesired + fVelPlus ) ) {
|
||||
// if it looks like we'll exceed maximum allowed speed start thinking about slight slowing down
|
||||
AccDesired = std::min( AccDesired, -0.25 );
|
||||
}
|
||||
else {
|
||||
// close enough to target to stop accelerating
|
||||
AccDesired = std::min(
|
||||
AccDesired, // but don't override decceleration for VelNext
|
||||
interpolate( // ease off as you close to the target velocity
|
||||
-0.06, AccPreferred,
|
||||
clamp( speedestimate - vel, 0.0, fVelPlus ) / fVelPlus ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// for cars the older version works better
|
||||
if( vel > VelDesired ) {
|
||||
// jesli jedzie za szybko do AKTUALNEGO
|
||||
if( VelDesired == 0.0 ) {
|
||||
// jesli stoj, to hamuj, ale i tak juz za pozno :)
|
||||
AccDesired = std::min( AccDesired, -0.9 ); // hamuj solidnie
|
||||
}
|
||||
else {
|
||||
// slow down, not full stop
|
||||
if( vel > ( VelDesired + fVelPlus ) ) {
|
||||
// hamuj tak średnio
|
||||
AccDesired = std::min( AccDesired, -fBrake_a0[ 0 ] * 0.5 );
|
||||
}
|
||||
else {
|
||||
// o 5 km/h to olej (zacznij luzować)
|
||||
AccDesired = std::min(
|
||||
AccDesired, // but don't override decceleration for VelNext
|
||||
std::max( 0.0, AccPreferred ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4587,6 +4631,10 @@ TController::UpdateSituation(double dt) {
|
||||
|
||||
// last step sanity check, until the whole calculation is straightened out
|
||||
AccDesired = std::min( AccDesired, AccPreferred );
|
||||
if( mvOccupied->CategoryFlag == 1 ) {
|
||||
// also take into account impact of gravity
|
||||
AccDesired = clamp( AccDesired - fAccGravity, -0.9, 0.9 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4643,15 +4691,20 @@ TController::UpdateSituation(double dt) {
|
||||
}
|
||||
// NOTE: as a stop-gap measure the routine is limited to trains only while car calculations seem off
|
||||
if( mvControlling->CategoryFlag == 1 ) {
|
||||
if( -AccDesired * BrakeAccFactor() < (
|
||||
( ( fReady > 0.4 ) || ( VelNext > vel - 40.0 ) ) ?
|
||||
fBrake_a0[ 0 ] * 0.8 :
|
||||
-fAccThreshold )
|
||||
/ braking_distance_multiplier( VelNext ) ) {
|
||||
AccDesired = std::max( -0.06, AccDesired );
|
||||
if( vel < VelDesired ) {
|
||||
// don't adjust acceleration when going above current goal speed
|
||||
if( -AccDesired * BrakeAccFactor() < (
|
||||
( ( fReady > 0.4 )
|
||||
|| ( VelNext > vel - 40.0 ) ) ?
|
||||
fBrake_a0[ 0 ] * 0.8 :
|
||||
-fAccThreshold )
|
||||
/ braking_distance_multiplier( VelNext ) ) {
|
||||
AccDesired = std::max( -0.06, AccDesired );
|
||||
}
|
||||
}
|
||||
else {
|
||||
ReactionTime = 0.25; // i orientuj się szybciej, jeśli hamujesz
|
||||
// i orientuj się szybciej, jeśli hamujesz
|
||||
ReactionTime = 0.25;
|
||||
}
|
||||
}
|
||||
if (mvOccupied->BrakeSystem == Pneumatic) // napełnianie uderzeniowe
|
||||
@@ -5538,6 +5591,13 @@ bool TController::IsStop()
|
||||
return TrainParams->IsStop();
|
||||
};
|
||||
|
||||
// returns most recently calculated distance to potential obstacle ahead
|
||||
double
|
||||
TController::TrackBlock() const {
|
||||
|
||||
return pVehicles[ TMoverParameters::side::front ]->fTrackBlock;
|
||||
}
|
||||
|
||||
void TController::MoveTo(TDynamicObject *to)
|
||||
{ // przesunięcie AI do innego pojazdu (przy zmianie kabiny)
|
||||
// mvOccupied->CabDeactivisation(); //wyłączenie kabiny w opuszczanym
|
||||
|
||||
77
Driver.h
77
Driver.h
@@ -171,8 +171,8 @@ extern bool WriteLogFlag; // logowanie parametrów fizycznych
|
||||
static const int BrakeAccTableSize = 20;
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class TController
|
||||
{
|
||||
class TController {
|
||||
|
||||
private: // obsługa tabelki prędkości (musi mieć możliwość odhaczania stacji w rozkładzie)
|
||||
int iLast{ 0 }; // ostatnia wypełniona pozycja w tabeli <iFirst (modulo iSpeedTableSize)
|
||||
int iTableDirection{ 0 }; // kierunek zapełnienia tabelki względem pojazdu z AI
|
||||
@@ -183,19 +183,19 @@ class TController
|
||||
std::size_t SemNextIndex{ std::size_t(-1) };
|
||||
std::size_t SemNextStopIndex{ std::size_t( -1 ) };
|
||||
double dMoveLen = 0.0; // odległość przejechana od ostatniego sprawdzenia tabelki
|
||||
private: // parametry aktualnego składu
|
||||
// parametry aktualnego składu
|
||||
double fLength = 0.0; // długość składu (do wyciągania z ograniczeń)
|
||||
double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji
|
||||
public:
|
||||
double fAccGravity = 0.0; // przyspieszenie składowej stycznej grawitacji
|
||||
public:
|
||||
TEvent *eSignNext = nullptr; // sygnał zmieniający prędkość, do pokazania na [F2]
|
||||
std::string asNextStop; // nazwa następnego punktu zatrzymania wg rozkładu
|
||||
int iStationStart = 0; // numer pierwszej stacji pokazywanej na podglądzie rozkładu
|
||||
private: // parametry sterowania pojazdem (stan, hamowanie)
|
||||
// parametry sterowania pojazdem (stan, hamowanie)
|
||||
private:
|
||||
double fShuntVelocity = 40.0; // maksymalna prędkość manewrowania, zależy m.in. od składu // domyślna prędkość manewrowa
|
||||
int iVehicles = 0; // ilość pojazdów w składzie
|
||||
int iEngineActive = 0; // ABu: Czy silnik byl juz zalaczony; Ra: postęp w załączaniu
|
||||
// vector3 vMechLoc; //pozycja pojazdu do liczenia odległości od semafora (?)
|
||||
bool Psyche = false;
|
||||
int iDrivigFlags = // flagi bitowe ruchu
|
||||
moveStopPoint | // podjedź do W4 możliwie blisko
|
||||
@@ -245,25 +245,20 @@ private:
|
||||
double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji)
|
||||
double AccDesired = AccPreferred; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj)
|
||||
double VelDesired = 0.0; // predkość, z jaką ma jechać, wynikająca z analizy tableki; <=VelSignal
|
||||
double fAccDesiredAv = 0.0; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby
|
||||
// ograniczyć migotanie
|
||||
public:
|
||||
double fAccDesiredAv = 0.0; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby ograniczyć migotanie
|
||||
double VelforDriver = -1.0; // prędkość, używana przy zmianie kierunku (ograniczenie przy nieznajmości szlaku?)
|
||||
double VelSignal = 0.0; // ograniczenie prędkości z kompilacji znaków i sygnałów // normalnie na początku ma stać, no chyba że jedzie
|
||||
double VelLimit = -1.0; // predkość zadawana przez event jednokierunkowego ograniczenia prędkości // -1: brak ograniczenia prędkości
|
||||
public:
|
||||
double VelSignalLast = -1.0; // prędkość zadana na ostatnim semaforze // ostatni semafor też bez ograniczenia
|
||||
double VelSignalNext = 0.0; // prędkość zadana na następnym semaforze
|
||||
double VelLimitLast = -1.0; // prędkość zadana przez ograniczenie // ostatnie ograniczenie bez ograniczenia
|
||||
double VelRoad = -1.0; // aktualna prędkość drogowa (ze znaku W27) (PutValues albo komendą) // prędkość drogowa bez ograniczenia
|
||||
public:
|
||||
double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist
|
||||
private:
|
||||
double fProximityDist = 0.0; // odleglosc podawana w SetProximityVelocity(); >0:przeliczać do punktu, <0:podana wartość
|
||||
double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora
|
||||
public:
|
||||
double
|
||||
ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia
|
||||
double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia
|
||||
private:
|
||||
vector3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego
|
||||
// odnosi sie komenda
|
||||
@@ -297,7 +292,7 @@ private:
|
||||
double fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku)
|
||||
double WaitingTime = 0.0; // zliczany czas oczekiwania do samoistnego ruszenia
|
||||
double WaitingExpireTime = 31.0; // tyle ma czekać, zanim się ruszy // maksymlany czas oczekiwania do samoistnego ruszenia
|
||||
// TEvent* eSignLast; //ostatnio znaleziony sygnał, o ile nie minięty
|
||||
|
||||
private: //---//---//---//---// koniec zmiennych, poniżej metody //---//---//---//---//
|
||||
void SetDriverPsyche();
|
||||
bool PrepareEngine();
|
||||
@@ -314,23 +309,16 @@ private:
|
||||
void AutoRewident(); // ustawia hamulce w składzie
|
||||
double ESMVelocity(bool Main);
|
||||
public:
|
||||
Mtable::TTrainParameters *Timetable()
|
||||
{
|
||||
return TrainParams;
|
||||
};
|
||||
Mtable::TTrainParameters *Timetable() {
|
||||
return TrainParams; };
|
||||
void PutCommand(std::string NewCommand, double NewValue1, double NewValue2,
|
||||
const TLocation &NewLocation, TStopReason reason = stopComm);
|
||||
bool PutCommand(std::string NewCommand, double NewValue1, double NewValue2,
|
||||
const vector3 *NewLocation, TStopReason reason = stopComm);
|
||||
void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę
|
||||
// procedury dotyczace rozkazow dla maszynisty
|
||||
void SetVelocity(double NewVel, double NewVelNext,
|
||||
TStopReason r = stopNone); // uaktualnia informacje o prędkości
|
||||
/*
|
||||
bool SetProximityVelocity(
|
||||
double NewDist,
|
||||
double NewVelNext); // uaktualnia informacje o prędkości przy nastepnym semaforze
|
||||
*/
|
||||
// uaktualnia informacje o prędkości
|
||||
void SetVelocity(double NewVel, double NewVelNext, TStopReason r = stopNone);
|
||||
public:
|
||||
void JumpToNextOrder();
|
||||
void JumpToFirstOrder();
|
||||
@@ -349,9 +337,7 @@ private:
|
||||
void OrdersInit(double fVel);
|
||||
void OrdersClear();
|
||||
void OrdersDump();
|
||||
TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
|
||||
bool primary = true // czy ma aktywnie prowadzić?
|
||||
);
|
||||
TController( bool AI, TDynamicObject *NewControll, bool InitPsyche, bool primary = true );
|
||||
std::string OrderCurrent();
|
||||
void WaitingSet(double Seconds);
|
||||
|
||||
@@ -360,33 +346,24 @@ private:
|
||||
void DirectionForward(bool forward);
|
||||
int OrderDirectionChange(int newdir, TMoverParameters *Vehicle);
|
||||
void Lights(int head, int rear);
|
||||
// double Distance(vector3 &p1, vector3 &n, vector3 &p2);
|
||||
|
||||
private: // Ra: metody obsługujące skanowanie toru
|
||||
// Ra: metody obsługujące skanowanie toru
|
||||
TEvent *CheckTrackEvent(TTrack *Track, double const fDirection ) const;
|
||||
// bool TableCheckEvent(TEvent *e);
|
||||
bool TableAddNew();
|
||||
bool TableNotFound(TEvent const *Event) const;
|
||||
// TEvent *TableCheckTrackEvent(double fDirection, TTrack *Track);
|
||||
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = nullptr);
|
||||
void TableCheck(double fDistance);
|
||||
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc);
|
||||
// modifies brake distance for low target speeds, to ease braking rate in such situations
|
||||
float
|
||||
braking_distance_multiplier( float const Targetvelocity );
|
||||
braking_distance_multiplier( float const Targetvelocity ) const;
|
||||
void TablePurger();
|
||||
void TableSort();
|
||||
inline double MoveDistanceGet()
|
||||
{
|
||||
return dMoveLen;
|
||||
}
|
||||
inline void MoveDistanceReset()
|
||||
{
|
||||
dMoveLen = 0.0;
|
||||
}
|
||||
inline double MoveDistanceGet() const {
|
||||
return dMoveLen; }
|
||||
inline void MoveDistanceReset() {
|
||||
dMoveLen = 0.0; }
|
||||
public:
|
||||
inline void MoveDistanceAdd(double distance)
|
||||
{
|
||||
inline void MoveDistanceAdd(double distance) {
|
||||
dMoveLen += distance * iDirection; //jak jedzie do tyłu to trzeba uwzględniać, że distance jest ujemna
|
||||
}
|
||||
std::size_t TableSize() const { return sSpeedTable.size(); }
|
||||
@@ -396,8 +373,7 @@ private:
|
||||
private: // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu
|
||||
bool BackwardTrackBusy(TTrack *Track);
|
||||
TEvent *CheckTrackEventBackward(double fDirection, TTrack *Track);
|
||||
TTrack *BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track,
|
||||
TEvent *&Event);
|
||||
TTrack *BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, TEvent *&Event);
|
||||
void SetProximityVelocity(double dist, double vel, const vector3 *pos);
|
||||
TCommandType BackwardScan();
|
||||
|
||||
@@ -417,13 +393,16 @@ private:
|
||||
return ( ( iDrivigFlags & movePrimary ) != 0 ); };
|
||||
inline
|
||||
int DrivigFlags() const {
|
||||
return iDrivigFlags;
|
||||
};
|
||||
return iDrivigFlags; };
|
||||
// returns most recently calculated distance to potential obstacle ahead
|
||||
double
|
||||
TrackBlock() const;
|
||||
void MoveTo(TDynamicObject *to);
|
||||
void DirectionInitial();
|
||||
std::string TableText(std::size_t const Index);
|
||||
int CrossRoute(TTrack *tr);
|
||||
void RouteSwitch(int d);
|
||||
std::string OwnerName() const;
|
||||
TMoverParameters const *Controlling() const { return mvControlling; }
|
||||
TMoverParameters const *Controlling() const {
|
||||
return mvControlling; }
|
||||
};
|
||||
|
||||
59
Ground.cpp
59
Ground.cpp
@@ -2437,7 +2437,7 @@ bool TGround::InitEvents()
|
||||
Current->Params[9].asTrack = tmp->pTrack;
|
||||
if (!Current->Params[9].asTrack)
|
||||
{
|
||||
ErrorLog("Bad event: Track \"" + cellastext + "\" does not exist in \"" + Current->asName + "\"");
|
||||
ErrorLog( "Bad event: multi-event \"" + Current->asName + "\" cannot find track \"" + cellastext + "\"" );
|
||||
Current->iFlags &= ~(conditional_trackoccupied | conditional_trackfree); // zerowanie flag
|
||||
}
|
||||
}
|
||||
@@ -2448,7 +2448,7 @@ bool TGround::InitEvents()
|
||||
Current->Params[9].asMemCell = tmp->MemCell;
|
||||
if (!Current->Params[9].asMemCell)
|
||||
{
|
||||
ErrorLog("Bad event: MemCell \"" + cellastext + "\" does not exist in \"" + Current->asName + "\"");
|
||||
ErrorLog( "Bad event: multi-event \"" + Current->asName + "\" cannot find memory cell \"" + cellastext + "\"" );
|
||||
Current->iFlags &= ~(conditional_memstring | conditional_memval1 | conditional_memval2);
|
||||
}
|
||||
}
|
||||
@@ -2459,13 +2459,13 @@ bool TGround::InitEvents()
|
||||
cellastext = Current->Params[ i ].asText;
|
||||
SafeDeleteArray(Current->Params[i].asText);
|
||||
Current->Params[i].asEvent = FindEvent(cellastext);
|
||||
if( !Current->Params[ i ].asEvent ) { // Ra: tylko w logu informacja o braku
|
||||
if( !Current->Params[ i ].asEvent ) {
|
||||
// Ra: tylko w logu informacja o braku
|
||||
if( ( Current->Params[ i ].asText == NULL )
|
||||
|| ( std::string( Current->Params[ i ].asText ).substr( 0, 5 ) != "none_" ) ) {
|
||||
WriteLog( "Event \"" + cellastext + "\" does not exist" );
|
||||
ErrorLog( "Missed event: " + cellastext + " in multiple " + Current->asName );
|
||||
ErrorLog( "Bad event: multi-event \"" + Current->asName + "\" cannot find event \"" + cellastext + "\"" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3410,18 +3410,22 @@ bool TGround::CheckQuery()
|
||||
owner != nullptr ?
|
||||
owner->fReady :
|
||||
-1.0 );
|
||||
auto const collisiondistance = (
|
||||
owner != nullptr ?
|
||||
owner->TrackBlock() :
|
||||
-1.0 );
|
||||
|
||||
tmpEvent->Params[ 9 ].asMemCell->UpdateValues(
|
||||
tmpEvent->Activator->MoverParameters->TypeName, // typ pojazdu
|
||||
consistbrakelevel,
|
||||
0, // na razie nic
|
||||
collisiondistance,
|
||||
tmpEvent->iFlags & ( update_memstring | update_memval1 | update_memval2 ) );
|
||||
|
||||
WriteLog(
|
||||
"whois request (" + to_string( tmpEvent->iFlags ) + ") "
|
||||
+ "[name: " + tmpEvent->Activator->MoverParameters->TypeName + "], "
|
||||
+ "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], "
|
||||
+ "[]" );
|
||||
+ "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" );
|
||||
}
|
||||
else {
|
||||
// jeśli parametry ładunku
|
||||
@@ -3589,6 +3593,45 @@ TGround::Update_Lights() {
|
||||
m_lights.update();
|
||||
}
|
||||
|
||||
void
|
||||
TGround::Update_Hidden() {
|
||||
|
||||
// rednerowanie globalnych (nie za często?)
|
||||
for( TGroundNode *node = srGlobal.nRenderHidden; node; node = node->nNext3 ) {
|
||||
node->RenderHidden();
|
||||
}
|
||||
|
||||
// render events and sounds from sectors near enough to the viewer
|
||||
auto const range = 2750.0; // audible range of 100 db sound
|
||||
int const camerax = static_cast<int>( std::floor( Global::pCameraPosition.x / 1000.0 ) + iNumRects / 2 );
|
||||
int const cameraz = static_cast<int>( std::floor( Global::pCameraPosition.z / 1000.0 ) + iNumRects / 2 );
|
||||
int const segmentcount = 2 * static_cast<int>( std::ceil( range / 1000.0 ) );
|
||||
int const originx = std::max( 0, camerax - segmentcount / 2 );
|
||||
int const originz = std::max( 0, cameraz - segmentcount / 2 );
|
||||
|
||||
for( int column = originx; column <= originx + segmentcount; ++column ) {
|
||||
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
||||
|
||||
auto &cell = Rects[ column ][ row ];
|
||||
|
||||
for( int subcellcolumn = 0; subcellcolumn < iNumSubRects; ++subcellcolumn ) {
|
||||
for( int subcellrow = 0; subcellrow < iNumSubRects; ++subcellrow ) {
|
||||
auto subcell = cell.FastGetSubRect( subcellcolumn, subcellrow );
|
||||
if( subcell == nullptr ) { continue; }
|
||||
// renderowanie obiektów aktywnych a niewidocznych
|
||||
for( auto node = subcell->nRenderHidden; node; node = node->nNext3 ) {
|
||||
node->RenderHidden();
|
||||
}
|
||||
// jeszcze dźwięki pojazdów by się przydały, również niewidocznych
|
||||
// TODO: move to sound renderer
|
||||
subcell->RenderSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Winger 170204 - szukanie trakcji nad pantografami
|
||||
bool TGround::GetTraction(TDynamicObject *model)
|
||||
{ // aktualizacja drutu zasilającego dla każdego pantografu, żeby odczytać napięcie
|
||||
|
||||
3
Ground.h
3
Ground.h
@@ -228,7 +228,7 @@ public:
|
||||
return pSubRects + iRow * iNumSubRects + iCol; // zwrócenie właściwego
|
||||
};
|
||||
// pobranie wskaźnika do małego kwadratu, bez tworzenia jeśli nie ma
|
||||
TSubRect * FastGetSubRect(int iCol, int iRow) {
|
||||
TSubRect *FastGetSubRect(int iCol, int iRow) const {
|
||||
return (
|
||||
pSubRects ?
|
||||
pSubRects + iRow * iNumSubRects + iCol :
|
||||
@@ -289,6 +289,7 @@ class TGround
|
||||
void UpdatePhys(double dt, int iter); // aktualizacja fizyki stałym krokiem
|
||||
bool Update(double dt, int iter); // aktualizacja przesunięć zgodna z FPS
|
||||
void Update_Lights(); // updates scene lights array
|
||||
void Update_Hidden(); // updates invisible elements of the scene
|
||||
bool AddToQuery(TEvent *Event, TDynamicObject *Node);
|
||||
bool GetTraction(TDynamicObject *model);
|
||||
bool CheckQuery();
|
||||
|
||||
@@ -2532,7 +2532,7 @@ void TTrain::OnCommand_instrumentlighttoggle( TTrain *Train, command_data const
|
||||
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
|
||||
if( Train->ggInstrumentLightButton.SubModel == nullptr ) {
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
WriteLog( "Universal3 switch is missing, or wasn't defined" );
|
||||
WriteLog( "Instrument light switch is missing, or wasn't defined" );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1052,6 +1052,7 @@ bool TWorld::Update()
|
||||
|
||||
Ground.CheckQuery();
|
||||
|
||||
Ground.Update_Hidden();
|
||||
Ground.Update_Lights();
|
||||
|
||||
{
|
||||
@@ -1452,6 +1453,10 @@ TWorld::Update_UI() {
|
||||
+ ", Fr: " + to_string( tmp->MoverParameters->RunningTrack.friction, 2 )
|
||||
+ ( tmp->MoverParameters->SlippingWheels ? " (!)" : "" );
|
||||
|
||||
if( tmp->Mechanik ) {
|
||||
uitextline2 += "; Ag: " + to_string( tmp->Mechanik->fAccGravity, 2 );
|
||||
}
|
||||
|
||||
uitextline2 +=
|
||||
"; TC:"
|
||||
+ to_string( tmp->MoverParameters->TotalCurrent, 0 );
|
||||
|
||||
29
renderer.cpp
29
renderer.cpp
@@ -22,6 +22,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Logs.h"
|
||||
#include "usefull.h"
|
||||
|
||||
#define EU07_NEW_CAB_RENDERCODE
|
||||
|
||||
opengl_renderer GfxRenderer;
|
||||
extern TWorld World;
|
||||
|
||||
@@ -1343,19 +1345,6 @@ opengl_renderer::Render( TGround *Ground ) {
|
||||
|
||||
m_drawqueue.clear();
|
||||
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::color: {
|
||||
// rednerowanie globalnych (nie za często?)
|
||||
for( TGroundNode *node = Ground->srGlobal.nRenderHidden; node; node = node->nNext3 ) {
|
||||
node->RenderHidden();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec3 const cameraposition { m_renderpass.camera.position() };
|
||||
int const camerax = static_cast<int>( std::floor( cameraposition.x / 1000.0f ) + iNumRects / 2 );
|
||||
int const cameraz = static_cast<int>( std::floor( cameraposition.z / 1000.0f ) + iNumRects / 2 );
|
||||
@@ -1372,20 +1361,6 @@ opengl_renderer::Render( TGround *Ground ) {
|
||||
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
||||
|
||||
auto *cell = &Ground->Rects[ column ][ row ];
|
||||
|
||||
for( int subcellcolumn = 0; subcellcolumn < iNumSubRects; ++subcellcolumn ) {
|
||||
for( int subcellrow = 0; subcellrow < iNumSubRects; ++subcellrow ) {
|
||||
auto subcell = cell->FastGetSubRect( subcellcolumn, subcellrow );
|
||||
if( subcell == nullptr ) { continue; }
|
||||
// renderowanie obiektów aktywnych a niewidocznych
|
||||
for( auto node = subcell->nRenderHidden; node; node = node->nNext3 ) {
|
||||
node->RenderHidden();
|
||||
}
|
||||
// jeszcze dźwięki pojazdów by się przydały, również niewidocznych
|
||||
subcell->RenderSounds();
|
||||
}
|
||||
}
|
||||
|
||||
if( m_renderpass.camera.visible( cell->m_area ) ) {
|
||||
Render( cell );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user