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/staging7ac2472c3into feat/gl46-migrationdb26a33ed, so that #468 merges into staging. Merge base037158104. Staging carries master up to571487612(squashed in #514); this branch had merged master up to7c12b83ba. 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'sf4f8c75e4(road orders measured along the lane) and8fbf05674(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:
@@ -23,8 +23,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "world/catenary_span.h"
|
||||
#include "vehicle/Camera.h"
|
||||
#include "world/mtable.h"
|
||||
#include "world/stationnames.h"
|
||||
#include "vehicle/Train.h"
|
||||
#include "vehicle/Driver.h"
|
||||
#include "vehicle/drivingaid.h"
|
||||
#include "model/AnimModel.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "model/Model3d.h"
|
||||
@@ -41,6 +43,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#endif
|
||||
|
||||
#include <format>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "audio/audiorenderer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -78,6 +84,13 @@ drivingaid_panel::update() {
|
||||
auto const *mover = controlled->MoverParameters;
|
||||
auto const *vehicledriver = controlled->Mechanik;
|
||||
auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik;
|
||||
// the numbers of the throttle and brakes lines, with the controls of the cab the driver is in
|
||||
auto const readout { drivingaid::compute( drivingaid::from_movers(
|
||||
*mover,
|
||||
*vehicledriver->Controlling(),
|
||||
drivingaid::cab_controls {
|
||||
train->ggLocalBrake.SubModel != nullptr,
|
||||
train->ggJointCtrl.SubModel != nullptr } ) ) };
|
||||
|
||||
{ // throttle, velocity, speed limits and grade
|
||||
std::string expandedtext;
|
||||
@@ -118,8 +131,8 @@ drivingaid_panel::update() {
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C("Throttle: %3d+%d %c%s"),
|
||||
mover->EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * mover->eimic_real)) : vehicledriver->Controlling()->MainCtrlPos,
|
||||
mover->EIMCtrlType > 0 ? vehicledriver->Controlling()->MainCtrlPos : vehicledriver->Controlling()->ScndCtrlPos,
|
||||
readout.throttle_first,
|
||||
readout.throttle_second,
|
||||
mover->SpeedCtrlUnit.IsActive ? 'T' :
|
||||
mover->DirActive > 0 ? 'D' :
|
||||
mover->DirActive < 0 ? 'R' :
|
||||
@@ -139,16 +152,32 @@ drivingaid_panel::update() {
|
||||
mover->PipePress * 100 );
|
||||
expandedtext = m_buffer.data();
|
||||
}
|
||||
auto const basicbraking { mover->fBrakeCtrlPos };
|
||||
auto const eimicbraking { std::max( 0.0, -100.0 * mover->eimic_real ) };
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C("Brakes: %5.1f+%-2.0f%c%s"),
|
||||
// ( mover->EIMCtrlType == 0 ? basicbraking : mover->EIMCtrlType == 3 ? ( mover->UniCtrlIntegratedBrakeCtrl ? eimicbraking : basicbraking ) : eimicbraking ),
|
||||
mover->UniCtrlIntegratedBrakeCtrl ? eimicbraking : basicbraking,
|
||||
mover->LocalBrakePosA * LocalBrakePosNo,
|
||||
mover->SlippingWheels ? '!' : ' ',
|
||||
expandedtext.c_str() );
|
||||
if( readout.ed_percent ) {
|
||||
// the ED braking demand, ahead of the expanded data (eu07/maszyna#558)
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C(" ED brake: %d%%%%"),
|
||||
*readout.ed_percent );
|
||||
expandedtext.insert( 0, m_buffer.data() );
|
||||
}
|
||||
if( readout.show_local_brake ) {
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C("Brakes: %5.1f+%-2.0f%c%s"),
|
||||
readout.brake_first,
|
||||
readout.local_brake,
|
||||
mover->SlippingWheels ? '!' : ' ',
|
||||
expandedtext.c_str() );
|
||||
}
|
||||
else {
|
||||
// the cab has no local brake control: its setting is left out (eu07/maszyna#555)
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C("Brakes: %5.1f%c%s"),
|
||||
readout.brake_first,
|
||||
mover->SlippingWheels ? '!' : ' ',
|
||||
expandedtext.c_str() );
|
||||
}
|
||||
|
||||
text_lines.emplace_back( m_buffer.data(), Global.UITextColor );
|
||||
}
|
||||
@@ -328,9 +357,10 @@ timetable_panel::update() {
|
||||
|
||||
// destination
|
||||
{
|
||||
auto textline = Bezogonkow( owner->Relation(), true );
|
||||
// the names with the letters their files have, in utf-8 as the user interface takes it
|
||||
auto textline = table.relation_caption();
|
||||
if( false == textline.empty() ) {
|
||||
textline += " (" + Bezogonkow( owner->TrainName(), true ) + ")";
|
||||
textline += " (" + data_name_to_utf8( owner->TrainName(), true ) + ")";
|
||||
}
|
||||
text_lines.emplace_back( textline, Global.UITextColor );
|
||||
}
|
||||
@@ -397,10 +427,9 @@ timetable_panel::update() {
|
||||
vmax += to_string( tableline->vmax, 0 );
|
||||
vmax = vmax.substr( vmax.size() - 3, 3 ); // z wyrównaniem do prawej
|
||||
}
|
||||
auto const station { (
|
||||
Bezogonkow( tableline->StationName, true )
|
||||
+ " " )
|
||||
.substr( 0, 34 ) };
|
||||
// the name as the timetable spells it; in utf-8 a letter can take more than one byte, the column is
|
||||
// 34 characters wide
|
||||
auto const station { utf8_fit( timetable::station_caption( tableline->StationLabel ), 34 ) };
|
||||
auto const location { (
|
||||
( tableline->km > 0.0 ?
|
||||
to_string( tableline->km, 2 ) :
|
||||
@@ -1159,7 +1188,7 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) const {
|
||||
if( mechanik.VelNext == 0.0
|
||||
&& mechanik.eSignNext ) {
|
||||
// jeśli ma zapamiętany event semafora, nazwa eventu semafora
|
||||
Output.emplace_back( "Current signal: " + Bezogonkow( mechanik.eSignNext->m_name ), Global.UITextColor );
|
||||
Output.emplace_back( "Current signal: " + data_name_to_utf8( mechanik.eSignNext->m_name ), Global.UITextColor );
|
||||
}
|
||||
|
||||
// distances
|
||||
@@ -1270,7 +1299,7 @@ debug_panel::update_section_scantable( std::vector<text_line> &Output ) const {
|
||||
do {
|
||||
auto const scanline = mechanik.TableText( i );
|
||||
if( scanline.empty() ) { break; }
|
||||
Output.emplace_back( Bezogonkow( scanline ), Global.UITextColor );
|
||||
Output.emplace_back( data_name_to_utf8( scanline ), Global.UITextColor );
|
||||
++i;
|
||||
} while( i < speedtablesize );
|
||||
if( Output.size() == 1 ) {
|
||||
@@ -1721,6 +1750,81 @@ bool debug_panel::render_section_developer() const
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// a combo choosing one of the names, the first entry standing for the library's own choice. the names are asked for
|
||||
// each time the list opens, as devices come and go. returns: true if the choice changed
|
||||
template <class Names_>
|
||||
bool name_combo( char const *Label, std::string &Value, Names_ const &Names, char const *Defaultlabel, std::string_view const Defaultvalue ) {
|
||||
|
||||
auto const preview { Value == Defaultvalue ? std::string{ Defaultlabel } : Value };
|
||||
if( false == ImGui::BeginCombo( Label, preview.c_str() ) ) { return false; }
|
||||
|
||||
static std::vector<std::string> names; // one list per call site, as each passes its own lambda
|
||||
if( ImGui::IsWindowAppearing() ) {
|
||||
names = Names();
|
||||
}
|
||||
auto changed { false };
|
||||
if( ImGui::Selectable( Defaultlabel, Value == Defaultvalue ) ) {
|
||||
Value = Defaultvalue;
|
||||
changed = true;
|
||||
}
|
||||
for( auto const &name : names ) {
|
||||
if( ImGui::Selectable( name.c_str(), name == Value ) ) {
|
||||
Value = name;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
return changed;
|
||||
}
|
||||
|
||||
// options of the audio device, applied by reopening it: output device, output mode, HRTF, limiter, mixing rate, sources
|
||||
void render_audio_device_settings() {
|
||||
|
||||
auto changed { false };
|
||||
changed |= name_combo( "Output device###audiodevice", Global.AudioRenderer,
|
||||
[] { return audio::renderer.output_devices(); }, "System default", "" );
|
||||
changed |= name_combo( "Output mode###audiooutputmode", Global.AudioOutputMode,
|
||||
[] { return std::vector<std::string>{ "mono", "stereo", "stereo-basic", "uhj", "headphones", "quad", "5.1", "6.1", "7.1" }; },
|
||||
"Automatic", "auto" );
|
||||
changed |= name_combo( "HRTF###audiohrtf", Global.AudioHrtf,
|
||||
[] { return std::vector<std::string>{ "on", "off" }; }, "Automatic", "auto" );
|
||||
changed |= name_combo( "HRTF data set###audiohrtfprofile", Global.AudioHrtfProfile,
|
||||
[] { return audio::renderer.hrtf_profiles(); }, "Library's choice", "" );
|
||||
changed |= name_combo( "Limiter###audiolimiter", Global.AudioLimiter,
|
||||
[] { return std::vector<std::string>{ "on", "off" }; }, "Automatic", "auto" );
|
||||
|
||||
auto frequency { Global.AudioFrequency > 0 ? std::to_string( Global.AudioFrequency ) : std::string{} };
|
||||
if( name_combo( "Mixing rate###audiofrequency", frequency,
|
||||
[] { return std::vector<std::string>{ "22050", "32000", "44100", "48000", "96000" }; }, "Device's", "" ) ) {
|
||||
Global.AudioFrequency = ( frequency.empty() ? 0 : std::stoi( frequency ) );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if( changed ) {
|
||||
audio::renderer.apply_device_settings();
|
||||
}
|
||||
}
|
||||
|
||||
// options of the sources, applied to the playing ones right away: resampler, Doppler effect, EFX
|
||||
void render_audio_source_settings() {
|
||||
|
||||
auto changed { false };
|
||||
changed |= name_combo( "Resampler###audioresampler", Global.AudioResampler,
|
||||
[] { return audio::renderer.resamplers(); }, "Library's default", "" );
|
||||
changed |= ImGui::SliderFloat( ( to_string( Global.AudioDoppler, 2 ) + "###audiodoppler" ).c_str(), &Global.AudioDoppler, 0.0f, 1.0f, "Doppler effect" );
|
||||
changed |= ImGui::Checkbox( "Soundproofing muffles high frequencies###audiolowpass", &Global.AudioLowpass );
|
||||
changed |= ImGui::SliderFloat( ( to_string( Global.AudioAirAbsorption, 1 ) + "###audioairabsorption" ).c_str(), &Global.AudioAirAbsorption, 0.0f, 10.0f, "Air absorption" );
|
||||
|
||||
if( changed ) {
|
||||
audio::renderer.apply_source_settings();
|
||||
}
|
||||
ImGui::TextWrapped( "%s", audio::renderer.device_status().c_str() );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool
|
||||
debug_panel::render_section_settings() const {
|
||||
|
||||
@@ -1775,6 +1879,10 @@ debug_panel::render_section_settings() const {
|
||||
commandrelay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
|
||||
}
|
||||
}
|
||||
if( Global.bSoundEnabled ) {
|
||||
render_audio_device_settings();
|
||||
render_audio_source_settings();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user