From ac7a15d66790caa5cbe9b3dded334459ab71eec0 Mon Sep 17 00:00:00 2001 From: milek7 Date: Sat, 10 Aug 2019 17:45:44 +0200 Subject: [PATCH 1/2] particles: do not use reserve/capacity, use separate var --- particles.cpp | 8 ++++---- particles.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/particles.cpp b/particles.cpp index aaca930c..a9a160ee 100644 --- a/particles.cpp +++ b/particles.cpp @@ -109,14 +109,14 @@ smoke_source::deserialize_mapping( cParser &Input ) { void smoke_source::initialize() { - m_particles.reserve( + m_max_particles = // put a cap on number of particles in a single source. TBD, TODO: make it part of he source configuration? std::min( 500, // NOTE: given nature of the smoke we're presuming opacity decreases over time and the particle is killed when it reaches 0 // this gives us estimate of longest potential lifespan of single particle, and how many particles total can there be at any given time // TBD, TODO: explicit lifespan variable as part of the source configuration? - static_cast( m_spawnrate / std::abs( m_opacitymodifier.value_change() ) ) ) ); + static_cast( m_spawnrate / std::abs( m_opacitymodifier.value_change() ) ) ); } void @@ -154,7 +154,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { 0.f : std::min( m_spawncount + ( m_spawnrate * Timedelta ), - m_particles.capacity() ) ); + m_max_particles ) ); // update spawned particles for( auto particleiterator { std::begin( m_particles ) }; particleiterator != std::end( m_particles ); ++particleiterator ) { @@ -185,7 +185,7 @@ smoke_source::update( double const Timedelta, bool const Onlydespawn ) { } // spawn pending particles in remaining container slots while( ( m_spawncount >= 1.f ) - && ( m_particles.size() < m_particles.capacity() ) ) { + && ( m_particles.size() < m_max_particles ) ) { m_spawncount -= 1.f; // work with a temporary copy in case initial update renders the particle dead diff --git a/particles.h b/particles.h index f7de0630..eae467d8 100644 --- a/particles.h +++ b/particles.h @@ -146,6 +146,7 @@ private: // current state float m_spawncount { 0.f }; // number of particles to spawn during next update particle_sequence m_particles; // collection of spawned particles + size_t m_max_particles; // maximum number of particles existing /* smoke_sequence::iterator // helpers, iterators marking currently used part of the particle container m_particlehead, From 7185904e3824043e28863dad9a54e5c2efd26841 Mon Sep 17 00:00:00 2001 From: milek7 Date: Wed, 14 Aug 2019 00:45:50 +0200 Subject: [PATCH 2/2] disable continuous brake for jointctrls --- Train.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Train.cpp b/Train.cpp index 42b62bf7..a4d5899a 100644 --- a/Train.cpp +++ b/Train.cpp @@ -1039,10 +1039,11 @@ void TTrain::OnCommand_secondcontrollerset( TTrain *Train, command_data const &C void TTrain::OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command ) { - if( Command.action == GLFW_REPEAT ) { - - if( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { - Train->mvOccupied->IncLocalBrakeLevel( Global.brake_speed * Command.time_delta * LocalBrakePosNo ); + if( Command.action != GLFW_RELEASE ) { + if( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { + Train->mvOccupied->IncLocalBrakeLevel( + (Train->ggJointCtrl.SubModel == nullptr) ? + (Global.brake_speed * Command.time_delta * LocalBrakePosNo) : 1); } } } @@ -1059,13 +1060,15 @@ void TTrain::OnCommand_independentbrakeincreasefast( TTrain *Train, command_data void TTrain::OnCommand_independentbrakedecrease( TTrain *Train, command_data const &Command ) { - if( Command.action == GLFW_REPEAT ) { + if( Command.action != GLFW_RELEASE ) { if( ( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba // TODO: sort AI out so it doesn't do things it doesn't have equipment for || ( Train->mvOccupied->LocalBrakePosA > 0 ) ) { - Train->mvOccupied->DecLocalBrakeLevel( Global.brake_speed * Command.time_delta * LocalBrakePosNo ); + Train->mvOccupied->DecLocalBrakeLevel( + (Train->ggJointCtrl.SubModel == nullptr) ? + (Global.brake_speed * Command.time_delta * LocalBrakePosNo) : 1); } } }