mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
potential vbo render path crash fix, minor bug fixes
This commit is contained in:
13
Event.cpp
13
Event.cpp
@@ -886,9 +886,14 @@ whois_event::run_() {
|
|||||||
auto *targetcell { static_cast<TMemCell *>( std::get<scene::basic_node *>( target ) ) };
|
auto *targetcell { static_cast<TMemCell *>( std::get<scene::basic_node *>( target ) ) };
|
||||||
if( targetcell == nullptr ) { continue; }
|
if( targetcell == nullptr ) { continue; }
|
||||||
// event effect code
|
// event effect code
|
||||||
|
// +24: vehicle type, consist brake level, obstacle distance
|
||||||
|
// +16: load type, load amount, max load amount
|
||||||
|
// +8: destination, direction, engine power
|
||||||
|
// +0: train name, station count, stop on next station
|
||||||
if( m_input.flags & flags::load ) {
|
if( m_input.flags & flags::load ) {
|
||||||
|
// +16 or +24
|
||||||
// jeśli pytanie o ładunek
|
// jeśli pytanie o ładunek
|
||||||
if( m_input.flags & flags::mode_add ) {
|
if( m_input.flags & flags::mode_alt ) {
|
||||||
// jeśli typ pojazdu
|
// jeśli typ pojazdu
|
||||||
// TODO: define and recognize individual request types
|
// TODO: define and recognize individual request types
|
||||||
auto const owner { (
|
auto const owner { (
|
||||||
@@ -912,7 +917,7 @@ whois_event::run_() {
|
|||||||
|
|
||||||
WriteLog(
|
WriteLog(
|
||||||
"Type: WhoIs (" + to_string( m_input.flags ) + ") - "
|
"Type: WhoIs (" + to_string( m_input.flags ) + ") - "
|
||||||
+ "[name: " + m_activator->MoverParameters->TypeName + "], "
|
+ "[type: " + m_activator->MoverParameters->TypeName + "], "
|
||||||
+ "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], "
|
+ "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], "
|
||||||
+ "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" );
|
+ "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" );
|
||||||
}
|
}
|
||||||
@@ -931,7 +936,8 @@ whois_event::run_() {
|
|||||||
+ "[max load: " + to_string( m_activator->MoverParameters->MaxLoad, 2 ) + "]" );
|
+ "[max load: " + to_string( m_activator->MoverParameters->MaxLoad, 2 ) + "]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( m_input.flags & flags::mode_add ) { // jeśli miejsce docelowe pojazdu
|
// +8
|
||||||
|
else if( m_input.flags & flags::mode_alt ) { // jeśli miejsce docelowe pojazdu
|
||||||
targetcell->UpdateValues(
|
targetcell->UpdateValues(
|
||||||
m_activator->asDestination, // adres docelowy
|
m_activator->asDestination, // adres docelowy
|
||||||
m_activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny)
|
m_activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny)
|
||||||
@@ -944,6 +950,7 @@ whois_event::run_() {
|
|||||||
+ "[direction: " + to_string( m_activator->DirectionGet() ) + "], "
|
+ "[direction: " + to_string( m_activator->DirectionGet() ) + "], "
|
||||||
+ "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" );
|
+ "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" );
|
||||||
}
|
}
|
||||||
|
// +0
|
||||||
else if( m_activator->Mechanik ) {
|
else if( m_activator->Mechanik ) {
|
||||||
if( m_activator->Mechanik->Primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
|
if( m_activator->Mechanik->Primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
|
||||||
targetcell->UpdateValues(
|
targetcell->UpdateValues(
|
||||||
|
|||||||
6
Event.h
6
Event.h
@@ -25,8 +25,10 @@ public:
|
|||||||
value_1 = 1 << 1,
|
value_1 = 1 << 1,
|
||||||
value_2 = 1 << 2,
|
value_2 = 1 << 2,
|
||||||
// update values
|
// update values
|
||||||
load = 1 << 3,
|
mode_add = 1 << 3,
|
||||||
mode_add = 1 << 4,
|
// whois
|
||||||
|
mode_alt = 1 << 3,
|
||||||
|
load = 1 << 4,
|
||||||
// condition values
|
// condition values
|
||||||
track_busy = 1 << 3,
|
track_busy = 1 << 3,
|
||||||
track_free = 1 << 4,
|
track_free = 1 << 4,
|
||||||
|
|||||||
19
TrkFoll.cpp
19
TrkFoll.cpp
@@ -96,10 +96,6 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
// bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd
|
// bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd
|
||||||
// Ra: zwraca false, jeśli pojazd ma być usunięty
|
// Ra: zwraca false, jeśli pojazd ma być usunięty
|
||||||
auto const ismoving { ( std::abs( fDistance ) > 0.01 ) && ( Owner->GetVelocity() > 0.01 ) };
|
auto const ismoving { ( std::abs( fDistance ) > 0.01 ) && ( Owner->GetVelocity() > 0.01 ) };
|
||||||
int const eventfilter { (
|
|
||||||
( ( true == ismoving ) && ( Owner->ctOwner != nullptr ) ) ?
|
|
||||||
Owner->ctOwner->Direction() * ( Owner->ctOwner->Vehicle()->DirectionGet() == Owner->DirectionGet() ? 1 : -1 ) * ( fDirection > 0 ? 1 : -1 ) :
|
|
||||||
0 ) };
|
|
||||||
fDistance *= fDirection; // dystans mnożnony przez kierunek
|
fDistance *= fDirection; // dystans mnożnony przez kierunek
|
||||||
double s; // roboczy dystans
|
double s; // roboczy dystans
|
||||||
double dir; // zapamiętany kierunek do sprawdzenia, czy się zmienił
|
double dir; // zapamiętany kierunek do sprawdzenia, czy się zmienił
|
||||||
@@ -110,6 +106,13 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
// TODO: refactor following block as track method
|
// TODO: refactor following block as track method
|
||||||
if( pCurrentTrack->m_events ) { // sumaryczna informacja o eventach
|
if( pCurrentTrack->m_events ) { // sumaryczna informacja o eventach
|
||||||
// omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma)
|
// omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma)
|
||||||
|
int const eventfilter { (
|
||||||
|
false == ismoving ? 0 : // only moving vehicles activate events type 1/2
|
||||||
|
false == bPrimary ? 0 : // only primary axle activates events type 1/2
|
||||||
|
Owner->ctOwner == nullptr ?
|
||||||
|
( fDistance > 0 ? 1 : -1 ) : // loose vehicle has no means to determine 'intended' direction so the filter does effectively nothing in such case
|
||||||
|
( fDirection > 0 ? 1 : -1 ) * Owner->ctOwner->Direction() * ( Owner->ctOwner->Vehicle()->DirectionGet() == Owner->DirectionGet() ? 1 : -1 ) ) };
|
||||||
|
|
||||||
if( false == ismoving ) {
|
if( false == ismoving ) {
|
||||||
//McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi
|
//McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi
|
||||||
if( ( Owner->Mechanik != nullptr )
|
if( ( Owner->Mechanik != nullptr )
|
||||||
@@ -127,18 +130,14 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
&& ( Owner->Mechanik->Primary() ) ) {
|
&& ( Owner->Mechanik->Primary() ) ) {
|
||||||
// tylko dla jednego członu
|
// tylko dla jednego członu
|
||||||
// McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada
|
// McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada
|
||||||
if( true == bPrimary ) {
|
|
||||||
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner );
|
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if( SetFlag( iEventallFlag, -1 ) ) {
|
if( SetFlag( iEventallFlag, -1 ) ) {
|
||||||
// McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow
|
// McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow
|
||||||
if( true == bPrimary ) {
|
|
||||||
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner );
|
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if( ( fDistance > 0 ) && ( eventfilter > 0 ) ) {
|
else if( ( fDistance > 0 ) && ( eventfilter > 0 ) ) {
|
||||||
// event2, eventall2
|
// event2, eventall2
|
||||||
if( SetFlag( iEventFlag, -2 ) ) {
|
if( SetFlag( iEventFlag, -2 ) ) {
|
||||||
@@ -146,19 +145,15 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
if( ( Owner->Mechanik != nullptr )
|
if( ( Owner->Mechanik != nullptr )
|
||||||
&& ( Owner->Mechanik->Primary() ) ) {
|
&& ( Owner->Mechanik->Primary() ) ) {
|
||||||
// tylko dla jednego członu
|
// tylko dla jednego członu
|
||||||
if( true == bPrimary ) {
|
|
||||||
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner );
|
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if( SetFlag( iEventallFlag, -2 ) ) {
|
if( SetFlag( iEventallFlag, -2 ) ) {
|
||||||
// sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0
|
// sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0
|
||||||
if( true == bPrimary ) {
|
|
||||||
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2all, Owner );
|
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2all, Owner );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!pCurrentSegment) // jeżeli nie ma powiązanego segmentu toru?
|
if (!pCurrentSegment) // jeżeli nie ma powiązanego segmentu toru?
|
||||||
return false;
|
return false;
|
||||||
// if (fDistance==0.0) return true; //Ra: jak stoi, to chyba dalej nie ma co kombinować?
|
// if (fDistance==0.0) return true; //Ra: jak stoi, to chyba dalej nie ma co kombinować?
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream
|
|||||||
// try to set up the buffer we need
|
// try to set up the buffer we need
|
||||||
::glGenBuffers( 1, &m_buffer );
|
::glGenBuffers( 1, &m_buffer );
|
||||||
bind_buffer();
|
bind_buffer();
|
||||||
|
if( m_buffer == 0 ) { return; } // if we didn't get a buffer we'll try again during the next draw call
|
||||||
// NOTE: we're using static_draw since it's generally true for all we have implemented at the moment
|
// NOTE: we're using static_draw since it's generally true for all we have implemented at the moment
|
||||||
// TODO: allow to specify usage hint at the object creation, and pass it here
|
// TODO: allow to specify usage hint at the object creation, and pass it here
|
||||||
::glBufferData(
|
::glBufferData(
|
||||||
|
|||||||
Reference in New Issue
Block a user