18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-29 20:23:33 +01:00

Merge staging into feat/gl46-migration

origin/staging 7ac2472c3 into feat/gl46-migration db26a33ed, so that #468
merges into staging. Merge base 037158104. Staging carries master up to
571487612 (squashed in #514); this branch had merged master up to 7c12b83ba.

Conflicts, file by file:
- README.md: WITH_BETTER_RENDERER row dropped (gl46), USE_SYSTEM_JSON row kept (staging)
- CMakeLists.txt: gl46 lists, plus staging's new core sources (hardwareinfo, sn_utils, regionfile, inionlysettings, fieldshunting, gaugewrap, drivingaid, signalpassing, brakereleaser, crew, brakecharge); none listed twice
- tests/unit/CMakeLists.txt: both (texturealpha, freecameramotion; editorSwitchDrives, Camera)
- vehicle/brakingcurve.{h,cpp}, tests/unit/test_braking_curve.cpp (add/add): staging (#479 brake_acting on the same #409 code)
- editor/editorHttp.cpp: staging (it has gl46's #432 and certificate fixes, plus #439 libcurl loaded at run time)
- tests/unit/test_editor_http.cpp (add/add): staging (adds the available() case of #439)
- utilities/Globals.h: gl46 crashdump_full (staging's CrashDumpFull is #425, replaced here by utilities/crashdump.cpp); fmradio and staging's OpenAL options both; gfx_headlights_beamwidth (#481) not taken
- utilities/Globals.cpp: both (odometer.expiry, OpenAL keys, fmradio, gl46 gfx keys); gfx.headlights.beamwidth (#481) not taken
- utilities/Logs.cpp: staging's log_file_name() for both files, with gl46's crashdump_set_log_file() for both
- utilities/utilities.h: gl46 set_thread_random_engine(); Random(int, int) gone on both sides
- tests/unit/test_utilities.cpp: staging's includes
- simulation/simulationtest.cpp: gl46 (no NvRenderer, LegacyRenderer, BasicRenderer here)
- ci_shadervalidator/* (incl. add/add utilities/Logs.h): gl46's validator of shaders/ogl46 and shaders/vk14; staging's #437 fixed the GL 3.3 one
- gl/shader.cpp, gl/glsl_common.cpp: gl46 (shaders come from rendering/common/shadersource.cpp); HEADLIGHT_BEAM_WIDTH (#481) not taken
- shaders/mat_wire.frag: gl46. Rename detection paired staging's mat_colored.frag (#481) with it
- lang/editor_pl.po: union; the 12 camera speed / orthophoto entries staging adds are here already (master #312)
- audio/audiorenderer.{h,cpp}: both (fmradio; startsample and the low-pass filter); the destructor releases the radio, then the filter
- application/editormode.h, application/editormodeswitchdrive.cpp: staging (#509 on #330, which is all this side had)
- application/application.cpp: gl46's start sequence (no init_ogl, ANGLE or NvRenderer; crash window after init_ui) with staging's hardware::log_system() (#389)
- EU07.cpp: gl46 (crash reports of utilities/crashdump.cpp); staging's side was #425's handler, replaced here
- model/Texture.{h,cpp}: gl46 (texture_source); staging's side is master #399/#411/#362/#386, merged here before
- world/Track.h, world/TrackSleepers.h: both (TrackBlend, lay(Fastened)/fasten; TrackBuckle, pack_models)
- world/Segment.cpp: staging's track buckling on the split stray factors both sides have
- vehicle/Driver.h: staging's additions (#444, #494, #473, #346, timetable flags)
- vehicle/Driver.cpp: staging's file, with this branch's f4f8c75e4 (road orders measured along the lane) and 8fbf05674 (a holding road order blocks the ones past it) applied again; #409's SeenAheadTolerance gives way to #473
- vehicle/DynObj.h: friend opengl46_renderer and friend class vehicle_table
- vehicle/DynObj.cpp: gl46's vehicle_table::update() with staging's update_off_track_contacts() and update_brake_pipes()
- McZapkie/Mover.cpp: staging's function splits (#239) and hose exchange (#388); every line this branch added to Mover.cpp/MOVER.h is kept
- .github/workflows/build_bin.yml: staging's apt-install step (#497) and pinned download-artifact (#331)

Modify/delete, kept deleted:
- rendering/opengl33renderer.{cpp,h}, rendering/openglparticles.cpp, rendering/openglrenderer.{cpp,h}: staging's versions are master's, and every master change to them is in this branch's history already
- shaders/light_common.glsl, shaders/mat_sunlessnormalmap_specgloss.frag: see below

Carried into this branch's code:
- the hose exchange after each sub-step (#387/#388) also in update_steps_parallel(), per group of vehicles, as update() does it single-threaded
- physics.pipewake (pipe_wakes(), wake_cause::scndpipe) in staging's GetScndDVc(), where the main reservoir hose exchange went
- hardware::log_gl_context() (#389) in after_window() of the GL 4.6 backend, init_ogl() being gone

Taken back out of the auto-merge (renderers this branch removed):
- shaders/vk14/tonemapping.glsl: #481's switch to ACES, applied there by rename detection
- environment/skydome.cpp, simulation/simulationenvironment.cpp: #415, the sky of the legacy renderer
- application/application.cpp: #384's fallback of an unknown gfxrenderer, which this branch had dropped

Not carried from staging (renderer files removed here):
- master #481 (571487612): old assets drawn as in 26.05 (metal diffuse, sun highlight tint, ACES, SUN_DIFFUSE_SCALE 2.5, untinted Diffuse, mat_colored base) and gfx.headlights.beamwidth. Made for the GL 3.3 shaders; the PBR shaders of shaders/ogl46 and vk14 (and their SPIR-V binaries) are the author's call
- #437: the unique temporary file of the shader validator (Sonar S5443); gl46's validator still writes /tmp/shader*

Unit tests: 1133 of 1137 cases pass. Four staging tests fail (derailment: a
repaired vehicle is back on the rails; three pullee cases): the vehicle
stands, and with physics.sleepheld (on by default here) its physics sleeps
with the Fb / FStand of before. With physics.sleepheld off they pass. Left
to the author.
This commit is contained in:
jerrrrycho
2026-11-27 05:26:13 +01:00
397 changed files with 48215 additions and 5231 deletions

View File

@@ -423,6 +423,42 @@ commanddescription_sequence Commands_descriptions = {
{"linebreakeropenc", command_target::vehicle, command_mode::oneoff},
{"linebreakerclosec", command_target::vehicle, command_mode::oneoff},
{"repaircoupler", command_target::simulation, command_mode::oneoff},
{"genericset0", command_target::vehicle, command_mode::oneoff},
{"genericset1", command_target::vehicle, command_mode::oneoff},
{"genericset2", command_target::vehicle, command_mode::oneoff},
{"genericset3", command_target::vehicle, command_mode::oneoff},
{"genericset4", command_target::vehicle, command_mode::oneoff},
{"genericset5", command_target::vehicle, command_mode::oneoff},
{"genericset6", command_target::vehicle, command_mode::oneoff},
{"genericset7", command_target::vehicle, command_mode::oneoff},
{"genericset8", command_target::vehicle, command_mode::oneoff},
{"genericset9", command_target::vehicle, command_mode::oneoff},
{"genericset10", command_target::vehicle, command_mode::oneoff},
{"genericset11", command_target::vehicle, command_mode::oneoff},
{"genericset12", command_target::vehicle, command_mode::oneoff},
{"genericset13", command_target::vehicle, command_mode::oneoff},
{"genericset14", command_target::vehicle, command_mode::oneoff},
{"genericset15", command_target::vehicle, command_mode::oneoff},
{"genericset16", command_target::vehicle, command_mode::oneoff},
{"genericset17", command_target::vehicle, command_mode::oneoff},
{"genericset18", command_target::vehicle, command_mode::oneoff},
{"genericset19", command_target::vehicle, command_mode::oneoff},
{"genericset20", command_target::vehicle, command_mode::oneoff},
{"genericset21", command_target::vehicle, command_mode::oneoff},
{"genericset22", command_target::vehicle, command_mode::oneoff},
{"genericset23", command_target::vehicle, command_mode::oneoff},
{"genericset24", command_target::vehicle, command_mode::oneoff},
{"genericset25", command_target::vehicle, command_mode::oneoff},
{"genericset26", command_target::vehicle, command_mode::oneoff},
{"genericset27", command_target::vehicle, command_mode::oneoff},
{"genericset28", command_target::vehicle, command_mode::oneoff},
{"genericset29", command_target::vehicle, command_mode::oneoff},
{"tractionmodetoggle", command_target::vehicle, command_mode::oneoff},
{"tractionmodecatenary", command_target::vehicle, command_mode::oneoff},
{"tractionmodegenset", command_target::vehicle, command_mode::oneoff},
{"gensettoggle", command_target::vehicle, command_mode::oneoff},
{"gensetenable", command_target::vehicle, command_mode::oneoff},
{"gensetdisable", command_target::vehicle, command_mode::oneoff},
};
// Maps of command and coresponding strings
@@ -825,6 +861,42 @@ std::unordered_map<std::string, user_command> const commandMap = {
{"linebreakeropenc", user_command::linebreakeropenc},
{"linebreakerclosec", user_command::linebreakerclosec},
{"repaircoupler", user_command::repaircoupler},
{"genericset0", user_command::genericset0},
{"genericset1", user_command::genericset1},
{"genericset2", user_command::genericset2},
{"genericset3", user_command::genericset3},
{"genericset4", user_command::genericset4},
{"genericset5", user_command::genericset5},
{"genericset6", user_command::genericset6},
{"genericset7", user_command::genericset7},
{"genericset8", user_command::genericset8},
{"genericset9", user_command::genericset9},
{"genericset10", user_command::genericset10},
{"genericset11", user_command::genericset11},
{"genericset12", user_command::genericset12},
{"genericset13", user_command::genericset13},
{"genericset14", user_command::genericset14},
{"genericset15", user_command::genericset15},
{"genericset16", user_command::genericset16},
{"genericset17", user_command::genericset17},
{"genericset18", user_command::genericset18},
{"genericset19", user_command::genericset19},
{"genericset20", user_command::genericset20},
{"genericset21", user_command::genericset21},
{"genericset22", user_command::genericset22},
{"genericset23", user_command::genericset23},
{"genericset24", user_command::genericset24},
{"genericset25", user_command::genericset25},
{"genericset26", user_command::genericset26},
{"genericset27", user_command::genericset27},
{"genericset28", user_command::genericset28},
{"genericset29", user_command::genericset29},
{"tractionmodetoggle", user_command::tractionmodetoggle},
{"tractionmodecatenary", user_command::tractionmodecatenary},
{"tractionmodegenset", user_command::tractionmodegenset},
{"gensettoggle", user_command::gensettoggle},
{"gensetenable", user_command::gensetenable},
{"gensetdisable", user_command::gensetdisable},
{"none", user_command::none}};
} // namespace simulation

View File

@@ -421,6 +421,44 @@ enum class user_command
linebreakeropenc,
linebreakerclosec,
repaircoupler, // the broken coupler of the vehicle (payload) at the end (param1)
// sets universal control N to the position given in param1, 0-1 (MaSzyna-EU07/maszyna#62)
genericset0,
genericset1,
genericset2,
genericset3,
genericset4,
genericset5,
genericset6,
genericset7,
genericset8,
genericset9,
genericset10,
genericset11,
genericset12,
genericset13,
genericset14,
genericset15,
genericset16,
genericset17,
genericset18,
genericset19,
genericset20,
genericset21,
genericset22,
genericset23,
genericset24,
genericset25,
genericset26,
genericset27,
genericset28,
genericset29,
// the traction selector and the genset of a dual-mode vehicle (eu07/maszyna#536)
tractionmodetoggle,
tractionmodecatenary,
tractionmodegenset,
gensettoggle,
gensetenable,
gensetdisable,
none = -1
};

View File

@@ -103,6 +103,12 @@ driverkeyboard_input::default_bindings() {
{ fuelpumptoggle, {GLFW_KEY_F, ""} },
// fuelpumpenable,
// fuelpumpdisable,
{ tractionmodetoggle, {GLFW_KEY_G | keymodifier::shift, ""} },
// tractionmodecatenary,
// tractionmodegenset,
{ gensettoggle, {GLFW_KEY_G | keymodifier::control, ""} },
// gensetenable,
// gensetdisable,
{ oilpumptoggle, {GLFW_KEY_F | keymodifier::shift, ""} },
// oilpumpenable,
// oilpumpdisable,

View File

@@ -28,6 +28,8 @@ void
mouse_slider::bind( user_command const &Command ) {
m_command = Command;
m_universal.reset();
m_universaldrag.reset();
auto const *train { simulation::Train };
TMoverParameters const *vehicle { nullptr };
@@ -124,18 +126,47 @@ mouse_slider::bind( user_command const &Command ) {
m_analogue ? controledge - m_value * controlsize : controledge - m_value * stepsize - 0.5 * stepsize );
}
void
mouse_slider::bind_universal( int const Index, universal_drag::direction const Drag, float const Position ) {
m_command = static_cast<user_command>( static_cast<int>( user_command::genericset0 ) + Index );
m_universal = Index;
m_universaldrag.emplace( Drag, Position );
m_value = m_universaldrag->position();
m_valuerange = 1.0;
m_analogue = true;
m_invertrange = false;
// the cursor is hidden for the drag and put back where it was when the drag ends; the drag follows its moves
// from wherever it is, so it isn't placed anywhere
m_cursorposition = glm::dvec2( Global.cursor_pos );
Application.set_cursor( GLFW_CURSOR_DISABLED );
}
void
mouse_slider::release() {
m_command = user_command::none;
m_universal.reset();
m_universaldrag.reset();
Application.set_cursor_pos( m_cursorposition.x, m_cursorposition.y );
Application.set_cursor( GLFW_CURSOR_NORMAL );
}
void
mouse_slider::on_move( double const /*Mousex*/, double const Mousey ) {
bool
mouse_slider::on_move( double const Mousex, double const Mousey ) {
auto const controlsize { Global.window_size.y * EU07_CONTROLLER_MOUSESLIDERSIZE };
if( m_universaldrag ) {
// a universal control, dragged the same way as the controllers: the move of the cursor over the size of the
// slider takes it from one end to the other
if( false == m_universaldrag->move( Mousex, Mousey, controlsize ) ) {
return false;
}
m_value = m_universaldrag->position();
return true;
}
auto const controledge { Global.window_size.y * 0.5 + controlsize * 0.5 };
auto const stepsize { controlsize / m_valuerange };
@@ -143,6 +174,7 @@ mouse_slider::on_move( double const /*Mousex*/, double const Mousey ) {
m_value = m_analogue ? (controledge - mousey) / controlsize : std::floor((controledge - mousey) / stepsize);
if( m_invertrange ) {
m_value = ( m_analogue ? 1.0 : m_valuerange ) - m_value; }
return true;
}
@@ -246,8 +278,8 @@ drivermouse_input::move( double Mousex, double Mousey ) {
}
else {
// control picking mode
if( m_slider.command() != user_command::none ) {
m_slider.on_move( Mousex, Mousey );
if( m_slider.command() != user_command::none
&& true == m_slider.on_move( Mousex, Mousey ) ) {
m_relay.post(
m_slider.command(),
m_slider.value(),
@@ -341,7 +373,14 @@ drivermouse_input::button( int const Button, int const Action ) {
else {
m_pickwaiting = false;
if (Button == GLFW_MOUSE_BUTTON_LEFT && m_slider.command() != user_command::none) {
m_relay.post( m_slider.command(), 0, 0, Action, 0 );
if( auto const universal { m_slider.universal() };
universal && m_slider.is_click() ) {
// a universal control clicked rather than dragged goes to its end, as a click on any universal does
toggle_universal( *universal );
}
else {
m_relay.post( m_slider.command(), 0, 0, Action, 0 );
}
m_slider.release();
}
// if it's the right mouse button that got released and we had no command active, we were potentially in view panning mode; stop it
@@ -392,6 +431,25 @@ drivermouse_input::button( int const Button, int const Action ) {
default: { break; }
}
}
// a universal control with drag: in its definition is dragged to any position between its ends,
// and a click without dragging toggles it as before (MaSzyna-EU07/maszyna#62)
if( Button == GLFW_MOUSE_BUTTON_LEFT ) {
auto const universal { universal_index( mousecommand ) };
auto const drag {
universal ?
simulation::Train->universal_drag_direction( *universal ) :
universal_drag::direction::none };
if( drag != universal_drag::direction::none ) {
mousecommand = none;
if( false == pickwaiting ) {
// the button was let go before the control was found under the cursor: a click
toggle_universal( *universal );
return;
}
m_slider.bind_universal( *universal, drag, simulation::Train->universal_position( *universal ) );
return;
}
}
switch( mousecommand ) {
case mastercontrollerincrease:
@@ -558,6 +616,9 @@ drivermouse_input::default_bindings() {
{ "maxcurrent_sw:", {
motoroverloadrelaythresholdtoggle,
none } },
{ "autorelay_sw:", {
notchingrelaytoggle,
none } },
{ "waterpumpbreaker_sw:", {
waterpumpbreakertoggle,
none } },
@@ -579,6 +640,12 @@ drivermouse_input::default_bindings() {
{ "oilfuelpump_sw:", {
oilfuelpumptoggle,
none } },
{ "tractionmode_sw:", {
tractionmodetoggle,
none } },
{ "genset_sw:", {
gensettoggle,
none } },
{ "motorblowersfront_sw:", {
motorblowerstogglefront,
none } },
@@ -1171,4 +1238,23 @@ drivermouse_input::adjust_command( user_command Command ) const {
return Command;
}
std::optional<int>
drivermouse_input::universal_index( user_command const Command ) {
auto const index { static_cast<int>( Command ) - static_cast<int>( user_command::generictoggle0 ) };
if( index < 0
|| index > static_cast<int>( user_command::generictoggle29 ) - static_cast<int>( user_command::generictoggle0 ) ) {
return std::nullopt;
}
return index;
}
void
drivermouse_input::toggle_universal( int const Index ) const {
auto const toggle { static_cast<user_command>( static_cast<int>( user_command::generictoggle0 ) + Index ) };
m_relay.post( toggle, 0, 0, GLFW_PRESS, 0 );
m_relay.post( toggle, 0, 0, GLFW_RELEASE, 0 );
}
//---------------------------------------------------------------------------

View File

@@ -9,8 +9,10 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <optional>
#include <unordered_map>
#include "input/command.h"
#include "vehicle/universaldrag.h"
// virtual slider; value determined by position of the mouse
class mouse_slider {
@@ -21,9 +23,14 @@ public:
// methods
void
bind( user_command const &Command );
// binds the slider to universal control Index, which the mouse drags in the Drag direction from its Position
// to any position between its ends (MaSzyna-EU07/maszyna#62)
void
bind_universal( int const Index, universal_drag::direction const Drag, float const Position );
void
release();
void
// returns whether the value changed
bool
on_move( double const Mousex, double const Mousey );
inline
user_command
@@ -32,10 +39,19 @@ public:
double
value() const {
return m_value; }
// the universal control the slider drags, if any, and whether letting it go now is a click rather than a drag
std::optional<int>
universal() const {
return m_universal; }
bool
is_click() const {
return m_universaldrag && m_universaldrag->is_click(); }
private:
// members
user_command m_command { user_command::none };
std::optional<int> m_universal; // the universal control dragged, if any
std::optional<universal_drag::drag> m_universaldrag;
double m_value { 0.0 };
double m_valuerange { 0.0 };
bool m_analogue { false };
@@ -92,6 +108,12 @@ private:
// potentially replaces supplied command with a more relevant one
user_command
adjust_command( user_command Command ) const;
// the universal control a command toggles, if it toggles one
static std::optional<int>
universal_index( user_command const Command );
// toggles universal control Index, as a click on it does
void
toggle_universal( int const Index ) const;
// members
command_relay m_relay;