mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 06:35:21 +01:00
feat(physics): buffer stops at the free ends of the tracks
A free end of a rail track marked bufferstop1 / bufferstop2 <kind> in the scenery is a buffer stop (physics/bufferstop.h): rigid, buffered, hydraulic or friction. With physics.collisions new a vehicle running into it meets the stages of the stop in series: the buffers of both, the absorber or the brake elements of a sliding stop, then the frame, whose hit goes through collision::hit() and whose ride-up goes through collision::override_of(), the stop an immovable body. It is held, the frame deforms, it rides up (Enfield 2021), demolishes the stop (Kirkby 2021) or overruns a sliding one. The log tells each hit once, and the memory cells __simulation.bufferstop and <track>:bufferstop and their events tell the scenery. physics.bufferstops marked (the default) takes the marked ends only, auto also the ends with a model of a stop within 3 m, off none. Every other free end keeps the derailment off the end of the track, and so does every end with physics.collisions old; monitor logs what the stop would have done.
This commit is contained in:
@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "simulation/simulationenvironment.h"
|
||||
#include "simulation/simulationtest.h"
|
||||
#include "simulation/blackboxrecorder.h"
|
||||
#include "physics/bufferstop.h"
|
||||
|
||||
#include "utilities/Globals.h"
|
||||
#include "world/Event.h"
|
||||
@@ -153,6 +154,26 @@ state_manager::report_derailment( TDynamicObject const &Vehicle, derailment::not
|
||||
test().vehicle_derailed( Vehicle, Notice );
|
||||
}
|
||||
|
||||
void
|
||||
state_manager::report_buffer_stop( TDynamicObject const &Vehicle, bufferstop::notice const &Notice ) {
|
||||
|
||||
auto const text { bufferstop::cell_text( Notice ) };
|
||||
auto const tell { [ & ]( std::string const &Name ) {
|
||||
if( auto *cell { Memory.find( Name ) } ) {
|
||||
cell->UpdateValues(
|
||||
text,
|
||||
Notice.velocity,
|
||||
static_cast<double>( static_cast<int>( Notice.result ) ),
|
||||
basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2 );
|
||||
}
|
||||
if( auto *launched { Events.FindEvent( Name ) } ) {
|
||||
Events.AddToQuery( launched, &Vehicle );
|
||||
}
|
||||
} };
|
||||
tell( std::string( bufferstop_name ) );
|
||||
tell( bufferstop::cell_name( Notice.track ) );
|
||||
}
|
||||
|
||||
// legacy method, calculates changes in simulation state over specified time
|
||||
void
|
||||
state_manager::update( double const Deltatime, int Iterationcount ) {
|
||||
|
||||
Reference in New Issue
Block a user