mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 08:04:57 +01:00
Merge remote-tracking branch 'origin/master' into feat/persistent-odometer-store
# Conflicts: # vehicle/DynObj.h
This commit is contained in:
@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/utilities.h"
|
||||
#include "simulation/simulation.h"
|
||||
#include "simulation/simulationsounds.h"
|
||||
#include "simulation/blackboxrecorder.h"
|
||||
#include "vehicle/Train.h"
|
||||
#include "utilities/dictionary.h"
|
||||
#include "scene/sceneeditor.h"
|
||||
@@ -425,6 +426,16 @@ int eu07_application::init(int Argc, char *Argv[])
|
||||
{
|
||||
m_taskqueue.init();
|
||||
}
|
||||
crashreport_add_info("luascreens_enabled", Global.luascreens_enabled ? "yes" : "no");
|
||||
crashreport_add_info("wasm_enabled", Global.wasm_enabled ? "yes" : "no");
|
||||
if (Global.luascreens_enabled || Global.wasm_enabled)
|
||||
{
|
||||
m_screenqueue.init();
|
||||
if (Global.screens_gpupost)
|
||||
{
|
||||
m_screenqueue.set_post_processor(GfxRenderer->Screen_post_processor());
|
||||
}
|
||||
}
|
||||
if ((result = init_modes()) != 0)
|
||||
{
|
||||
ErrorLog("Failed to initialize game modes");
|
||||
@@ -635,6 +646,7 @@ int eu07_application::run()
|
||||
EditorTerrain.update(Global.pCamera.Pos);
|
||||
|
||||
m_taskqueue.update();
|
||||
m_screenqueue.update();
|
||||
opengl_texture::reset_unit_cache();
|
||||
|
||||
if (!GfxRenderer->Render())
|
||||
@@ -715,11 +727,15 @@ void eu07_application::exit()
|
||||
auto const step = [closing](char const *What) {
|
||||
WriteLog(std::format("Closing: {} at {} ms", What, std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - closing).count()));
|
||||
};
|
||||
step("the black box");
|
||||
simulation::Blackbox.close();
|
||||
step("the modes");
|
||||
for (auto &mode : m_modes)
|
||||
mode.reset();
|
||||
|
||||
step("the renderer");
|
||||
// the screens' post-processing goes with the renderer
|
||||
m_screenqueue.set_post_processor(nullptr);
|
||||
GfxRenderer->Shutdown();
|
||||
m_network.reset();
|
||||
|
||||
@@ -734,6 +750,7 @@ void eu07_application::exit()
|
||||
|
||||
// the python workers detach their GL context on the way out, so they have to be done before the windows they use are destroyed
|
||||
m_taskqueue.exit();
|
||||
m_screenqueue.exit();
|
||||
step("the windows");
|
||||
for (auto *window : m_windows)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "application/applicationmode.h"
|
||||
#include "scripting/PyInt.h"
|
||||
#include "scripting/scriptscreens.h"
|
||||
#include "network/manager.h"
|
||||
#include "utilities/headtrack.h"
|
||||
#ifdef WITH_UART
|
||||
@@ -49,6 +50,10 @@ public:
|
||||
// frees the python gil and swaps out the main thread
|
||||
void
|
||||
release_python_lock();
|
||||
// the screens drawn by scripts (Lua, WebAssembly)
|
||||
script_screen_queue &
|
||||
screens() {
|
||||
return m_screenqueue; }
|
||||
void
|
||||
exit();
|
||||
void
|
||||
@@ -122,6 +127,7 @@ private:
|
||||
modeptr_array m_modes { nullptr }; // collection of available application behaviour modes
|
||||
mode_stack m_modestack; // current behaviour mode
|
||||
python_taskqueue m_taskqueue;
|
||||
script_screen_queue m_screenqueue;
|
||||
std::vector<GLFWwindow *> m_windows;
|
||||
int m_glfwversion;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "simulation/simulationtime.h"
|
||||
#include "simulation/simulationenvironment.h"
|
||||
#include "simulation/simulationtest.h"
|
||||
#include "simulation/blackboxrecorder.h"
|
||||
#include "scene/scene.h"
|
||||
#include "rendering/lightarray.h"
|
||||
#include "rendering/particles.h"
|
||||
@@ -160,6 +161,30 @@ bool driver_mode::init()
|
||||
}
|
||||
|
||||
// mode-specific update of simulation data. returns: false on error, true otherwise
|
||||
namespace {
|
||||
|
||||
// the camera as the black box tells it: where it is and where it looks, as the heading of a vehicle
|
||||
blackbox::camera_state blackbox_camera(TCamera const &Camera, std::uint8_t const Mode, int const View) {
|
||||
blackbox::camera_state state;
|
||||
state.mode = Mode;
|
||||
state.view = static_cast<std::uint8_t>(View);
|
||||
state.position = Camera.Pos;
|
||||
state.pitch = Camera.Angle.x;
|
||||
if (Camera.m_owner != nullptr && false == DebugCameraFlag) {
|
||||
// it looks at a point, then turns by its yaw from there
|
||||
auto const where{Camera.LookAt - Camera.Pos};
|
||||
state.heading = static_cast<float>(std::atan2(where.x, where.z)) + Camera.Angle.y;
|
||||
}
|
||||
else {
|
||||
// the yaw alone: 0 looks towards -z
|
||||
state.heading = static_cast<float>(std::atan2(-std::sin(Camera.Angle.y), -std::cos(Camera.Angle.y)));
|
||||
}
|
||||
state.heading = std::remainder(state.heading, 2.0f * glm::pi<float>());
|
||||
return state;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool driver_mode::update()
|
||||
{
|
||||
|
||||
@@ -306,6 +331,17 @@ bool driver_mode::update()
|
||||
simulation::Events.update();
|
||||
simulation::Region->update_events();
|
||||
simulation::Lights.update();
|
||||
{
|
||||
// where the user looks from, for the black box
|
||||
auto const &camera{DebugCameraFlag ? DebugCamera : Camera};
|
||||
auto const mode{DebugCameraFlag ? blackbox::camera_modes::debug :
|
||||
false == FreeFlyModeFlag ? blackbox::camera_modes::cab :
|
||||
m_externalview ? blackbox::camera_modes::external :
|
||||
blackbox::camera_modes::free};
|
||||
simulation::Blackbox.camera(blackbox_camera(camera, mode, mode == blackbox::camera_modes::external ? m_externalviewmode : 0),
|
||||
DebugCameraFlag ? nullptr : camera.m_owner);
|
||||
}
|
||||
simulation::Blackbox.update(deltatime);
|
||||
|
||||
if (Global.test.enabled && simulation::is_ready)
|
||||
{
|
||||
|
||||
@@ -38,6 +38,26 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/uart.h"
|
||||
#endif
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace {
|
||||
|
||||
// how close to a broken coupler the camera has to be for the driving aid to offer its repair [m]
|
||||
constexpr float coupler_repair_radius { 5.f };
|
||||
|
||||
// the broken coupler nearest to the camera, within reach: the vehicle and its end, or no vehicle
|
||||
std::pair<TDynamicObject const *, int> broken_coupler_nearby( glm::dvec3 const &Camera ) {
|
||||
auto const *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Camera, coupler_repair_radius, false, true ) ) };
|
||||
if( vehicle == nullptr || vehicle->MoverParameters == nullptr ) { return { nullptr, end::front }; }
|
||||
auto const front { glm::distance( vehicle->CouplerPosition( end::front ), Camera ) };
|
||||
auto const rear { glm::distance( vehicle->CouplerPosition( end::rear ), Camera ) };
|
||||
auto const nearest { front <= rear ? end::front : end::rear };
|
||||
if( std::min( front, rear ) > coupler_repair_radius || false == vehicle->MoverParameters->Couplers[ nearest ].broken ) { return { nullptr, end::front }; }
|
||||
return { vehicle, nearest };
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
drivingaid_panel::update() {
|
||||
|
||||
@@ -45,6 +65,8 @@ drivingaid_panel::update() {
|
||||
|
||||
text_lines.clear();
|
||||
|
||||
std::tie( m_brokenvehicle, m_brokenend ) = broken_coupler_nearby( Global.pCamera.Pos );
|
||||
|
||||
auto const *train { simulation::Train };
|
||||
auto const *controlled { ( train ? train->Dynamic() : nullptr ) };
|
||||
|
||||
@@ -70,53 +92,7 @@ drivingaid_panel::update() {
|
||||
}
|
||||
// next speed limit
|
||||
auto const speedlimit { static_cast<int>( owner->VelDesired ) };
|
||||
auto nextspeedlimit { speedlimit };
|
||||
auto nextspeedlimitdistance { std::numeric_limits<double>::max() };
|
||||
if( speedlimit != 0 ) { // if we aren't allowed to move then any next speed limit is irrelevant
|
||||
// nie przekraczać rozkladowej
|
||||
auto const schedulespeedlimit { (
|
||||
(owner->OrderCurrentGet() & (Obey_train | Bank)) != 0 && owner->TrainParams.TTVmax > 0.0 ? static_cast<int>( owner->TrainParams.TTVmax ) :
|
||||
(owner->OrderCurrentGet() & (Obey_train | Bank)) == 0 ? static_cast<int>( owner->fShuntVelocity ) :
|
||||
-1 ) };
|
||||
// first take note of any speed change which should occur after passing potential current speed limit
|
||||
if( owner->VelLimitLastDist.second > 0 ) {
|
||||
nextspeedlimit = min_speed( schedulespeedlimit, static_cast<int>( owner->VelLimitLastDist.first ) );
|
||||
nextspeedlimitdistance = owner->VelLimitLastDist.second;
|
||||
}
|
||||
// then take into account speed change ahead, compare it with speed after potentially clearing last limit
|
||||
// lower of these two takes priority; otherwise limit lasts at least until potential last limit is cleared
|
||||
auto const noactivespeedlimit { owner->VelLimitLastDist.second < 0 };
|
||||
if( auto const speedatproximitydistance { min_speed( schedulespeedlimit, static_cast<int>( owner->VelNext ) ) }; speedatproximitydistance == nextspeedlimit ) {
|
||||
if( noactivespeedlimit ) {
|
||||
nextspeedlimit = speedatproximitydistance;
|
||||
nextspeedlimitdistance = owner->ActualProximityDist;
|
||||
}
|
||||
}
|
||||
else if( speedatproximitydistance < nextspeedlimit ) {
|
||||
// if the speed limit ahead is more strict than our current limit, it's important enough to report
|
||||
if( speedatproximitydistance < owner->VelDesired ) {
|
||||
nextspeedlimit = speedatproximitydistance;
|
||||
nextspeedlimitdistance = owner->ActualProximityDist;
|
||||
}
|
||||
// otherwise report it only if it's located after our current (lower) limit ends
|
||||
else if( owner->ActualProximityDist > nextspeedlimitdistance ) {
|
||||
nextspeedlimit = speedatproximitydistance;
|
||||
nextspeedlimitdistance = owner->ActualProximityDist;
|
||||
}
|
||||
}
|
||||
else if( noactivespeedlimit ) { // implicit proximity > last, report only if last limit isn't present
|
||||
nextspeedlimit = speedatproximitydistance;
|
||||
nextspeedlimitdistance = owner->ActualProximityDist;
|
||||
}
|
||||
// HACK: if our current speed limit extends beyond our scan range don't display potentially misleading information about its length
|
||||
if( nextspeedlimitdistance >= EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE ) {
|
||||
nextspeedlimit = speedlimit;
|
||||
}
|
||||
// HACK: hide next speed limit if the 'limit' is a vehicle in front of us
|
||||
else if( owner->ActualProximityDist == std::abs( owner->TrackObstacle() ) ) {
|
||||
nextspeedlimit = speedlimit;
|
||||
}
|
||||
}
|
||||
auto const [ nextspeedlimit, nextspeedlimitdistance ] { owner->next_speed_limit() };
|
||||
std::string nextspeedlimittext;
|
||||
if( nextspeedlimit != speedlimit ) {
|
||||
std::snprintf(
|
||||
@@ -221,6 +197,12 @@ drivingaid_panel::render_contents() {
|
||||
}
|
||||
}
|
||||
|
||||
// only the coupler the camera is next to, and the one of the vehicle it was coupled with
|
||||
if( m_brokenvehicle != nullptr && ImGui::Button( STR_C( "Repair coupler" ) ) ) {
|
||||
command_relay commandrelay;
|
||||
commandrelay.post( user_command::repaircoupler, m_brokenend, 0.0, GLFW_PRESS, 0, glm::vec3( 0.0f ), &m_brokenvehicle->name() );
|
||||
}
|
||||
|
||||
ui_panel::render_contents();
|
||||
}
|
||||
|
||||
@@ -544,6 +526,7 @@ void debug_panel::update()
|
||||
m_powergridlines.clear();
|
||||
m_cameralines.clear();
|
||||
m_rendererlines.clear();
|
||||
m_couplerlines.clear();
|
||||
#ifdef WITH_UART
|
||||
m_uartlines.clear();
|
||||
#endif
|
||||
@@ -557,6 +540,7 @@ void debug_panel::update()
|
||||
update_section_powergrid( m_powergridlines );
|
||||
update_section_camera( m_cameralines );
|
||||
update_section_renderer( m_rendererlines );
|
||||
update_section_coupler( m_couplerlines );
|
||||
#ifdef WITH_UART
|
||||
update_section_uart(m_uartlines);
|
||||
#endif
|
||||
@@ -590,6 +574,7 @@ debug_panel::render() {
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
|
||||
}
|
||||
render_section_coupler();
|
||||
render_section( "Vehicle Engine", m_enginelines );
|
||||
render_section( "Vehicle AI", m_ailines );
|
||||
render_section( "Vehicle Scan Table", m_scantablelines );
|
||||
@@ -1508,6 +1493,172 @@ debug_panel::update_section_renderer( std::vector<text_line> &Output ) const {
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// how far from the camera a coupler shows in the coupler section [m]
|
||||
constexpr float coupler_pick_radius { 10.f };
|
||||
|
||||
std::string_view coupler_type_name( TCouplerType const Type ) {
|
||||
switch( Type ) {
|
||||
case TCouplerType::Articulated: { return "articulated"; }
|
||||
case TCouplerType::Bare: { return "bare"; }
|
||||
case TCouplerType::Chain: { return "chain"; }
|
||||
case TCouplerType::Screw: { return "screw"; }
|
||||
case TCouplerType::Automatic: { return "automatic"; }
|
||||
default: { return "none"; }
|
||||
}
|
||||
}
|
||||
|
||||
// the couplerphysics setting of eu07.ini
|
||||
std::string_view coupler_physics_setting() {
|
||||
if( Global.coupler_physics_all ) { return "all"; }
|
||||
return Global.coupler_physics ? "yes" : "no";
|
||||
}
|
||||
|
||||
std::string_view coupler_stop_name( int const Stop ) {
|
||||
if( Stop > 0 ) { return "draw gear solid"; }
|
||||
if( Stop < 0 ) { return "buffers solid"; }
|
||||
return "none";
|
||||
}
|
||||
|
||||
// a value shown in the Scale of its unit (1000 for kN, 0.001 for mm), dragged within Min and Max of that unit
|
||||
bool edit_value( char const *Label, double &Value, double const Scale, double const Min, double const Max, char const *Format ) {
|
||||
auto shown { Value / Scale };
|
||||
if( false == ImGui::DragScalar( Label, ImGuiDataType_Double, &shown, static_cast<float>( ( Max - Min ) / 1000.0 ), &Min, &Max, Format ) ) {
|
||||
return false;
|
||||
}
|
||||
Value = std::clamp( shown, Min, Max ) * Scale;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool edit_spring( char const *Name, coupler_physics::spring_curve &Curve, double &Unloading ) {
|
||||
ImGui::PushID( Name );
|
||||
ImGui::TextUnformatted( Name );
|
||||
auto changed { edit_value( "Stiffness [kN/m]", Curve.stiffness, 1000.0, 100.0, 50000.0, "%.0f" ) };
|
||||
changed = edit_value( "Travel [mm]", Curve.travel, 0.001, 5.0, 300.0, "%.0f" ) || changed;
|
||||
changed = edit_value( "Progression", Curve.progression, 1.0, 0.0, 0.9, "%.2f" ) || changed;
|
||||
changed = edit_value( "Unloading ratio", Unloading, 1.0, 0.05, 1.0, "%.2f" ) || changed;
|
||||
ImGui::Text( "End force: %.0f kN", Curve.end_force() / 1000.0 );
|
||||
ImGui::PopID();
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool edit_link( coupler_physics::end_parameters &Parameters ) {
|
||||
auto &link { Parameters.link };
|
||||
ImGui::PushID( "link" );
|
||||
ImGui::TextUnformatted( "Link" );
|
||||
auto changed { ImGui::Checkbox( "Breakable", &link.breakable ) };
|
||||
changed = edit_value( "Ultimate force [kN]", link.ultimate, 1000.0, 10.0, 5000.0, "%.0f" ) || changed;
|
||||
changed = edit_value( "Yield force [kN]", link.yield, 1000.0, 10.0, 5000.0, "%.0f" ) || changed;
|
||||
link.yield = std::min( link.yield, link.ultimate );
|
||||
// the permanent stretch at which the link breaks, which is what the hardening gives
|
||||
auto stretch { ( link.ultimate - link.yield ) / link.hardening };
|
||||
if( edit_value( "Stretch to break [mm]", stretch, 0.001, 1.0, 200.0, "%.1f" ) ) {
|
||||
link.hardening = std::max( ( link.ultimate - link.yield ) / stretch, 1.0 );
|
||||
changed = true;
|
||||
}
|
||||
changed = edit_value( "Link stiffness [kN/m]", Parameters.link_stiffness, 1000.0, 1000.0, 2000000.0, "%.0f" ) || changed;
|
||||
changed = edit_value( "Buffers crush force [kN]", Parameters.crush_force, 1000.0, 100.0, 10000.0, "%.0f" ) || changed;
|
||||
changed = edit_value( "Restitution of a solid hit", Parameters.solid_restitution, 1.0, 0.05, 0.95, "%.2f" ) || changed;
|
||||
ImGui::PopID();
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool edit_coupler_parameters( coupler_physics::end_parameters &Parameters ) {
|
||||
auto changed { edit_value( "Slack [mm]", Parameters.slack, 0.001, -100.0, 300.0, "%.1f" ) };
|
||||
changed = edit_value( "Damping [kN s/m]", Parameters.damping, 1000.0, 0.0, 1000.0, "%.1f" ) || changed;
|
||||
changed = edit_spring( "Buffers", Parameters.buffers, Parameters.buffers_unloading ) || changed;
|
||||
changed = edit_spring( "Draw gear", Parameters.draw_gear, Parameters.draw_gear_unloading ) || changed;
|
||||
changed = edit_link( Parameters ) || changed;
|
||||
return changed;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
debug_panel::update_section_coupler( std::vector<text_line> &Output ) {
|
||||
|
||||
m_coupler = {};
|
||||
if( m_input.camera == nullptr ) { return; }
|
||||
auto const &camera { m_input.camera->Pos };
|
||||
auto const *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera, coupler_pick_radius, false, true ) ) };
|
||||
if( vehicle == nullptr || vehicle->MoverParameters == nullptr ) {
|
||||
Output.emplace_back( std::format( "No coupler within {:.0f} m of the camera", coupler_pick_radius ), Global.UITextColor );
|
||||
return;
|
||||
}
|
||||
auto const nearerfront { glm::distance( vehicle->CouplerPosition( end::front ), camera ) <= glm::distance( vehicle->CouplerPosition( end::rear ), camera ) };
|
||||
m_coupler = { vehicle, nearerfront ? end::front : end::rear };
|
||||
|
||||
auto const &mover { *vehicle->MoverParameters };
|
||||
auto const &coupler { mover.Couplers[ m_coupler.end ] };
|
||||
auto const &neighbour { mover.Neighbours[ m_coupler.end ] };
|
||||
auto const &state { coupler.physics_state };
|
||||
|
||||
Output.emplace_back(
|
||||
std::format( "{}, {} end, {} coupler{}", vehicle->name(), nearerfront ? "front" : "rear", coupler_type_name( coupler.type() ), coupler.has_adapter() ? " (adapter)" : "" ),
|
||||
Global.UITextColor );
|
||||
Output.emplace_back(
|
||||
std::format(
|
||||
"Model: {} (couplerphysics {}, vehicle {}covered), crash damage {}",
|
||||
mover.coupler_physics_at( m_coupler.end ) ? "physical" : "legacy",
|
||||
coupler_physics_setting(),
|
||||
mover.CouplerPhysics ? "" : "not ",
|
||||
Global.crash_damage ? "on" : "off" ),
|
||||
Global.UITextColor );
|
||||
if( neighbour.vehicle != nullptr ) {
|
||||
Output.emplace_back(
|
||||
std::format( "Neighbour: {} ({} end), coupling [{}], gap {:.1f} mm", neighbour.vehicle->name(), neighbour.vehicle_end == end::front ? "front" : "rear", coupler.CouplingFlag, neighbour.distance * 1000.0 ),
|
||||
Global.UITextColor );
|
||||
}
|
||||
else {
|
||||
Output.emplace_back( "Neighbour: none", Global.UITextColor );
|
||||
}
|
||||
Output.emplace_back( std::format( "Force: {:.1f} kN", coupler.CForce / 1000.0 ), Global.UITextColor );
|
||||
Output.emplace_back(
|
||||
std::format( "Draw gear: {:.1f} mm, {:.1f} kN Buffers: {:.1f} mm, {:.1f} kN", state.draw_gear.deflection * 1000.0, state.draw_gear.force / 1000.0, state.buffers.deflection * 1000.0, state.buffers.force / 1000.0 ),
|
||||
Global.UITextColor );
|
||||
Output.emplace_back(
|
||||
std::format( "Stretch: {:.1f} mm, stop: {}, overloaded for {:.1f} s", state.elongation * 1000.0, coupler_stop_name( state.stop ), coupler.stretch_duration ),
|
||||
Global.UITextColor );
|
||||
if( coupler.broken ) {
|
||||
Output.emplace_back( "Coupler broken (repair it in the driving aid, F1)", glm::vec4( 1.f, 0.25f, 0.25f, 1.f ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
debug_panel::render_section_coupler() {
|
||||
|
||||
if( false == render_section( "Coupler", m_couplerlines ) ) { return false; }
|
||||
// the parameters to try out, in the debug mode, on the simulation itself
|
||||
if( false == DebugModeFlag || m_coupler.vehicle == nullptr || Application.is_client() ) { return true; }
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Checkbox( "Physical coupler model", &Global.coupler_physics );
|
||||
ImGui::Checkbox( "Physical model for every train", &Global.coupler_physics_all );
|
||||
ImGui::Checkbox( "Crash damage", &Global.crash_damage );
|
||||
ImGui::Checkbox( "Apply to the other end of the pair too", &m_couplerbothends );
|
||||
|
||||
auto &mover { *m_coupler.vehicle->MoverParameters };
|
||||
auto &coupler { mover.Couplers[ m_coupler.end ] };
|
||||
auto const &neighbour { mover.Neighbours[ m_coupler.end ] };
|
||||
auto *othercoupler { neighbour.vehicle != nullptr ? &neighbour.vehicle->MoverParameters->Couplers[ neighbour.vehicle_end ] : nullptr };
|
||||
|
||||
if( auto parameters { coupler.physics }; edit_coupler_parameters( parameters ) ) {
|
||||
coupler.physics = parameters;
|
||||
if( m_couplerbothends && othercoupler != nullptr ) {
|
||||
othercoupler->physics = parameters;
|
||||
}
|
||||
}
|
||||
if( ImGui::Button( "Reset the stretch of the coupling" ) ) {
|
||||
// both vehicles keep the state of the pair alike
|
||||
coupler.physics_state.elongation = 0.0;
|
||||
if( othercoupler != nullptr ) {
|
||||
othercoupler->physics_state.elongation = 0.0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
debug_panel::render_section( std::string const &Header, std::vector<text_line> const &Lines ) {
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ public:
|
||||
private:
|
||||
// members
|
||||
std::array<char, 256> m_buffer;
|
||||
// the broken coupler next to the camera, which the panel offers to repair: the vehicle and its end
|
||||
TDynamicObject const *m_brokenvehicle { nullptr };
|
||||
int m_brokenend { 0 };
|
||||
};
|
||||
|
||||
class timetable_panel : public ui_expandable_panel {
|
||||
@@ -89,6 +92,8 @@ private:
|
||||
void update_section_powergrid( std::vector<text_line> &Output ) const;
|
||||
void update_section_camera( std::vector<text_line> &Output ) const;
|
||||
void update_section_renderer( std::vector<text_line> &Output ) const;
|
||||
// the coupler nearest to the camera, and the state of its coupling
|
||||
void update_section_coupler( std::vector<text_line> &Output );
|
||||
#ifdef WITH_UART
|
||||
void update_section_uart( std::vector<text_line> &Output ) const;
|
||||
#endif
|
||||
@@ -100,6 +105,8 @@ private:
|
||||
bool render_section( std::vector<text_line> const &Lines ) const;
|
||||
bool render_section_scenario();
|
||||
bool render_section_eventqueue();
|
||||
// the coupler section, with the parameters of the physical model to try out in the debug mode
|
||||
bool render_section_coupler();
|
||||
bool render_section_settings() const;
|
||||
bool render_section_developer() const;
|
||||
// members
|
||||
@@ -116,6 +123,14 @@ private:
|
||||
std::vector<text_line> m_powergridlines;
|
||||
std::vector<text_line> m_rendererlines;
|
||||
std::vector<text_line> m_uartlines;
|
||||
std::vector<text_line> m_couplerlines;
|
||||
// the coupler nearest to the camera
|
||||
struct coupler_pick {
|
||||
TDynamicObject const *vehicle { nullptr };
|
||||
int end { 0 };
|
||||
};
|
||||
coupler_pick m_coupler;
|
||||
bool m_couplerbothends { true }; // changes to the parameters apply to the end of the other vehicle of the pair too
|
||||
|
||||
double last_time = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ extern char **environ;
|
||||
#include "simulation/simulation.h"
|
||||
#include "simulation/simulationtime.h"
|
||||
#include "simulation/simulationenvironment.h"
|
||||
#include "simulation/blackboxrecorder.h"
|
||||
#include "utilities/Timer.h"
|
||||
#include "Console.h"
|
||||
#include "rendering/renderer.h"
|
||||
@@ -5060,6 +5061,8 @@ void editor_mode::update_camera(double const Deltatime)
|
||||
void editor_mode::enter()
|
||||
{
|
||||
m_statebackup = {Global.pCamera, FreeFlyModeFlag, Global.ControlPicking};
|
||||
// the editor may remove the tracks and the vehicles the recording refers to: it ends here
|
||||
simulation::Blackbox.close();
|
||||
|
||||
if (simulation::Region != nullptr)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user