From 3f7960aad5019277d13798daa2f00493e3012010 Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 9 Sep 2026 20:35:26 +0200 Subject: [PATCH] pch migration to modules [wip] --- .github/workflows/build.yml | 8 +- .github/workflows/build_bin.yml | 12 +- CMakeLists.txt | 121 +++++- Console.cpp | 19 +- Console.h => Console.cppm | 20 +- Console/LPT.cpp | 6 +- Console/{LPT.h => LPT.cppm} | 10 +- Console/PoKeys55.cpp | 9 +- Console/{PoKeys55.h => PoKeys55.cppm} | 10 +- EU07.cpp | 37 +- McZapkie/{MOVER.h => MOVER.cppm} | 226 +++++------ McZapkie/MOVER_macros.h | 11 + McZapkie/Mover.cpp | 33 +- McZapkie/Oerlikon_ESt.cpp | 12 +- .../{Oerlikon_ESt.h => Oerlikon_ESt.cppm} | 55 +-- McZapkie/friction.cpp | 6 +- McZapkie/{friction.h => friction.cppm} | 11 +- McZapkie/hamulce.cpp | 42 ++- McZapkie/{hamulce.h => hamulce.cppm} | 148 ++++---- application/application.cpp | 95 +++-- .../{application.h => application.cppm} | 29 +- ...applicationmode.h => applicationmode.cppm} | 10 +- application/driverhints.cpp | 16 +- application/driverhints.cppm | 17 + application/driverhints.h | 21 -- application/driverhints_texts.h | 15 + application/drivermode.cpp | 56 +-- application/{drivermode.h => drivermode.cppm} | 40 +- application/driveruilayer.cpp | 27 +- .../{driveruilayer.h => driveruilayer.cppm} | 30 +- application/driveruipanels.cpp | 70 ++-- .../{driveruipanels.h => driveruipanels.cppm} | 19 +- application/editormode.cpp | 61 +-- application/{editormode.h => editormode.cppm} | 35 +- application/editoruilayer.cpp | 17 +- .../{editoruilayer.h => editoruilayer.cppm} | 17 +- application/editoruipanels.cpp | 32 +- .../{editoruipanels.h => editoruipanels.cppm} | 19 +- application/scenarioloadermode.cpp | 30 +- ...ioloadermode.h => scenarioloadermode.cppm} | 15 +- application/scenarioloaderuilayer.cpp | 20 +- ...eruilayer.h => scenarioloaderuilayer.cppm} | 17 +- application/uilayer.cpp | 40 +- application/{uilayer.h => uilayer.cppm} | 52 ++- application/uitranscripts.cpp | 15 +- .../{uitranscripts.h => uitranscripts.cppm} | 13 +- audio/audio.cpp | 25 +- audio/{audio.h => audio.cppm} | 50 ++- audio/audiorenderer.cpp | 33 +- audio/audiorenderer.h | 168 --------- audio/audiorenderer_extra.h | 1 + audio/audiorenderer_macros.h | 8 + audio/sound.cpp | 53 ++- audio/{sound.h => sound.cppm} | 214 ++++++++++- ci_shadervalidator/Logs.h | 1 + ci_shadervalidator/main.cpp | 1 - editor/editorSettings.cpp | 16 +- ...editorSettings.hpp => editorSettings.cppm} | 8 +- editor/editorTerrain.cpp | 23 +- .../{editorTerrain.hpp => editorTerrain.cppm} | 24 +- editor/editorTerrainStreamer.cpp | 18 +- ...treamer.hpp => editorTerrainStreamer.cppm} | 20 +- environment/moon.cpp | 21 +- environment/{moon.h => moon.cppm} | 11 +- environment/sky.cpp | 11 +- environment/{sky.h => sky.cppm} | 20 +- environment/skydome.cpp | 16 +- environment/{skydome.h => skydome.cppm} | 11 +- environment/stars.cpp | 10 +- environment/{stars.h => stars.cppm} | 24 +- environment/sun.cpp | 20 +- environment/{sun.h => sun.cppm} | 11 +- export_e3d_standalone.cpp | 9 +- extras/piped_proc.cpp | 10 +- extras/{piped_proc.h => piped_proc.cppm} | 17 +- gl/{bindable.h => bindable.cppm} | 8 +- gl/buffer.cpp | 8 +- gl/{buffer.h => buffer.cppm} | 13 +- gl/cubemap.cpp | 6 +- gl/{cubemap.h => cubemap.cppm} | 11 +- gl/fence.cpp | 6 +- gl/{fence.h => fence.cppm} | 11 +- gl/framebuffer.cpp | 13 +- gl/{framebuffer.h => framebuffer.cppm} | 19 +- gl/gldebug.h | 19 + gl/glsl_common.cpp | 9 +- gl/glsl_common.cppm | 18 + gl/glsl_common.h | 10 - gl/{object.h => object.cppm} | 10 +- gl/pbo.cpp | 8 +- gl/{pbo.h => pbo.cppm} | 15 +- gl/postfx.cpp | 9 +- gl/{postfx.h => postfx.cppm} | 18 +- gl/query.cpp | 9 +- gl/{query.h => query.cppm} | 13 +- gl/renderbuffer.cpp | 6 +- gl/{renderbuffer.h => renderbuffer.cppm} | 13 +- gl/shader.cpp | 19 +- gl/{shader.h => shader.cppm} | 16 +- gl/ubo.cpp | 8 +- gl/{ubo.h => ubo.cppm} | 26 +- gl/vao.cpp | 7 +- gl/{vao.h => vao.cppm} | 15 +- .../{IMaterial.h => IMaterial.cppm} | 16 +- .../interfaces/{ITexture.h => ITexture.cppm} | 14 +- global_include/interfaces/ITexture_macros.h | 8 + imgui/imgui_impl_opengl3.cpp | 7 +- input/command.cpp | 21 +- input/{command.h => command.cppm} | 15 +- input/driverkeyboardinput.cpp | 7 +- ...yboardinput.h => driverkeyboardinput.cppm} | 10 +- input/drivermouseinput.cpp | 47 ++- ...ivermouseinput.h => drivermouseinput.cppm} | 17 +- input/editorkeyboardinput.cpp | 9 +- ...yboardinput.h => editorkeyboardinput.cppm} | 10 +- input/editormouseinput.cpp | 7 +- ...itormouseinput.h => editormouseinput.cppm} | 12 +- input/gamepadinput.cpp | 21 +- input/{gamepadinput.h => gamepadinput.cppm} | 18 +- input/keyboardinput.cpp | 25 +- input/{keyboardinput.h => keyboardinput.cppm} | 27 +- input/messaging.cpp | 36 +- input/{messaging.h => messaging.cppm} | 16 +- input/zmq_input.cpp | 22 +- input/{zmq_input.h => zmq_input.cppm} | 19 +- .../{deferred_image.h => deferred_image.cppm} | 17 +- launcher/keymapper.cpp | 17 +- launcher/{keymapper.h => keymapper.cppm} | 14 +- launcher/launchermode.cpp | 16 +- .../{launchermode.h => launchermode.cppm} | 10 +- launcher/launcheruilayer.cpp | 14 +- ...launcheruilayer.h => launcheruilayer.cppm} | 20 +- launcher/scenery_list.cpp | 25 +- .../{scenery_list.h => scenery_list.cppm} | 20 +- launcher/scenery_scanner.cpp | 14 +- ...scenery_scanner.h => scenery_scanner.cppm} | 19 +- launcher/textures_scanner.cpp | 15 +- ...xtures_scanner.h => textures_scanner.cppm} | 17 +- launcher/vehicle_picker.cpp | 20 +- .../{vehicle_picker.h => vehicle_picker.cppm} | 21 +- model/AnimModel.cpp | 31 +- model/{AnimModel.h => AnimModel.cppm} | 28 +- model/MdlMngr.cpp | 20 +- model/{MdlMngr.h => MdlMngr.cppm} | 16 +- model/Model3d.cpp | 43 ++- model/{Model3d.h => Model3d.cppm} | 35 +- model/ResourceManager.cpp | 6 +- ...ResourceManager.h => ResourceManager.cppm} | 12 +- model/Texture.cpp | 45 ++- model/{Texture.h => Texture.cppm} | 22 +- model/material.cpp | 35 +- model/{material.h => material.cppm} | 28 +- model/vertex.cpp | 11 +- model/{vertex.h => vertex.cppm} | 17 +- network/backend/{asio.cpp => asio.cppm} | 114 +++++- network/backend/asio.h | 82 ---- network/manager.cpp | 13 +- network/{manager.h => manager.cppm} | 14 +- network/message.cpp | 10 +- network/{message.h => message.cppm} | 16 +- network/network.cpp | 28 +- network/{network.h => network.cppm} | 14 +- rendering/{flip-s3tc.h => flip-s3tc.cppm} | 12 +- rendering/frustum.cpp | 10 +- rendering/{frustum.h => frustum.cppm} | 12 +- rendering/geometrybank.cpp | 29 +- .../{geometrybank.h => geometrybank.cppm} | 24 +- rendering/{light.h => light.cppm} | 13 +- rendering/lightarray.cpp | 9 +- rendering/{lightarray.h => lightarray.cppm} | 14 +- rendering/nullrenderer.cpp | 6 +- .../{nullrenderer.h => nullrenderer.cppm} | 35 +- rendering/opengl33geometrybank.cpp | 12 +- ...ometrybank.h => opengl33geometrybank.cppm} | 19 +- rendering/opengl33light.cpp | 7 +- .../{opengl33light.h => opengl33light.cppm} | 13 +- rendering/opengl33particles.cpp | 24 +- ...gl33particles.h => opengl33particles.cppm} | 22 +- rendering/opengl33precipitation.cpp | 17 +- ...ipitation.h => opengl33precipitation.cppm} | 20 +- rendering/opengl33renderer.cpp | 64 +++- ...engl33renderer.h => opengl33renderer.cppm} | 72 ++-- rendering/opengl33skydome.cpp | 10 +- ...opengl33skydome.h => opengl33skydome.cppm} | 15 +- rendering/openglcamera.cpp | 12 +- .../{openglcamera.h => openglcamera.cppm} | 17 +- rendering/openglcolor.cpp | 6 +- rendering/{openglcolor.h => openglcolor.cppm} | 22 +- rendering/openglcolor_macros.h | 11 + rendering/openglgeometrybank.cpp | 17 +- ...geometrybank.h => openglgeometrybank.cppm} | 15 +- rendering/opengllight.cpp | 10 +- rendering/{opengllight.h => opengllight.cppm} | 13 +- rendering/openglmatrixstack.cpp | 6 +- ...glmatrixstack.h => openglmatrixstack.cppm} | 29 +- rendering/openglmatrixstack_macros.h | 19 + rendering/openglparticles.cpp | 24 +- ...openglparticles.h => openglparticles.cppm} | 17 +- rendering/openglprecipitation.cpp | 18 +- ...ecipitation.h => openglprecipitation.cppm} | 16 +- rendering/openglrenderer.cpp | 65 +++- .../{openglrenderer.h => openglrenderer.cppm} | 51 ++- rendering/openglrenderer_macros.h | 8 + rendering/openglskydome.cpp | 9 +- .../{openglskydome.h => openglskydome.cppm} | 10 +- rendering/particles.cpp | 24 +- rendering/{particles.h => particles.cppm} | 25 +- rendering/precipitation.cpp | 17 +- .../{precipitation.h => precipitation.cppm} | 10 +- rendering/renderer.cpp | 11 +- rendering/{renderer.h => renderer.cppm} | 33 +- rendering/screenshot.cpp | 19 +- rendering/{screenshot.h => screenshot.cppm} | 7 + resource.h => resource.cppm | 7 + scene/scene.cpp | 46 ++- scene/{scene.h => scene.cppm} | 56 ++- scene/sceneeditor.cpp | 24 +- scene/{sceneeditor.h => sceneeditor.cppm} | 11 +- scene/scenenode.cpp | 29 +- scene/{scenenode.h => scenenode.cppm} | 29 +- scene/scenenodegroups.cpp | 24 +- ...scenenodegroups.h => scenenodegroups.cppm} | 20 +- scene/sn_utils.cpp | 9 +- scene/{sn_utils.h => sn_utils.cppm} | 11 +- scripting/PyInt.cpp | 37 +- scripting/{PyInt.h => PyInt.cppm} | 76 ++-- scripting/PyIntStub.cpp | 4 +- scripting/PyInt_macros.h | 8 + scripting/ladderlogic.cpp | 17 +- scripting/{ladderlogic.h => ladderlogic.cppm} | 21 +- scripting/lua.cpp | 17 +- scripting/{lua.h => lua.cppm} | 14 +- scripting/pythonscreenviewer.cpp | 26 +- ...screenviewer.h => pythonscreenviewer.cppm} | 21 +- simcore/simcore-fwd.cppm | 45 +++ simcore/simcore.cppm | 36 ++ simulation/simulation.cpp | 44 +-- simulation/{simulation.h => simulation.cppm} | 32 +- simulation/simulationenvironment.cpp | 23 +- ...vironment.h => simulationenvironment.cppm} | 37 +- simulation/simulationsounds.cpp | 7 +- ...mulationsounds.h => simulationsounds.cppm} | 13 +- simulation/simulationstateserializer.cpp | 55 +-- ...lizer.h => simulationstateserializer.cppm} | 17 +- simulation/simulationtime.cpp | 18 +- .../{simulationtime.h => simulationtime.cppm} | 14 +- stdafx.cpp | 8 - stdafx.h | 134 ------- targetver.h | 14 - utilities/{Classes.h => Classes.cppm} | 51 +-- utilities/Float3d.cpp | 9 +- utilities/Float3d.cppm | 348 +++++++++++++++++ utilities/Float3d.h | 356 ------------------ utilities/Globals.cpp | 28 +- utilities/{Globals.h => Globals.cppm} | 45 ++- utilities/Globals_macros.h | 8 + utilities/Logs.cpp | 19 +- utilities/{Logs.h => Logs.cppm} | 10 +- utilities/{Names.h => Names.cppm} | 14 +- utilities/Timer.cpp | 11 +- utilities/{Timer.h => Timer.cppm} | 9 +- utilities/U8.cppm | 9 + utilities/U8.h | 3 - utilities/U8_macros.h | 8 + utilities/{color.h => color.cppm} | 11 +- utilities/{comparison.h => comparison.cppm} | 11 +- utilities/crashreporter.cpp | 3 + .../{crashreporter.h => crashreporter.cppm} | 17 +- utilities/crashreporter_macros.h | 13 + utilities/dictionary.cpp | 16 +- utilities/{dictionary.h => dictionary.cppm} | 11 +- utilities/{glmHelpers.h => glmHelpers.cppm} | 11 +- utilities/glm_module.cppm | 71 ++++ utilities/headtrack.cpp | 10 +- utilities/{headtrack.h => headtrack.cppm} | 8 +- utilities/motiontelemetry.cpp | 43 ++- ...motiontelemetry.h => motiontelemetry.cppm} | 11 +- utilities/parser.cpp | 20 +- utilities/{parser.h => parser.cppm} | 19 +- utilities/translation.cpp | 21 +- utilities/{translation.h => translation.cppm} | 16 +- utilities/translation_macros.h | 10 + utilities/uart.cpp | 33 +- utilities/{uart.h => uart.cppm} | 14 +- utilities/utilities.cpp | 24 +- utilities/{utilities.h => utilities.cppm} | 22 +- utilities/utilities_macros.h | 8 + utilities/{uuid.hpp => uuid.cppm} | 9 +- vehicle/AirCoupler.cpp | 9 +- vehicle/{AirCoupler.h => AirCoupler.cppm} | 13 +- vehicle/Button.cpp | 20 +- vehicle/{Button.h => Button.cppm} | 17 +- vehicle/Camera.cpp | 26 +- vehicle/{Camera.h => Camera.cppm} | 13 +- vehicle/Driver.cpp | 49 ++- vehicle/{Driver.h => Driver.cppm} | 197 +++++----- vehicle/DynObj.cpp | 47 +-- vehicle/{DynObj.h => DynObj.cppm} | 54 ++- vehicle/DynObj_macros.h | 8 + vehicle/Gauge.cpp | 28 +- vehicle/{Gauge.h => Gauge.cppm} | 17 +- vehicle/Train.cpp | 55 +-- vehicle/{Train.h => Train.cppm} | 56 ++- vr/openvr_imp.cpp | 23 +- vr/{openvr_imp.h => openvr_imp.cppm} | 18 +- vr/vr_interface.cpp | 9 +- vr/{vr_interface.h => vr_interface.cppm} | 19 +- widgets/cameraview_extcam.cpp | 19 +- ...raview_extcam.h => cameraview_extcam.cppm} | 17 +- widgets/imgui_scale.h | 17 + widgets/map.cpp | 40 +- widgets/{map.h => map.cppm} | 37 +- widgets/map_objects.cpp | 9 +- widgets/{map_objects.h => map_objects.cppm} | 20 +- widgets/perfgraphs.cpp | 12 +- widgets/{perfgraphs.h => perfgraphs.cppm} | 11 +- widgets/popup.cpp | 7 +- widgets/popup.h | 24 -- widgets/time.cpp | 13 +- widgets/{time.h => time.cppm} | 14 +- widgets/trainingcard.cpp | 19 +- widgets/{trainingcard.h => trainingcard.cppm} | 12 +- widgets/vehiclelist.cpp | 18 +- widgets/{vehiclelist.h => vehiclelist.cppm} | 9 +- widgets/vehicleparams.cpp | 27 +- .../{vehicleparams.h => vehicleparams.cppm} | 21 +- windows.cpp | 6 +- world/{Curve.h => Curve.cppm} | 14 +- world/EvLaunch.cpp | 27 +- world/{EvLaunch.h => EvLaunch.cppm} | 15 +- world/Event.cpp | 50 ++- world/{Event.h => Event.cppm} | 33 +- world/MemCell.cpp | 13 +- world/{MemCell.h => MemCell.cppm} | 23 +- world/Segment.cpp | 25 +- world/{Segment.h => Segment.cppm} | 18 +- world/Spring.cpp | 6 +- world/{Spring.h => Spring.cppm} | 11 +- world/Track.cpp | 40 +- world/{Track.h => Track.cppm} | 38 +- world/Traction.cpp | 26 +- world/{Traction.h => Traction.cppm} | 31 +- world/TractionPower.cpp | 10 +- world/{TractionPower.h => TractionPower.cppm} | 37 +- world/TrkFoll.cpp | 16 +- world/{TrkFoll.h => TrkFoll.cppm} | 17 +- world/mtable.cpp | 15 +- world/{mtable.h => mtable.cppm} | 23 +- world/station.cpp | 17 +- world/{station.h => station.cppm} | 14 +- 350 files changed, 5958 insertions(+), 3059 deletions(-) rename Console.h => Console.cppm (90%) rename Console/{LPT.h => LPT.cppm} (85%) rename Console/{PoKeys55.h => PoKeys55.cppm} (95%) rename McZapkie/{MOVER.h => MOVER.cppm} (96%) create mode 100644 McZapkie/MOVER_macros.h rename McZapkie/{Oerlikon_ESt.h => Oerlikon_ESt.cppm} (85%) rename McZapkie/{friction.h => friction.cppm} (94%) rename McZapkie/{hamulce.h => hamulce.cppm} (95%) rename application/{application.h => application.cppm} (90%) rename application/{applicationmode.h => applicationmode.cppm} (93%) create mode 100644 application/driverhints.cppm delete mode 100644 application/driverhints.h create mode 100644 application/driverhints_texts.h rename application/{drivermode.h => drivermode.cppm} (85%) rename application/{driveruilayer.h => driveruilayer.cppm} (81%) rename application/{driveruipanels.h => driveruipanels.cppm} (93%) rename application/{editormode.h => editormode.cppm} (94%) rename application/{editoruilayer.h => editoruilayer.cppm} (86%) rename application/{editoruipanels.h => editoruipanels.cppm} (92%) rename application/{scenarioloadermode.h => scenarioloadermode.cppm} (84%) rename application/{scenarioloaderuilayer.h => scenarioloaderuilayer.cppm} (79%) rename application/{uilayer.h => uilayer.cppm} (85%) rename application/{uitranscripts.h => uitranscripts.cppm} (90%) rename audio/{audio.h => audio.cppm} (74%) delete mode 100644 audio/audiorenderer.h create mode 100644 audio/audiorenderer_macros.h rename audio/{sound.h => sound.cppm} (62%) rename editor/{editorSettings.hpp => editorSettings.cppm} (87%) rename editor/{editorTerrain.hpp => editorTerrain.cppm} (94%) rename editor/{editorTerrainStreamer.hpp => editorTerrainStreamer.cppm} (96%) rename environment/{moon.h => moon.cppm} (97%) rename environment/{sky.h => sky.cppm} (56%) rename environment/{skydome.h => skydome.cppm} (94%) rename environment/{stars.h => stars.cppm} (58%) rename environment/{sun.h => sun.cppm} (97%) rename extras/{piped_proc.h => piped_proc.cppm} (83%) rename gl/{bindable.h => bindable.cppm} (88%) rename gl/{buffer.h => buffer.cppm} (89%) rename gl/{cubemap.h => cubemap.cppm} (75%) rename gl/{fence.h => fence.cppm} (68%) rename gl/{framebuffer.h => framebuffer.cppm} (81%) create mode 100644 gl/gldebug.h create mode 100644 gl/glsl_common.cppm delete mode 100644 gl/glsl_common.h rename gl/{object.h => object.cppm} (88%) rename gl/{pbo.h => pbo.cppm} (80%) rename gl/{postfx.h => postfx.cppm} (68%) rename gl/{query.h => query.cppm} (76%) rename gl/{renderbuffer.h => renderbuffer.cppm} (68%) rename gl/{shader.h => shader.cppm} (93%) rename gl/{ubo.h => ubo.cppm} (89%) rename gl/{vao.h => vao.cppm} (79%) rename global_include/interfaces/{IMaterial.h => IMaterial.cppm} (85%) rename global_include/interfaces/{ITexture.h => ITexture.cppm} (90%) create mode 100644 global_include/interfaces/ITexture_macros.h rename input/{command.h => command.cppm} (99%) rename input/{driverkeyboardinput.h => driverkeyboardinput.cppm} (80%) rename input/{drivermouseinput.h => drivermouseinput.cppm} (94%) rename input/{editorkeyboardinput.h => editorkeyboardinput.cppm} (84%) rename input/{editormouseinput.h => editormouseinput.cppm} (88%) rename input/{gamepadinput.h => gamepadinput.cppm} (94%) rename input/{keyboardinput.h => keyboardinput.cppm} (88%) rename input/{messaging.h => messaging.cppm} (93%) rename input/{zmq_input.h => zmq_input.cppm} (89%) rename launcher/{deferred_image.h => deferred_image.cppm} (75%) rename launcher/{keymapper.h => keymapper.cppm} (64%) rename launcher/{launchermode.h => launchermode.cppm} (91%) rename launcher/{launcheruilayer.h => launcheruilayer.cppm} (70%) rename launcher/{scenery_list.h => scenery_list.cppm} (84%) rename launcher/{scenery_scanner.h => scenery_scanner.cppm} (82%) rename launcher/{textures_scanner.h => textures_scanner.cppm} (89%) rename launcher/{vehicle_picker.h => vehicle_picker.cppm} (82%) rename model/{AnimModel.h => AnimModel.cppm} (96%) rename model/{MdlMngr.h => MdlMngr.cppm} (86%) rename model/{Model3d.h => Model3d.cppm} (95%) rename model/{ResourceManager.h => ResourceManager.cppm} (95%) rename model/{Texture.h => Texture.cppm} (96%) rename model/{material.h => material.cppm} (90%) rename model/{vertex.h => vertex.cppm} (89%) rename network/backend/{asio.cpp => asio.cppm} (67%) delete mode 100644 network/backend/asio.h rename network/{manager.h => manager.cppm} (81%) rename network/{message.h => message.cppm} (89%) rename network/{network.h => network.cppm} (94%) rename rendering/{flip-s3tc.h => flip-s3tc.cppm} (98%) rename rendering/{frustum.h => frustum.cppm} (95%) rename rendering/{geometrybank.h => geometrybank.cppm} (97%) rename rendering/{light.h => light.cppm} (80%) rename rendering/{lightarray.h => lightarray.cppm} (89%) rename rendering/{nullrenderer.h => nullrenderer.cppm} (92%) rename rendering/{opengl33geometrybank.h => opengl33geometrybank.cppm} (91%) rename rendering/{opengl33light.h => opengl33light.cppm} (80%) rename rendering/{opengl33particles.h => opengl33particles.cppm} (83%) rename rendering/{opengl33precipitation.h => opengl33precipitation.cppm} (76%) rename rendering/{opengl33renderer.h => opengl33renderer.cppm} (94%) rename rendering/{opengl33skydome.h => opengl33skydome.cppm} (80%) rename rendering/{openglcamera.h => openglcamera.cppm} (92%) rename rendering/{openglcolor.h => openglcolor.cppm} (84%) create mode 100644 rendering/openglcolor_macros.h rename rendering/{openglgeometrybank.h => openglgeometrybank.cppm} (95%) rename rendering/{opengllight.h => opengllight.cppm} (81%) rename rendering/{openglmatrixstack.h => openglmatrixstack.cppm} (94%) create mode 100644 rendering/openglmatrixstack_macros.h rename rendering/{openglparticles.h => openglparticles.cppm} (88%) rename rendering/{openglprecipitation.h => openglprecipitation.cppm} (75%) rename rendering/{openglrenderer.h => openglrenderer.cppm} (93%) create mode 100644 rendering/openglrenderer_macros.h rename rendering/{openglskydome.h => openglskydome.cppm} (87%) rename rendering/{particles.h => particles.cppm} (96%) rename rendering/{precipitation.h => precipitation.cppm} (90%) rename rendering/{renderer.h => renderer.cppm} (90%) rename rendering/{screenshot.h => screenshot.cppm} (64%) rename resource.h => resource.cppm (87%) rename scene/{scene.h => scene.cppm} (97%) rename scene/{sceneeditor.h => sceneeditor.cppm} (93%) rename scene/{scenenode.h => scenenode.cppm} (97%) rename scene/{scenenodegroups.h => scenenodegroups.cppm} (88%) rename scene/{sn_utils.h => sn_utils.cppm} (93%) rename scripting/{PyInt.h => PyInt.cppm} (82%) create mode 100644 scripting/PyInt_macros.h rename scripting/{ladderlogic.h => ladderlogic.cppm} (93%) rename scripting/{lua.h => lua.cppm} (94%) rename scripting/{pythonscreenviewer.h => pythonscreenviewer.cppm} (76%) create mode 100644 simcore/simcore-fwd.cppm create mode 100644 simcore/simcore.cppm rename simulation/{simulation.h => simulation.cppm} (85%) rename simulation/{simulationenvironment.h => simulationenvironment.cppm} (78%) rename simulation/{simulationsounds.h => simulationsounds.cppm} (75%) rename simulation/{simulationstateserializer.h => simulationstateserializer.cppm} (95%) rename simulation/{simulationtime.h => simulationtime.cppm} (96%) delete mode 100644 stdafx.cpp delete mode 100644 stdafx.h delete mode 100644 targetver.h rename utilities/{Classes.h => Classes.cppm} (56%) create mode 100644 utilities/Float3d.cppm delete mode 100644 utilities/Float3d.h rename utilities/{Globals.h => Globals.cppm} (95%) create mode 100644 utilities/Globals_macros.h rename utilities/{Logs.h => Logs.cppm} (90%) rename utilities/{Names.h => Names.cppm} (96%) rename utilities/{Timer.h => Timer.cppm} (95%) create mode 100644 utilities/U8.cppm delete mode 100644 utilities/U8.h create mode 100644 utilities/U8_macros.h rename utilities/{color.h => color.cppm} (96%) rename utilities/{comparison.h => comparison.cppm} (96%) rename utilities/{crashreporter.h => crashreporter.cppm} (54%) create mode 100644 utilities/crashreporter_macros.h rename utilities/{dictionary.h => dictionary.cppm} (91%) rename utilities/{glmHelpers.h => glmHelpers.cppm} (84%) create mode 100644 utilities/glm_module.cppm rename utilities/{headtrack.h => headtrack.cppm} (71%) rename utilities/{motiontelemetry.h => motiontelemetry.cppm} (84%) rename utilities/{parser.h => parser.cppm} (94%) rename utilities/{translation.h => translation.cppm} (87%) create mode 100644 utilities/translation_macros.h rename utilities/{uart.h => uart.cppm} (95%) rename utilities/{utilities.h => utilities.cppm} (97%) create mode 100644 utilities/utilities_macros.h rename utilities/{uuid.hpp => uuid.cppm} (96%) rename vehicle/{AirCoupler.h => AirCoupler.cppm} (90%) rename vehicle/{Button.h => Button.cppm} (89%) rename vehicle/{Camera.h => Camera.cppm} (89%) rename vehicle/{Driver.h => Driver.cppm} (94%) rename vehicle/{DynObj.h => DynObj.cppm} (98%) create mode 100644 vehicle/DynObj_macros.h rename vehicle/{Gauge.h => Gauge.cppm} (95%) rename vehicle/{Train.h => Train.cppm} (98%) rename vr/{openvr_imp.h => openvr_imp.cppm} (89%) rename vr/{vr_interface.h => vr_interface.cppm} (79%) rename widgets/{cameraview_extcam.h => cameraview_extcam.cppm} (79%) create mode 100644 widgets/imgui_scale.h rename widgets/{map.h => map.cppm} (83%) rename widgets/{map_objects.h => map_objects.cppm} (90%) rename widgets/{perfgraphs.h => perfgraphs.cppm} (83%) delete mode 100644 widgets/popup.h rename widgets/{time.h => time.cppm} (55%) rename widgets/{trainingcard.h => trainingcard.cppm} (81%) rename widgets/{vehiclelist.h => vehiclelist.cppm} (67%) rename widgets/{vehicleparams.h => vehicleparams.cppm} (55%) rename world/{Curve.h => Curve.cppm} (91%) rename world/{EvLaunch.h => EvLaunch.cppm} (92%) rename world/{Event.h => Event.cppm} (98%) rename world/{MemCell.h => MemCell.cppm} (90%) rename world/{Segment.h => Segment.cppm} (95%) rename world/{Spring.h => Spring.cppm} (93%) rename world/{Track.h => Track.cppm} (97%) rename world/{Traction.h => Traction.cppm} (93%) rename world/{TractionPower.h => TractionPower.cppm} (84%) rename world/{TrkFoll.h => TrkFoll.cppm} (93%) rename world/{mtable.h => mtable.cppm} (92%) rename world/{station.h => station.cppm} (82%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e4a74ba..7fd05a33 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y \ - build-essential \ + build-essential gcc-14 g++-14 ninja-build \ libgl1-mesa-dev libglew-dev libglfw3-dev \ libpng-dev libopenal-dev libluajit-5.1-dev \ libserialport-dev libsndfile1-dev \ @@ -64,8 +64,12 @@ jobs: uses: SonarSource/sonarqube-scan-action/install-build-wrapper@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6.0.0 - name: Configure (CMake) + env: + # C++20 named modules need GCC 14+; noble's default build-essential is GCC 13 + CC: gcc-14 + CXX: g++-14 run: | - cmake -S . -B build \ + cmake -S . -B build -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_BETTER_RENDERER=OFF \ -DWITH_ZMQ=OFF -DWITH_OPENVR=OFF -DUSE_LTO=OFF \ diff --git a/.github/workflows/build_bin.yml b/.github/workflows/build_bin.yml index f0b1fdec..485cfc4b 100644 --- a/.github/workflows/build_bin.yml +++ b/.github/workflows/build_bin.yml @@ -149,7 +149,7 @@ jobs: sudo apt-get update sudo apt-get install -y \ - build-essential \ + build-essential gcc-14 g++-14 ninja-build \ libgl1-mesa-dev \ libglew-dev \ libglfw3-dev \ @@ -193,16 +193,22 @@ jobs: - name: Show environment run: | - gcc --version - g++ --version + gcc-14 --version + g++-14 --version + ninja --version cmake --version python --version - name: Configure + env: + # C++20 named modules need GCC 14+; noble's default build-essential is GCC 13 + CC: gcc-14 + CXX: g++-14 run: | cmake \ -S . \ -B build \ + -G Ninja \ -DCMAKE_BUILD_TYPE="${CONFIG_LINUX}" \ -DWITH_BETTER_RENDERER=OFF \ -DWITH_ZMQ=OFF \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 56cf1bce..0e6ec765 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.26) +cmake_minimum_required(VERSION 3.28) # 3.28+: FILE_SET CXX_MODULES if(POLICY CMP0058) cmake_policy(SET CMP0058 NEW) endif() @@ -145,7 +145,6 @@ set(SOURCES "input/drivermouseinput.cpp" "utilities/translation.cpp" "model/material.cpp" -"stdafx.cpp" "input/messaging.cpp" "scene/scene.cpp" "scene/scenenode.cpp" @@ -192,7 +191,6 @@ set(SOURCES "network/network.cpp" "network/message.cpp" "network/manager.cpp" -"network/backend/asio.cpp" "widgets/vehiclelist.cpp" "widgets/map.cpp" @@ -240,10 +238,44 @@ set(SOURCES ) set(DEFINITIONS) + +# Definitions that used to live at the top of stdafx.h. They must be identical in +# every translation unit (glm is header-only and its GLM_FORCE_* switches change +# type layout), so they are set on the target rather than in a header that a file +# could forget to include first. +set(DEFINITIONS ${DEFINITIONS} + "_USE_MATH_DEFINES" + "NOMINMAX" + "GLFW_INCLUDE_NONE" + "GLM_FORCE_SWIZZLE" + "GLM_ENABLE_EXPERIMENTAL" + "GLM_FORCE_CTOR_INIT" + # empty value, not 1: glm/simd/platform.h defines this itself as a bare + # #define, and a differing definition would warn on every translation unit + "GLM_FORCE_INTRINSICS=") + +if (WIN32) + # _WIN32_WINNT came from targetver.h, which only ever existed to be pulled in + # by stdafx.h; keep the same Windows 7 API level now that both are gone + set(DEFINITIONS ${DEFINITIONS} "WIN32_LEAN_AND_MEAN" "_WIN32_WINNT=0x0601") +endif() + +if (APPLE) + # parts of the codebase gate posix-only code on __unix__, which Apple does not define + set(DEFINITIONS ${DEFINITIONS} "__unix__=1") +endif() + +if (MSVC) + set(DEFINITIONS ${DEFINITIONS} "GLM_FORCE_INLINE" "_CRTDBG_MAP_ALLOC") +endif() + +if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|ARM64)$") + set(DEFINITIONS ${DEFINITIONS} "GLM_FORCE_NEON") +elseif (ENABLE_AVX2) + set(DEFINITIONS ${DEFINITIONS} "GLM_FORCE_AVX2") +endif() set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl3.cpp") set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl2.cpp") -set_source_files_properties("imgui/imgui_impl_opengl3.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) -set_source_files_properties("imgui/imgui_impl_opengl2.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) if (WITH_CRASHPAD) set(DEFINITIONS ${DEFINITIONS} "WITH_CRASHPAD") @@ -403,6 +435,74 @@ endif() add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) +# C++20 module interface units. They must be declared through a CXX_MODULES file +# set so CMake runs the dependency scanner and orders the build; the matching +# .cpp implementation units stay ordinary sources in ${SOURCES}. +file(GLOB MODULE_INTERFACES CONFIGURE_DEPENDS "*.cppm" +"Console/*.cppm" +"McZapkie/*.cppm" +"gl/*.cppm" +"network/*.cppm" +"vr/*.cppm" +"network/backend/*.cppm" +"widgets/*.cppm" +"launcher/*.cppm" +"extras/*.cppm" +"global_include/*.cppm" +"global_include/interfaces/*.cppm" +"simulation/*.cppm" +"scene/*.cppm" +"rendering/*.cppm" +"audio/*.cppm" +"environment/*.cppm" +"application/*.cppm" +"input/*.cppm" +"scripting/*.cppm" +"model/*.cppm" +"utilities/*.cppm" +"world/*.cppm" +"editor/*.cppm" +"vehicle/*.cppm" +"simcore/*.cppm") + +# Unlike ordinary sources, every interface unit in the file set is scanned even +# when the feature that owns it is switched off, so the optional ones have to be +# dropped explicitly or the scan fails on their missing SDK headers. +list(REMOVE_ITEM MODULE_INTERFACES "${CMAKE_CURRENT_SOURCE_DIR}/world/Curve.cppm") +if (NOT WITH_ZMQ) + list(REMOVE_ITEM MODULE_INTERFACES "${CMAKE_CURRENT_SOURCE_DIR}/input/zmq_input.cppm") +endif() +if (NOT WITH_OPENVR) + list(REMOVE_ITEM MODULE_INTERFACES "${CMAKE_CURRENT_SOURCE_DIR}/vr/openvr_imp.cppm") +endif() + +target_sources(${PROJECT_NAME} + PUBLIC FILE_SET CXX_MODULES + BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} + FILES ${MODULE_INTERFACES}) + +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF) + +# GCC's lazy loading of module interfaces trips over the simulation-core partition +# ("failed to load pendings" / "Bad file data" while reading eu07.simcore:dynobj). +# Loading eagerly avoids it; drop this once the compiler bug is fixed. +# GCC 16's lazy loading of module interfaces is broken for this project: reading +# eu07.simcore:dynobj gives "Bad file data", and eu07.glm gives "recursive lazy +# load" / "failed to load pendings for glm::vec". Eager loading is the only way +# through, and it costs roughly twice the memory per compiler process. +# Drop both this and the job pool below once the compiler bug is fixed. +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${PROJECT_NAME} PRIVATE -fno-module-lazy) + + # Eager loading makes each compiler process hold ~1 GB, so a plain -j16 needs + # far more RAM than most machines have. This pool caps how many compilations + # run at once no matter what -j the caller passes; raise it if you have memory + # to spare. Ninja only. + set(MODULE_COMPILE_JOBS "6" CACHE STRING "Concurrent compiles (bounds peak RAM; see -fno-module-lazy above)") + set_property(GLOBAL APPEND PROPERTY JOB_POOLS module_compile=${MODULE_COMPILE_JOBS}) + set_property(TARGET ${PROJECT_NAME} PROPERTY JOB_POOL_COMPILE module_compile) +endif() + target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINITIONS}) target_include_directories(${PROJECT_NAME} PRIVATE @@ -444,17 +544,6 @@ if (COMPILER_HAVE_GNUC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") endif() -if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0") - option(USE_PCH "Use precompiled header" ON) - - if (USE_PCH) - target_precompile_headers(${PROJECT_NAME} PRIVATE "$<$:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>") - set_source_files_properties("/glad/src/glad.c" "ref/dds-ktx/src/dds-ktx.c" "stb/stb_image.c" - "imgui/imgui.cpp" "imgui/imgui_demo.cpp" "imgui/imgui_draw.cpp" "imgui/imgui_widgets.cpp" "imgui/imgui_impl_glfw.cpp" "imgui/ImGuizmo.cpp" - PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) - endif() -endif() - if (USE_LTO) set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) endif() diff --git a/Console.cpp b/Console.cpp index f06a1e7c..9fe717c1 100644 --- a/Console.cpp +++ b/Console.cpp @@ -1,3 +1,14 @@ +module; +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.console; +import eu07.utilities.globals; +import eu07.application.application; +import eu07.console.lpt; +import eu07.utilities.logs; +import eu07.console.pokeys55; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +18,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "Console.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "LPT.h" -#include "utilities/Logs.h" -#include "PoKeys55.h" -#include "utilities/utilities.h" //--------------------------------------------------------------------------- // Ra: klasa statyczna gromadząca sygnały sterujące oraz informacje zwrotne diff --git a/Console.h b/Console.cppm similarity index 90% rename from Console.h rename to Console.cppm index e99beb4b..bb2b57b3 100644 --- a/Console.h +++ b/Console.cppm @@ -7,14 +7,19 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef ConsoleH -#define ConsoleH -#include "utilities/Globals.h" -#include "application/application.h" //--------------------------------------------------------------------------- +module; +#include "utilities/Globals_macros.h" +#include + +export module eu07.console; +import eu07.console.lpt; +import eu07.console.pokeys55; +import eu07.utilities.globals; +import eu07.application.application; + +export { class TConsoleDevice; // urządzenie podłączalne za pomocą DLL -class TPoKeys55; -class TLPT; // klasy konwersji znaków wprowadzanych z klawiatury class TKeyTrans @@ -69,4 +74,5 @@ class Console static int KeyUpConvert(int k); }; -#endif + +} // export diff --git a/Console/LPT.cpp b/Console/LPT.cpp index c7be8275..f2fccf0f 100644 --- a/Console/LPT.cpp +++ b/Console/LPT.cpp @@ -1,3 +1,6 @@ +module; + +module eu07.console.lpt; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,9 +10,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "LPT.h" -#include "utilities/Logs.h" // LPT na USB: // USB\VID_067B&PID_2305&REV_0200 diff --git a/Console/LPT.h b/Console/LPT.cppm similarity index 85% rename from Console/LPT.h rename to Console/LPT.cppm index 96be5bb5..53e11e9c 100644 --- a/Console/LPT.h +++ b/Console/LPT.cppm @@ -7,9 +7,12 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef LPTH -#define LPTH //--------------------------------------------------------------------------- +module; + +export module eu07.console.lpt; + +export { class TLPT { @@ -20,4 +23,5 @@ class TLPT bool Connect(int port); void Out(int x); }; -#endif + +} // export diff --git a/Console/PoKeys55.cpp b/Console/PoKeys55.cpp index 40d23c83..4263cecb 100644 --- a/Console/PoKeys55.cpp +++ b/Console/PoKeys55.cpp @@ -1,3 +1,8 @@ +module; +#include +#include "utilities/utilities_macros.h" + +module eu07.console.pokeys55; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,10 +12,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "PoKeys55.h" -#include -#include "utilities/utilities.h" //--------------------------------------------------------------------------- // HIDscaner: http://forum.simflight.com/topic/68257-latest-lua-package-for-fsuipc-and-wideclient/ diff --git a/Console/PoKeys55.h b/Console/PoKeys55.cppm similarity index 95% rename from Console/PoKeys55.h rename to Console/PoKeys55.cppm index a32cf529..0c872500 100644 --- a/Console/PoKeys55.h +++ b/Console/PoKeys55.cppm @@ -6,10 +6,14 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include //--------------------------------------------------------------------------- +module; +#include + +export module eu07.console.pokeys55; + +export { class TPoKeys55 { // komunikacja z PoKeys bez określania przeznaczenia pinów unsigned char cRequest; // numer żądania do sprawdzania odpowiedzi @@ -36,3 +40,5 @@ class TPoKeys55 bool Update(bool pause); }; //--------------------------------------------------------------------------- + +} // export diff --git a/EU07.cpp b/EU07.cpp index e1be8584..644014ec 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -1,3 +1,26 @@ +#include +#ifdef WITHDUMPGEN +#ifdef _WIN32 +#include +#endif +#endif +#ifdef WITHDUMPGEN +#ifdef _WIN32 +#include +#endif +#endif +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include +#ifdef _WIN32 +#include +#endif +import eu07.application.application; +import eu07.utilities.logs; +import eu07.utilities.globals; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -16,15 +39,9 @@ MarcinW, McZapkie, Shaxbee, ABu, nbmx, youBy, Ra, winger, mamut, Q424, Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others */ -#include "stdafx.h" -#include "application/application.h" -#include "utilities/Logs.h" -#include #ifdef WITHDUMPGEN #ifdef _WIN32 -#include -#include #endif #endif @@ -34,11 +51,9 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic); -#include -#include -#include -#include -#include + +#ifdef _WIN32 +#endif #ifdef _WIN32 #pragma comment(lib, "Dbghelp.lib") diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.cppm similarity index 96% rename from McZapkie/MOVER.h rename to McZapkie/MOVER.cppm index a6658494..b92621b2 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.cppm @@ -7,12 +7,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once //--------------------------------------------------------------------------- // Q: 20160805 - odlaczenie pliku fizyki .pas od kompilacji -#include -#include "hamulce.h" -#include "scripting/ladderlogic.h" /* MaSzyna EU07 locomotive simulator Copyright (C) 2001-2004 Maciej Czapkiewicz and others @@ -79,6 +75,23 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona /// Global counter incremented when a string-to-numeric conversion fails during config parsing. +module; +#include "McZapkie/MOVER_macros.h" +#include +#include +#include +#include +#include +#include +#include +#include + +export module eu07.simcore:mover; +import :fwd; +import eu07.mczapkie.hamulce; +import eu07.scripting.ladderlogic; +import eu07.glm; +export { extern int ConversionError; /// Static friction coefficient for steel-on-steel contact (used for adhesion at standstill). @@ -92,65 +105,65 @@ const double Pirazy2 = 6.2831853071794f; //-- var, const, procedure --------------------------------------------------- /// Truthy alias used by CheckLocomotiveParameters() to ignore a check failure. -static bool const Go = true; +inline bool const Go = true; /// Falsy alias used by CheckLocomotiveParameters() to abort on a check failure. -static bool const Hold = false; /*dla CheckLocomotiveParameters*/ +inline bool const Hold = false; /*dla CheckLocomotiveParameters*/ /// Maximum number of resistor / scheme entries for electric motor traction. -static int const ResArraySize = 64; /*dla silnikow elektrycznych*/ +inline int const ResArraySize = 64; /*dla silnikow elektrycznych*/ /// Maximum number of motor-parameter table entries (gear stages). -static int const MotorParametersArraySize = 10; +inline int const MotorParametersArraySize = 10; /// Maximum number of pantograph current collectors per vehicle. -static int const maxcc = 4; /*max. ilosc odbierakow pradu*/ +inline int const maxcc = 4; /*max. ilosc odbierakow pradu*/ // static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca pomocniczego*/ // static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ /// Number of positions on the manual (parking) brake handle. -static int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/ +inline int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/ /// Number of positions on the lights selector switch. -static int const LightsSwitchPosNo = 16; +inline int const LightsSwitchPosNo = 16; /// Maximum number of positions of the universal (auxiliary) controller. -static int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/ +inline int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/ /*uszkodzenia toru*/ /// Track damage flag: rail wear. -static int const dtrack_railwear = 2; +inline int const dtrack_railwear = 2; /// Track damage flag: free / loose rail. -static int const dtrack_freerail = 4; +inline int const dtrack_freerail = 4; /// Track damage flag: thin (worn-out) rail. -static int const dtrack_thinrail = 8; +inline int const dtrack_thinrail = 8; /// Track damage flag: bent rail. -static int const dtrack_railbend = 16; +inline int const dtrack_railbend = 16; /// Track damage flag: vegetation overgrowth. -static int const dtrack_plants = 32; +inline int const dtrack_plants = 32; /// Track damage flag: track impassable for movement. -static int const dtrack_nomove = 64; +inline int const dtrack_nomove = 64; /// Track damage flag: rails missing entirely. -static int const dtrack_norail = 128; +inline int const dtrack_norail = 128; /*uszkodzenia taboru*/ /// Vehicle damage flag: thin wheel (locomotives). -static int const dtrain_thinwheel = 1; /*dla lokomotyw*/ +inline int const dtrain_thinwheel = 1; /*dla lokomotyw*/ /// Vehicle damage flag: shifted load (wagons). -static int const dtrain_loadshift = 1; /*dla wagonow*/ +inline int const dtrain_loadshift = 1; /*dla wagonow*/ /// Vehicle damage flag: wheel wear. -static int const dtrain_wheelwear = 2; +inline int const dtrain_wheelwear = 2; /// Vehicle damage flag: bearing failure. -static int const dtrain_bearing = 4; +inline int const dtrain_bearing = 4; /// Vehicle damage flag: coupling damage. -static int const dtrain_coupling = 8; +inline int const dtrain_coupling = 8; /// Vehicle damage flag: ventilator failure (electric locomotive). -static int const dtrain_ventilator = 16; /*dla lokomotywy el.*/ +inline int const dtrain_ventilator = 16; /*dla lokomotywy el.*/ /// Vehicle damage flag: load damage (wagons). -static int const dtrain_loaddamage = 16; /*dla wagonow*/ +inline int const dtrain_loaddamage = 16; /*dla wagonow*/ /// Vehicle damage flag: engine failure (locomotives). -static int const dtrain_engine = 32; /*dla lokomotyw*/ +inline int const dtrain_engine = 32; /*dla lokomotyw*/ /// Vehicle damage flag: load destroyed (wagons). -static int const dtrain_loaddestroyed = 32; /*dla wagonow*/ +inline int const dtrain_loaddestroyed = 32; /*dla wagonow*/ /// Vehicle damage flag: axle damage. -static int const dtrain_axle = 64; +inline int const dtrain_axle = 64; /// Vehicle damage flag: derailment. -static int const dtrain_out = 128; /*wykolejenie*/ +inline int const dtrain_out = 128; /*wykolejenie*/ /// Vehicle damage flag: broken pantograph. -static int const dtrain_pantograph = 256; /*polamanie pantografu*/ +inline int const dtrain_pantograph = 256; /*polamanie pantografu*/ /// Reason for a derailment event. enum DerailReason @@ -171,37 +184,33 @@ enum DerailReason /*wagi prawdopodobienstwa dla funkcji FuzzyLogic*/ /// Fuzzy-logic probability weight: electric engine general problem. -#define p_elengproblem (1e-02) /// Fuzzy-logic probability weight: electric engine damage. #define p_elengdamage (1e-01) /// Fuzzy-logic probability weight: coupler damage. -#define p_coupldmg (2e-03) /// Fuzzy-logic probability weight: derailment. #define p_derail (1e-03) /// Fuzzy-logic probability weight: acceleration-related event. -#define p_accn (1e-01) /// Fuzzy-logic probability weight: damage caused by wheel slip. -#define p_slippdmg (1e-03) /*typ sprzegu*/ /// Coupling type: virtual — vehicles share a track and are aware of each other. -static int const ctrain_virtual = 0; // gdy pojazdy na tym samym torze się widzą wzajemnie +inline int const ctrain_virtual = 0; // gdy pojazdy na tym samym torze się widzą wzajemnie /// Coupling type: physical coupler. -static int const ctrain_coupler = 1; // sprzeg fizyczny +inline int const ctrain_coupler = 1; // sprzeg fizyczny /// Coupling type: pneumatic brake hose. -static int const ctrain_pneumatic = 2; // przewody hamulcowe +inline int const ctrain_pneumatic = 2; // przewody hamulcowe /// Coupling type: control cable (multiple-unit). -static int const ctrain_controll = 4; // przewody sterujące (ukrotnienie) +inline int const ctrain_controll = 4; // przewody sterujące (ukrotnienie) /// Coupling type: high-voltage power cable. -static int const ctrain_power = 8; // przewody zasilające (WN) +inline int const ctrain_power = 8; // przewody zasilające (WN) /// Coupling type: passenger gangway. -static int const ctrain_passenger = 16; // mostek przejściowy +inline int const ctrain_passenger = 16; // mostek przejściowy /// Coupling type: secondary 8 atm pneumatic line (yellow, main air). -static int const ctrain_scndpneumatic = 32; // przewody 8 atm (żółte; zasilanie powietrzem) +inline int const ctrain_scndpneumatic = 32; // przewody 8 atm (żółte; zasilanie powietrzem) /// Coupling type: high-voltage train heating cable. -static int const ctrain_heating = 64; // przewody ogrzewania WN +inline int const ctrain_heating = 64; // przewody ogrzewania WN /// Coupling type: permanent (inter-section) — not separable during ordinary shunting; encoded as negative in config files. -static int const ctrain_depot = 128; // nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna +inline int const ctrain_depot = 128; // nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna /// Vehicle ends — front or rear (mutually exclusive). enum end { @@ -338,15 +347,15 @@ enum control_t }; /*typ hamulca elektrodynamicznego*/ /// Electrodynamic-brake type: no ED brake. -static int const dbrake_none = 0; +inline int const dbrake_none = 0; /// Electrodynamic-brake type: passive (always on while moving). -static int const dbrake_passive = 1; +inline int const dbrake_passive = 1; /// Electrodynamic-brake type: switchable (driver toggles). -static int const dbrake_switch = 2; +inline int const dbrake_switch = 2; /// Electrodynamic-brake type: reversal (engaged via reverser). -static int const dbrake_reversal = 4; +inline int const dbrake_reversal = 4; /// Electrodynamic-brake type: automatic (engages from main brake). -static int const dbrake_automatic = 8; +inline int const dbrake_automatic = 8; /*dzwieki*/ /// Bit flags identifying sound events emitted by a vehicle. Combinable. @@ -436,126 +445,126 @@ enum activation // zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT) // TODO: convert to enums, they're used as specific checks anyway /// Vehicle type flag: default (no special handling). -static int const dt_Default = 0; +inline int const dt_Default = 0; /// Vehicle type flag: EZT (electric multiple unit). -static int const dt_EZT = 1; +inline int const dt_EZT = 1; /// Vehicle type flag: ET41 locomotive. -static int const dt_ET41 = 2; +inline int const dt_ET41 = 2; /// Vehicle type flag: ET42 locomotive. -static int const dt_ET42 = 4; +inline int const dt_ET42 = 4; /// Vehicle type flag: pseudo-diesel (electric drivetrain with diesel input model). -static int const dt_PseudoDiesel = 8; +inline int const dt_PseudoDiesel = 8; /// Vehicle type flag: ET22 locomotive (added in Megapack). -static int const dt_ET22 = 0x10; // używane od Megapacka +inline int const dt_ET22 = 0x10; // używane od Megapacka /// Vehicle type flag: SN61 (set from CHK only, not used in conditions). -static int const dt_SN61 = 0x20; // nie używane w warunkach, ale ustawiane z CHK +inline int const dt_SN61 = 0x20; // nie używane w warunkach, ale ustawiane z CHK /// Vehicle type flag: EP05 locomotive. -static int const dt_EP05 = 0x40; +inline int const dt_EP05 = 0x40; /// Vehicle type flag: ET40 locomotive. -static int const dt_ET40 = 0x80; +inline int const dt_ET40 = 0x80; /// Vehicle type flag: ŠKODA 181 locomotive. -static int const dt_181 = 0x100; +inline int const dt_181 = 0x100; /// Vehicle type flag: DMU (diesel multiple unit). -static int const dt_DMU = 0x200; +inline int const dt_DMU = 0x200; // stałe dla asynchronów /// EIM config index: dfic — frequency rise rate at start. -static int const eimc_s_dfic = 0; +inline int const eimc_s_dfic = 0; /// EIM config index: dfmax — maximum frequency rate of change. -static int const eimc_s_dfmax = 1; +inline int const eimc_s_dfmax = 1; /// EIM config index: p — number of pole pairs. -static int const eimc_s_p = 2; +inline int const eimc_s_p = 2; /// EIM config index: cfu — voltage / frequency conversion coefficient. -static int const eimc_s_cfu = 3; +inline int const eimc_s_cfu = 3; /// EIM config index: cim — current / current conversion coefficient. -static int const eimc_s_cim = 4; +inline int const eimc_s_cim = 4; /// EIM config index: icif — magnetisation current ratio. -static int const eimc_s_icif = 5; +inline int const eimc_s_icif = 5; /// EIM config index: Uzmax — maximum DC link voltage. -static int const eimc_f_Uzmax = 7; +inline int const eimc_f_Uzmax = 7; /// EIM config index: Uzh — DC link voltage at field-weakening transition. -static int const eimc_f_Uzh = 8; +inline int const eimc_f_Uzh = 8; /// EIM config index: DU — voltage drop at the converter. -static int const eimc_f_DU = 9; +inline int const eimc_f_DU = 9; /// EIM config index: I0 — no-load magnetising current. -static int const eimc_f_I0 = 10; +inline int const eimc_f_I0 = 10; /// EIM config index: cfu — V/f gain in normal mode. -static int const eimc_f_cfu = 11; +inline int const eimc_f_cfu = 11; /// EIM config index: cfuH — V/f gain in field-weakening region. -static int const eimc_f_cfuH = 12; +inline int const eimc_f_cfuH = 12; /// EIM config index: F0 — starting force at zero speed. -static int const eimc_p_F0 = 13; +inline int const eimc_p_F0 = 13; /// EIM config index: a1 — force-frequency slope coefficient. -static int const eimc_p_a1 = 14; +inline int const eimc_p_a1 = 14; /// EIM config index: Pmax — maximum power. -static int const eimc_p_Pmax = 15; +inline int const eimc_p_Pmax = 15; /// EIM config index: Fh — force at field-weakening point. -static int const eimc_p_Fh = 16; +inline int const eimc_p_Fh = 16; /// EIM config index: Ph — power at field-weakening point. -static int const eimc_p_Ph = 17; +inline int const eimc_p_Ph = 17; /// EIM config index: Vh0 — speed where field weakening begins. -static int const eimc_p_Vh0 = 18; +inline int const eimc_p_Vh0 = 18; /// EIM config index: Vh1 — speed of full field weakening. -static int const eimc_p_Vh1 = 19; +inline int const eimc_p_Vh1 = 19; /// EIM config index: Imax — maximum motor current. -static int const eimc_p_Imax = 20; +inline int const eimc_p_Imax = 20; /// EIM config index: abed — anti-skid set point. -static int const eimc_p_abed = 21; +inline int const eimc_p_abed = 21; /// EIM config index: eped — EP brake intensity bias. -static int const eimc_p_eped = 22; +inline int const eimc_p_eped = 22; // zmienne dla asynchronów /// EIM variable index: FMAXMAX — absolute maximum allowable force. -static int const eimv_FMAXMAX = 0; +inline int const eimv_FMAXMAX = 0; /// EIM variable index: Fmax — current force limit. -static int const eimv_Fmax = 1; +inline int const eimv_Fmax = 1; /// EIM variable index: ks — slip coefficient. -static int const eimv_ks = 2; +inline int const eimv_ks = 2; /// EIM variable index: df — frequency offset. -static int const eimv_df = 3; +inline int const eimv_df = 3; /// EIM variable index: fp — base frequency. -static int const eimv_fp = 4; +inline int const eimv_fp = 4; /// EIM variable index: U — applied voltage. -static int const eimv_U = 5; +inline int const eimv_U = 5; /// EIM variable index: pole — pole-pair indicator. -static int const eimv_pole = 6; +inline int const eimv_pole = 6; /// EIM variable index: Ic — control current. -static int const eimv_Ic = 7; +inline int const eimv_Ic = 7; /// EIM variable index: If — field current. -static int const eimv_If = 8; +inline int const eimv_If = 8; /// EIM variable index: M — torque. -static int const eimv_M = 9; +inline int const eimv_M = 9; /// EIM variable index: Fr — actual force. -static int const eimv_Fr = 10; +inline int const eimv_Fr = 10; /// EIM variable index: Ipoj — line current. -static int const eimv_Ipoj = 11; +inline int const eimv_Ipoj = 11; /// EIM variable index: Pm — mechanical power. -static int const eimv_Pm = 12; +inline int const eimv_Pm = 12; /// EIM variable index: Pe — electrical power. -static int const eimv_Pe = 13; +inline int const eimv_Pe = 13; /// EIM variable index: eta — efficiency. -static int const eimv_eta = 14; +inline int const eimv_eta = 14; /// EIM variable index: fkr — critical frequency. -static int const eimv_fkr = 15; +inline int const eimv_fkr = 15; /// EIM variable index: Uzsmax — maximum measured DC link voltage. -static int const eimv_Uzsmax = 16; +inline int const eimv_Uzsmax = 16; /// EIM variable index: Pmax — instantaneous power limit. -static int const eimv_Pmax = 17; +inline int const eimv_Pmax = 17; /// EIM variable index: Fzad — set-point force. -static int const eimv_Fzad = 18; +inline int const eimv_Fzad = 18; /// EIM variable index: Imax — maximum allowed current. -static int const eimv_Imax = 19; +inline int const eimv_Imax = 19; /// EIM variable index: Fful — full force. -static int const eimv_Fful = 20; +inline int const eimv_Fful = 20; /// Brake-of-mode flag: PS (pneumatic, primary). -static int const bom_PS = 1; +inline int const bom_PS = 1; /// Brake-of-mode flag: PN (pneumatic, no electrodynamic). -static int const bom_PN = 2; +inline int const bom_PN = 2; /// Brake-of-mode flag: EP (electro-pneumatic). -static int const bom_EP = 4; +inline int const bom_EP = 4; /// Brake-of-mode flag: MED (mixed pneumatic+ED). -static int const bom_MED = 8; +inline int const bom_MED = 8; /// Bit flags reporting vehicle problems that prevent driving. enum TProblem // lista problemów taboru, które uniemożliwiają jazdę @@ -1246,7 +1255,6 @@ struct TCoupling } }; -class TDynamicObject; struct neighbour_data { TDynamicObject *vehicle{nullptr}; // detected obstacle @@ -2606,3 +2614,5 @@ using weights_table = std::unordered_map; extern weights_table Weights; } // namespace simulation + +} // export diff --git a/McZapkie/MOVER_macros.h b/McZapkie/MOVER_macros.h new file mode 100644 index 00000000..2721c085 --- /dev/null +++ b/McZapkie/MOVER_macros.h @@ -0,0 +1,11 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define p_elengproblem (1e-02) +#define p_coupldmg (2e-03) +#define p_accn (1e-01) +#define p_slippdmg (1e-03) diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 83c918e2..85c29b81 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1,4 +1,27 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "McZapkie/MOVER_macros.h" +#include "vehicle/DynObj_macros.h" +#include "utilities/Globals_macros.h" + +module eu07.simcore; +import eu07.mczapkie.oerlikon_est; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.parser; +import eu07.simulation.simulation; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +30,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "MOVER.h" -#include "vehicle/DynObj.h" -#include "Oerlikon_ESt.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/parser.h" -#include "simulation/simulation.h" //--------------------------------------------------------------------------- // Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane. diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp index 9559d305..0516fdd9 100644 --- a/McZapkie/Oerlikon_ESt.cpp +++ b/McZapkie/Oerlikon_ESt.cpp @@ -1,3 +1,12 @@ +module; +#include +#include +#include +#include +#include "utilities/utilities_macros.h" + +module eu07.mczapkie.oerlikon_est; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,9 +21,6 @@ Brakes. Oerlikon ESt. Copyright (C) 2007-2014 Maciej Cierniak */ -#include "stdafx.h" -#include "Oerlikon_ESt.h" -#include "utilities/utilities.h" double d2A( double const d ) { diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.cppm similarity index 85% rename from McZapkie/Oerlikon_ESt.h rename to McZapkie/Oerlikon_ESt.cppm index c1269185..43537f2d 100644 --- a/McZapkie/Oerlikon_ESt.h +++ b/McZapkie/Oerlikon_ESt.cppm @@ -1,6 +1,3 @@ -#pragma once -#ifndef INCLUDED_OERLIKON_EST_H -#define INCLUDED_OERLIKON_EST_H /*fizyka hamulcow Oerlikon ESt dla symulatora*/ /* @@ -17,10 +14,6 @@ http://mozilla.org/MPL/2.0/. Copyright (C) 2007-2014 Maciej Cierniak */ -#include -#include -#include "hamulce.h" // Pascal unit -#include "friction.h" // Pascal unit /* (C) youBy @@ -45,27 +38,36 @@ Co brakuje: - samoczynne ep - PZZ dla dodatkowego */ +module; +#include +#include -static int const dMAX = 11; // dysze -static int const dON = 0; // osobowy napelnianie (+ZP) -static int const dOO = 1; // osobowy oproznianie -static int const dTN = 2; // towarowy napelnianie (+ZP) -static int const dTO = 3; // towarowy oproznianie -static int const dP = 4; // zbiornik pomocniczy -static int const dSd = 5; // zbiornik sterujacy -static int const dSm = 6; // zbiornik sterujacy -static int const dPd = 7; // duzy przelot zamykajcego -static int const dPm = 8; // maly przelot zamykajacego -static int const dPO = 9; // zasilanie pomocniczego O -static int const dPT = 10; // zasilanie pomocniczego T +export module eu07.mczapkie.oerlikon_est; +import eu07.mczapkie.hamulce; +import eu07.mczapkie.friction; + +export { + +inline int const dMAX = 11; // dysze +inline int const dON = 0; // osobowy napelnianie (+ZP) +inline int const dOO = 1; // osobowy oproznianie +inline int const dTN = 2; // towarowy napelnianie (+ZP) +inline int const dTO = 3; // towarowy oproznianie +inline int const dP = 4; // zbiornik pomocniczy +inline int const dSd = 5; // zbiornik sterujacy +inline int const dSm = 6; // zbiornik sterujacy +inline int const dPd = 7; // duzy przelot zamykajcego +inline int const dPm = 8; // maly przelot zamykajacego +inline int const dPO = 9; // zasilanie pomocniczego O +inline int const dPT = 10; // zasilanie pomocniczego T // przekladniki -static int const p_none = 0; -static int const p_rapid = 1; -static int const p_pp = 2; -static int const p_al2 = 3; -static int const p_ppz = 4; -static int const P_ed = 5; +inline int const p_none = 0; +inline int const p_rapid = 1; +inline int const p_pp = 2; +inline int const p_al2 = 3; +inline int const p_ppz = 4; +inline int const P_ed = 5; class TPrzekladnik : public TReservoir // przekladnik (powtarzacz) @@ -226,5 +228,6 @@ class TNESt3 : public TBrake { extern double d2A( double const d ); -#endif // INCLUDED_OERLIKON_EST_H // END + +} // export diff --git a/McZapkie/friction.cpp b/McZapkie/friction.cpp index 6ecf5a06..6ba35af7 100644 --- a/McZapkie/friction.cpp +++ b/McZapkie/friction.cpp @@ -1,3 +1,7 @@ +module; +#include + +module eu07.mczapkie.friction; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,8 +16,6 @@ Friction coefficient. Copyright (C) 2007-2013 Maciej Cierniak */ -#include "stdafx.h" -#include "friction.h" double TFricMat::GetFC(double N, double Vel) { diff --git a/McZapkie/friction.h b/McZapkie/friction.cppm similarity index 94% rename from McZapkie/friction.h rename to McZapkie/friction.cppm index 067a61b9..efb92320 100644 --- a/McZapkie/friction.h +++ b/McZapkie/friction.cppm @@ -1,6 +1,3 @@ -#pragma once -#ifndef INCLUDED_FRICTION_H -#define INCLUDED_FRICTION_H /*wspolczynnik tarcia roznych materialow*/ /* @@ -34,6 +31,11 @@ Zrobione: //uses hamulce; +module; + +export module eu07.mczapkie.friction; + +export { class TFricMat @@ -147,5 +149,6 @@ public: -#endif//INCLUDED_FRICTION_H //END + +} // export diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index 44e8be4b..bf4a9ecd 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -1,3 +1,14 @@ +module; +#include +#include +#include +#include +#include "McZapkie/MOVER_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.mczapkie.hamulce; +import eu07.simcore; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,11 +23,6 @@ Brakes. Oerlikon ESt. Copyright (C) 2007-2014 Maciej Cierniak */ -#include "stdafx.h" -#include "hamulce.h" -#include -#include "MOVER.h" -#include "utilities/utilities.h" //---FUNKCJE OGOLNE--- @@ -1315,7 +1321,7 @@ void TEStEP1::EPCalc(double dt) double temp = EPS - std::floor(EPS); // część ułamkowa jest hamulcem EP double LBPLim = std::min(MaxBP * LoadC * temp, BrakeRes->P()); // do czego dążymy double S = 10 * std::clamp(LBPLim - LBP, -0.1, 0.1); // przymykanie zaworku - double dv = PF(S > 0 ? BrakeRes->P() : 0, LBP, abs(S) * (0.00053 + 0.00060 * int(S < 0))) * dt; // przepływ + double dv = PF(S > 0 ? BrakeRes->P() : 0, LBP, std::abs(S) * (0.00053 + 0.00060 * int(S < 0))) * dt; // przepływ LBP = LBP - dv; } @@ -2975,7 +2981,7 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep) // if(cp+0.03<5.4)then if (RP + 0.03 < 5.4 || CP + 0.03 < 5.4) // fala dpMainValve = PF(std::min(HP, 17.1), PP, ActFlowSpeed / LBDelay) * dt; - // dpMainValve:=20*std::min(abs(ep-7.1),0.05)*PF(HP,pp,ActFlowSpeed/LBDelay)*dt; + // dpMainValve:=20*std::min(std::abs(ep-7.1),0.05)*PF(HP,pp,ActFlowSpeed/LBDelay)*dt; else { RP = 5.45; @@ -3314,9 +3320,9 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep pom = std::min(CP, HP); if (LimPP > CP) // podwyzszanie szybkie - CP = CP + 60 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy; + CP = CP + 60 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy; else - CP = CP + 13 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy + CP = CP + 13 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy LimPP = pom; // cp // if (EQ(i_bcp, -1)) @@ -3517,9 +3523,9 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) ActFlowSpeed = 4; if (LimCP > CP) // podwyzszanie szybkie - CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy; + CP = CP + 9 * std::min(std::abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy; else - CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy + CP = CP + 9 * std::min(std::abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy double uop = UnbrakeOverPressure; // unbrake over pressure in actual state ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed @@ -3700,9 +3706,9 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) ActFlowSpeed = 4; if (LimCP > CP) // podwyzszanie szybkie - CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy; + CP = CP + 9 * std::min(std::abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy; else - CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy + CP = CP + 9 * std::min(std::abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy dpPipe = std::min(HP, CP + TP + RedAdj); @@ -3864,13 +3870,13 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep) LimPP = LimPP + RedAdj; if (BCP != 2) if (CP < LimPP) - CP = CP + 4 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy - // cp:=cp+6*(2+int(bcp<0))*std::min(abs(Limpp-cp),0.05)*PR(cp,Limpp)*dt //zbiornik + CP = CP + 4 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy + // cp:=cp+6*(2+int(bcp<0))*std::min(std::abs(Limpp-cp),0.05)*PR(cp,Limpp)*dt //zbiornik // sterujacy; else if (BCP == 0) CP = CP - 0.2 * dt / 100; else - CP = CP + 4 * (1 + int(BCP != 3) + int(BCP > 4)) * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy + CP = CP + 4 * (1 + int(BCP != 3) + int(BCP > 4)) * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy LimPP = CP; dpPipe = std::min(HP, LimPP); @@ -4060,7 +4066,7 @@ double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep) LimPP = CP; ActFlowSpeed = BPT_K[BCP + 1][0]; - CP = CP + 6 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy + CP = CP + 6 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy dpMainValve = 0; @@ -4140,7 +4146,7 @@ double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep) if (i_bcp == -1) LimPP = 7; - CP = CP + 20 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1; + CP = CP + 20 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1; LimPP = CP; dpPipe = std::min(HP, LimPP); diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.cppm similarity index 95% rename from McZapkie/hamulce.h rename to McZapkie/hamulce.cppm index a05a3635..d50e8c69 100644 --- a/McZapkie/hamulce.h +++ b/McZapkie/hamulce.cppm @@ -31,155 +31,161 @@ H14K1 (zasadniczy), H1405 (pomocniczy), St113 (ep) Knorr/West EP - żeby był */ -#pragma once -#include "friction.h" // Pascal unit /// Number of positions of the local (auxiliary/manual) brake handle. -static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/ +module; +#include +#include + +export module eu07.mczapkie.hamulce; +import eu07.mczapkie.friction; + +export { +inline int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/ /// Maximum number of positions of the main (train) brake handle. -static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ +inline int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ /*nastawy hamulca*/ /// Brake delay setting flag: G (goods/freight slow). -static int const bdelay_G = 1; // G +inline int const bdelay_G = 1; // G /// Brake delay setting flag: P (passenger fast). -static int const bdelay_P = 2; // P +inline int const bdelay_P = 2; // P /// Brake delay setting flag: R (rapid - high braking force). -static int const bdelay_R = 4; // R +inline int const bdelay_R = 4; // R /// Brake delay setting flag: Mg (magnetic rail brake enabled). -static int const bdelay_M = 8; // Mg +inline int const bdelay_M = 8; // Mg /*stan hamulca*/ /// Brake state flag: brake released (no action). -static int const b_off = 0; // luzowanie +inline int const b_off = 0; // luzowanie /// Brake state flag: hold (lap) - keep current cylinder pressure. -static int const b_hld = 1; // trzymanie +inline int const b_hld = 1; // trzymanie /// Brake state flag: applying - filling brake cylinder. -static int const b_on = 2; // napelnianie +inline int const b_on = 2; // napelnianie /// Brake state flag: replenishing the auxiliary reservoir. -static int const b_rfl = 4; // uzupelnianie +inline int const b_rfl = 4; // uzupelnianie /// Brake state flag: releaser engaged (vents the control reservoir to release brakes). -static int const b_rls = 8; // odluzniacz +inline int const b_rls = 8; // odluzniacz /// Brake state flag: electro-pneumatic action active. -static int const b_ep = 16; // elektropneumatyczny +inline int const b_ep = 16; // elektropneumatyczny /// Brake state flag: anti-slip protection holding the brake (preventing further filling). -static int const b_asb = 32; // przeciwposlizg-wstrzymanie +inline int const b_asb = 32; // przeciwposlizg-wstrzymanie /// Brake state flag: anti-slip protection releasing the brake. -static int const b_asb_unbrake = 64; // przeciwposlizg-luzowanie +inline int const b_asb_unbrake = 64; // przeciwposlizg-luzowanie /// Brake state flag: brake disabled / damaged. -static int const b_dmg = 128; // wylaczony z dzialania +inline int const b_dmg = 128; // wylaczony z dzialania /*uszkodzenia hamulca*/ /// Brake damage flag: faulty filling phase. -static int const df_on = 1; // napelnianie +inline int const df_on = 1; // napelnianie /// Brake damage flag: faulty release phase. -static int const df_off = 2; // luzowanie +inline int const df_off = 2; // luzowanie /// Brake damage flag: leak in auxiliary reservoir (ZP). -static int const df_br = 4; // wyplyw z ZP +inline int const df_br = 4; // wyplyw z ZP /// Brake damage flag: leak in valve pre-chamber. -static int const df_vv = 8; // wyplyw z komory wstepnej +inline int const df_vv = 8; // wyplyw z komory wstepnej /// Brake damage flag: leak in brake cylinder. -static int const df_bc = 16; // wyplyw z silownika +inline int const df_bc = 16; // wyplyw z silownika /// Brake damage flag: leak in control reservoir (ZS). -static int const df_cv = 32; // wyplyw z ZS +inline int const df_cv = 32; // wyplyw z ZS /// Brake damage flag: stuck at low load step. -static int const df_PP = 64; // zawsze niski stopien +inline int const df_PP = 64; // zawsze niski stopien /// Brake damage flag: stuck at high load step. -static int const df_RR = 128; // zawsze wysoki stopien +inline int const df_RR = 128; // zawsze wysoki stopien /*indeksy dzwiekow FV4a*/ /// FV4a sound index: braking flow. -static int const s_fv4a_b = 0; // hamowanie +inline int const s_fv4a_b = 0; // hamowanie /// FV4a sound index: release flow. -static int const s_fv4a_u = 1; // luzowanie +inline int const s_fv4a_u = 1; // luzowanie /// FV4a sound index: emergency braking flow. -static int const s_fv4a_e = 2; // hamowanie nagle +inline int const s_fv4a_e = 2; // hamowanie nagle /// FV4a sound index: control wave outflow. -static int const s_fv4a_x = 3; // wyplyw sterujacego fala +inline int const s_fv4a_x = 3; // wyplyw sterujacego fala /// FV4a sound index: timing chamber outflow. -static int const s_fv4a_t = 4; // wyplyw z czasowego +inline int const s_fv4a_t = 4; // wyplyw z czasowego /*pary cierne*/ /// Friction pair: P10 (default cast iron). -static int const bp_P10 = 0; +inline int const bp_P10 = 0; /// Friction pair: P10 phosphoric cast iron with Bg block. -static int const bp_P10Bg = 2; // żeliwo fosforowe P10 +inline int const bp_P10Bg = 2; // żeliwo fosforowe P10 /// Friction pair: P10 phosphoric cast iron with Bgu block. -static int const bp_P10Bgu = 1; +inline int const bp_P10Bgu = 1; /// Friction pair: low-friction composite (b.n.t.) with Bg block. -static int const bp_LLBg = 4; // komp. b.n.t. +inline int const bp_LLBg = 4; // komp. b.n.t. /// Friction pair: low-friction composite (b.n.t.) with Bgu block. -static int const bp_LLBgu = 3; +inline int const bp_LLBgu = 3; /// Friction pair: low-friction composite (n.t.) with Bg block. -static int const bp_LBg = 6; // komp. n.t. +inline int const bp_LBg = 6; // komp. n.t. /// Friction pair: low-friction composite (n.t.) with Bgu block. -static int const bp_LBgu = 5; +inline int const bp_LBgu = 5; /// Friction pair: high-friction composite (w.t.) with Bg block. -static int const bp_KBg = 8; // komp. w.t. +inline int const bp_KBg = 8; // komp. w.t. /// Friction pair: high-friction composite (w.t.) with Bgu block. -static int const bp_KBgu = 7; +inline int const bp_KBgu = 7; /// Friction pair: disc brake type 1. -static int const bp_D1 = 9; // tarcze +inline int const bp_D1 = 9; // tarcze /// Friction pair: disc brake type 2. -static int const bp_D2 = 10; +inline int const bp_D2 = 10; /// Friction pair: Frenoplast FR513 composite. -static int const bp_FR513 = 11; // Frenoplast FR513 +inline int const bp_FR513 = 11; // Frenoplast FR513 /// Friction pair: Cosid composite. -static int const bp_Cosid = 12; // jakistam kompozyt :D +inline int const bp_Cosid = 12; // jakistam kompozyt :D /// Friction pair: PKP cast iron with Bg block. -static int const bp_PKPBg = 13; // żeliwo PKP +inline int const bp_PKPBg = 13; // żeliwo PKP /// Friction pair: PKP cast iron with Bgu block. -static int const bp_PKPBgu = 14; +inline int const bp_PKPBgu = 14; /// Friction pair flag: magnetic rail brake (added bitwise to other types). -static int const bp_MHS = 128; // magnetyczny hamulec szynowy +inline int const bp_MHS = 128; // magnetyczny hamulec szynowy /// Friction pair: P10y phosphoric cast iron with Bg block. -static int const bp_P10yBg = 15; // żeliwo fosforowe P10 +inline int const bp_P10yBg = 15; // żeliwo fosforowe P10 /// Friction pair: P10y phosphoric cast iron with Bgu block. -static int const bp_P10yBgu = 16; +inline int const bp_P10yBgu = 16; /// Friction pair: Frenoplast FR510 composite. -static int const bp_FR510 = 17; // Frenoplast FR510 +inline int const bp_FR510 = 17; // Frenoplast FR510 /// Sound flag: accelerator (rapid pressure drop in valve pre-chamber). -static int const sf_Acc = 1; // przyspieszacz +inline int const sf_Acc = 1; // przyspieszacz /// Sound flag: brake transmission/load relay actuating. -static int const sf_BR = 2; // przekladnia +inline int const sf_BR = 2; // przekladnia /// Sound flag: brake cylinder filling. -static int const sf_CylB = 4; // cylinder - napelnianie +inline int const sf_CylB = 4; // cylinder - napelnianie /// Sound flag: brake cylinder venting. -static int const sf_CylU = 8; // cylinder - oproznianie +inline int const sf_CylU = 8; // cylinder - oproznianie /// Sound flag: releaser actuated. -static int const sf_rel = 16; // odluzniacz +inline int const sf_rel = 16; // odluzniacz /// Sound flag: electro-pneumatic valves switching. -static int const sf_ep = 32; // zawory ep +inline int const sf_ep = 32; // zawory ep /// Brake handle position index: minimum position. -static int const bh_MIN = 0; // minimalna pozycja +inline int const bh_MIN = 0; // minimalna pozycja /// Brake handle position index: maximum position. -static int const bh_MAX = 1; // maksymalna pozycja +inline int const bh_MAX = 1; // maksymalna pozycja /// Brake handle position index: filling stroke (high-pressure overcharge); if not present, equivalent to running. -static int const bh_FS = 2; // napelnianie uderzeniowe //jesli nie ma, to jazda +inline int const bh_FS = 2; // napelnianie uderzeniowe //jesli nie ma, to jazda /// Brake handle position index: running (driving) position. -static int const bh_RP = 3; // jazda +inline int const bh_RP = 3; // jazda /// Brake handle position index: cut-off (double traction / neutral). -static int const bh_NP = 4; // odciecie - podwojna trakcja +inline int const bh_NP = 4; // odciecie - podwojna trakcja /// Brake handle position index: minimum braking step (lap or first step). -static int const bh_MB = 5; // odciecie - utrzymanie stopnia hamowania/pierwszy 1 stopien hamowania +inline int const bh_MB = 5; // odciecie - utrzymanie stopnia hamowania/pierwszy 1 stopien hamowania /// Brake handle position index: full service brake. -static int const bh_FB = 6; // pelne +inline int const bh_FB = 6; // pelne /// Brake handle position index: emergency brake. -static int const bh_EB = 7; // nagle +inline int const bh_EB = 7; // nagle /// Brake handle position index: EP release (full release for angular EP). -static int const bh_EPR = 8; // ep - luzowanie //pelny luz dla ep kątowego +inline int const bh_EPR = 8; // ep - luzowanie //pelny luz dla ep kątowego /// Brake handle position index: EP hold/lap; if equal to release, button-only EP control. -static int const bh_EPN = 9; // ep - utrzymanie //jesli rowne luzowaniu, wtedy sterowanie przyciskiem +inline int const bh_EPN = 9; // ep - utrzymanie //jesli rowne luzowaniu, wtedy sterowanie przyciskiem /// Brake handle position index: EP brake (full braking for angular EP). -static int const bh_EPB = 10; // ep - hamowanie //pelne hamowanie dla ep kątowego +inline int const bh_EPB = 10; // ep - hamowanie //pelne hamowanie dla ep kątowego /// Diameter of the brake pipe (1") used in flow calculations. -static double const SpgD = 0.7917; +inline double const SpgD = 0.7917; /// Cross-section of a 1" brake pipe expressed in l/m (used to keep volumes in liters and lengths in meters). -static double const SpO = 0.5067; // przekroj przewodu 1" w l/m +inline double const SpO = 0.5067; // przekroj przewodu 1" w l/m // wyj: jednostka dosyc dziwna, ale wszystkie obliczenia // i pojemnosci sa podane w litrach (rozsadne wielkosci) // zas dlugosc pojazdow jest podana w metrach @@ -191,12 +197,12 @@ static double const SpO = 0.5067; // przekroj przewodu 1" w l/m /// Brake handle position table for FV4a-family valves (range -2..6). /// Each row holds {flow speed, target brake pipe pressure [bar]} for the matching position index (offset by +2). /// -static double const BPT[9][2] = {{0, 5.0}, {7, 5.0}, {2.0, 5.0}, {4.5, 4.6}, {4.5, 4.2}, {4.5, 3.8}, {4.5, 3.4}, {4.5, 2.8}, {8, 2.8}}; +inline double const BPT[9][2] = {{0, 5.0}, {7, 5.0}, {2.0, 5.0}, {4.5, 4.6}, {4.5, 4.2}, {4.5, 3.8}, {4.5, 3.4}, {4.5, 2.8}, {8, 2.8}}; /// /// Brake handle position table for the Matrosow 394 valve (range -1..5). /// Each row holds {flow speed, target brake pipe pressure [bar]} for the matching position index (offset by +1). /// -static double const BPT_394[7][2] = {{13, 10.0}, {5, 5.0}, {0, -1}, {5, -1}, {5, 0.0}, {5, 0.0}, {18, 0.0}}; +inline double const BPT_394[7][2] = {{13, 10.0}, {5, 5.0}, {0, -1}, {5, -1}, {5, 0.0}, {5, 0.0}, {18, 0.0}}; // double *BPT = zero_based_BPT[2]; //tablica pozycji hamulca dla zakresu -2..6 // double *BPT_394 = zero_based_BPT_394[1]; //tablica pozycji hamulca dla zakresu -1..5 // BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (12, 5.4), (9, 5.0), (9, 4.6), (9, 4.2), (9, 3.8), (9, 3.4), (9, 2.8), (34, 2.8)); @@ -1656,3 +1662,5 @@ extern double PFVa(double PH, double PL, double const S, double LIM, double cons /// Throttling distance from LIM (default 0.1). /// Flow rate from PH to PL. extern double PFVd(double PH, double PL, double const S, double LIM, double const DP = 0.1); // zawor wypuszczajacy z PH do PL, PH do LIM + +} // export diff --git a/application/application.cpp b/application/application.cpp index e5d0b6ba..b029c3cd 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -1,4 +1,64 @@ -/* +module; +#include +#include "glad/glad.h" +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +#include "utilities/translation_macros.h" +#include "version_info.h" +#include +#include "utilities/translation_macros.h" +#if WITH_DISCORD_RPC +#include "ref/discord-rpc/include/discord_rpc.h" +#endif +#if WITH_DISCORD_RPC +#include +#endif +#include +#include "utilities/translation_macros.h" +#include "imgui/imgui.h" +#include "utilities/crashreporter_macros.h" +#include "widgets/imgui_scale.h" +#include +#ifdef _WIN32 +#include +#endif +#ifdef __unix__ +#include +#endif +#ifdef __unix__ +#include +#endif + +module eu07.application.application; +import eu07.rendering.screenshot; +import eu07.utilities.parser; +import eu07.audio.sound; +import eu07.glm; +import eu07.application.drivermode; +import eu07.application.editormode; +import eu07.application.scenarioloadermode; +import eu07.editor.editorterrainstreamer; +import eu07.input.command; +import eu07.launcher.launchermode; +import eu07.model.texture; +import eu07.simcore; +import eu07.utilities.globals; +import eu07.utilities.utilities; +import eu07.simulation.simulation; +import eu07.simulation.simulationsounds; +import eu07.vehicle.train; +import eu07.utilities.dictionary; +import eu07.scene.sceneeditor; +import eu07.rendering.renderer; +import eu07.application.uilayer; +import eu07.utilities.logs; +import eu07.utilities.translation; +import eu07.utilities.timer; +import eu07.utilities.crashreporter; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,39 +67,14 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/application.h" -#include "application/drivermode.h" -#include "application/editormode.h" -#include "application/scenarioloadermode.h" -#include "launcher/launchermode.h" -#include "utilities/Globals.h" -#include "utilities/utilities.h" -#include "simulation/simulation.h" -#include "simulation/simulationsounds.h" -#include "vehicle/Train.h" -#include "utilities/dictionary.h" -#include "scene/sceneeditor.h" -#include "rendering/renderer.h" -#include "application/uilayer.h" -#include "utilities/Logs.h" -#include "rendering/screenshot.h" -#include "utilities/translation.h" -#include "vehicle/Train.h" -#include "utilities/Timer.h" -#include "utilities/dictionary.h" -#include "version_info.h" -#include -#include "utilities/translation.h" #if WITH_DISCORD_RPC -#include "ref/discord-rpc/include/discord_rpc.h" -#include #endif -#include -#include "utilities/translation.h" + +#ifdef _WIN32 +#endif #ifdef _WIN32 #pragma comment(lib, "dsound.lib") @@ -50,8 +85,6 @@ http://mozilla.org/MPL/2.0/. #endif #ifdef __unix__ -#include -#include #endif eu07_application Application; diff --git a/application/application.h b/application/application.cppm similarity index 90% rename from application/application.h rename to application/application.cppm index 11415603..d90f43a0 100644 --- a/application/application.h +++ b/application/application.cppm @@ -6,15 +6,28 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include +#include +#include "scripting/PyInt_macros.h" +#include +#include + +export module eu07.application.application; +import eu07.network.manager; +import eu07.application.applicationmode; +import eu07.scripting.pyint; +import eu07.utilities.headtrack; +#ifdef WITH_UART +import eu07.utilities.uart; +#endif + +export { + -#pragma once - -#include "application/applicationmode.h" -#include "scripting/PyInt.h" -#include "network/manager.h" -#include "utilities/headtrack.h" #ifdef WITH_UART -#include "utilities/uart.h" #endif class eu07_application { @@ -130,3 +143,5 @@ private: }; extern eu07_application Application; + +} // export diff --git a/application/applicationmode.h b/application/applicationmode.cppm similarity index 93% rename from application/applicationmode.h rename to application/applicationmode.cppm index feea3bdb..63f0b22e 100644 --- a/application/applicationmode.h +++ b/application/applicationmode.cppm @@ -7,12 +7,16 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/uilayer.h" // component implementing specific mode of application behaviour // base interface +module; +#include + +export module eu07.application.applicationmode; +import eu07.application.uilayer; +export { class application_mode { public: @@ -57,3 +61,5 @@ protected: // members std::shared_ptr m_userinterface; }; + +} // export diff --git a/application/driverhints.cpp b/application/driverhints.cpp index afa654cf..e66dfcd9 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -1,4 +1,14 @@ -/* +module; +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.simcore; +import eu07.application.driverhints; +import eu07.utilities.globals; +import eu07.utilities.utilities; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +17,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/Driver.h" -#include "utilities/Globals.h" -#include "utilities/utilities.h" void TController::hint( driver_hint const Value, hintpredicate const Predicate, float const Predicateparameter ) { diff --git a/application/driverhints.cppm b/application/driverhints.cppm new file mode 100644 index 00000000..e0e3b9cc --- /dev/null +++ b/application/driverhints.cppm @@ -0,0 +1,17 @@ +module; + +export module eu07.application.driverhints; + +export { + +// The hint list is an X-macro file expanded once here for the enumerators and +// again, with a different DRIVER_HINT_DEF, for the texts in driverhints_texts.h. +#define DRIVER_HINT_DEF(a, b) a, + +enum class driver_hint { + #include "application/driverhints_def.h" +}; + +#undef DRIVER_HINT_DEF + +} // export diff --git a/application/driverhints.h b/application/driverhints.h deleted file mode 100644 index 7b6130c2..00000000 --- a/application/driverhints.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DRIVER_HINT_INCL -#define DRIVER_HINT_INCL -#define DRIVER_HINT_DEF(a, b) a, - -enum class driver_hint { - #include "application/driverhints_def.h" -}; - -#undef DRIVER_HINT_DEF -#endif - -#ifdef DRIVER_HINT_CONTENT -#define DRIVER_HINT_DEF(a, b) b, - -const char *driver_hints_texts[] = -{ - #include "application/driverhints_def.h" -}; - -#undef DRIVER_HINT_DEF -#endif diff --git a/application/driverhints_texts.h b/application/driverhints_texts.h new file mode 100644 index 00000000..7d3324c3 --- /dev/null +++ b/application/driverhints_texts.h @@ -0,0 +1,15 @@ +#pragma once + +// The hint texts are built by re-expanding the X-macro list with a different +// DRIVER_HINT_DEF. A module cannot do that on a consumer's behalf -- the macro +// state would not cross the boundary -- so this stays a plain header, included +// in the global module fragment of the single translation unit that needs it. + +#define DRIVER_HINT_DEF(a, b) b, + +const char *driver_hints_texts[] = +{ + #include "application/driverhints_def.h" +}; + +#undef DRIVER_HINT_DEF diff --git a/application/drivermode.cpp b/application/drivermode.cpp index 80fd3b17..df5660e7 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -1,4 +1,37 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.application.drivermode; +import eu07.application.uitranscripts; +import eu07.application.uilayer; +import eu07.audio.sound; +import eu07.utilities.utilities; +import eu07.application.driveruilayer; +import eu07.utilities.globals; +import eu07.application.application; +import eu07.utilities.translation; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationenvironment; +import eu07.simcore; +import eu07.rendering.lightarray; +import eu07.rendering.particles; +import eu07.vehicle.train; +import eu07.input.messaging; +import eu07.utilities.timer; +import eu07.rendering.renderer; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,28 +40,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/drivermode.h" -#include "application/driveruilayer.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "utilities/translation.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationenvironment.h" -#include "scene/scene.h" -#include "rendering/lightarray.h" -#include "rendering/particles.h" -#include "vehicle/Train.h" -#include "vehicle/Driver.h" -#include "vehicle/DynObj.h" -#include "model/Model3d.h" -#include "world/Event.h" -#include "input/messaging.h" -#include "utilities/Timer.h" -#include "rendering/renderer.h" -#include "utilities/Logs.h" /* namespace input { diff --git a/application/drivermode.h b/application/drivermode.cppm similarity index 85% rename from application/drivermode.h rename to application/drivermode.cppm index 66ff6936..e5c5feed 100644 --- a/application/drivermode.h +++ b/application/drivermode.cppm @@ -1,4 +1,30 @@ -/* +module; +#include +#include +#include +#include + +export module eu07.application.drivermode; +import eu07.utilities.motiontelemetry; +import eu07.glm; +import eu07.input.command; +import eu07.simcore; +import eu07.application.applicationmode; +import eu07.input.driverkeyboardinput; +import eu07.input.drivermouseinput; +import eu07.input.gamepadinput; +import eu07.console; +import eu07.vehicle.camera; +import eu07.utilities.classes; +#ifdef WITH_UART +import eu07.utilities.uart; +#endif +#ifdef WITH_ZMQ +import eu07.input.zmq_input; +#endif + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,21 +33,11 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/applicationmode.h" -#include "input/driverkeyboardinput.h" -#include "input/drivermouseinput.h" -#include "input/gamepadinput.h" -#include "Console.h" -#include "vehicle/Camera.h" -#include "utilities/Classes.h" #ifdef WITH_UART -#include "utilities/uart.h" #endif #ifdef WITH_ZMQ -#include "input/zmq_input.h" #endif class driver_mode : public application_mode { @@ -117,3 +133,5 @@ private: command_relay m_relay; std::string change_train; // train name awaiting entering }; + +} // export diff --git a/application/driveruilayer.cpp b/application/driveruilayer.cpp index 0b8463f8..bd4c2b88 100644 --- a/application/driveruilayer.cpp +++ b/application/driveruilayer.cpp @@ -1,4 +1,20 @@ -/* +module; +#include "imgui/imgui.h" +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" + +module eu07.application.driveruilayer; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.application.application; +import eu07.utilities.translation; +import eu07.simulation.simulation; +import eu07.vehicle.train; +import eu07.simcore; +import eu07.rendering.renderer; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,16 +23,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/driveruilayer.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "utilities/translation.h" -#include "simulation/simulation.h" -#include "vehicle/Train.h" -#include "model/AnimModel.h" -#include "rendering/renderer.h" driver_ui::driver_ui() { diff --git a/application/driveruilayer.h b/application/driveruilayer.cppm similarity index 81% rename from application/driveruilayer.h rename to application/driveruilayer.cppm index 8ad1d775..638f0f52 100644 --- a/application/driveruilayer.h +++ b/application/driveruilayer.cppm @@ -1,4 +1,19 @@ -/* +module; + +export module eu07.application.driveruilayer; +import eu07.application.uilayer; +import eu07.application.driveruipanels; +import eu07.input.command; +import eu07.widgets.vehiclelist; +import eu07.widgets.vehicleparams; +import eu07.widgets.map; +import eu07.widgets.time; +import eu07.widgets.trainingcard; +import eu07.widgets.perfgraphs; +import eu07.widgets.cameraview_extcam; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,19 +22,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/uilayer.h" -#include "application/driveruipanels.h" -#include "input/command.h" -#include "widgets/vehiclelist.h" -#include "widgets/vehicleparams.h" -#include "widgets/map.h" -#include "widgets/time.h" -#include "widgets/trainingcard.h" -#include "widgets/perfgraphs.h" -#include "widgets/cameraview_extcam.h" class driver_ui : public ui_layer { @@ -70,3 +74,5 @@ private: ui::time_panel m_timepanel; ui::cameraview_panel m_cameraviewpanel; }; + +} // export diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 729b854c..90a85f97 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -1,4 +1,47 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include "vehicle/DynObj_macros.h" +#include "utilities/U8_macros.h" +#include "application/driverhints_texts.h" +#include "widgets/imgui_scale.h" + +module eu07.application.driveruipanels; +import eu07.mczapkie.hamulce; +import eu07.audio.sound; +import eu07.utilities.color; +import eu07.glm; +import eu07.application.uilayer; +import eu07.application.uitranscripts; +import eu07.input.command; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.application.application; +import eu07.utilities.translation; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationenvironment; +import eu07.utilities.timer; +import eu07.simcore; +import eu07.vehicle.camera; +import eu07.world.mtable; +import eu07.vehicle.train; +import eu07.rendering.renderer; +import eu07.utilities.logs; +import eu07.widgets.vehicleparams; +import eu07.utilities.u8; +import eu07.application.driverhints; +#ifdef WITH_UART +import eu07.utilities.uart; +using namespace Mtable; +#endif +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,35 +50,10 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/driveruipanels.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "utilities/translation.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationenvironment.h" -#include "utilities/Timer.h" -#include "world/Event.h" -#include "world/TractionPower.h" -#include "vehicle/Camera.h" -#include "world/mtable.h" -#include "vehicle/Train.h" -#include "vehicle/Driver.h" -#include "model/AnimModel.h" -#include "vehicle/DynObj.h" -#include "model/Model3d.h" -#include "rendering/renderer.h" -#include "utilities/Logs.h" -#include "widgets/vehicleparams.h" -#include "utilities/U8.h" -#define DRIVER_HINT_CONTENT -#include "application/driverhints.h" #ifdef WITH_UART -#include "utilities/uart.h" #endif void diff --git a/application/driveruipanels.h b/application/driveruipanels.cppm similarity index 93% rename from application/driveruipanels.h rename to application/driveruipanels.cppm index da4cad87..d71f74ce 100644 --- a/application/driveruipanels.h +++ b/application/driveruipanels.cppm @@ -1,4 +1,16 @@ -/* +module; +#include +#include + +export module eu07.application.driveruipanels; +import eu07.simcore; +import eu07.vehicle.camera; +import eu07.vehicle.train; +import eu07.application.uilayer; +import eu07.utilities.classes; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +19,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/uilayer.h" -#include "utilities/Classes.h" class drivingaid_panel : public ui_expandable_panel { @@ -149,3 +158,5 @@ public: void update() override; void render() override; }; + +} // export diff --git a/application/editormode.cpp b/application/editormode.cpp index 46a8edad..e1bdfdeb 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -1,4 +1,35 @@ -/* +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "imgui/imgui.h" +#include "imgui/ImGuizmo.h" +#include +#include +#include +#include +#include + +module eu07.application.editormode; +import eu07.audio.sound; +import eu07.rendering.geometrybank; +import eu07.editor.editorsettings; +import eu07.utilities.utilities; +import eu07.glm; +import eu07.application.application; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationenvironment; +import eu07.utilities.timer; +import eu07.console; +import eu07.rendering.renderer; +import eu07.utilities.float3d; +import eu07.simcore; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,35 +38,9 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/editormode.h" -#include "application/editoruilayer.h" - -#include "application/application.h" -#include "editor/editorSettings.hpp" -#include "utilities/Globals.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationenvironment.h" -#include "utilities/Timer.h" -#include "Console.h" -#include "rendering/renderer.h" -#include "model/AnimModel.h" -#include "model/Model3d.h" -#include "utilities/Float3d.h" -#include "scene/scene.h" -#include "imgui/imgui.h" -#include "imgui/ImGuizmo.h" -#include "utilities/Logs.h" -#include -#include -#include -#include -#include -#include -#include + // Static member initialization TCamera editor_mode::Camera; diff --git a/application/editormode.h b/application/editormode.cppm similarity index 94% rename from application/editormode.h rename to application/editormode.cppm index 29b1ad69..67c23e7e 100644 --- a/application/editormode.h +++ b/application/editormode.cppm @@ -6,20 +6,29 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - -#include "application/applicationmode.h" -#include "input/editormouseinput.h" -#include "input/editorkeyboardinput.h" -#include "vehicle/Camera.h" -#include "scene/sceneeditor.h" -#include "scene/scenenode.h" -#include "editor/editorTerrain.hpp" -#include "editor/editorTerrainStreamer.hpp" - +module; +#include +#include #include +export module eu07.application.editormode; +import eu07.glm; +import eu07.editor.editorterrain; +import eu07.input.command; +import eu07.input.editorkeyboardinput; +import eu07.utilities.uuid; +import eu07.application.applicationmode; +import eu07.input.editormouseinput; +import eu07.vehicle.camera; +import eu07.scene.sceneeditor; +import eu07.simcore; +import eu07.editor.editorterrainstreamer; + +export { + + + + class editor_mode : public application_mode { @@ -205,3 +214,5 @@ class editor_mode : public application_mode gizmo_operation m_gizmo_op{gizmo_operation::translate}; // current transform mode (translate/rotate/scale) float m_gizmo_snap{1.0f}; // translation snap step (metres) applied while Ctrl is held }; + +} // export diff --git a/application/editoruilayer.cpp b/application/editoruilayer.cpp index d87dd8fa..921f7610 100644 --- a/application/editoruilayer.cpp +++ b/application/editoruilayer.cpp @@ -1,4 +1,13 @@ -/* +module; +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.simcore; +import eu07.utilities.globals; +import eu07.utilities.utilities; +import eu07.rendering.renderer; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +16,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/editoruilayer.h" -#include "utilities/Globals.h" -#include "utilities/utilities.h" -#include "scene/scenenode.h" -#include "rendering/renderer.h" editor_ui::editor_ui() { diff --git a/application/editoruilayer.h b/application/editoruilayer.cppm similarity index 86% rename from application/editoruilayer.h rename to application/editoruilayer.cppm index ad3d5447..a0118098 100644 --- a/application/editoruilayer.h +++ b/application/editoruilayer.cppm @@ -1,4 +1,13 @@ -/* +module; +#include + +export module eu07.simcore:editoruilayer; +import :fwd; +import eu07.application.uilayer; +import :editoruipanels; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +16,11 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/uilayer.h" -#include "application/editoruipanels.h" namespace scene { -class basic_node; } @@ -46,3 +51,5 @@ class editor_ui : public ui_layer brush_object_list m_brushobjects{"Brush properties", false}; scene::basic_node *m_node{nullptr}; // currently bound scene node, if any }; + +} // export diff --git a/application/editoruipanels.cpp b/application/editoruipanels.cpp index f15f791e..def3b095 100644 --- a/application/editoruipanels.cpp +++ b/application/editoruipanels.cpp @@ -1,4 +1,23 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "widgets/imgui_scale.h" + +module eu07.simcore; +import eu07.utilities.utilities; +import eu07.scene.scenenodegroups; +import eu07.utilities.globals; +import eu07.vehicle.camera; +import eu07.rendering.renderer; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,18 +26,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/editoruipanels.h" -#include "scene/scenenodegroups.h" -#include "utilities/Globals.h" -#include "vehicle/Camera.h" -#include "model/AnimModel.h" -#include "world/Track.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "application/editoruilayer.h" -#include "rendering/renderer.h" void itemproperties_panel::update(scene::basic_node *Node) { diff --git a/application/editoruipanels.h b/application/editoruipanels.cppm similarity index 92% rename from application/editoruipanels.h rename to application/editoruipanels.cppm index 41da7173..a166d42f 100644 --- a/application/editoruipanels.h +++ b/application/editoruipanels.cppm @@ -1,4 +1,15 @@ -/* +module; +#include "global_include/interfaces/ITexture_macros.h" +#include +#include + +export module eu07.simcore:editoruipanels; +import :fwd; +import eu07.application.uilayer; +import eu07.utilities.classes; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +18,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/uilayer.h" -#include "utilities/Classes.h" /* // helper, associated bool is set when the primary value was changed and expects processing at the observer's leisure template @@ -128,4 +136,5 @@ class functions_panel : public ui_panel scene::group_handle m_grouphandle{null_handle}; // scene group bound to the panel std::string m_groupprefix; std::vector m_grouplines; -}; \ No newline at end of file +}; +} // export diff --git a/application/scenarioloadermode.cpp b/application/scenarioloadermode.cpp index f05c3869..82c5c1a5 100644 --- a/application/scenarioloadermode.cpp +++ b/application/scenarioloadermode.cpp @@ -1,3 +1,22 @@ +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" + +module eu07.application.scenarioloadermode; +import eu07.utilities.classes; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationenvironment; +import eu07.application.application; +import eu07.application.scenarioloaderuilayer; +import eu07.rendering.renderer; +import eu07.utilities.logs; +import eu07.utilities.translation; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,18 +26,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/scenarioloadermode.h" -#include "utilities/Globals.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationenvironment.h" -#include "application/application.h" -#include "application/scenarioloaderuilayer.h" -#include "rendering/renderer.h" -#include "utilities/Logs.h" -#include "utilities/translation.h" scenarioloader_mode::scenarioloader_mode() { m_userinterface = std::make_shared(); diff --git a/application/scenarioloadermode.h b/application/scenarioloadermode.cppm similarity index 84% rename from application/scenarioloadermode.h rename to application/scenarioloadermode.cppm index db23458d..ffedc020 100644 --- a/application/scenarioloadermode.h +++ b/application/scenarioloadermode.cppm @@ -6,11 +6,18 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include + +export module eu07.application.scenarioloadermode; +import eu07.simulation.simulationstateserializer; +import eu07.application.applicationmode; +import eu07.simulation.simulation; + +export { -#pragma once -#include "application/applicationmode.h" -#include "simulation/simulation.h" class scenarioloader_mode : public application_mode { std::shared_ptr state; @@ -37,3 +44,5 @@ public: void on_event_poll() override { ; } bool is_command_processor() const override; }; + +} // export diff --git a/application/scenarioloaderuilayer.cpp b/application/scenarioloaderuilayer.cpp index c4e7df3d..8503178e 100644 --- a/application/scenarioloaderuilayer.cpp +++ b/application/scenarioloaderuilayer.cpp @@ -1,3 +1,17 @@ +module; +#include "glad/glad.h" +#include "imgui/imgui.h" +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include +#include + +module eu07.application.scenarioloaderuilayer; +import eu07.glm; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.utilities.translation; +import eu07.utilities.logs; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,13 +21,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "application/scenarioloaderuilayer.h" -#include "utilities/Globals.h" -#include "utilities/translation.h" -#include -#include "utilities/Logs.h" -#include using json = nlohmann::json; diff --git a/application/scenarioloaderuilayer.h b/application/scenarioloaderuilayer.cppm similarity index 79% rename from application/scenarioloaderuilayer.h rename to application/scenarioloaderuilayer.cppm index 72d7c3df..17634d09 100644 --- a/application/scenarioloaderuilayer.h +++ b/application/scenarioloaderuilayer.cppm @@ -1,4 +1,14 @@ -/* +module; +#include "glad/glad.h" +#include +#include + +export module eu07.application.scenarioloaderuilayer; +import eu07.application.uilayer; +import eu07.launcher.deferred_image; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "application/uilayer.h" -#include "launcher/deferred_image.h" class scenarioloader_ui : public ui_layer { int m_gradient_overlay_width; @@ -36,3 +43,5 @@ private: /// std::string sceneryName; }; + +} // export diff --git a/application/uilayer.cpp b/application/uilayer.cpp index 60c8a778..76696278 100644 --- a/application/uilayer.cpp +++ b/application/uilayer.cpp @@ -1,4 +1,31 @@ -/* +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include "imgui/imgui.h" +#include "imgui/imgui_impl_glfw.h" +#include "imgui/imgui.h" +#include "widgets/imgui_scale.h" + +module eu07.application.uilayer; +import eu07.simcore; +import eu07.application.application; +import eu07.application.editormode; +import eu07.input.command; +import eu07.utilities.utilities; +import eu07.vehicle.camera; +import eu07.utilities.globals; +import eu07.rendering.renderer; +import eu07.utilities.logs; +import eu07.simulation.simulation; +import eu07.utilities.translation; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,20 +34,9 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "application/uilayer.h" -#include -#include "utilities/Globals.h" -#include "rendering/renderer.h" -#include "utilities/Logs.h" -#include "simulation/simulation.h" -#include "utilities/translation.h" -#include "application/application.h" -#include "application/editormode.h" -#include "imgui/imgui_impl_glfw.h" GLFWwindow *ui_layer::m_window{nullptr}; ImGuiIO *ui_layer::m_imguiio{nullptr}; diff --git a/application/uilayer.h b/application/uilayer.cppm similarity index 85% rename from application/uilayer.h rename to application/uilayer.cppm index 6d4019c6..82c1bb9e 100644 --- a/application/uilayer.h +++ b/application/uilayer.cppm @@ -1,4 +1,21 @@ -/* +module; +#include "global_include/interfaces/ITexture_macros.h" +#include "glad/glad.h" +#include +#include "imgui/imgui.h" +#include +#include +#include +#include +#include + +export module eu07.application.uilayer; +import eu07.glm; +import eu07.global_include.interfaces.itexture; +import eu07.model.texture; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +24,33 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include "model/Texture.h" -#include "widgets/popup.h" + +// ui::popup and ui_panel refer to each other, so they have to share a module: +// a forward declaration cannot cross a module boundary. popup only needs the +// name, while ui_panel holds popups by value in a list and needs the definition. +class ui_panel; + +namespace ui +{ + +class popup +{ + std::string m_id; + static int id; + + public: + popup(ui_panel &panel); + virtual ~popup(); + + virtual bool render(); + + protected: + ui_panel &m_parent; + virtual void render_content() = 0; +}; + +} // namespace ui // GuiLayer -- basic user interface class. draws requested information on top of openGL screen @@ -66,7 +105,6 @@ class ui_log_panel : public ui_panel { void render_contents() override; }; -struct ImFont; class ui_layer { public: @@ -162,3 +200,5 @@ protected: bool m_editor_hierarchy = false; bool m_editor_change_history = false; }; + +} // export diff --git a/application/uitranscripts.cpp b/application/uitranscripts.cpp index 96c9f735..297a59ef 100644 --- a/application/uitranscripts.cpp +++ b/application/uitranscripts.cpp @@ -1,9 +1,14 @@ -#include "stdafx.h" -#include "application/uitranscripts.h" +module; +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +#include + +module eu07.application.uitranscripts; +import eu07.utilities.globals; +import eu07.utilities.parser; +import eu07.utilities.utilities; -#include "utilities/Globals.h" -#include "utilities/parser.h" -#include "utilities/utilities.h" namespace ui { diff --git a/application/uitranscripts.h b/application/uitranscripts.cppm similarity index 90% rename from application/uitranscripts.h rename to application/uitranscripts.cppm index 7db201a1..70de0623 100644 --- a/application/uitranscripts.h +++ b/application/uitranscripts.cppm @@ -1,9 +1,13 @@ - -#pragma once - +module; #include #include +export module eu07.application.uitranscripts; + +export { + + + namespace ui { // klasa obsługująca linijkę napisu do dźwięku @@ -38,4 +42,5 @@ private: extern TTranscripts Transcripts; -} // namespace ui \ No newline at end of file +} // namespace ui +} // export diff --git a/audio/audio.cpp b/audio/audio.cpp index 1c72d1bc..fe026d8e 100644 --- a/audio/audio.cpp +++ b/audio/audio.cpp @@ -1,4 +1,20 @@ -/* +module; +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.audio.audio; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.model.resourcemanager; +import eu07.utilities.utilities; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +23,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include -#include "audio/audio.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "model/ResourceManager.h" -#include "utilities/utilities.h" namespace audio { diff --git a/audio/audio.h b/audio/audio.cppm similarity index 74% rename from audio/audio.h rename to audio/audio.cppm index 5e306d25..77f126cc 100644 --- a/audio/audio.h +++ b/audio/audio.cppm @@ -1,4 +1,44 @@ -/* +module; +#include "global_include/interfaces/ITexture_macros.h" +#if defined(__APPLE__) && !__has_include() +#include +#endif +#if defined(__APPLE__) && !__has_include() +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif +#if defined(__APPLE__) && !__has_include() +#else +#include +#endif + +export module eu07.audio.audio; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +47,9 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once #if defined(__APPLE__) && !__has_include() -#include -#include #else -#include -#include -#include #endif namespace audio { @@ -80,3 +114,5 @@ private: } // audio //--------------------------------------------------------------------------- + +} // export diff --git a/audio/audiorenderer.cpp b/audio/audiorenderer.cpp index 81f81570..22a009e0 100644 --- a/audio/audiorenderer.cpp +++ b/audio/audiorenderer.cpp @@ -1,4 +1,27 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "audio/audiorenderer_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/crashreporter_macros.h" + +module eu07.audio.sound; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.vehicle.camera; +import eu07.utilities.logs; +import eu07.simulation.simulation; +import eu07.vehicle.train; +import eu07.utilities.crashreporter; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +30,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "audio/audiorenderer.h" -#include "audio/sound.h" -#include "utilities/Globals.h" -#include "vehicle/Camera.h" -#include "utilities/Logs.h" -#include "simulation/simulation.h" -#include "vehicle/Train.h" namespace audio { diff --git a/audio/audiorenderer.h b/audio/audiorenderer.h deleted file mode 100644 index ec26ec82..00000000 --- a/audio/audiorenderer.h +++ /dev/null @@ -1,168 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include "audio/audio.h" -#include "model/ResourceManager.h" -#include "application/uitranscripts.h" - -// Dodaj brakujące includy -#include -#include -#include -#include - -// Definicje dla OpenAL 1.25 jeśli brakuje -#ifndef ALC_CONNECTED -#define ALC_CONNECTED 0x313 -#endif - -#ifndef ALC_DEFAULT_ALL_DEVICES_SPECIFIER -#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 -#endif - -#define EU07_SOUND_PROOFINGUSESRANGE - -class opengl_renderer; -class sound_source; - -using uint32_sequence = std::vector; - -enum class sound_category : unsigned int { - unknown = 0, - vehicle, - local, - ambient, -}; - -struct sound_properties { - glm::dvec3 location; - float pitch { 1.f }; - sound_category category { sound_category::unknown }; - float gain { 1.f }; - float soundproofing { 1.f }; - std::uintptr_t soundproofing_stamp { ~std::uintptr_t{0} }; -}; - -enum class sync_state { - good, - bad_distance, - bad_resource -}; - -namespace audio { - -struct openal_source { - - friend class openal_renderer; - - using buffer_sequence = std::vector; - - ALuint id { audio::null_resource }; - sound_source *controller { nullptr }; - uint32_sequence sounds; - int sound_index { 0 }; - bool sound_change { false }; - bool is_playing { false }; - bool is_looping { false }; - sound_properties properties; - sync_state sync { sync_state::good }; - - openal_source() = default; - - template - openal_source &bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ); - - void play(); - void update( double const Deltatime, glm::vec3 const &Listenervelocity ); - void sync_with( sound_properties const &State ); - void stop(); - void loop( bool const State ); - void range( float const Range ); - void pitch( float const Pitch ); - void clear(); - -private: - double update_deltatime { 0.0 }; - float pitch_variation { 1.f }; - float sound_range { 50.f }; - glm::vec3 sound_distance { 0.f }; - glm::vec3 sound_velocity { 0.f }; - bool is_in_range { false }; - bool is_multipart { false }; -}; - -class openal_renderer { - - friend opengl_renderer; - -public: - openal_renderer() = default; - ~openal_renderer(); - - audio::buffer_handle fetch_buffer( std::string const &Filename ); - audio::openal_buffer const &buffer( audio::buffer_handle const Buffer ) const; - - bool init(); - - template - void insert( Iterator_ First, Iterator_ Last, sound_source *Controller, uint32_sequence Sounds ) { - m_sources.emplace_back( fetch_source().bind( Controller, Sounds, First, Last ) ); - } - - void erase( sound_source const *Controller ); - void update( double const Deltatime ); - - glm::dvec3 cached_camerapos; - -private: - using source_list = std::list; - using source_sequence = std::stack; - - bool init_caps(); - audio::openal_source fetch_source(); - - ALCdevice *m_device { nullptr }; - ALCcontext *m_context { nullptr }; - bool m_ready { false }; - glm::vec3 m_listenervelocity; - bool m_freeflymode { true }; - bool m_windowopen { true }; - int m_activecab { 0 }; - - buffer_manager m_buffers; - source_list m_sources; - source_sequence m_sourcespares; - - // OpenAL Soft extension entry points, resolved at runtime via al(c)GetProcAddress - LPALDEFERUPDATESSOFT m_alDeferUpdatesSOFT { nullptr }; - LPALPROCESSUPDATESSOFT m_alProcessUpdatesSOFT { nullptr }; - LPALCDEVICEPAUSESOFT m_alcDevicePauseSOFT { nullptr }; - LPALCDEVICERESUMESOFT m_alcDeviceResumeSOFT { nullptr }; - LPALCREOPENDEVICESOFT m_alcReopenDeviceSOFT { nullptr }; - - bool m_candetectdisconnect { false }; - ALCint m_contextattributes[3] { 0, 0, 0 }; - double m_devicechecktime { 0.0 }; - - // ALC_SOFT_system_events: event-driven following of output-device / default-output changes. - // Preferred over polling because it reliably catches both device removal and default changes - // (e.g. re-plugging headphones), which alcGetString(DEFAULT_ALL_DEVICES) does not report live. - LPALCEVENTCONTROLSOFT m_alcEventControlSOFT { nullptr }; - LPALCEVENTCALLBACKSOFT m_alcEventCallbackSOFT { nullptr }; - bool m_usedeviceevents { false }; - std::atomic m_outputchanged { false }; // set from the (possibly off-thread) event callback - static void ALC_APIENTRY device_event_callback( ALCenum eventtype, ALCenum devicetype, ALCdevice *device, ALCsizei length, ALCchar const *message, void *userparam ) noexcept; -}; - -extern openal_renderer renderer; -extern bool event_volume_change; - -} // namespace audio \ No newline at end of file diff --git a/audio/audiorenderer_extra.h b/audio/audiorenderer_extra.h index 430f594b..97aaacc8 100644 --- a/audio/audiorenderer_extra.h +++ b/audio/audiorenderer_extra.h @@ -1,5 +1,6 @@ // separate file because of include dependecies mess +#include namespace audio { template openal_source & diff --git a/audio/audiorenderer_macros.h b/audio/audiorenderer_macros.h new file mode 100644 index 00000000..d05c7636 --- /dev/null +++ b/audio/audiorenderer_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 diff --git a/audio/sound.cpp b/audio/sound.cpp index 0ff2eff9..141d500f 100644 --- a/audio/sound.cpp +++ b/audio/sound.cpp @@ -1,4 +1,35 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.audio.sound; +import eu07.utilities.logs; +import eu07.utilities.utilities; +import eu07.utilities.parser; +import eu07.utilities.globals; +import eu07.vehicle.camera; +import eu07.vehicle.train; +import eu07.simcore; +import eu07.simulation.simulation; + +namespace { +// sound_source stores its owner as an opaque pointer to keep TDynamicObject out of +// the module interface; this puts the type back on where the implementation needs it. +inline TDynamicObject const *as_vehicle( void const *Owner ) { + return static_cast( Owner ); +} +} // namespace +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +38,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "audio/sound.h" -#include "utilities/parser.h" -#include "utilities/Globals.h" -#include "vehicle/Camera.h" -#include "vehicle/Train.h" -#include "vehicle/DynObj.h" -#include "simulation/simulation.h" #include "audio/audiorenderer_extra.h" // constructors @@ -517,7 +540,7 @@ void sound_source::update( audio::openal_source &Source ) { if( m_owner != nullptr - && false == m_owner->bEnabled ) { + && false == as_vehicle( m_owner )->bEnabled ) { // terminate the sound if the owner is gone // TBD, TODO: replace with a listener pattern to receive vehicle removal and cab change events and such? m_stop = true; @@ -914,10 +937,10 @@ sound_source::location() const { } // otherwise combine offset with the location of the carrier return { - m_owner->GetPosition() - + m_owner->VectorLeft() * (double)m_offset.x - + m_owner->VectorUp() * (double)m_offset.y - + m_owner->VectorFront() * (double)m_offset.z }; + as_vehicle( m_owner )->GetPosition() + + as_vehicle( m_owner )->VectorLeft() * (double)m_offset.x + + as_vehicle( m_owner )->VectorUp() * (double)m_offset.y + + as_vehicle( m_owner )->VectorFront() * (double)m_offset.z }; } void @@ -994,7 +1017,7 @@ sound_source::update_soundproofing() { occupiedcab ) }; m_properties.soundproofing = m_soundproofing ? // custom soundproofing has higher priority than that of the owner m_soundproofing.value()[listenerlocation + 1] : // cab indices start from -1 so we have to account for this - m_owner->soundproofing(static_cast(placement), listenerlocation); + as_vehicle( m_owner )->soundproofing(static_cast(placement), listenerlocation); } if( listenervehicle && listenervehicle != m_owner ) { // if the listener is located in another vehicle, calculate additional proofing of the sound coming from outside diff --git a/audio/sound.h b/audio/sound.cppm similarity index 62% rename from audio/sound.h rename to audio/sound.cppm index c0f14513..357dc586 100644 --- a/audio/sound.h +++ b/audio/sound.cppm @@ -1,4 +1,29 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "audio/audiorenderer_macros.h" +#include +#include +#include +#include + +export module eu07.audio.sound; +import eu07.audio.audio; +import eu07.glm; +import eu07.utilities.parser; +import eu07.application.uitranscripts; +import eu07.model.resourcemanager; +import eu07.utilities.classes; +import eu07.utilities.names; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +32,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "audio/audiorenderer.h" -#include "utilities/Classes.h" -#include "utilities/Names.h" float const EU07_SOUND_GLOBALRANGE { -1.f }; float const EU07_SOUND_CABCONTROLSCUTOFFRANGE { 7.5f }; @@ -54,6 +75,166 @@ auto const EU07_SOUNDPROOFING_VERYSTRONG{ std::sqrt( 0.01f ) }; // mini controller and audio dispatcher; issues play commands for the audio renderer, // updates parameters of created audio emitters for the playback duration // TODO: move to simulation namespace after clean up of owner classes +// openal_source and sound_source refer to each other, so they must share a +// module: neither can forward-declare the other across a module boundary. +// The renderer only ever handles a sound_source through a pointer. +class sound_source; + +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + + + +// Dodaj brakujące includy + +// Definicje dla OpenAL 1.25 jeśli brakuje +#ifndef ALC_CONNECTED +#define ALC_CONNECTED 0x313 +#endif + +#ifndef ALC_DEFAULT_ALL_DEVICES_SPECIFIER +#endif + +#define EU07_SOUND_PROOFINGUSESRANGE + + +using uint32_sequence = std::vector; + +enum class sound_category : unsigned int { + unknown = 0, + vehicle, + local, + ambient, +}; + +struct sound_properties { + glm::dvec3 location; + float pitch { 1.f }; + sound_category category { sound_category::unknown }; + float gain { 1.f }; + float soundproofing { 1.f }; + std::uintptr_t soundproofing_stamp { ~std::uintptr_t{0} }; +}; + +enum class sync_state { + good, + bad_distance, + bad_resource +}; + +namespace audio { + +struct openal_source { + + friend class openal_renderer; + + using buffer_sequence = std::vector; + + ALuint id { audio::null_resource }; + sound_source *controller { nullptr }; + uint32_sequence sounds; + int sound_index { 0 }; + bool sound_change { false }; + bool is_playing { false }; + bool is_looping { false }; + sound_properties properties; + sync_state sync { sync_state::good }; + + openal_source() = default; + + template + openal_source &bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ); + + void play(); + void update( double const Deltatime, glm::vec3 const &Listenervelocity ); + void sync_with( sound_properties const &State ); + void stop(); + void loop( bool const State ); + void range( float const Range ); + void pitch( float const Pitch ); + void clear(); + +private: + double update_deltatime { 0.0 }; + float pitch_variation { 1.f }; + float sound_range { 50.f }; + glm::vec3 sound_distance { 0.f }; + glm::vec3 sound_velocity { 0.f }; + bool is_in_range { false }; + bool is_multipart { false }; +}; + +class openal_renderer { +public: + openal_renderer() = default; + ~openal_renderer(); + + audio::buffer_handle fetch_buffer( std::string const &Filename ); + audio::openal_buffer const &buffer( audio::buffer_handle const Buffer ) const; + + bool init(); + + template + void insert( Iterator_ First, Iterator_ Last, sound_source *Controller, uint32_sequence Sounds ) { + m_sources.emplace_back( fetch_source().bind( Controller, Sounds, First, Last ) ); + } + + void erase( sound_source const *Controller ); + void update( double const Deltatime ); + + glm::dvec3 cached_camerapos; + +private: + using source_list = std::list; + using source_sequence = std::stack; + + bool init_caps(); + audio::openal_source fetch_source(); + + ALCdevice *m_device { nullptr }; + ALCcontext *m_context { nullptr }; + bool m_ready { false }; + glm::vec3 m_listenervelocity; + bool m_freeflymode { true }; + bool m_windowopen { true }; + int m_activecab { 0 }; + + buffer_manager m_buffers; + source_list m_sources; + source_sequence m_sourcespares; + + // OpenAL Soft extension entry points, resolved at runtime via al(c)GetProcAddress + LPALDEFERUPDATESSOFT m_alDeferUpdatesSOFT { nullptr }; + LPALPROCESSUPDATESSOFT m_alProcessUpdatesSOFT { nullptr }; + LPALCDEVICEPAUSESOFT m_alcDevicePauseSOFT { nullptr }; + LPALCDEVICERESUMESOFT m_alcDeviceResumeSOFT { nullptr }; + LPALCREOPENDEVICESOFT m_alcReopenDeviceSOFT { nullptr }; + + bool m_candetectdisconnect { false }; + ALCint m_contextattributes[3] { 0, 0, 0 }; + double m_devicechecktime { 0.0 }; + + // ALC_SOFT_system_events: event-driven following of output-device / default-output changes. + // Preferred over polling because it reliably catches both device removal and default changes + // (e.g. re-plugging headphones), which alcGetString(DEFAULT_ALL_DEVICES) does not report live. + LPALCEVENTCONTROLSOFT m_alcEventControlSOFT { nullptr }; + LPALCEVENTCALLBACKSOFT m_alcEventCallbackSOFT { nullptr }; + bool m_usedeviceevents { false }; + std::atomic m_outputchanged { false }; // set from the (possibly off-thread) event callback + static void ALC_APIENTRY device_event_callback( ALCenum eventtype, ALCenum devicetype, ALCdevice *device, ALCsizei length, ALCchar const *message, void *userparam ) noexcept; +}; + +extern openal_renderer renderer; +extern bool event_volume_change; + +} // namespace audio + class sound_source { public: @@ -96,11 +277,13 @@ public: // sets base pitch of the emitter to specified value sound_source & pitch( float const Pitch ); - // owner setter/getter + // Owner setter. The owning vehicle is stored as an opaque pointer so that this + // interface does not name TDynamicObject: the vehicle module imports this one + // (vehicles hold sound sources by value), so naming it here would close a cycle + // in the module graph, and a forward declaration cannot cross a module boundary. + // sound.cpp casts it back before use. void - owner( TDynamicObject const *Owner ); - TDynamicObject const * - owner() const; + owner( void const *Owner ); // sound source offset setter/getter void offset( glm::vec3 const Offset ); @@ -224,7 +407,7 @@ private: sound( sound_handle const Sound ) const; // members - TDynamicObject const * m_owner { nullptr }; // optional, the vehicle carrying this sound source + void const * m_owner { nullptr }; // optional, the vehicle carrying this sound source (a TDynamicObject) glm::vec3 m_offset; // relative position of the source, either from the owner or the region centre sound_placement m_placement; float m_range { 50.f }; // audible range of the emitted sounds @@ -245,9 +428,11 @@ private: std::optional< std::array > m_soundproofing; // custom soundproofing parameters }; -// owner setter/getter -inline void sound_source::owner( TDynamicObject const *Owner ) { m_owner = Owner; } -inline TDynamicObject const * sound_source::owner() const { return m_owner; } +} // export -- out-of-line member definitions and explicit +// specialisations are not namespace-scope declarations, so they cannot +// carry `export`; the class itself is exported and that is what counts. +// owner setter +inline void sound_source::owner( void const *Owner ) { m_owner = Owner; } // sound source offset setter/getter inline void sound_source::offset( glm::vec3 const Offset ) { m_offset = Offset; } inline glm::vec3 const & sound_source::offset() const { return m_offset; } @@ -260,9 +445,12 @@ inline float const & sound_source::start() const { return m_startoffset; } // custom soundproofing setter/getter inline auto & sound_source::soundproofing() { return m_soundproofing; } inline auto const & sound_source::soundproofing() const { return m_soundproofing; } +export { // collection of sound sources present in the scene class sound_table : public basic_table { }; + +} // export diff --git a/ci_shadervalidator/Logs.h b/ci_shadervalidator/Logs.h index d5c87b7e..9c2047de 100644 --- a/ci_shadervalidator/Logs.h +++ b/ci_shadervalidator/Logs.h @@ -1,4 +1,5 @@ #pragma once +#include enum class logtype : unsigned int { shader }; diff --git a/ci_shadervalidator/main.cpp b/ci_shadervalidator/main.cpp index 7a4b53aa..e069910a 100644 --- a/ci_shadervalidator/main.cpp +++ b/ci_shadervalidator/main.cpp @@ -1,4 +1,3 @@ -#include "stdafx.h" #include "../gl/shader.h" #include "../gl/glsl_common.h" #include "Globals.h" diff --git a/editor/editorSettings.cpp b/editor/editorSettings.cpp index 86214d6b..07f1c3e9 100644 --- a/editor/editorSettings.cpp +++ b/editor/editorSettings.cpp @@ -1,3 +1,12 @@ +module; +#include "utilities/utilities_macros.h" +#include +#include +#include + +module eu07.editor.editorsettings; +import eu07.utilities.logs; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +16,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "editor/editorSettings.hpp" -#include "utilities/Logs.h" -#include "utilities/utilities.h" -#include -#include -#include editorSettings EditorSettings; diff --git a/editor/editorSettings.hpp b/editor/editorSettings.cppm similarity index 87% rename from editor/editorSettings.hpp rename to editor/editorSettings.cppm index 4ed09444..2b4cb771 100644 --- a/editor/editorSettings.hpp +++ b/editor/editorSettings.cppm @@ -1,4 +1,8 @@ -#pragma once +module; + +export module eu07.editor.editorsettings; + +export { class editorSettings { @@ -24,3 +28,5 @@ private: // global editor settings instance extern editorSettings EditorSettings; + +} // export diff --git a/editor/editorTerrain.cpp b/editor/editorTerrain.cpp index 55e71b5c..99abdaa6 100644 --- a/editor/editorTerrain.cpp +++ b/editor/editorTerrain.cpp @@ -1,3 +1,16 @@ +module; +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include +#include +#include + +module eu07.editor.editorterrain; +import eu07.simcore; +import eu07.simulation.simulation; +import eu07.rendering.renderer; +import eu07.model.vertex; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,18 +20,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "editor/editorTerrain.hpp" -#include "scene/scene.h" -#include "scene/scenenode.h" -#include "simulation/simulation.h" -#include "rendering/renderer.h" -#include "model/vertex.h" -#include -#include -#include namespace { diff --git a/editor/editorTerrain.hpp b/editor/editorTerrain.cppm similarity index 94% rename from editor/editorTerrain.hpp rename to editor/editorTerrain.cppm index 04436685..98f9d37f 100644 --- a/editor/editorTerrain.hpp +++ b/editor/editorTerrain.cppm @@ -6,19 +6,25 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; #include #include #include -#include +#include "global_include/interfaces/ITexture_macros.h" + +export module eu07.editor.editorterrain; +import eu07.simcore; +import eu07.model.vertex; +import eu07.glm; +import eu07.utilities.classes; +import eu07.global_include.interfaces.itexture; +import eu07.rendering.geometrybank; + +export { + + -#include "utilities/Classes.h" // material_handle -#include "interfaces/ITexture.h" // null_handle -#include "rendering/geometrybank.h" // gfx::geometry_handle / geometrybank_handle -namespace scene { class basic_section; } // Editor-owned, editable terrain patch. // @@ -111,3 +117,5 @@ class editor_terrain bool m_dirty{false}; // edited since the last optimize (full-res, awaiting simplification) bool m_modified{false}; // edited since load/save (for streaming persistence) }; + +} // export diff --git a/editor/editorTerrainStreamer.cpp b/editor/editorTerrainStreamer.cpp index 6d45ef34..daf01ec4 100644 --- a/editor/editorTerrainStreamer.cpp +++ b/editor/editorTerrainStreamer.cpp @@ -1,3 +1,13 @@ +module; +#include +#include +#include +#include +#include +#include +#include + +module eu07.editor.editorterrainstreamer; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,15 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "editor/editorTerrainStreamer.hpp" -#include -#include -#include -#include -#include -#include // simulation-level streamer instance (see header) terrain_streamer EditorTerrain; diff --git a/editor/editorTerrainStreamer.hpp b/editor/editorTerrainStreamer.cppm similarity index 96% rename from editor/editorTerrainStreamer.hpp rename to editor/editorTerrainStreamer.cppm index ead4a3e1..5c554276 100644 --- a/editor/editorTerrainStreamer.hpp +++ b/editor/editorTerrainStreamer.cppm @@ -7,15 +7,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include -#include -#include -#include -#include "editor/editorTerrain.hpp" // Streams editable terrain chunks around the camera for an effectively unbounded world. // @@ -23,6 +16,17 @@ http://mozilla.org/MPL/2.0/. // camera; chunks entering the radius are built, chunks leaving it are destroyed (the renderer's // geometry GC reclaims their GPU memory). Heights are flat + a gentle procedural roll so streaming // is observable. Phase 2 will add 16-bit on-disk chunk paging, per-chunk flag bits and persistence. +module; +#include +#include +#include +#include +#include + +export module eu07.editor.editorterrainstreamer; +import eu07.editor.editorterrain; +import eu07.glm; +export { class terrain_streamer { public: @@ -114,3 +118,5 @@ class terrain_streamer // loader (so streamed terrain renders in every mode, including the driver). loaded from the // `editorterrain` scenery directive and updated each frame with the active camera. extern terrain_streamer EditorTerrain; + +} // export diff --git a/environment/moon.cpp b/environment/moon.cpp index 0cd4ce7d..0b0ced96 100644 --- a/environment/moon.cpp +++ b/environment/moon.cpp @@ -1,9 +1,18 @@ -#include "stdafx.h" -#include "environment/moon.h" -#include "utilities/Globals.h" -#include "world/mtable.h" -#include "utilities/utilities.h" -#include "simulation/simulationtime.h" +module; +#include +#include "winheaders.h" +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.environment.moon; +import eu07.glm; +import eu07.utilities.globals; +import eu07.world.mtable; +import eu07.utilities.utilities; +import eu07.simulation.simulationtime; ////////////////////////////////////////////////////////////////////////////////////////// // cSun -- class responsible for dynamic calculation of position and intensity of the Sun, diff --git a/environment/moon.h b/environment/moon.cppm similarity index 97% rename from environment/moon.h rename to environment/moon.cppm index ca8ff29c..e0ff8615 100644 --- a/environment/moon.h +++ b/environment/moon.cppm @@ -1,8 +1,13 @@ -#pragma once -#include "winheaders.h" // TODO: sun and moon share code as celestial bodies, we could make a base class out of it +module; +#include "winheaders.h" + +export module eu07.environment.moon; +import eu07.glm; + +export { class cMoon { @@ -97,3 +102,5 @@ protected: glm::vec3 m_position; float m_phase; }; + +} // export diff --git a/environment/sky.cpp b/environment/sky.cpp index f3f09f82..1c29af62 100644 --- a/environment/sky.cpp +++ b/environment/sky.cpp @@ -1,3 +1,10 @@ +module; +#include +#include "utilities/Globals_macros.h" + +module eu07.environment.sky; +import eu07.utilities.globals; +import eu07.model.mdlmngr; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,10 +14,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "environment/sky.h" -#include "utilities/Globals.h" -#include "model/MdlMngr.h" //--------------------------------------------------------------------------- //GLfloat lightPos[4] = {0.0f, 0.0f, 0.0f, 1.0f}; diff --git a/environment/sky.h b/environment/sky.cppm similarity index 56% rename from environment/sky.h rename to environment/sky.cppm index 34b1ae75..d447fb48 100644 --- a/environment/sky.h +++ b/environment/sky.cppm @@ -7,23 +7,29 @@ obtain one at http://mozilla.org/MPL/2.0/. */ //--------------------------------------------------------------------------- +module; + +export module eu07.environment.sky; +import eu07.simcore; +import eu07.utilities.classes; + +export { -#pragma once -#include "utilities/Classes.h" class TSky { - - friend opengl_renderer; - friend opengl33_renderer; - public: TSky() = default; void Init(); -private: +public: + // read directly by the renderers. They used to be friends, but a friend + // declaration naming a class from another module would require importing it, + // and that import closes a cycle the module graph does not allow. TModel3d *mdCloud { nullptr }; }; //--------------------------------------------------------------------------- + +} // export diff --git a/environment/skydome.cpp b/environment/skydome.cpp index f5b936f5..c54bdc25 100644 --- a/environment/skydome.cpp +++ b/environment/skydome.cpp @@ -1,9 +1,15 @@ +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.environment.skydome; +import eu07.utilities.color; +import eu07.simulation.simulationenvironment; +import eu07.utilities.globals; -#include "stdafx.h" -#include "environment/skydome.h" -#include "utilities/color.h" -#include "simulation/simulationenvironment.h" -#include "utilities/Globals.h" // sky gradient based on "A practical analytic model for daylight" // by A. J. Preetham Peter Shirley Brian Smits (University of Utah) diff --git a/environment/skydome.h b/environment/skydome.cppm similarity index 94% rename from environment/skydome.h rename to environment/skydome.cppm index 74d024d1..28e3bb00 100644 --- a/environment/skydome.h +++ b/environment/skydome.cppm @@ -1,7 +1,14 @@ -#pragma once // sky gradient based on "A practical analytic model for daylight" // by A. J. Preetham Peter Shirley Brian Smits (University of Utah) +module; +#include +#include + +export module eu07.environment.skydome; +import eu07.glm; + +export { class CSkyDome { public: @@ -65,3 +72,5 @@ private: float PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ); }; + +} // export diff --git a/environment/stars.cpp b/environment/stars.cpp index 5fd112c5..fa684de6 100644 --- a/environment/stars.cpp +++ b/environment/stars.cpp @@ -1,7 +1,9 @@ -#include "stdafx.h" -#include "environment/stars.h" -#include "utilities/Globals.h" -#include "model/MdlMngr.h" +module; +#include "utilities/Globals_macros.h" + +module eu07.environment.stars; +import eu07.utilities.globals; +import eu07.model.mdlmngr; ////////////////////////////////////////////////////////////////////////////////////////// // cStars -- simple starfield model, simulating appearance of starry sky diff --git a/environment/stars.h b/environment/stars.cppm similarity index 58% rename from environment/stars.h rename to environment/stars.cppm index f3643d26..a9b9f4be 100644 --- a/environment/stars.h +++ b/environment/stars.cppm @@ -1,16 +1,17 @@ -#pragma once -#include "utilities/Classes.h" ////////////////////////////////////////////////////////////////////////////////////////// // cStars -- simple starfield model, simulating appearance of starry sky +module; + +export module eu07.environment.stars; +import eu07.simcore; +import eu07.utilities.classes; + +export { class cStars { - - friend opengl_renderer; - friend opengl33_renderer; - public: // types: @@ -22,13 +23,14 @@ public: // members: -private: -// types: - -// methods: - +public: + // read directly by the renderers. They used to be friends, but a friend + // declaration naming a class from another module would require importing it, + // and that import closes a cycle the module graph does not allow. // members: float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being float m_latitude{ 52.0f }; TModel3d *m_stars { nullptr }; }; + +} // export diff --git a/environment/sun.cpp b/environment/sun.cpp index 1ecd94ed..cba0206c 100644 --- a/environment/sun.cpp +++ b/environment/sun.cpp @@ -1,9 +1,17 @@ -#include "stdafx.h" -#include "environment/sun.h" -#include "utilities/Globals.h" -#include "world/mtable.h" -#include "utilities/utilities.h" -#include "simulation/simulationtime.h" +module; +#include +#include "winheaders.h" +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.environment.sun; +import eu07.glm; +import eu07.utilities.globals; +import eu07.world.mtable; +import eu07.utilities.utilities; +import eu07.simulation.simulationtime; ////////////////////////////////////////////////////////////////////////////////////////// // cSun -- class responsible for dynamic calculation of position and intensity of the Sun, diff --git a/environment/sun.h b/environment/sun.cppm similarity index 97% rename from environment/sun.h rename to environment/sun.cppm index 7fdea413..d2401779 100644 --- a/environment/sun.h +++ b/environment/sun.cppm @@ -1,10 +1,15 @@ -#pragma once -#include "winheaders.h" ////////////////////////////////////////////////////////////////////////////////////////// // cSun -- class responsible for dynamic calculation of position and intensity of the Sun, // given current weather, time and geographic location. +module; +#include "winheaders.h" + +export module eu07.environment.sun; +import eu07.glm; + +export { class cSun { @@ -99,3 +104,5 @@ protected: observer m_observer; glm::vec3 m_position; }; + +} // export diff --git a/export_e3d_standalone.cpp b/export_e3d_standalone.cpp index ecdd4ab9..f6642bf1 100644 --- a/export_e3d_standalone.cpp +++ b/export_e3d_standalone.cpp @@ -1,8 +1,9 @@ -#include "stdafx.h" +#include "utilities/Globals_macros.h" +#include +import eu07.simcore; +import eu07.utilities.globals; +import eu07.rendering.renderer; -#include "model/Model3d.h" -#include "utilities/Globals.h" -#include "rendering/renderer.h" void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic) { diff --git a/extras/piped_proc.cpp b/extras/piped_proc.cpp index f7e4e67c..3cebd0db 100644 --- a/extras/piped_proc.cpp +++ b/extras/piped_proc.cpp @@ -1,10 +1,14 @@ +module; +#include +#include +#include + +module eu07.extras.piped_proc; +import eu07.utilities.logs; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "piped_proc.h" -#include "utilities/Logs.h" #ifdef __unix__ piped_proc::piped_proc(std::string cmd, bool write) diff --git a/extras/piped_proc.h b/extras/piped_proc.cppm similarity index 83% rename from extras/piped_proc.h rename to extras/piped_proc.cppm index b16c6b3d..546786d0 100644 --- a/extras/piped_proc.h +++ b/extras/piped_proc.cppm @@ -1,16 +1,25 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; #ifdef __unix__ #include +#endif +#ifdef __unix__ #elif _WIN32 #include "winheaders.h" #endif #include +export module eu07.extras.piped_proc; + +export { + + +#ifdef __unix__ +#elif _WIN32 +#endif + class piped_proc { private: @@ -28,3 +37,5 @@ public: size_t write(unsigned char *buf, size_t len); ~piped_proc(); }; + +} // export diff --git a/gl/bindable.h b/gl/bindable.cppm similarity index 88% rename from gl/bindable.h rename to gl/bindable.cppm index b845dadb..e6d6aa6a 100644 --- a/gl/bindable.h +++ b/gl/bindable.cppm @@ -1,4 +1,8 @@ -#pragma once +module; + +export module eu07.gl.bindable; + +export { namespace gl { @@ -25,3 +29,5 @@ namespace gl template thread_local bindable* bindable::active; } + +} // export diff --git a/gl/buffer.cpp b/gl/buffer.cpp index 8b8bd486..bb4bac77 100644 --- a/gl/buffer.cpp +++ b/gl/buffer.cpp @@ -1,5 +1,9 @@ -#include "stdafx.h" -#include "buffer.h" +module; +#include "glad/glad.h" +#include +#include + +module eu07.gl.buffer; GLenum gl::buffer::glenum_target(gl::buffer::targets target) { diff --git a/gl/buffer.h b/gl/buffer.cppm similarity index 89% rename from gl/buffer.h rename to gl/buffer.cppm index 8b4e7d9c..a01d2dd8 100644 --- a/gl/buffer.h +++ b/gl/buffer.cppm @@ -1,7 +1,12 @@ -#pragma once +module; +#include "glad/glad.h" + +export module eu07.gl.buffer; +import eu07.gl.object; +import eu07.gl.bindable; + +export { -#include "object.h" -#include "bindable.h" namespace gl { @@ -44,3 +49,5 @@ namespace gl void download(targets target, void *data, int offset, GLsizeiptr size); }; } + +} // export diff --git a/gl/cubemap.cpp b/gl/cubemap.cpp index ca0e6c08..b139e775 100644 --- a/gl/cubemap.cpp +++ b/gl/cubemap.cpp @@ -1,5 +1,7 @@ -#include "stdafx.h" -#include "cubemap.h" +module; +#include "glad/glad.h" + +module eu07.gl.cubemap; gl::cubemap::cubemap() { diff --git a/gl/cubemap.h b/gl/cubemap.cppm similarity index 75% rename from gl/cubemap.h rename to gl/cubemap.cppm index e874c221..7a4a74c3 100644 --- a/gl/cubemap.h +++ b/gl/cubemap.cppm @@ -1,6 +1,11 @@ -#pragma once +module; +#include "glad/glad.h" + +export module eu07.gl.cubemap; +import eu07.gl.object; + +export { -#include "object.h" namespace gl { @@ -17,3 +22,5 @@ namespace gl void generate_mipmaps(); }; } + +} // export diff --git a/gl/fence.cpp b/gl/fence.cpp index b6db88f7..1f0301f5 100644 --- a/gl/fence.cpp +++ b/gl/fence.cpp @@ -1,5 +1,7 @@ -#include "stdafx.h" -#include "fence.h" +module; +#include "glad/glad.h" + +module eu07.gl.fence; gl::fence::fence() { diff --git a/gl/fence.h b/gl/fence.cppm similarity index 68% rename from gl/fence.h rename to gl/fence.cppm index 50564163..a3454905 100644 --- a/gl/fence.h +++ b/gl/fence.cppm @@ -1,6 +1,11 @@ -#pragma once +module; +#include "glad/glad.h" + +export module eu07.gl.fence; +import eu07.gl.object; + +export { -#include "object.h" namespace gl { @@ -18,3 +23,5 @@ namespace gl fence& operator=(const fence&) = delete; }; } + +} // export diff --git a/gl/framebuffer.cpp b/gl/framebuffer.cpp index af1f63de..38d84de8 100644 --- a/gl/framebuffer.cpp +++ b/gl/framebuffer.cpp @@ -1,8 +1,13 @@ -#include "stdafx.h" -#include "framebuffer.h" +module; +#include +#include "glad/glad.h" +#include +#include "utilities/utilities_macros.h" + +module eu07.gl.framebuffer; +import eu07.utilities.logs; +import eu07.utilities.utilities; -#include "utilities/Logs.h" -#include "utilities/utilities.h" gl::framebuffer::framebuffer() { diff --git a/gl/framebuffer.h b/gl/framebuffer.cppm similarity index 81% rename from gl/framebuffer.h rename to gl/framebuffer.cppm index e5dccf57..a0706955 100644 --- a/gl/framebuffer.h +++ b/gl/framebuffer.cppm @@ -1,10 +1,15 @@ -#pragma once +module; +#include "glad/glad.h" + +export module eu07.gl.framebuffer; +import eu07.gl.object; +import eu07.gl.bindable; +import eu07.gl.renderbuffer; +import eu07.model.texture; +import eu07.gl.cubemap; + +export { -#include "object.h" -#include "bindable.h" -#include "renderbuffer.h" -#include "model/Texture.h" -#include "cubemap.h" namespace gl { @@ -32,3 +37,5 @@ namespace gl static void bind(GLuint id); }; } + +} // export diff --git a/gl/gldebug.h b/gl/gldebug.h new file mode 100644 index 00000000..793120c4 --- /dev/null +++ b/gl/gldebug.h @@ -0,0 +1,19 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "glad/glad.h" + +#define STRINGIZE_DETAIL(x) #x +#define STRINGIZE(x) STRINGIZE_DETAIL(x) + +// drops a marker into the command stream so gDEBugger/apitrace captures show +// which source line issued the calls that follow +#define glDebug(x) if (GLAD_GL_GREMEDY_string_marker) glStringMarkerGREMEDY(0, __FILE__ ":" STRINGIZE(__LINE__) ": " x); diff --git a/gl/glsl_common.cpp b/gl/glsl_common.cpp index 26c31000..8b334a20 100644 --- a/gl/glsl_common.cpp +++ b/gl/glsl_common.cpp @@ -1,5 +1,10 @@ -#include "stdafx.h" -#include "glsl_common.h" +module; +#include "utilities/Globals_macros.h" +#include + +module eu07.gl.glsl_common; +import eu07.utilities.globals; +import eu07.utilities.utilities; std::string gl::glsl_common; diff --git a/gl/glsl_common.cppm b/gl/glsl_common.cppm new file mode 100644 index 00000000..72cb57e9 --- /dev/null +++ b/gl/glsl_common.cppm @@ -0,0 +1,18 @@ +module; +#include +#include "utilities/Globals_macros.h" + +export module eu07.gl.glsl_common; +import eu07.gl.ubo; +import eu07.utilities.globals; + +export { + + +namespace gl +{ + extern std::string glsl_common; + void glsl_common_setup(); +} + +} // export diff --git a/gl/glsl_common.h b/gl/glsl_common.h deleted file mode 100644 index 17e46723..00000000 --- a/gl/glsl_common.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "ubo.h" -#include "utilities/Globals.h" - -namespace gl -{ - extern std::string glsl_common; - void glsl_common_setup(); -} diff --git a/gl/object.h b/gl/object.cppm similarity index 88% rename from gl/object.h rename to gl/object.cppm index eb200889..965dcd4e 100644 --- a/gl/object.h +++ b/gl/object.cppm @@ -1,7 +1,11 @@ -#pragma once - +module; #include +export module eu07.gl.object; + +export { + + namespace gl { class object @@ -30,3 +34,5 @@ namespace gl object& operator=(const object&) = delete; }; } + +} // export diff --git a/gl/pbo.cpp b/gl/pbo.cpp index 6923e09d..f52e5664 100644 --- a/gl/pbo.cpp +++ b/gl/pbo.cpp @@ -1,5 +1,9 @@ -#include "stdafx.h" -#include "pbo.h" +module; +#include +#include "glad/glad.h" + +module eu07.gl.pbo; +import eu07.gl.fence; void gl::pbo::request_read(int x, int y, int lx, int ly, int pixsize, GLenum format, GLenum type) { diff --git a/gl/pbo.h b/gl/pbo.cppm similarity index 80% rename from gl/pbo.h rename to gl/pbo.cppm index ba804404..4c3e69dd 100644 --- a/gl/pbo.h +++ b/gl/pbo.cppm @@ -1,9 +1,14 @@ -#pragma once - -#include "buffer.h" -#include "fence.h" +module; +#include "glad/glad.h" #include +export module eu07.gl.pbo; +import eu07.gl.buffer; +import eu07.gl.fence; + +export { + + namespace gl { class pbo : public buffer { @@ -20,3 +25,5 @@ namespace gl { void unmap(targets target = PIXEL_UNPACK_BUFFER); }; } + +} // export diff --git a/gl/postfx.cpp b/gl/postfx.cpp index 6587475a..44769ef2 100644 --- a/gl/postfx.cpp +++ b/gl/postfx.cpp @@ -1,6 +1,11 @@ -#include "stdafx.h" +module; +#include "glad/glad.h" +#include +#include + +module eu07.gl.postfx; +import eu07.gl.framebuffer; -#include "postfx.h" std::shared_ptr gl::postfx::vertex; std::shared_ptr gl::postfx::vao; diff --git a/gl/postfx.h b/gl/postfx.cppm similarity index 68% rename from gl/postfx.h rename to gl/postfx.cppm index cc0c5450..f2f65120 100644 --- a/gl/postfx.h +++ b/gl/postfx.cppm @@ -1,9 +1,15 @@ -#pragma once +module; +#include +#include + +export module eu07.gl.postfx; +import eu07.gl.shader; +import eu07.gl.vao; +import eu07.gl.framebuffer; +import eu07.model.texture; + +export { -#include "shader.h" -#include "vao.h" -#include "framebuffer.h" -#include "model/Texture.h" namespace gl { @@ -23,3 +29,5 @@ namespace gl void apply(std::vector src, framebuffer *dst); }; } + +} // export diff --git a/gl/query.cpp b/gl/query.cpp index 3f3b56af..eb9991d6 100644 --- a/gl/query.cpp +++ b/gl/query.cpp @@ -1,7 +1,10 @@ -#include "stdafx.h" -#include "query.h" -#include "utilities/Globals.h" +module; +#include "glad/glad.h" +#include +#include "utilities/Globals_macros.h" +module eu07.gl.query; +import eu07.utilities.globals; gl::query::query(targets target) : target(target) { diff --git a/gl/query.h b/gl/query.cppm similarity index 76% rename from gl/query.h rename to gl/query.cppm index 83114092..d8a33e1a 100644 --- a/gl/query.h +++ b/gl/query.cppm @@ -1,6 +1,13 @@ -#pragma once +module; +#include "glad/glad.h" +#include +#include + +export module eu07.gl.query; +import eu07.gl.object; + +export { -#include "object.h" namespace gl { @@ -34,3 +41,5 @@ public: std::optional result(); }; } + +} // export diff --git a/gl/renderbuffer.cpp b/gl/renderbuffer.cpp index 4d896dab..929bd3f3 100644 --- a/gl/renderbuffer.cpp +++ b/gl/renderbuffer.cpp @@ -1,6 +1,8 @@ -#include "stdafx.h" +module; +#include "glad/glad.h" + +module eu07.gl.renderbuffer; -#include "renderbuffer.h" gl::renderbuffer::renderbuffer() { diff --git a/gl/renderbuffer.h b/gl/renderbuffer.cppm similarity index 68% rename from gl/renderbuffer.h rename to gl/renderbuffer.cppm index 576cf229..003276d8 100644 --- a/gl/renderbuffer.h +++ b/gl/renderbuffer.cppm @@ -1,7 +1,12 @@ -#pragma once +module; +#include "glad/glad.h" + +export module eu07.gl.renderbuffer; +import eu07.gl.object; +import eu07.gl.bindable; + +export { -#include "object.h" -#include "bindable.h" namespace gl { @@ -17,3 +22,5 @@ namespace gl using bindable::bind; }; } + +} // export diff --git a/gl/shader.cpp b/gl/shader.cpp index 5d818833..561bd206 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -1,11 +1,20 @@ -#include "stdafx.h" - +module; +#include "utilities/Globals_macros.h" +#include "glad/glad.h" +#include +#include +#include +#include #include #include #include -#include "shader.h" -#include "glsl_common.h" -#include "utilities/Logs.h" + +module eu07.gl.shader; +import eu07.gl.ubo; +import eu07.utilities.globals; +import eu07.gl.glsl_common; +import eu07.utilities.logs; + inline bool strcend(std::string const &value, std::string const &ending) { diff --git a/gl/shader.h b/gl/shader.cppm similarity index 93% rename from gl/shader.h rename to gl/shader.cppm index 4cd25f07..c4da6e03 100644 --- a/gl/shader.h +++ b/gl/shader.cppm @@ -1,12 +1,18 @@ -#pragma once - +module; +#include "glad/glad.h" +#include #include #include #include #include -#include "object.h" -#include "bindable.h" +export module eu07.gl.shader; +import eu07.gl.object; +import eu07.gl.bindable; + +export { + + namespace gl { @@ -101,3 +107,5 @@ namespace gl void init(); }; } + +} // export diff --git a/gl/ubo.cpp b/gl/ubo.cpp index cecf84f0..4683b440 100644 --- a/gl/ubo.cpp +++ b/gl/ubo.cpp @@ -1,5 +1,9 @@ -#include "stdafx.h" -#include "ubo.h" +module; +#include "glad/glad.h" +#include +#include + +module eu07.gl.ubo; gl::ubo::ubo(size_t size, int idx, GLenum hint) { diff --git a/gl/ubo.h b/gl/ubo.cppm similarity index 89% rename from gl/ubo.h rename to gl/ubo.cppm index e4cb7c00..290165c0 100644 --- a/gl/ubo.h +++ b/gl/ubo.cppm @@ -1,20 +1,18 @@ -#pragma once +module; +#include +#include "glad/glad.h" + +export module eu07.gl.ubo; +import eu07.glm; +import eu07.gl.object; +import eu07.gl.bindable; +import eu07.gl.buffer; + +export { -#include "object.h" -#include "bindable.h" -#include "buffer.h" -#include #define UBS_PAD(x) uint8_t PAD[x] -// 12-byte vec3 for structs that must match an exact binary layout (UBOs, vertex data). -// Stays packed regardless of GLM_FORCE_DEFAULT_ALIGNED_GENTYPES. -// Guard prevents redefinition when stdafx.h also defines it. -#ifndef PACKED_VEC3_DEFINED -#define PACKED_VEC3_DEFINED -using packed_vec3 = glm::vec<3, float, glm::packed_highp>; -#endif - namespace gl { class ubo : public buffer @@ -151,3 +149,5 @@ namespace gl #pragma pack(pop) } + +} // export diff --git a/gl/vao.cpp b/gl/vao.cpp index 6d1e055d..5f3b2a4a 100644 --- a/gl/vao.cpp +++ b/gl/vao.cpp @@ -1,5 +1,8 @@ -#include "stdafx.h" -#include "vao.h" +module; +#include "glad/glad.h" +#include + +module eu07.gl.vao; bool gl::vao::use_vao = true; diff --git a/gl/vao.h b/gl/vao.cppm similarity index 79% rename from gl/vao.h rename to gl/vao.cppm index a4415d03..7079c773 100644 --- a/gl/vao.h +++ b/gl/vao.cppm @@ -1,8 +1,13 @@ -#pragma once +module; +#include + +export module eu07.gl.vao; +import eu07.gl.object; +import eu07.gl.bindable; +import eu07.gl.buffer; + +export { -#include "object.h" -#include "bindable.h" -#include "buffer.h" namespace gl { @@ -35,3 +40,5 @@ namespace gl static bool use_vao; }; } + +} // export diff --git a/global_include/interfaces/IMaterial.h b/global_include/interfaces/IMaterial.cppm similarity index 85% rename from global_include/interfaces/IMaterial.h rename to global_include/interfaces/IMaterial.cppm index eaf7268f..7b0c28c4 100644 --- a/global_include/interfaces/IMaterial.h +++ b/global_include/interfaces/IMaterial.cppm @@ -1,10 +1,15 @@ -#pragma once - -#include +module; #include #include +#include "global_include/interfaces/ITexture_macros.h" + +export module eu07.global_include.interfaces.imaterial; +import eu07.glm; +import eu07.global_include.interfaces.itexture; + +export { + -#include "ITexture.h" struct IMaterial { @@ -57,4 +62,5 @@ struct IMaterial } null_material{}; return &null_material; } -}; \ No newline at end of file +}; +} // export diff --git a/global_include/interfaces/ITexture.h b/global_include/interfaces/ITexture.cppm similarity index 90% rename from global_include/interfaces/ITexture.h rename to global_include/interfaces/ITexture.cppm index 8a1a6796..328c24b5 100644 --- a/global_include/interfaces/ITexture.h +++ b/global_include/interfaces/ITexture.cppm @@ -1,8 +1,15 @@ -#pragma once +module; +#include "global_include/interfaces/ITexture_macros.h" +#include +#include +#include + +export module eu07.global_include.interfaces.itexture; + +export { typedef int texture_handle; -#define null_handle (0) struct ITexture { @@ -73,4 +80,5 @@ struct ITexture } null_texture{}; return &null_texture; } -}; \ No newline at end of file +}; +} // export diff --git a/global_include/interfaces/ITexture_macros.h b/global_include/interfaces/ITexture_macros.h new file mode 100644 index 00000000..ff46eedc --- /dev/null +++ b/global_include/interfaces/ITexture_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define null_handle (0) diff --git a/imgui/imgui_impl_opengl3.cpp b/imgui/imgui_impl_opengl3.cpp index e4bf631c..945885c7 100644 --- a/imgui/imgui_impl_opengl3.cpp +++ b/imgui/imgui_impl_opengl3.cpp @@ -61,8 +61,8 @@ // ES 3.0 300 "#version 300 es" = WebGL 2.0 //---------------------------------------- -#include "stdafx.h" -#include "utilities/Globals.h" +#include "glad/glad.h" +#include "utilities/Globals_macros.h" #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS @@ -73,6 +73,9 @@ #include // Needs to be initialized with gladLoadGL() in user's code +#include + +import eu07.utilities.globals; // OpenGL Data static char g_GlslVersionString[128] = ""; diff --git a/input/command.cpp b/input/command.cpp index 9a373fef..82400adc 100644 --- a/input/command.cpp +++ b/input/command.cpp @@ -1,3 +1,17 @@ +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.input.command; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.timer; +import eu07.simulation.simulation; +import eu07.vehicle.train; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +21,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/command.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/Timer.h" -#include "simulation/simulation.h" -#include "vehicle/Train.h" namespace simulation { diff --git a/input/command.h b/input/command.cppm similarity index 99% rename from input/command.h rename to input/command.cppm index 7ff5b272..c8fc36dd 100644 --- a/input/command.h +++ b/input/command.cppm @@ -6,12 +6,19 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; #include #include #include +#include +#include + +export module eu07.input.command; +import eu07.glm; + +export { + + enum class user_command { @@ -536,3 +543,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/input/driverkeyboardinput.cpp b/input/driverkeyboardinput.cpp index 48c8c1fc..f59b89aa 100644 --- a/input/driverkeyboardinput.cpp +++ b/input/driverkeyboardinput.cpp @@ -1,3 +1,8 @@ +module; +#include + +module eu07.input.driverkeyboardinput; +import eu07.input.command; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,8 +12,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/driverkeyboardinput.h" bool driverkeyboard_input::init() { diff --git a/input/driverkeyboardinput.h b/input/driverkeyboardinput.cppm similarity index 80% rename from input/driverkeyboardinput.h rename to input/driverkeyboardinput.cppm index 1e3f11b1..04ea56f9 100644 --- a/input/driverkeyboardinput.h +++ b/input/driverkeyboardinput.cppm @@ -6,10 +6,14 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; + +export module eu07.input.driverkeyboardinput; +import eu07.input.keyboardinput; + +export { -#pragma once -#include "input/keyboardinput.h" class driverkeyboard_input : public keyboard_input { @@ -25,3 +29,5 @@ protected: }; //--------------------------------------------------------------------------- + +} // export diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp index 2d5f3d24..52658bad 100644 --- a/input/drivermouseinput.cpp +++ b/input/drivermouseinput.cpp @@ -1,3 +1,34 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +#ifdef _WIN32 +#include +#endif + +module eu07.input.drivermouseinput; +import eu07.utilities.parser; +import eu07.mczapkie.hamulce; +import eu07.utilities.globals; +import eu07.application.application; +import eu07.utilities.timer; +import eu07.simulation.simulation; +import eu07.vehicle.train; +import eu07.simcore; +import eu07.rendering.renderer; +import eu07.application.uilayer; +import eu07.utilities.logs; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,20 +38,10 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/drivermouseinput.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "utilities/Globals.h" -#include "utilities/Timer.h" -#include "simulation/simulation.h" -#include "vehicle/Train.h" -#include "model/AnimModel.h" -#include "rendering/renderer.h" -#include "application/uilayer.h" -#include "utilities/Logs.h" -#include "utilities/utilities.h" + +#ifdef _WIN32 +#endif auto const EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 }; diff --git a/input/drivermouseinput.h b/input/drivermouseinput.cppm similarity index 94% rename from input/drivermouseinput.h rename to input/drivermouseinput.cppm index 142ef99c..05f2d56d 100644 --- a/input/drivermouseinput.h +++ b/input/drivermouseinput.cppm @@ -7,12 +7,20 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include "input/command.h" // virtual slider; value determined by position of the mouse +module; +#include +#include +#include +#include + +export module eu07.input.drivermouseinput; +import eu07.glm; +import eu07.input.command; + +export { class mouse_slider { public: @@ -111,4 +119,5 @@ private: bool m_pickwaiting; }; -//--------------------------------------------------------------------------- \ No newline at end of file +//--------------------------------------------------------------------------- +} // export diff --git a/input/editorkeyboardinput.cpp b/input/editorkeyboardinput.cpp index 209ca65a..2f9e810d 100644 --- a/input/editorkeyboardinput.cpp +++ b/input/editorkeyboardinput.cpp @@ -1,3 +1,9 @@ +module; +#include + +module eu07.input.editorkeyboardinput; +import eu07.input.command; +import eu07.editor.editorsettings; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,9 +13,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/editorkeyboardinput.h" -#include "editor/editorSettings.hpp" bool editorkeyboard_input::init() { diff --git a/input/editorkeyboardinput.h b/input/editorkeyboardinput.cppm similarity index 84% rename from input/editorkeyboardinput.h rename to input/editorkeyboardinput.cppm index cf335e5c..96516b79 100644 --- a/input/editorkeyboardinput.h +++ b/input/editorkeyboardinput.cppm @@ -6,10 +6,14 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; + +export module eu07.input.editorkeyboardinput; +import eu07.input.keyboardinput; + +export { -#pragma once -#include "input/keyboardinput.h" class editorkeyboard_input : public keyboard_input { @@ -28,3 +32,5 @@ protected: }; //--------------------------------------------------------------------------- + +} // export diff --git a/input/editormouseinput.cpp b/input/editormouseinput.cpp index 6daa542c..8b17d1a8 100644 --- a/input/editormouseinput.cpp +++ b/input/editormouseinput.cpp @@ -1,3 +1,8 @@ +module; +#include + +module eu07.input.editormouseinput; +import eu07.glm; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,8 +12,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/editormouseinput.h" bool editormouse_input::init() { diff --git a/input/editormouseinput.h b/input/editormouseinput.cppm similarity index 88% rename from input/editormouseinput.h rename to input/editormouseinput.cppm index aab8770f..2b8fafd4 100644 --- a/input/editormouseinput.h +++ b/input/editormouseinput.cppm @@ -6,10 +6,16 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include + +export module eu07.input.editormouseinput; +import eu07.input.command; +import eu07.glm; +export { -#pragma once -#include "input/command.h" class editormouse_input { @@ -43,3 +49,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/input/gamepadinput.cpp b/input/gamepadinput.cpp index ac819b82..376709eb 100644 --- a/input/gamepadinput.cpp +++ b/input/gamepadinput.cpp @@ -1,3 +1,18 @@ +module; +#include +#include +#include +#include +#include "utilities/utilities_macros.h" +#include +#include + +module eu07.input.gamepadinput; +import eu07.glm; +import eu07.utilities.logs; +import eu07.utilities.timer; +import eu07.utilities.utilities; +import eu07.utilities.parser; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,12 +22,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/gamepadinput.h" -#include "utilities/Logs.h" -#include "utilities/Timer.h" -#include "utilities/utilities.h" -#include "utilities/parser.h" glm::vec2 circle_to_square( glm::vec2 const &Point, int const Roundness = 0 ) { diff --git a/input/gamepadinput.h b/input/gamepadinput.cppm similarity index 94% rename from input/gamepadinput.h rename to input/gamepadinput.cppm index ba8d4e38..da322d54 100644 --- a/input/gamepadinput.h +++ b/input/gamepadinput.cppm @@ -6,12 +6,18 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include +#include #include -#include "input/command.h" -#include "utilities/parser.h" + +export module eu07.input.gamepadinput; +import eu07.input.command; +import eu07.utilities.parser; + +export { + + class gamepad_input { @@ -93,3 +99,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/input/keyboardinput.cpp b/input/keyboardinput.cpp index 0279f055..5f69b8ed 100644 --- a/input/keyboardinput.cpp +++ b/input/keyboardinput.cpp @@ -1,3 +1,22 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +#include + +module eu07.input.keyboardinput; +import eu07.rendering.geometrybank; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.parser; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,12 +26,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/keyboardinput.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/parser.h" -#include "utilities/utilities.h" namespace input { diff --git a/input/keyboardinput.h b/input/keyboardinput.cppm similarity index 88% rename from input/keyboardinput.h rename to input/keyboardinput.cppm index 1c1b5f2a..890c25c1 100644 --- a/input/keyboardinput.h +++ b/input/keyboardinput.cppm @@ -6,12 +6,21 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; #include #include -#include "input/command.h" +#include +#include +#include + +export module eu07.input.keyboardinput; +import eu07.glm; +import eu07.application.uitranscripts; +import eu07.input.command; + +export { + + namespace input { @@ -22,12 +31,7 @@ extern bool key_shift; } -namespace ui { -class keymapper_panel; -} - class keyboard_input { - friend class ui::keymapper_panel; public: // types @@ -79,8 +83,11 @@ protected: default_bindings() = 0; bool recall_bindings(); +public: + // the keymapper widget rebinds keys through this void bind(); +protected: // members bindingsetup_sequence m_bindingsetups; @@ -114,3 +121,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/input/messaging.cpp b/input/messaging.cpp index 36ed853c..7b509966 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -1,4 +1,27 @@ -/* +module; +#include "winheaders.h" +#include "utilities/utilities_macros.h" +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.input.messaging; +import eu07.utilities.utilities; +import eu07.glm; +import eu07.input.command; +import eu07.utilities.globals; +import eu07.application.application; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.simcore; +import eu07.world.mtable; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,18 +30,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "input/messaging.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "world/Event.h" -#include "vehicle/DynObj.h" -#include "vehicle/Driver.h" -#include "world/mtable.h" -#include "utilities/Logs.h" #ifdef _WIN32 extern "C" diff --git a/input/messaging.h b/input/messaging.cppm similarity index 93% rename from input/messaging.h rename to input/messaging.cppm index f3592b27..9a03eccb 100644 --- a/input/messaging.h +++ b/input/messaging.cppm @@ -1,4 +1,12 @@ -/* +module; +#include +#include "winheaders.h" + +export module eu07.input.messaging; +import eu07.simcore; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,12 +15,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include "winheaders.h" -class TDynamicObject; namespace multiplayer { @@ -51,3 +55,5 @@ void WyslijObsadzone(); // -> skladanie wielu pojazdow } // multiplayer //--------------------------------------------------------------------------- + +} // export diff --git a/input/zmq_input.cpp b/input/zmq_input.cpp index 62fb41ee..a0b2d2f5 100644 --- a/input/zmq_input.cpp +++ b/input/zmq_input.cpp @@ -1,10 +1,18 @@ -#include "stdafx.h" -#include "input/zmq_input.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "vehicle/Train.h" +module; +#include "utilities/Globals_macros.h" +#include +#include +#include +#include +#include +#include + +module eu07.input.zmq_input; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.vehicle.train; zmq_input::zmq_input() { diff --git a/input/zmq_input.h b/input/zmq_input.cppm similarity index 89% rename from input/zmq_input.h rename to input/zmq_input.cppm index 503a6a59..4632ce95 100644 --- a/input/zmq_input.h +++ b/input/zmq_input.cppm @@ -1,7 +1,18 @@ -#pragma once - +module; #include -#include "input/command.h" +#include +#include +#include +#include +#include +#include +#include + +export module eu07.input.zmq_input; +import eu07.input.command; + +export { + class zmq_input { @@ -75,3 +86,5 @@ public: zmq_input(); void poll(); }; + +} // export diff --git a/launcher/deferred_image.h b/launcher/deferred_image.cppm similarity index 75% rename from launcher/deferred_image.h rename to launcher/deferred_image.cppm index fcd25fd6..801e9e50 100644 --- a/launcher/deferred_image.h +++ b/launcher/deferred_image.cppm @@ -1,7 +1,16 @@ -#pragma once +module; +#include "glad/glad.h" +#include +#include "global_include/interfaces/ITexture_macros.h" + +export module eu07.launcher.deferred_image; +import eu07.glm; +import eu07.global_include.interfaces.itexture; +import eu07.model.texture; +import eu07.rendering.renderer; + +export { -#include "model/Texture.h" -#include "rendering/renderer.h" class deferred_image { public: @@ -46,3 +55,5 @@ private: mutable std::string path; mutable texture_handle image = 0; }; + +} // export diff --git a/launcher/keymapper.cpp b/launcher/keymapper.cpp index 6ec882bd..b03f23ad 100644 --- a/launcher/keymapper.cpp +++ b/launcher/keymapper.cpp @@ -1,6 +1,17 @@ -#include "stdafx.h" -#include "keymapper.h" -#include "simulation/simulation.h" +module; +#include "utilities/translation_macros.h" +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "imgui/imgui.h" + +module eu07.launcher.keymapper; +import eu07.utilities.utilities; +import eu07.utilities.translation; +import eu07.input.keyboardinput; +import eu07.utilities.globals; +import eu07.simulation.simulation; ui::keymapper_panel::keymapper_panel() : ui_panel(STR("Keymapper"), false) diff --git a/launcher/keymapper.h b/launcher/keymapper.cppm similarity index 64% rename from launcher/keymapper.h rename to launcher/keymapper.cppm index 65e789b5..b4934865 100644 --- a/launcher/keymapper.h +++ b/launcher/keymapper.cppm @@ -1,7 +1,13 @@ -#pragma once +module; +#include + +export module eu07.launcher.keymapper; +import eu07.input.command; +import eu07.application.uilayer; +import eu07.input.driverkeyboardinput; + +export { -#include "application/uilayer.h" -#include "input/driverkeyboardinput.h" namespace ui { @@ -19,3 +25,5 @@ private: const std::string panelname = (title.empty() ? m_name : title) + "###" + m_name; }; } // namespace ui + +} // export diff --git a/launcher/launchermode.cpp b/launcher/launchermode.cpp index 08c4c101..0c9fca9a 100644 --- a/launcher/launchermode.cpp +++ b/launcher/launchermode.cpp @@ -1,9 +1,13 @@ -#include "stdafx.h" -#include "launcher/launchermode.h" -#include "launcher/launcheruilayer.h" -#include "application/application.h" -#include "simulation/simulation.h" -#include "utilities/Globals.h" +module; +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.launcher.launchermode; +import eu07.launcher.launcheruilayer; +import eu07.application.application; +import eu07.simulation.simulation; +import eu07.utilities.globals; launcher_mode::launcher_mode() { diff --git a/launcher/launchermode.h b/launcher/launchermode.cppm similarity index 91% rename from launcher/launchermode.h rename to launcher/launchermode.cppm index 53a65f4d..63595173 100644 --- a/launcher/launchermode.h +++ b/launcher/launchermode.cppm @@ -6,10 +6,14 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; + +export module eu07.launcher.launchermode; +import eu07.application.applicationmode; + +export { -#pragma once -#include "application/applicationmode.h" class launcher_mode : public application_mode { @@ -34,3 +38,5 @@ public: void on_event_poll() override { ; } bool is_command_processor() const override { return false; } }; + +} // export diff --git a/launcher/launcheruilayer.cpp b/launcher/launcheruilayer.cpp index 91974bbc..e4d3c4b6 100644 --- a/launcher/launcheruilayer.cpp +++ b/launcher/launcheruilayer.cpp @@ -1,7 +1,13 @@ -#include "stdafx.h" -#include "launcher/launcheruilayer.h" -#include "application/application.h" -#include "utilities/translation.h" +module; +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include "imgui/imgui.h" + +module eu07.launcher.launcheruilayer; +import eu07.utilities.globals; +import eu07.glm; +import eu07.application.application; +import eu07.utilities.translation; launcher_ui::launcher_ui() : m_scenery_scanner(m_vehicles_bank), m_scenerylist_panel(m_scenery_scanner) { diff --git a/launcher/launcheruilayer.h b/launcher/launcheruilayer.cppm similarity index 70% rename from launcher/launcheruilayer.h rename to launcher/launcheruilayer.cppm index 91e36bbd..bdc694e3 100644 --- a/launcher/launcheruilayer.h +++ b/launcher/launcheruilayer.cppm @@ -6,15 +6,19 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; + +export module eu07.launcher.launcheruilayer; +import eu07.application.uilayer; +import eu07.launcher.scenery_list; +import eu07.launcher.keymapper; +import eu07.launcher.vehicle_picker; +import eu07.launcher.textures_scanner; +import eu07.launcher.scenery_scanner; + +export { -#pragma once -#include "application/uilayer.h" -#include "launcher/scenery_list.h" -#include "launcher/keymapper.h" -#include "launcher/vehicle_picker.h" -#include "launcher/textures_scanner.h" -#include "launcher/scenery_scanner.h" class launcher_ui : public ui_layer { public: @@ -36,3 +40,5 @@ private: ui_panel *m_current_panel; }; + +} // export diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp index 0b49e80f..fc714036 100644 --- a/launcher/scenery_list.cpp +++ b/launcher/scenery_list.cpp @@ -1,14 +1,23 @@ -#include "stdafx.h" -#include "scenery_list.h" +module; +#include "utilities/Globals_macros.h" +#include +#include "global_include/interfaces/ITexture_macros.h" #include "imgui/imgui.h" -#include "utilities/utilities.h" -#include "rendering/renderer.h" -#include "application/application.h" -#include "utilities/Logs.h" -#include "utilities/translation.h" - +#include "utilities/utilities_macros.h" +#include "utilities/translation_macros.h" #include +module eu07.launcher.scenery_list; +import eu07.utilities.globals; +import eu07.glm; +import eu07.launcher.textures_scanner; +import eu07.utilities.utilities; +import eu07.rendering.renderer; +import eu07.application.application; +import eu07.utilities.logs; +import eu07.utilities.translation; + + ui::scenerylist_panel::scenerylist_panel(scenery_scanner &scanner) : ui_panel(STR("Scenario list"), false), scanner(scanner), placeholder_mini("textures/mini/other") { diff --git a/launcher/scenery_list.h b/launcher/scenery_list.cppm similarity index 84% rename from launcher/scenery_list.h rename to launcher/scenery_list.cppm index 957f1b5e..b8d8aafb 100644 --- a/launcher/scenery_list.h +++ b/launcher/scenery_list.cppm @@ -1,9 +1,17 @@ -#pragma once +module; +#include +#include +#include +#include + +export module eu07.launcher.scenery_list; +import eu07.launcher.deferred_image; +import eu07.input.driverkeyboardinput; +import eu07.application.uilayer; +import eu07.launcher.scenery_scanner; + +export { -#include "input/driverkeyboardinput.h" -#include "application/uilayer.h" -#include "scenery_scanner.h" -#include "widgets/popup.h" namespace ui { @@ -70,3 +78,5 @@ private: void purge_selected_trainset(); }; } // namespace ui + +} // export diff --git a/launcher/scenery_scanner.cpp b/launcher/scenery_scanner.cpp index 7bfa8a07..0dc63ffb 100644 --- a/launcher/scenery_scanner.cpp +++ b/launcher/scenery_scanner.cpp @@ -1,6 +1,14 @@ -#include "stdafx.h" -#include "scenery_scanner.h" -#include "utilities/Logs.h" +module; +#include +#include +#include +#include +#include +#include + +module eu07.launcher.scenery_scanner; +import eu07.utilities.utilities; +import eu07.utilities.logs; scenery_scanner::scenery_scanner(ui::vehicles_bank &bank) : bank(bank) diff --git a/launcher/scenery_scanner.h b/launcher/scenery_scanner.cppm similarity index 82% rename from launcher/scenery_scanner.h rename to launcher/scenery_scanner.cppm index 44854438..f5a9d036 100644 --- a/launcher/scenery_scanner.h +++ b/launcher/scenery_scanner.cppm @@ -1,9 +1,16 @@ -#pragma once - +module; +#include +#include #include -#include "model/Texture.h" -#include "utilities/parser.h" -#include "textures_scanner.h" + +export module eu07.launcher.scenery_scanner; +import eu07.global_include.interfaces.itexture; +import eu07.model.texture; +import eu07.utilities.parser; +import eu07.launcher.textures_scanner; + +export { + struct dynamic_desc { std::string name; @@ -69,3 +76,5 @@ private: ui::vehicles_bank &bank; }; + +} // export diff --git a/launcher/textures_scanner.cpp b/launcher/textures_scanner.cpp index 201ff967..ba8926e1 100644 --- a/launcher/textures_scanner.cpp +++ b/launcher/textures_scanner.cpp @@ -1,6 +1,15 @@ -#include "stdafx.h" -#include "textures_scanner.h" -#include "utilities/utilities.h" +module; +#include +#include +#include +#include +#include +#include +#include "utilities/utilities_macros.h" + +module eu07.launcher.textures_scanner; +import eu07.rendering.geometrybank; +import eu07.utilities.utilities; void ui::vehicles_bank::scan_textures() { diff --git a/launcher/textures_scanner.h b/launcher/textures_scanner.cppm similarity index 89% rename from launcher/textures_scanner.h rename to launcher/textures_scanner.cppm index affa0b94..4fb7c944 100644 --- a/launcher/textures_scanner.h +++ b/launcher/textures_scanner.cppm @@ -1,6 +1,17 @@ -#pragma once +module; +#include +#include +#include +#include +#include +#include +#include + +export module eu07.launcher.textures_scanner; +import eu07.launcher.deferred_image; + +export { -#include "deferred_image.h" namespace ui { enum class vehicle_type { @@ -95,3 +106,5 @@ private: std::string ctx_model; }; } + +} // export diff --git a/launcher/vehicle_picker.cpp b/launcher/vehicle_picker.cpp index 88c40ef9..2104e554 100644 --- a/launcher/vehicle_picker.cpp +++ b/launcher/vehicle_picker.cpp @@ -1,7 +1,19 @@ -#include "stdafx.h" -#include "launcher/vehicle_picker.h" -#include "rendering/renderer.h" -#include "utilities/translation.h" +module; +#include "glad/glad.h" +#include "imgui/imgui.h" +#include +#include +#include +#include +#include +#include +#include "utilities/translation_macros.h" + +module eu07.launcher.vehicle_picker; +import eu07.utilities.utilities; +import eu07.glm; +import eu07.rendering.renderer; +import eu07.utilities.translation; ui::vehiclepicker_panel::vehiclepicker_panel() : ui_panel(STR("Select vehicle"), false), placeholder_mini("textures/mini/other") diff --git a/launcher/vehicle_picker.h b/launcher/vehicle_picker.cppm similarity index 82% rename from launcher/vehicle_picker.h rename to launcher/vehicle_picker.cppm index ad6e6dc2..650a4bc0 100644 --- a/launcher/vehicle_picker.h +++ b/launcher/vehicle_picker.cppm @@ -1,8 +1,19 @@ -#pragma once +module; +#include +#include +#include +#include +#include +#include "utilities/translation_macros.h" + +export module eu07.launcher.vehicle_picker; +import eu07.launcher.deferred_image; +import eu07.application.uilayer; +import eu07.launcher.textures_scanner; +import eu07.utilities.translation; + +export { -#include "application/uilayer.h" -#include "textures_scanner.h" -#include "utilities/translation.h" namespace ui { @@ -63,3 +74,5 @@ private: bool skin_filter(const skin_set *skin, std::vector &info_list); }; } // namespace ui + +} // export diff --git a/model/AnimModel.cpp b/model/AnimModel.cpp index ef4f90a8..0501b53f 100644 --- a/model/AnimModel.cpp +++ b/model/AnimModel.cpp @@ -1,3 +1,23 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" + +module eu07.simcore; +import eu07.model.mdlmngr; +import eu07.rendering.renderer; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.utilities.globals; +import eu07.utilities.timer; +import eu07.utilities.logs; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,18 +32,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "model/AnimModel.h" -#include "rendering/renderer.h" -#include "model/MdlMngr.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "world/Event.h" -#include "utilities/Globals.h" -#include "utilities/Timer.h" -#include "utilities/Logs.h" -#include "rendering/renderer.h" std::list> TAnimModel::acAnimList; diff --git a/model/AnimModel.h b/model/AnimModel.cppm similarity index 96% rename from model/AnimModel.h rename to model/AnimModel.cppm index 435c1dba..30d07751 100644 --- a/model/AnimModel.h +++ b/model/AnimModel.cppm @@ -11,14 +11,24 @@ http://mozilla.org/MPL/2.0/. Copyright (C) 2001-2004 Marcin Wozniak and others */ +module; +#include +#include +#include +#include +#include "vehicle/DynObj_macros.h" + +export module eu07.simcore:animmodel; +import :fwd; +import eu07.utilities.classes; +import eu07.utilities.float3d; +import :model3d; +import :dynobj; +import :scenenode; + +export { -#pragma once -#include "utilities/Classes.h" -#include "utilities/Float3d.h" -#include "model/Model3d.h" -#include "vehicle/DynObj.h" -#include "scene/scenenode.h" const int iMaxNumLights = 8; float const DefaultDarkThresholdLevel { 0.325f }; @@ -44,7 +54,6 @@ class TAnimVocaloidFrame char cBezier[64]; // krzywe Béziera do interpolacji dla x,y,z i obrotu }; -class basic_event; class TAnimContainer : std::enable_shared_from_this { // opakowanie submodelu, określające animację egzemplarza - obsługiwane jako lista @@ -106,9 +115,6 @@ class TAnimContainer : std::enable_shared_from_this // opakowanie modelu, określające stan egzemplarza class TAnimModel : public scene::basic_node { - - friend opengl_renderer; - friend opengl33_renderer; friend itemproperties_panel; public: @@ -235,3 +241,5 @@ class instance_table : public basic_table { }; //--------------------------------------------------------------------------- + +} // export diff --git a/model/MdlMngr.cpp b/model/MdlMngr.cpp index 9ead9716..6c0631a2 100644 --- a/model/MdlMngr.cpp +++ b/model/MdlMngr.cpp @@ -1,3 +1,17 @@ +module; +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.model.mdlmngr; +import eu07.simcore; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,13 +27,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "model/MdlMngr.h" -#include "model/Model3d.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/utilities.h" // wczytanie modelu do kontenerka TModel3d * diff --git a/model/MdlMngr.h b/model/MdlMngr.cppm similarity index 86% rename from model/MdlMngr.h rename to model/MdlMngr.cppm index 94baf3d4..9fd3c6ea 100644 --- a/model/MdlMngr.h +++ b/model/MdlMngr.cppm @@ -6,9 +6,19 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once +module; +#include +#include +#include +#include +#include + +export module eu07.model.mdlmngr; +import eu07.simcore; +import eu07.utilities.classes; + +export { -#include "utilities/Classes.h" class TMdlContainer { friend class TModelsManager; @@ -40,3 +50,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/model/Model3d.cpp b/model/Model3d.cpp index 5f59558b..01478ff7 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -1,3 +1,32 @@ +module; +#include "utilities/utilities_macros.h" +#include +#include +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "rendering/openglmatrixstack_macros.h" + +module eu07.simcore; +import eu07.glm; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.rendering.renderer; +import eu07.utilities.timer; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.world.mtable; +import eu07.scene.sn_utils; +import eu07.rendering.openglmatrixstack; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,17 +41,7 @@ Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others */ -#include "stdafx.h" -#include "model/Model3d.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "rendering/renderer.h" -#include "utilities/Timer.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "world/mtable.h" -#include "scene/sn_utils.h" //--------------------------------------------------------------------------- @@ -1081,7 +1100,7 @@ void TSubModel::SetRotateIK1(float3 vNewAngles) iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } -struct ToLower +struct to_lower_char { char operator()(char input) { @@ -1092,7 +1111,7 @@ struct ToLower TSubModel *TSubModel::GetFromName(std::string const &search, bool i) { TSubModel *result; - // std::transform(search.begin(),search.end(),search.begin(),ToLower()); + // std::transform(search.begin(),search.end(),search.begin(),to_lower_char()); // search=search.LowerCase(); // AnsiString name=AnsiString(); std::string search_lc = search; diff --git a/model/Model3d.h b/model/Model3d.cppm similarity index 95% rename from model/Model3d.h rename to model/Model3d.cppm index 7ebb1317..217bc431 100644 --- a/model/Model3d.h +++ b/model/Model3d.cppm @@ -6,14 +6,26 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include "global_include/interfaces/ITexture_macros.h" +#include +#include +#include +#include + +export module eu07.simcore:model3d; +import eu07.glm; +import :fwd; +import :editoruilayer; +import eu07.utilities.parser; +import eu07.utilities.classes; +import eu07.utilities.float3d; +import eu07.rendering.geometrybank; +import eu07.gl.query; + +export { -#pragma once -#include "utilities/Classes.h" -#include "utilities/Float3d.h" -#include "rendering/geometrybank.h" -#include "model/material.h" -#include "gl/query.h" #define EU07_USE_GEOMETRYINDEXING @@ -46,7 +58,6 @@ enum class TAnimType // rodzaj animacji }; namespace scene { -class shape_node; } class TModel3d; @@ -55,10 +66,9 @@ using nameoffset_sequence = std::vector>; class TSubModel { // klasa submodelu - pojedyncza siatka, punkt świetlny albo grupa punktów //m7todo: zrobić normalną serializację - - friend opengl_renderer; - friend opengl33_renderer; friend TModel3d; // temporary workaround. TODO: clean up class content/hierarchy + // the :fwd declaration is enough for a friend; importing :dynobj here would + // close a partition cycle model3d -> dynobj -> traction -> scenenode -> model3d friend TDynamicObject; // temporary etc friend scene::shape_node; // temporary etc @@ -255,9 +265,6 @@ public: class TModel3d { - friend opengl_renderer; - friend opengl33_renderer; - public: TSubModel *Root { nullptr }; // drzewo submodeli uint32_t iFlags { 0 }; // Ra: czy submodele mają przezroczyste tekstury @@ -300,3 +307,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/model/ResourceManager.cpp b/model/ResourceManager.cpp index 0d91f788..51071bc2 100644 --- a/model/ResourceManager.cpp +++ b/model/ResourceManager.cpp @@ -1,3 +1,6 @@ +module; + +module eu07.model.resourcemanager; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,11 +10,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" /* -#include "model/ResourceManager.h" -#include "utilities/Logs.h" ResourceManager::Resources ResourceManager::_resources; double ResourceManager::_expiry = 5.0f; diff --git a/model/ResourceManager.h b/model/ResourceManager.cppm similarity index 95% rename from model/ResourceManager.h rename to model/ResourceManager.cppm index c9f3cb0b..ccaf5f97 100644 --- a/model/ResourceManager.h +++ b/model/ResourceManager.cppm @@ -6,8 +6,16 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include +#include + +export module eu07.model.resourcemanager; + +export { -#pragma once enum class resource_state { none, @@ -77,3 +85,5 @@ private: typename Container_::size_type m_resourcesweepindex { 0 }; std::chrono::steady_clock::time_point m_resourcetimestamp { std::chrono::steady_clock::now() }; }; + +} // export diff --git a/model/Texture.cpp b/model/Texture.cpp index a5397663..992be6f9 100644 --- a/model/Texture.cpp +++ b/model/Texture.cpp @@ -1,3 +1,36 @@ +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +#include "stb/stb_image.h" +#include "dds-ktx/dds-ktx.h" +#include "winheaders.h" + +module eu07.model.texture; +import eu07.application.application; +import eu07.glm; +import eu07.simcore; +import eu07.scripting.pyint; +import eu07.utilities.dictionary; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.utilities; +import eu07.scene.sn_utils; +import eu07.rendering.flip_s3tc; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,20 +46,8 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "model/Texture.h" -#include "application/application.h" -#include "utilities/dictionary.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/utilities.h" -#include "scene/sn_utils.h" -#include "rendering/flip-s3tc.h" -#include "stb/stb_image.h" //#include -#include "dds-ktx/dds-ktx.h" -#include "winheaders.h" #define EU07_DEFERRED_TEXTURE_UPLOAD diff --git a/model/Texture.h b/model/Texture.cppm similarity index 96% rename from model/Texture.h rename to model/Texture.cppm index 1f582640..8491d82c 100644 --- a/model/Texture.h +++ b/model/Texture.cppm @@ -6,15 +6,23 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include "glad/glad.h" #include #include "winheaders.h" #include -#include "model/ResourceManager.h" -#include "gl/ubo.h" -#include "interfaces/ITexture.h" +#include "global_include/interfaces/ITexture_macros.h" +#include +#include + +export module eu07.model.texture; +import eu07.model.resourcemanager; +import eu07.gl.ubo; +import eu07.global_include.interfaces.itexture; + +export { + + struct opengl_texture : public ITexture { static DDSURFACEDESC2 deserialize_ddsd(std::istream&); @@ -252,3 +260,5 @@ downsample( std::size_t const Width, std::size_t const Height, unsigned char *Im } //--------------------------------------------------------------------------- + +} // export diff --git a/model/material.cpp b/model/material.cpp index f5e32689..ff8257e6 100644 --- a/model/material.cpp +++ b/model/material.cpp @@ -1,4 +1,29 @@ -/* +module; +#include +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/utilities_macros.h" +#include "utilities/Globals_macros.h" + +module eu07.model.material; +import eu07.rendering.geometrybank; +import eu07.widgets.map_objects; +import eu07.rendering.renderer; +import eu07.utilities.parser; +import eu07.utilities.utilities; +import eu07.utilities.logs; +import eu07.scene.sn_utils; +import eu07.utilities.globals; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +32,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "model/material.h" -#include "rendering/renderer.h" -#include "utilities/parser.h" -#include "utilities/utilities.h" -#include "utilities/Logs.h" -#include "scene/sn_utils.h" -#include "utilities/Globals.h" opengl_material::path_data opengl_material::paths; diff --git a/model/material.h b/model/material.cppm similarity index 90% rename from model/material.h rename to model/material.cppm index 6d3f2b8d..73ebc0ad 100644 --- a/model/material.h +++ b/model/material.cppm @@ -1,4 +1,22 @@ -/* +module; +#include "global_include/interfaces/ITexture_macros.h" +#include +#include +#include +#include + +export module eu07.model.material; +import eu07.gl.shader; +import eu07.glm; +import eu07.utilities.parser; +import eu07.audio.audio; +import eu07.global_include.interfaces.imaterial; +import eu07.utilities.classes; +import eu07.model.texture; +import eu07.gl.ubo; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +25,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "interfaces/IMaterial.h" -#include "utilities/Classes.h" -#include "model/Texture.h" -#include "gl/shader.h" -#include "gl/ubo.h" // a collection of parameters for the rendering setup. // for modern opengl this translates to set of attributes for shaders @@ -140,3 +152,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/model/vertex.cpp b/model/vertex.cpp index 41b655b5..f72c8000 100644 --- a/model/vertex.cpp +++ b/model/vertex.cpp @@ -1,4 +1,10 @@ -/* +module; +#include +#include + +module eu07.model.vertex; +import eu07.scene.sn_utils; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +13,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "model/vertex.h" -#include "scene/sn_utils.h" void world_vertex::serialize( std::ostream &s ) const { diff --git a/model/vertex.h b/model/vertex.cppm similarity index 89% rename from model/vertex.h rename to model/vertex.cppm index 4c2ff2ad..d5a5fa01 100644 --- a/model/vertex.h +++ b/model/vertex.cppm @@ -1,4 +1,12 @@ -/* +module; +#include +#include + +export module eu07.model.vertex; +import eu07.glm; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,7 +15,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once // geometry vertex with double precision position struct world_vertex { @@ -80,6 +87,9 @@ struct world_vertex { ( Z - Vertex1.position.z ) / ( Vertex2.position.z - Vertex1.position.z ) ); } }; +} // export -- out-of-line member definitions and explicit +// specialisations are not namespace-scope declarations, so they cannot +// carry `export`; the class itself is exported and that is what counts. template <> world_vertex & world_vertex::operator+=( world_vertex const &Right ); @@ -87,5 +97,8 @@ world_vertex::operator+=( world_vertex const &Right ); template <> world_vertex & world_vertex::operator*=( world_vertex const &Right ); +export { //--------------------------------------------------------------------------- + +} // export diff --git a/network/backend/asio.cpp b/network/backend/asio.cppm similarity index 67% rename from network/backend/asio.cpp rename to network/backend/asio.cppm index 958b084e..7f7790a9 100644 --- a/network/backend/asio.cpp +++ b/network/backend/asio.cppm @@ -1,7 +1,113 @@ -#include "stdafx.h" -#include "network/backend/asio.h" -#include "scene/sn_utils.h" -#include "utilities/Logs.h" +module; +#define ASIO_DISABLE_VISIBILITY +#include +#include +#include +#include +#include +#include +#include +#include +#include + +export module eu07.network.backend.asio; + +import eu07.network.message; +import eu07.network.network; +import eu07.gl.buffer; +import eu07.rendering.geometrybank; +import eu07.scene.sn_utils; +import eu07.utilities.logs; + + +export { +#ifdef DBG_NEW +#undef new +#endif + + + +namespace network::tcp +{ + const uint32_t NETWORK_MAGIC = 0x37305545; + const uint32_t MAX_MSG_SIZE = 100000; + + class connection : public network::connection + { + friend class server; + friend class client; + + public: + connection(asio::io_context &io_ctx, bool client = false, size_t counter = 0); + ~connection(); + + virtual void connected() override; + virtual void disconnect() override; + virtual void send_messages(const std::vector > &messages) override; + virtual void send_message(const message &msg) override; + + asio::ip::tcp::socket m_socket; + + private: + std::string m_header_buffer; + std::string m_body_buffer; + + void write_message(const message &msg, std::ostream &stream); + void send_data(std::shared_ptr buffer); + void read_header(); + void handle_header(const asio::error_code &err, size_t bytes_transferred); + void handle_data(const asio::error_code &err, size_t bytes_transferred); + }; + + class server : public network::server + { + private: + void accept_conn(); + void handle_accept(std::shared_ptr conn, const asio::error_code &err); + + asio::ip::tcp::acceptor m_acceptor; + asio::io_context &m_io_ctx; + + public: + server(std::shared_ptr buf, asio::io_context &io_ctx, const std::string &host, uint32_t port); + }; + + class client : public network::client + { + private: + void handle_accept(const asio::error_code &err); + asio::io_context &io_ctx; + std::string host; + uint32_t port; + + protected: + virtual void connect() override; + + public: + client(asio::io_context &io_ctx, const std::string &host, uint32_t port); + }; + + class asio_manager : public network::backend_manager { + asio::io_context io_context; + + public: + asio_manager(); + + virtual std::shared_ptr create_server(std::shared_ptr, const std::string &conf) override; + virtual std::shared_ptr create_client(const std::string &conf) override; + virtual void update() override; + }; + + asio_manager manager; +} + +} // export + +// The implementation lives here rather than in a separate implementation unit: +// asio defines its customization points as objects in an anonymous namespace, and +// GCC emits those a second time in any implementation unit that also includes +// asio.hpp, which the assembler rejects as duplicate symbols. One translation unit +// including asio is the way around it. network::tcp::connection::connection(asio::io_context &io_ctx, bool client, size_t counter) : network::connection(client, counter), diff --git a/network/backend/asio.h b/network/backend/asio.h deleted file mode 100644 index 47e731c7..00000000 --- a/network/backend/asio.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifdef DBG_NEW -#undef new -#endif - -#define ASIO_DISABLE_VISIBILITY -#include - -#include "network/network.h" - -namespace network::tcp -{ - const uint32_t NETWORK_MAGIC = 0x37305545; - const uint32_t MAX_MSG_SIZE = 100000; - - class connection : public network::connection - { - friend class server; - friend class client; - - public: - connection(asio::io_context &io_ctx, bool client = false, size_t counter = 0); - ~connection(); - - virtual void connected() override; - virtual void disconnect() override; - virtual void send_messages(const std::vector > &messages) override; - virtual void send_message(const message &msg) override; - - asio::ip::tcp::socket m_socket; - - private: - std::string m_header_buffer; - std::string m_body_buffer; - - void write_message(const message &msg, std::ostream &stream); - void send_data(std::shared_ptr buffer); - void read_header(); - void handle_header(const asio::error_code &err, size_t bytes_transferred); - void handle_data(const asio::error_code &err, size_t bytes_transferred); - }; - - class server : public network::server - { - private: - void accept_conn(); - void handle_accept(std::shared_ptr conn, const asio::error_code &err); - - asio::ip::tcp::acceptor m_acceptor; - asio::io_context &m_io_ctx; - - public: - server(std::shared_ptr buf, asio::io_context &io_ctx, const std::string &host, uint32_t port); - }; - - class client : public network::client - { - private: - void handle_accept(const asio::error_code &err); - asio::io_context &io_ctx; - std::string host; - uint32_t port; - - protected: - virtual void connect() override; - - public: - client(asio::io_context &io_ctx, const std::string &host, uint32_t port); - }; - - class asio_manager : public network::backend_manager { - asio::io_context io_context; - - public: - asio_manager(); - - virtual std::shared_ptr create_server(std::shared_ptr, const std::string &conf) override; - virtual std::shared_ptr create_client(const std::string &conf) override; - virtual void update() override; - }; - - asio_manager manager; -} diff --git a/network/manager.cpp b/network/manager.cpp index 37d72401..93973073 100644 --- a/network/manager.cpp +++ b/network/manager.cpp @@ -1,3 +1,12 @@ +module; +#include +#include +#include + +module eu07.network.manager; +import eu07.network.message; +import eu07.simulation.simulation; +import eu07.utilities.logs; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,10 +16,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "network/manager.h" -#include "simulation/simulation.h" -#include "utilities/Logs.h" network::server_manager::server_manager() { diff --git a/network/manager.h b/network/manager.cppm similarity index 81% rename from network/manager.h rename to network/manager.cppm index 572a8c6b..67ec6504 100644 --- a/network/manager.h +++ b/network/manager.cppm @@ -1,7 +1,13 @@ -#pragma once +module; +#include +#include #include -#include "network/network.h" -#include "input/command.h" + +export module eu07.network.manager; +import eu07.network.network; +import eu07.input.command; + +export { namespace network { @@ -32,3 +38,5 @@ namespace network void update(); }; } + +} // export diff --git a/network/message.cpp b/network/message.cpp index 12609905..93f25265 100644 --- a/network/message.cpp +++ b/network/message.cpp @@ -1,6 +1,10 @@ -#include "stdafx.h" -#include "network/message.h" -#include "scene/sn_utils.h" +module; +#include +#include +#include + +module eu07.network.message; +import eu07.scene.sn_utils; void network::client_hello::serialize(std::ostream &stream) const { diff --git a/network/message.h b/network/message.cppm similarity index 89% rename from network/message.h rename to network/message.cppm index 43ad13ec..e0b134d6 100644 --- a/network/message.h +++ b/network/message.cppm @@ -1,7 +1,15 @@ -#pragma once -#include "network/message.h" -#include "input/command.h" +module; #include +#include +#include +#include +#include +#include + +export module eu07.network.message; +import eu07.input.command; + +export { namespace network { @@ -73,3 +81,5 @@ struct frame_info : public request_command std::shared_ptr deserialize_message(std::istream &stream); void serialize_message(const message &msg, std::ostream &stream); } // namespace network + +} // export diff --git a/network/network.cpp b/network/network.cpp index ae83bf78..a6bdcdf1 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -1,11 +1,23 @@ -#include "stdafx.h" -#include "network/network.h" -#include "network/message.h" -#include "utilities/Logs.h" -#include "scene/sn_utils.h" -#include "utilities/Timer.h" -#include "application/application.h" -#include "utilities/Globals.h" +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.network.network; +import eu07.network.message; +import eu07.utilities.logs; +import eu07.scene.sn_utils; +import eu07.utilities.timer; +import eu07.application.application; +import eu07.utilities.globals; std::uint32_t const EU07_NETWORK_VERSION = 2; diff --git a/network/network.h b/network/network.cppm similarity index 94% rename from network/network.h rename to network/network.cppm index 1ce802be..777ebc29 100644 --- a/network/network.h +++ b/network/network.cppm @@ -1,11 +1,17 @@ -#pragma once +module; #include +#include +#include #include #include #include #include -#include "network/message.h" -#include "input/command.h" + +export module eu07.network.network; +import eu07.network.message; +import eu07.input.command; + +export { namespace network { @@ -119,3 +125,5 @@ namespace network using backend_list_t = std::unordered_map; backend_list_t& backend_list(); } + +} // export diff --git a/rendering/flip-s3tc.h b/rendering/flip-s3tc.cppm similarity index 98% rename from rendering/flip-s3tc.h rename to rendering/flip-s3tc.cppm index a529add4..eab34423 100644 --- a/rendering/flip-s3tc.h +++ b/rendering/flip-s3tc.cppm @@ -1,10 +1,14 @@ // https://github.com/inequation/flip-s3tc // Leszek Godlewski places this file in the public domain. - -#pragma once - +module; #include +export module eu07.rendering.flip_s3tc; + +export { + + + #ifdef __cplusplus namespace flip_s3tc { @@ -205,3 +209,5 @@ void flip_dxt45_image(void *data, int width, int height) #if __cplusplus } // namespace flip_s3tc #endif + +} // export diff --git a/rendering/frustum.cpp b/rendering/frustum.cpp index afe16441..c6271827 100644 --- a/rendering/frustum.cpp +++ b/rendering/frustum.cpp @@ -1,3 +1,11 @@ +module; +#include +#include "glad/glad.h" +#include "rendering/openglmatrixstack_macros.h" + +module eu07.rendering.frustum; +import eu07.glm; +import eu07.rendering.openglmatrixstack; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,8 +15,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/frustum.h" void cFrustum::calculate() { diff --git a/rendering/frustum.h b/rendering/frustum.cppm similarity index 95% rename from rendering/frustum.h rename to rendering/frustum.cppm index 4afe02f0..14561a72 100644 --- a/rendering/frustum.h +++ b/rendering/frustum.cppm @@ -6,10 +6,16 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include + +export module eu07.rendering.frustum; +import eu07.glm; +import eu07.utilities.float3d; + +export { -#pragma once -#include "utilities/Float3d.h" inline std::vector const ndcfrustumshapepoints // { @@ -84,3 +90,5 @@ private: // members: float m_frustum[6][4]; // holds the A B C and D values (normal & distance) for each side of the frustum. }; + +} // export diff --git a/rendering/geometrybank.cpp b/rendering/geometrybank.cpp index fcd731dd..53cab6c1 100644 --- a/rendering/geometrybank.cpp +++ b/rendering/geometrybank.cpp @@ -1,4 +1,25 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "glad/glad.h" +#include + +module eu07.rendering.geometrybank; +import eu07.simcore; +import eu07.glm; +import eu07.model.vertex; +import eu07.scene.sn_utils; +import eu07.utilities.logs; +import eu07.utilities.globals; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +28,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/geometrybank.h" -#include "model/vertex.h" -#include "scene/sn_utils.h" -#include "utilities/Logs.h" -#include "utilities/Globals.h" namespace gfx { diff --git a/rendering/geometrybank.h b/rendering/geometrybank.cppm similarity index 97% rename from rendering/geometrybank.h rename to rendering/geometrybank.cppm index 39735e00..aebcd494 100644 --- a/rendering/geometrybank.h +++ b/rendering/geometrybank.cppm @@ -1,4 +1,21 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include "glad/glad.h" + +export module eu07.rendering.geometrybank; +import eu07.glm; +import eu07.model.vertex; +import eu07.model.resourcemanager; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +24,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "model/ResourceManager.h" -struct world_vertex; namespace gfx { @@ -262,3 +276,5 @@ private: }; } // namespace gfx + +} // export diff --git a/rendering/light.h b/rendering/light.cppm similarity index 80% rename from rendering/light.h rename to rendering/light.cppm index 246056d3..ca25b749 100644 --- a/rendering/light.h +++ b/rendering/light.cppm @@ -1,4 +1,11 @@ -/* +module; + +export module eu07.rendering.light; +import eu07.glm; +import eu07.utilities.color; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "utilities/color.h" // a simple light source, either omni- or directional struct basic_light { @@ -21,3 +26,5 @@ struct basic_light { glm::vec3 direction; bool is_directional { true }; }; + +} // export diff --git a/rendering/lightarray.cpp b/rendering/lightarray.cpp index 41bff159..7192ffe2 100644 --- a/rendering/lightarray.cpp +++ b/rendering/lightarray.cpp @@ -1,3 +1,9 @@ +module; +#include +#include "vehicle/DynObj_macros.h" +#include + +module eu07.rendering.lightarray; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,9 +19,6 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/lightarray.h" -#include "vehicle/DynObj.h" void light_array::insert( TDynamicObject const *Owner ) { diff --git a/rendering/lightarray.h b/rendering/lightarray.cppm similarity index 89% rename from rendering/lightarray.h rename to rendering/lightarray.cppm index 670cbea8..01a73dd5 100644 --- a/rendering/lightarray.h +++ b/rendering/lightarray.cppm @@ -1,6 +1,14 @@ -#pragma once +module; +#include + +export module eu07.rendering.lightarray; +import eu07.simcore; +import eu07.glm; +import eu07.utilities.classes; + +export { +#pragma once -#include "utilities/Classes.h" // collection of virtual light sources present in the scene // used by the renderer to determine most suitable placement for actual light sources during render @@ -41,3 +49,5 @@ public: // members lightrecord_array data; }; + +} // export diff --git a/rendering/nullrenderer.cpp b/rendering/nullrenderer.cpp index a37eddb9..af8d14bd 100644 --- a/rendering/nullrenderer.cpp +++ b/rendering/nullrenderer.cpp @@ -1,5 +1,7 @@ -#include "stdafx.h" -#include "rendering/nullrenderer.h" +module; +#include + +module eu07.rendering.nullrenderer; std::unique_ptr null_renderer::create_func() { diff --git a/rendering/nullrenderer.h b/rendering/nullrenderer.cppm similarity index 92% rename from rendering/nullrenderer.h rename to rendering/nullrenderer.cppm index 69839f11..fab809c9 100644 --- a/rendering/nullrenderer.h +++ b/rendering/nullrenderer.cppm @@ -1,17 +1,32 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - -#include "model/Texture.h" -#include "rendering/geometrybank.h" -#include "model/material.h" -#include "rendering/renderer.h" -#include "stdafx.h" -#include +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include #include +export module eu07.rendering.nullrenderer; +import eu07.gl.shader; +import eu07.simcore; +import eu07.global_include.interfaces.imaterial; +import eu07.global_include.interfaces.itexture; +import eu07.utilities.classes; +import eu07.utilities.globals; +import eu07.glm; +import eu07.model.texture; +import eu07.rendering.geometrybank; +import eu07.model.material; +import eu07.rendering.renderer; + +export { + + + class null_geometrybank : public gfx::geometry_bank { public: // constructors: @@ -160,3 +175,5 @@ public: gfx::geometrybank_manager m_geometry; std::vector> m_materials; }; + +} // export diff --git a/rendering/opengl33geometrybank.cpp b/rendering/opengl33geometrybank.cpp index 91c9a8dd..561b2311 100644 --- a/rendering/opengl33geometrybank.cpp +++ b/rendering/opengl33geometrybank.cpp @@ -1,4 +1,11 @@ -/* +module; +#include +#include "glad/glad.h" +#include + +module eu07.rendering.opengl33geometrybank; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengl33geometrybank.h" -#include "utilities/Logs.h" namespace gfx { diff --git a/rendering/opengl33geometrybank.h b/rendering/opengl33geometrybank.cppm similarity index 91% rename from rendering/opengl33geometrybank.h rename to rendering/opengl33geometrybank.cppm index f5cd7e37..535f17ff 100644 --- a/rendering/opengl33geometrybank.h +++ b/rendering/opengl33geometrybank.cppm @@ -1,4 +1,15 @@ -/* +module; +#include +#include +#include + +export module eu07.rendering.opengl33geometrybank; +import eu07.rendering.geometrybank; +import eu07.gl.buffer; +import eu07.gl.vao; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +18,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/geometrybank.h" -#include "gl/buffer.h" -#include "gl/vao.h" namespace gfx { @@ -77,3 +84,5 @@ private: }; } // namespace gfx + +} // export diff --git a/rendering/opengl33light.cpp b/rendering/opengl33light.cpp index ea1baf78..d9b81fda 100644 --- a/rendering/opengl33light.cpp +++ b/rendering/opengl33light.cpp @@ -1,4 +1,7 @@ -/* +module; + +module eu07.rendering.opengl33light; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +10,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengl33light.h" void opengl33_light::apply_intensity(float const Factor) { diff --git a/rendering/opengl33light.h b/rendering/opengl33light.cppm similarity index 80% rename from rendering/opengl33light.h rename to rendering/opengl33light.cppm index b87564aa..c5a20508 100644 --- a/rendering/opengl33light.h +++ b/rendering/opengl33light.cppm @@ -1,4 +1,11 @@ -/* +module; +#include "glad/glad.h" + +export module eu07.rendering.opengl33light; +import eu07.rendering.light; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/light.h" struct opengl33_light : public basic_light { @@ -26,3 +31,5 @@ struct opengl33_light : public basic_light { }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/opengl33particles.cpp b/rendering/opengl33particles.cpp index b869012b..d0cfae2c 100644 --- a/rendering/opengl33particles.cpp +++ b/rendering/opengl33particles.cpp @@ -1,4 +1,20 @@ -/* +module; +#include +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.rendering.opengl33particles; +import eu07.utilities.globals; +import eu07.rendering.particles; +import eu07.rendering.openglcamera; +import eu07.simulation.simulation; +import eu07.simulation.simulationenvironment; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +23,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengl33particles.h" -#include "rendering/particles.h" -#include "rendering/openglcamera.h" -#include "simulation/simulation.h" -#include "simulation/simulationenvironment.h" std::vector> const billboard_vertices { diff --git a/rendering/opengl33particles.h b/rendering/opengl33particles.cppm similarity index 83% rename from rendering/opengl33particles.h rename to rendering/opengl33particles.cppm index 0d51a8ec..5fe1d770 100644 --- a/rendering/opengl33particles.h +++ b/rendering/opengl33particles.cppm @@ -1,4 +1,17 @@ -/* +module; +#include +#include +#include + +export module eu07.rendering.opengl33particles; +import eu07.glm; +import eu07.rendering.openglcamera; +import eu07.gl.buffer; +import eu07.gl.vao; +import eu07.gl.shader; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +20,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "gl/buffer.h" -#include "gl/vao.h" -#include "gl/shader.h" -class opengl_camera; // particle data visualizer class opengl33_particles { @@ -52,3 +60,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/opengl33precipitation.cpp b/rendering/opengl33precipitation.cpp index e31eb25f..bf7cb6b5 100644 --- a/rendering/opengl33precipitation.cpp +++ b/rendering/opengl33precipitation.cpp @@ -1,3 +1,15 @@ +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.rendering.opengl33precipitation; +import eu07.utilities.globals; +import eu07.rendering.renderer; +import eu07.simulation.simulationenvironment; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,12 +19,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengl33precipitation.h" -#include "utilities/Globals.h" -#include "rendering/renderer.h" -#include "simulation/simulationenvironment.h" opengl33_precipitation::~opengl33_precipitation() { // TODO: release allocated resources diff --git a/rendering/opengl33precipitation.h b/rendering/opengl33precipitation.cppm similarity index 76% rename from rendering/opengl33precipitation.h rename to rendering/opengl33precipitation.cppm index 9aab5ec5..6f0a4d76 100644 --- a/rendering/opengl33precipitation.h +++ b/rendering/opengl33precipitation.cppm @@ -6,12 +6,22 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include + +export module eu07.rendering.opengl33precipitation; +import eu07.glm; +import eu07.gl.buffer; +import eu07.global_include.interfaces.itexture; +import eu07.model.texture; +import eu07.gl.vao; +import eu07.gl.shader; + +export { -#pragma once -#include "model/Texture.h" -#include "gl/vao.h" -#include "gl/shader.h" class opengl33_precipitation { @@ -41,3 +51,5 @@ private: std::optional m_shader; std::optional m_vao; }; + +} // export diff --git a/rendering/opengl33renderer.cpp b/rendering/opengl33renderer.cpp index 576cf404..84594fc0 100644 --- a/rendering/opengl33renderer.cpp +++ b/rendering/opengl33renderer.cpp @@ -1,4 +1,49 @@ -/* +module; +#include "imgui/imgui.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include +#include "gl/gldebug.h" +#include "glad/glad.h" +#include "utilities/crashreporter_macros.h" +#include "widgets/imgui_scale.h" +#include "rendering/openglmatrixstack_macros.h" + +module eu07.rendering.opengl33renderer; +import eu07.gl.buffer; +import eu07.rendering.particles; +import eu07.utilities.utilities; +import eu07.glm; +import eu07.utilities.color; +import eu07.utilities.globals; +import eu07.utilities.timer; +import eu07.vehicle.train; +import eu07.vehicle.camera; +import eu07.simulation.simulation; +import eu07.utilities.logs; +import eu07.simulation.simulationtime; +import eu07.application.application; +import eu07.simcore; +import eu07.rendering.opengl33geometrybank; +import eu07.rendering.screenshot; +import eu07.utilities.crashreporter; +import eu07.rendering.openglmatrixstack; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,21 +52,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengl33renderer.h" -#include "utilities/color.h" -#include "utilities/Globals.h" -#include "utilities/Timer.h" -#include "vehicle/Train.h" -#include "vehicle/Camera.h" -#include "simulation/simulation.h" -#include "utilities/Logs.h" -#include "simulation/simulationtime.h" -#include "application/application.h" -#include "model/AnimModel.h" -#include "rendering/opengl33geometrybank.h" -#include "rendering/screenshot.h" -#include //#define EU07_DEBUG_OPENGL @@ -218,7 +248,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window) if (vr) { glm::ivec2 target_size = vr->get_target_size(); - WriteLog("using vr rendertarget: " + glm::to_string(target_size)); + WriteLog("using vr rendertarget: " + std::to_string(target_size.x) + "x" + std::to_string(target_size.y)); // hijack main window for left eye default_viewport.width = target_size.x; diff --git a/rendering/opengl33renderer.h b/rendering/opengl33renderer.cppm similarity index 94% rename from rendering/opengl33renderer.h rename to rendering/opengl33renderer.cppm index 6fda37c3..656a302c 100644 --- a/rendering/opengl33renderer.h +++ b/rendering/opengl33renderer.cppm @@ -1,4 +1,51 @@ -/* +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +export module eu07.rendering.opengl33renderer; +import eu07.gl.vao; +import eu07.utilities.color; +import eu07.glm; +import eu07.global_include.interfaces.imaterial; +import eu07.global_include.interfaces.itexture; +import eu07.model.material; +import eu07.model.texture; +import eu07.rendering.geometrybank; +import eu07.utilities.classes; +import eu07.vehicle.camera; +import eu07.utilities.globals; +import eu07.rendering.renderer; +import eu07.rendering.openglcamera; +import eu07.rendering.opengl33light; +import eu07.rendering.opengl33particles; +import eu07.rendering.opengl33skydome; +import eu07.rendering.opengl33precipitation; +import eu07.simulation.simulationenvironment; +import eu07.simcore; +import eu07.rendering.lightarray; +import eu07.vr.vr_interface; +import eu07.gl.ubo; +import eu07.gl.framebuffer; +import eu07.gl.renderbuffer; +import eu07.gl.postfx; +import eu07.gl.shader; +import eu07.gl.cubemap; +import eu07.gl.glsl_common; +import eu07.gl.pbo; +import eu07.gl.query; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,28 +54,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/renderer.h" -#include "rendering/openglcamera.h" -#include "rendering/opengl33light.h" -#include "rendering/opengl33particles.h" -#include "rendering/opengl33skydome.h" -#include "rendering/opengl33precipitation.h" -#include "simulation/simulationenvironment.h" -#include "scene/scene.h" -#include "world/MemCell.h" -#include "rendering/lightarray.h" -#include "vr/vr_interface.h" -#include "gl/ubo.h" -#include "gl/framebuffer.h" -#include "gl/renderbuffer.h" -#include "gl/postfx.h" -#include "gl/shader.h" -#include "gl/cubemap.h" -#include "gl/glsl_common.h" -#include "gl/pbo.h" -#include "gl/query.h" // bare-bones render controller, in lack of anything better yet class opengl33_renderer : public gfx_renderer { @@ -521,3 +547,5 @@ class opengl33_renderer : public gfx_renderer { }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/opengl33skydome.cpp b/rendering/opengl33skydome.cpp index 35e1d8c0..7531e330 100644 --- a/rendering/opengl33skydome.cpp +++ b/rendering/opengl33skydome.cpp @@ -1,3 +1,10 @@ +module; +#include "glad/glad.h" +#include + +module eu07.rendering.opengl33skydome; +import eu07.glm; +import eu07.simulation.simulationenvironment; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,10 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengl33skydome.h" -#include "simulation/simulationenvironment.h" void opengl33_skydome::update() { diff --git a/rendering/opengl33skydome.h b/rendering/opengl33skydome.cppm similarity index 80% rename from rendering/opengl33skydome.h rename to rendering/opengl33skydome.cppm index 425c276b..a64790b9 100644 --- a/rendering/opengl33skydome.h +++ b/rendering/opengl33skydome.cppm @@ -6,12 +6,17 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include + +export module eu07.rendering.opengl33skydome; +import eu07.gl.vao; +import eu07.gl.shader; +import eu07.gl.buffer; + +export { -#pragma once -#include "gl/vao.h" -#include "gl/shader.h" -#include "gl/buffer.h" class opengl33_skydome { @@ -34,3 +39,5 @@ private: std::optional m_shader; std::optional m_vao; }; + +} // export diff --git a/rendering/openglcamera.cpp b/rendering/openglcamera.cpp index 97891e63..f307ef64 100644 --- a/rendering/openglcamera.cpp +++ b/rendering/openglcamera.cpp @@ -1,4 +1,11 @@ -/* +module; +#include +#include "glad/glad.h" +#include "vehicle/DynObj_macros.h" + +module eu07.rendering.openglcamera; +import eu07.simcore; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglcamera.h" -#include "vehicle/DynObj.h" void opengl_camera::update_frustum( glm::mat4 const &Projection, glm::mat4 const &Modelview ) { diff --git a/rendering/openglcamera.h b/rendering/openglcamera.cppm similarity index 92% rename from rendering/openglcamera.h rename to rendering/openglcamera.cppm index 569a798c..17dedbf3 100644 --- a/rendering/openglcamera.h +++ b/rendering/openglcamera.cppm @@ -1,4 +1,14 @@ -/* +module; +#include +#include + +export module eu07.rendering.openglcamera; +import eu07.glm; +import eu07.simcore; +import eu07.rendering.frustum; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/frustum.h" -#include "scene/scene.h" // simple camera object. paired with 'virtual camera' in the scene class opengl_camera { @@ -79,3 +86,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/openglcolor.cpp b/rendering/openglcolor.cpp index 3ca8ad66..022afe40 100644 --- a/rendering/openglcolor.cpp +++ b/rendering/openglcolor.cpp @@ -1,3 +1,7 @@ +module; +#include "rendering/openglcolor_macros.h" + +module eu07.rendering.openglcolor; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,8 +11,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglcolor.h" opengl_color OpenGLColor; diff --git a/rendering/openglcolor.h b/rendering/openglcolor.cppm similarity index 84% rename from rendering/openglcolor.h rename to rendering/openglcolor.cppm index f6777bed..d9b32c1d 100644 --- a/rendering/openglcolor.h +++ b/rendering/openglcolor.cppm @@ -7,11 +7,18 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "utilities/Globals.h" // encapsulation of the fixed pipeline opengl color +module; +#include +#include "utilities/Globals_macros.h" + +export module eu07.rendering.openglcolor; +import eu07.glm; +import eu07.utilities.globals; + +export { class opengl_color { public: @@ -62,16 +69,9 @@ private: extern opengl_color OpenGLColor; -// NOTE: standard opengl calls re-definitions -#undef glColor3f -#undef glColor3fv -#undef glColor4f -#undef glColor4fv -#define glColor3f OpenGLColor.color3 -#define glColor3fv OpenGLColor.color3 -#define glColor4f OpenGLColor.color4 -#define glColor4fv OpenGLColor.color4 //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/openglcolor_macros.h b/rendering/openglcolor_macros.h new file mode 100644 index 00000000..3e15e659 --- /dev/null +++ b/rendering/openglcolor_macros.h @@ -0,0 +1,11 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define glColor3f OpenGLColor.color3 +#define glColor3fv OpenGLColor.color3 +#define glColor4f OpenGLColor.color4 +#define glColor4fv OpenGLColor.color4 diff --git a/rendering/openglgeometrybank.cpp b/rendering/openglgeometrybank.cpp index ec950c0f..1ac1c19f 100644 --- a/rendering/openglgeometrybank.cpp +++ b/rendering/openglgeometrybank.cpp @@ -1,4 +1,15 @@ -/* +module; +#include "rendering/openglcolor_macros.h" +#include "glad/glad.h" +#include +#include +#include + +module eu07.rendering.openglgeometrybank; +import eu07.rendering.openglcolor; +import eu07.glm; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +18,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglgeometrybank.h" -#include "rendering/openglcolor.h" -#include "utilities/Logs.h" namespace gfx { diff --git a/rendering/openglgeometrybank.h b/rendering/openglgeometrybank.cppm similarity index 95% rename from rendering/openglgeometrybank.h rename to rendering/openglgeometrybank.cppm index ec6bdd89..67b9859b 100644 --- a/rendering/openglgeometrybank.h +++ b/rendering/openglgeometrybank.cppm @@ -1,4 +1,13 @@ -/* +module; +#include "glad/glad.h" +#include +#include + +export module eu07.rendering.openglgeometrybank; +import eu07.rendering.geometrybank; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +16,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/geometrybank.h" namespace gfx { @@ -122,3 +129,5 @@ private: }; } // namespace gfx + +} // export diff --git a/rendering/opengllight.cpp b/rendering/opengllight.cpp index 79ce967c..f459327c 100644 --- a/rendering/opengllight.cpp +++ b/rendering/opengllight.cpp @@ -1,4 +1,10 @@ -/* +module; +#include "glad/glad.h" +#include + +module eu07.rendering.opengllight; +import eu07.glm; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +13,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/opengllight.h" void opengl_light::apply_intensity( float const Factor ) { diff --git a/rendering/opengllight.h b/rendering/opengllight.cppm similarity index 81% rename from rendering/opengllight.h rename to rendering/opengllight.cppm index 1fe71b9d..90647485 100644 --- a/rendering/opengllight.h +++ b/rendering/opengllight.cppm @@ -1,4 +1,11 @@ -/* +module; +#include "glad/glad.h" + +export module eu07.rendering.opengllight; +import eu07.rendering.light; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/light.h" struct opengl_light : public basic_light { @@ -27,3 +32,5 @@ struct opengl_light : public basic_light { }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/openglmatrixstack.cpp b/rendering/openglmatrixstack.cpp index 2b4ce4e0..4339d68c 100644 --- a/rendering/openglmatrixstack.cpp +++ b/rendering/openglmatrixstack.cpp @@ -1,3 +1,7 @@ +module; +#include "rendering/openglmatrixstack_macros.h" + +module eu07.rendering.openglmatrixstack; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,6 +11,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" + opengl_matrices OpenGLMatrices; diff --git a/rendering/openglmatrixstack.h b/rendering/openglmatrixstack.cppm similarity index 94% rename from rendering/openglmatrixstack.h rename to rendering/openglmatrixstack.cppm index 9ba2fa41..71ca9a43 100644 --- a/rendering/openglmatrixstack.h +++ b/rendering/openglmatrixstack.cppm @@ -1,4 +1,14 @@ -/* +module; +#include "rendering/openglmatrixstack_macros.h" +#include +#include +#include "glad/glad.h" + +export module eu07.rendering.openglmatrixstack; +import eu07.glm; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include // encapsulation of the fixed pipeline opengl matrix stack class opengl_matrices { @@ -234,22 +241,12 @@ extern opengl_matrices OpenGLMatrices; #undef gluPerspective #undef gluLookAt -#define glMatrixMode OpenGLMatrices.mode -#define glPushMatrix OpenGLMatrices.push_matrix -#define glPopMatrix OpenGLMatrices.pop_matrix -#define glLoadIdentity OpenGLMatrices.load_identity -#define glLoadMatrixf OpenGLMatrices.load_matrix #define glLoadMatrixd OpenGLMatrices.load_matrix -#define glRotated OpenGLMatrices.rotate -#define glRotatef OpenGLMatrices.rotate -#define glTranslated OpenGLMatrices.translate -#define glTranslatef OpenGLMatrices.translate #define glScaled OpenGLMatrices.scale -#define glScalef OpenGLMatrices.scale -#define glMultMatrixd OpenGLMatrices.multiply -#define glMultMatrixf OpenGLMatrices.multiply #define glOrtho OpenGLMatrices.ortho #define gluPerspective OpenGLMatrices.perspective #define gluLookAt OpenGLMatrices.look_at //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/openglmatrixstack_macros.h b/rendering/openglmatrixstack_macros.h new file mode 100644 index 00000000..83763e9d --- /dev/null +++ b/rendering/openglmatrixstack_macros.h @@ -0,0 +1,19 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define glMatrixMode OpenGLMatrices.mode +#define glPushMatrix OpenGLMatrices.push_matrix +#define glPopMatrix OpenGLMatrices.pop_matrix +#define glLoadIdentity OpenGLMatrices.load_identity +#define glLoadMatrixf OpenGLMatrices.load_matrix +#define glRotated OpenGLMatrices.rotate +#define glRotatef OpenGLMatrices.rotate +#define glTranslated OpenGLMatrices.translate +#define glTranslatef OpenGLMatrices.translate +#define glScalef OpenGLMatrices.scale +#define glMultMatrixd OpenGLMatrices.multiply +#define glMultMatrixf OpenGLMatrices.multiply diff --git a/rendering/openglparticles.cpp b/rendering/openglparticles.cpp index 54db2ddf..8296fe2b 100644 --- a/rendering/openglparticles.cpp +++ b/rendering/openglparticles.cpp @@ -1,4 +1,20 @@ -/* +module; +#include +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.rendering.openglparticles; +import eu07.utilities.globals; +import eu07.rendering.particles; +import eu07.rendering.openglcamera; +import eu07.simulation.simulation; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +23,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglparticles.h" -#include "rendering/particles.h" -#include "rendering/openglcamera.h" -#include "simulation/simulation.h" -#include "utilities/Logs.h" std::vector> const billboard_vertices { diff --git a/rendering/openglparticles.h b/rendering/openglparticles.cppm similarity index 88% rename from rendering/openglparticles.h rename to rendering/openglparticles.cppm index 267fffc4..b32e9afe 100644 --- a/rendering/openglparticles.h +++ b/rendering/openglparticles.cppm @@ -1,4 +1,15 @@ -/* +module; +#include +#include +#include +#include "glad/glad.h" + +export module eu07.rendering.openglparticles; +import eu07.glm; +import eu07.rendering.openglcamera; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +18,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -class opengl_camera; // particle data visualizer class opengl_particles { @@ -49,3 +58,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/openglprecipitation.cpp b/rendering/openglprecipitation.cpp index fc93b2a9..cad329ab 100644 --- a/rendering/openglprecipitation.cpp +++ b/rendering/openglprecipitation.cpp @@ -1,3 +1,16 @@ +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" + +module eu07.rendering.openglprecipitation; +import eu07.utilities.globals; +import eu07.rendering.renderer; +import eu07.simulation.simulationenvironment; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,12 +20,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglprecipitation.h" -#include "utilities/Globals.h" -#include "rendering/renderer.h" -#include "simulation/simulationenvironment.h" opengl_precipitation::~opengl_precipitation() { diff --git a/rendering/openglprecipitation.h b/rendering/openglprecipitation.cppm similarity index 75% rename from rendering/openglprecipitation.h rename to rendering/openglprecipitation.cppm index a0bb2dcd..eaa83356 100644 --- a/rendering/openglprecipitation.h +++ b/rendering/openglprecipitation.cppm @@ -6,10 +6,20 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include "global_include/interfaces/ITexture_macros.h" +#include "glad/glad.h" +#include +#include + +export module eu07.rendering.openglprecipitation; +import eu07.glm; +import eu07.global_include.interfaces.itexture; +import eu07.model.texture; + +export { -#pragma once -#include "model/Texture.h" class opengl_precipitation { @@ -37,3 +47,5 @@ private: texture_handle m_texture { null_handle }; float m_overcast { -1.f }; // cached overcast level, difference from current state triggers texture update }; + +} // export diff --git a/rendering/openglrenderer.cpp b/rendering/openglrenderer.cpp index d159c31a..13602a07 100644 --- a/rendering/openglrenderer.cpp +++ b/rendering/openglrenderer.cpp @@ -1,4 +1,49 @@ -/* +module; +#include "imgui/imgui.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "rendering/openglrenderer_macros.h" +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" +#include "rendering/openglcolor_macros.h" +#include +#include "glad/glad.h" +#include "utilities/crashreporter_macros.h" +#include "rendering/openglmatrixstack_macros.h" + +module eu07.rendering.openglrenderer; +import eu07.gl.buffer; +import eu07.application.uilayer; +import eu07.rendering.particles; +import eu07.utilities.utilities; +import eu07.glm; +import eu07.utilities.color; +import eu07.utilities.globals; +import eu07.vehicle.camera; +import eu07.utilities.timer; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.vehicle.train; +import eu07.simcore; +import eu07.application.application; +import eu07.utilities.logs; +import eu07.rendering.openglgeometrybank; +import eu07.rendering.openglcolor; +import eu07.rendering.screenshot; +import eu07.utilities.crashreporter; +import eu07.rendering.openglmatrixstack; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,25 +52,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglrenderer.h" -#include "utilities/color.h" -#include "utilities/Globals.h" -#include "vehicle/Camera.h" -#include "utilities/Timer.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "vehicle/Train.h" -#include "vehicle/DynObj.h" -#include "model/AnimModel.h" -#include "world/Traction.h" -#include "application/application.h" -#include "utilities/Logs.h" -#include "rendering/openglgeometrybank.h" -#include "rendering/openglcolor.h" -#include "rendering/screenshot.h" -#include int constexpr EU07_PICKBUFFERSIZE { 1024 }; // size of (square) textures bound with the pick framebuffer int constexpr EU07_ENVIRONMENTBUFFERSIZE { 256 }; // size of (square) environmental cube map texture diff --git a/rendering/openglrenderer.h b/rendering/openglrenderer.cppm similarity index 93% rename from rendering/openglrenderer.h rename to rendering/openglrenderer.cppm index 820deb92..667ededc 100644 --- a/rendering/openglrenderer.h +++ b/rendering/openglrenderer.cppm @@ -1,4 +1,39 @@ -/* +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "rendering/openglrenderer_macros.h" + +export module eu07.rendering.openglrenderer; +import eu07.gl.shader; +import eu07.utilities.color; +import eu07.glm; +import eu07.global_include.interfaces.imaterial; +import eu07.global_include.interfaces.itexture; +import eu07.model.material; +import eu07.model.texture; +import eu07.rendering.geometrybank; +import eu07.rendering.opengl33renderer; +import eu07.utilities.classes; +import eu07.utilities.globals; +import eu07.rendering.renderer; +import eu07.rendering.opengllight; +import eu07.rendering.openglcamera; +import eu07.rendering.openglparticles; +import eu07.rendering.openglskydome; +import eu07.rendering.openglprecipitation; +import eu07.rendering.lightarray; +import eu07.simcore; +import eu07.simulation.simulationenvironment; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,20 +42,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/renderer.h" -#include "rendering/opengllight.h" -#include "rendering/openglcamera.h" -#include "rendering/openglparticles.h" -#include "rendering/openglskydome.h" -#include "rendering/openglprecipitation.h" -#include "rendering/lightarray.h" -#include "scene/scene.h" -#include "simulation/simulationenvironment.h" -#include "world/MemCell.h" -#define EU07_USE_PICKING_FRAMEBUFFER //#define EU07_USE_DEBUG_SHADOWMAP //#define EU07_USE_DEBUG_CABSHADOWMAP //#define EU07_USE_DEBUG_CAMERA @@ -391,3 +414,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/openglrenderer_macros.h b/rendering/openglrenderer_macros.h new file mode 100644 index 00000000..211dd1f4 --- /dev/null +++ b/rendering/openglrenderer_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define EU07_USE_PICKING_FRAMEBUFFER diff --git a/rendering/openglskydome.cpp b/rendering/openglskydome.cpp index 58951f17..41dd7454 100644 --- a/rendering/openglskydome.cpp +++ b/rendering/openglskydome.cpp @@ -1,3 +1,9 @@ +module; +#include "glad/glad.h" + +module eu07.rendering.openglskydome; +import eu07.glm; +import eu07.simulation.simulationenvironment; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,10 +13,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/openglskydome.h" -#include "simulation/simulationenvironment.h" opengl_skydome::~opengl_skydome() { diff --git a/rendering/openglskydome.h b/rendering/openglskydome.cppm similarity index 87% rename from rendering/openglskydome.h rename to rendering/openglskydome.cppm index 90d88f89..3b81fae8 100644 --- a/rendering/openglskydome.h +++ b/rendering/openglskydome.cppm @@ -6,8 +6,14 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include "glad/glad.h" + +export module eu07.rendering.openglskydome; + +export { -#pragma once class opengl_skydome { @@ -29,3 +35,5 @@ private: GLuint m_vertexbuffer{ (GLuint)-1 }; // id of the buffer holding vertex data on the opengl end GLuint m_coloursbuffer{ (GLuint)-1 }; // id of the buffer holding colour data on the opengl end }; + +} // export diff --git a/rendering/particles.cpp b/rendering/particles.cpp index eb02bf41..7eb38311 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -1,3 +1,20 @@ +module; +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.rendering.particles; +import eu07.glm; +import eu07.simcore; +import eu07.utilities.utilities; +import eu07.utilities.timer; +import eu07.utilities.globals; +import eu07.simulation.simulationenvironment; +import eu07.utilities.logs; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +24,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/particles.h" -#include "utilities/Timer.h" -#include "utilities/Globals.h" -#include "model/AnimModel.h" -#include "simulation/simulationenvironment.h" -#include "utilities/Logs.h" void diff --git a/rendering/particles.h b/rendering/particles.cppm similarity index 96% rename from rendering/particles.h rename to rendering/particles.cppm index 5ee44230..ec7e99cb 100644 --- a/rendering/particles.h +++ b/rendering/particles.cppm @@ -1,4 +1,19 @@ -/* +module; +#include +#include +#include +#include +#include + +export module eu07.rendering.particles; +import eu07.glm; +import eu07.audio.sound; +import eu07.utilities.parser; +import eu07.utilities.classes; +import eu07.simcore; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,10 +22,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "utilities/Classes.h" -#include "scene/scene.h" // particle specialized for drawing smoke // given smoke features we can take certain shortcuts @@ -163,9 +175,6 @@ private: // holds all particle emitters defined in the scene and updates their state class particle_manager { - - friend opengl_renderer; - public: // types using source_sequence = std::vector; @@ -241,3 +250,5 @@ fixedstep_modifier::deserialize( cParser &Input ) { lookup->second = Input.getToken( true, "\n\r\t ,;[]" ); } } + +} // export diff --git a/rendering/precipitation.cpp b/rendering/precipitation.cpp index 3f9ecaec..6d959103 100644 --- a/rendering/precipitation.cpp +++ b/rendering/precipitation.cpp @@ -1,3 +1,14 @@ +module; +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.rendering.precipitation; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.utilities.timer; +import eu07.simulation.simulation; +import eu07.vehicle.train; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,13 +18,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/precipitation.h" -#include "utilities/Globals.h" -#include "utilities/Timer.h" -#include "simulation/simulation.h" -#include "vehicle/Train.h" basic_precipitation::~basic_precipitation() { // TODO: release allocated resources diff --git a/rendering/precipitation.h b/rendering/precipitation.cppm similarity index 90% rename from rendering/precipitation.h rename to rendering/precipitation.cppm index 2926fd1b..203b1cad 100644 --- a/rendering/precipitation.h +++ b/rendering/precipitation.cppm @@ -7,10 +7,16 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once + // based on "Rendering Falling Rain and Snow" // by Niniane Wang, Bretton Wade +module; + +export module eu07.rendering.precipitation; +import eu07.glm; + +export { class basic_precipitation { @@ -40,3 +46,5 @@ private: int m_activecab{ 0 }; glm::dvec3 m_cabcameramove{ 0.0 }; }; + +} // export diff --git a/rendering/renderer.cpp b/rendering/renderer.cpp index 610473a3..4335a77b 100644 --- a/rendering/renderer.cpp +++ b/rendering/renderer.cpp @@ -1,4 +1,10 @@ -/* +module; +#include +#include + +module eu07.rendering.renderer; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +13,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "rendering/renderer.h" -#include "utilities/Logs.h" std::unique_ptr GfxRenderer; diff --git a/rendering/renderer.h b/rendering/renderer.cppm similarity index 90% rename from rendering/renderer.h rename to rendering/renderer.cppm index f7b6d762..68145c42 100644 --- a/rendering/renderer.h +++ b/rendering/renderer.cppm @@ -1,4 +1,26 @@ -/* +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include + +export module eu07.rendering.renderer; +import eu07.gl.shader; +import eu07.glm; +import eu07.simcore; +import eu07.rendering.geometrybank; +import eu07.utilities.classes; +import eu07.utilities.globals; +import eu07.global_include.interfaces.imaterial; +import eu07.global_include.interfaces.itexture; +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,18 +29,11 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "rendering/geometrybank.h" -#include "interfaces/IMaterial.h" -#include "interfaces/ITexture.h" -#include "utilities/Globals.h" -struct lighting_data; namespace gl { -class program; } class gfx_renderer { @@ -121,3 +136,5 @@ class imgui_renderer extern std::unique_ptr GfxRenderer; //--------------------------------------------------------------------------- + +} // export diff --git a/rendering/screenshot.cpp b/rendering/screenshot.cpp index 285679b7..4e6d139d 100644 --- a/rendering/screenshot.cpp +++ b/rendering/screenshot.cpp @@ -1,8 +1,19 @@ -#include "stdafx.h" -#include "rendering/screenshot.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" +module; +#include "utilities/Globals_macros.h" #include +#include "glad/glad.h" +#include +#include +#ifdef _WIN32 +#include +#endif + +module eu07.rendering.screenshot; +import eu07.utilities.globals; +import eu07.utilities.logs; + +#ifdef _WIN32 +#endif void screenshot_manager::screenshot_save_thread( char *img, int w, int h ) { diff --git a/rendering/screenshot.h b/rendering/screenshot.cppm similarity index 64% rename from rendering/screenshot.h rename to rendering/screenshot.cppm index 47226e29..36aad3e3 100644 --- a/rendering/screenshot.h +++ b/rendering/screenshot.cppm @@ -1,3 +1,8 @@ +module; + +export module eu07.rendering.screenshot; + +export { class screenshot_manager { static void screenshot_save_thread(char *img , int w, int h); @@ -5,3 +10,5 @@ class screenshot_manager public: static void make_screenshot(); }; + +} // export diff --git a/resource.h b/resource.cppm similarity index 87% rename from resource.h rename to resource.cppm index d8e43de2..c696959f 100644 --- a/resource.h +++ b/resource.cppm @@ -6,6 +6,11 @@ // Next default values for new objects // +module; + +export module eu07.resource; + +export { #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 @@ -14,3 +19,5 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif + +} // export diff --git a/scene/scene.cpp b/scene/scene.cpp index 14825705..7531a3a5 100644 --- a/scene/scene.cpp +++ b/scene/scene.cpp @@ -1,4 +1,35 @@ -/* +module; +#include "utilities/utilities_macros.h" +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" + +module eu07.simcore; +import eu07.simulation.simulation; +import eu07.rendering.renderer; +import :mover; +import eu07.utilities.globals; +import eu07.glm; +import eu07.utilities.timer; +import eu07.scene.sn_utils; +import eu07.widgets.map_objects; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,20 +38,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scene/scene.h" -#include "simulation/simulation.h" -#include "utilities/Globals.h" -#include "vehicle/Camera.h" -#include "model/AnimModel.h" -#include "world/Event.h" -#include "world/EvLaunch.h" -#include "utilities/Timer.h" -#include "utilities/Logs.h" -#include "scene/sn_utils.h" -#include "rendering/renderer.h" -#include "widgets/map_objects.h" namespace scene { diff --git a/scene/scene.h b/scene/scene.cppm similarity index 97% rename from scene/scene.h rename to scene/scene.cppm index 9f5201f8..34c32e6e 100644 --- a/scene/scene.h +++ b/scene/scene.cppm @@ -1,4 +1,26 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/utilities_macros.h" + +export module eu07.simcore:scene; +import :fwd; +import eu07.input.command; +import eu07.utilities.parser; +import :scenenode; +import :track; +import :traction; +import eu07.utilities.utilities; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,27 +29,9 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include "utilities/parser.h" -#include "rendering/geometrybank.h" -#include "scene/scenenode.h" -#include "world/Track.h" -#include "world/Traction.h" -#include "audio/sound.h" -#include "input/command.h" -#include "utilities/utilities.h" -class opengl_renderer; -class opengl33_renderer; namespace scene { @@ -77,10 +81,6 @@ struct scratch_data { // basic element of rudimentary partitioning scheme for the section. fixed size, no further subdivision // TBD, TODO: replace with quadtree scheme? class basic_cell { - - friend opengl_renderer; - friend opengl33_renderer; - public: // constructors basic_cell() = default; @@ -248,10 +248,6 @@ public: // basic scene partitioning structure, holds terrain geometry and collection of cells class basic_section { - - friend opengl_renderer; - friend opengl33_renderer; - public: // constructors basic_section() = default; @@ -364,10 +360,6 @@ public: // top-level of scene spatial structure, holds collection of sections class basic_region { - - friend opengl_renderer; - friend opengl33_renderer; - public: // constructors basic_region(); @@ -496,3 +488,5 @@ extern std::map Hierarchy; } // scene //--------------------------------------------------------------------------- + +} // export diff --git a/scene/sceneeditor.cpp b/scene/sceneeditor.cpp index 4516425d..283e13f8 100644 --- a/scene/sceneeditor.cpp +++ b/scene/sceneeditor.cpp @@ -1,3 +1,17 @@ +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.scene.sceneeditor; +import eu07.scene.scenenodegroups; +import eu07.utilities.utilities; +import eu07.simulation.simulation; +import eu07.simcore; +import eu07.utilities.globals; +import eu07.glm; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,17 +21,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scene/sceneeditor.h" -#include "scene/scenenodegroups.h" -#include "utilities/Globals.h" -#include "application/application.h" -#include "simulation/simulation.h" -#include "world/MemCell.h" -#include "vehicle/Camera.h" -#include "model/AnimModel.h" -#include "rendering/renderer.h" namespace scene { diff --git a/scene/sceneeditor.h b/scene/sceneeditor.cppm similarity index 93% rename from scene/sceneeditor.h rename to scene/sceneeditor.cppm index bcff58b6..8c77c665 100644 --- a/scene/sceneeditor.h +++ b/scene/sceneeditor.cppm @@ -6,10 +6,15 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include + +export module eu07.scene.sceneeditor; +import eu07.glm; +import eu07.simcore; +export { -#pragma once -#include "scene/scenenode.h" namespace scene { @@ -62,3 +67,5 @@ private: } // scene //--------------------------------------------------------------------------- + +} // export diff --git a/scene/scenenode.cpp b/scene/scenenode.cpp index 1ba822e1..b31daf4f 100644 --- a/scene/scenenode.cpp +++ b/scene/scenenode.cpp @@ -1,4 +1,24 @@ -/* +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" + +module eu07.simcore; +import eu07.rendering.renderer; +import :mover; +import eu07.utilities.utilities; +import eu07.utilities.parser; +import eu07.scene.sn_utils; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,14 +27,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scene/scenenode.h" -#include "model/Model3d.h" -#include "rendering/renderer.h" -#include "utilities/parser.h" -#include "utilities/Logs.h" -#include "scene/sn_utils.h" // stores content of the struct in provided output stream void diff --git a/scene/scenenode.h b/scene/scenenode.cppm similarity index 97% rename from scene/scenenode.h rename to scene/scenenode.cppm index ca727c2c..aeea1c24 100644 --- a/scene/scenenode.h +++ b/scene/scenenode.cppm @@ -1,4 +1,22 @@ -/* +module; +#include "global_include/interfaces/ITexture_macros.h" +#include +#include +#include +#include + +export module eu07.simcore:scenenode; +import eu07.glm; +import :fwd; +import :model3d; +import eu07.rendering.geometrybank; +import eu07.utilities.parser; +import eu07.utilities.classes; +import eu07.model.vertex; +import eu07.utilities.uuid; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,15 +25,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include "utilities/Classes.h" -#include "model/material.h" -#include "model/vertex.h" -#include "rendering/geometrybank.h" -#include "../utilities/uuid.hpp" struct lighting_data { @@ -446,3 +457,5 @@ basic_node::group() const { } // scene //--------------------------------------------------------------------------- + +} // export diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp index 20ac524b..ebd92b94 100644 --- a/scene/scenenodegroups.cpp +++ b/scene/scenenodegroups.cpp @@ -1,3 +1,21 @@ +module; +#include +#include "utilities/Globals_macros.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" + +module eu07.scene.scenenodegroups; +import eu07.simulation.simulation; +import eu07.utilities.globals; +import eu07.simcore; +import eu07.widgets.map_objects; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +25,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scene/scenenodegroups.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "model/AnimModel.h" -#include "widgets/map_objects.h" namespace scene { diff --git a/scene/scenenodegroups.h b/scene/scenenodegroups.cppm similarity index 88% rename from scene/scenenodegroups.h rename to scene/scenenodegroups.cppm index 350fa3d3..002bc014 100644 --- a/scene/scenenodegroups.h +++ b/scene/scenenodegroups.cppm @@ -6,11 +6,23 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" + +export module eu07.scene.scenenodegroups; +import eu07.utilities.classes; +import eu07.simcore; +import eu07.widgets.map_objects; + +export { -#pragma once -#include "scene/scenenode.h" -#include "widgets/map_objects.h" namespace scene { @@ -76,3 +88,5 @@ extern node_groups Groups; } // scene //--------------------------------------------------------------------------- + +} // export diff --git a/scene/sn_utils.cpp b/scene/sn_utils.cpp index 71e6549c..a617c3fc 100644 --- a/scene/sn_utils.cpp +++ b/scene/sn_utils.cpp @@ -1,9 +1,14 @@ +module; +#include +#include +#include + +module eu07.scene.sn_utils; +import eu07.glm; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scene/sn_utils.h" // sanity checks static_assert(std::numeric_limits::is_iec559, "IEEE754 required"); diff --git a/scene/sn_utils.h b/scene/sn_utils.cppm similarity index 93% rename from scene/sn_utils.h rename to scene/sn_utils.cppm index 54005c6c..9e6f50f8 100644 --- a/scene/sn_utils.h +++ b/scene/sn_utils.cppm @@ -1,8 +1,15 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - +module; #include +#include + +export module eu07.scene.sn_utils; +import eu07.glm; + +export { + class sn_utils { @@ -35,3 +42,5 @@ public: static void s_vec3(std::ostream&, glm::vec3 const &); static void s_vec4(std::ostream&, glm::vec4 const &); }; + +} // export diff --git a/scripting/PyInt.cpp b/scripting/PyInt.cpp index fbbd0b80..93c2afc1 100644 --- a/scripting/PyInt.cpp +++ b/scripting/PyInt.cpp @@ -1,3 +1,31 @@ +module; +#include +#include +#include "Python.h" +#include +#include +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include "scripting/PyInt_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/crashreporter_macros.h" +#include +#include + +module eu07.scripting.pyint; +import eu07.application.application; +import eu07.input.command; +import eu07.glm; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.dictionary; +import eu07.simulation.simulation; +import eu07.utilities.crashreporter; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,18 +35,11 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "scripting/PyInt.h" -#include "stdafx.h" -#include "application/application.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/dictionary.h" #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wwrite-strings" #endif -#include void render_task::run() { @@ -92,7 +113,7 @@ void render_task::run() for (size_t i = 0; i < datapair.second.size(); i++) { auto const &vec = datapair.second[i]; - WriteLog("passing " + glm::to_string(vec)); + WriteLog("passing (" + std::to_string(vec.x) + ", " + std::to_string(vec.y) + ")"); PyObject *tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, PyGetFloat(vec.x)); // steals ref diff --git a/scripting/PyInt.h b/scripting/PyInt.cppm similarity index 82% rename from scripting/PyInt.h rename to scripting/PyInt.cppm index 1f1511a0..479031af 100644 --- a/scripting/PyInt.h +++ b/scripting/PyInt.cppm @@ -6,9 +6,53 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#ifdef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif +#ifdef _XOPEN_SOURCE +#undef _XOPEN_SOURCE +#endif +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wregister" +#endif +#ifdef WITH_PYTHON +#ifdef _DEBUG +#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu +#include "Python.h" +#define _DEBUG +#else +#include "Python.h" +#endif +#else +// stubs for a build without Python; they must stay inside this branch, or they +// would clobber the real Python types +#define PyObject void +#define PyThreadState void +#endif +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +#include +#include "scripting/PyInt_macros.h" +#include "utilities/utilities_macros.h" +#include +#include +#include +#include +#include +#include + +export module eu07.scripting.pyint; +import eu07.global_include.interfaces.itexture; +import eu07.utilities.dictionary; +import eu07.utilities.classes; +import eu07.utilities.utilities; +import eu07.model.texture; + +export { -#ifndef PYINT_H -#define PYINT_H #ifdef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE @@ -27,33 +71,8 @@ http://mozilla.org/MPL/2.0/. #pragma GCC diagnostic ignored "-Wregister" #endif -#ifdef WITH_PYTHON -#ifdef _DEBUG -#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu -#include "Python.h" -#define _DEBUG -#else -#include "Python.h" -#endif -#else -#define PyObject void -#define PyThreadState void -#endif -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif -#ifdef _MSC_VER -#pragma warning(pop) -#endif -#include "utilities/Classes.h" -#include "utilities/utilities.h" -#include "model/Texture.h" -#include - -#define PyGetFloat(param) PyFloat_FromDouble(param) -#define PyGetBool(param) param ? Py_True : Py_False // python rendertarget struct python_rt @@ -154,4 +173,5 @@ class python_external_utils static std::vector PyObjectToStringArray(PyObject *pyList); }; -#endif + +} // export diff --git a/scripting/PyIntStub.cpp b/scripting/PyIntStub.cpp index 767228e4..cc3ee35d 100644 --- a/scripting/PyIntStub.cpp +++ b/scripting/PyIntStub.cpp @@ -1,3 +1,5 @@ +#include "scripting/PyInt_macros.h" +import eu07.scripting.pyint; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,8 +9,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scripting/PyInt.h" bool python_taskqueue::init() { diff --git a/scripting/PyInt_macros.h b/scripting/PyInt_macros.h new file mode 100644 index 00000000..9cc51a88 --- /dev/null +++ b/scripting/PyInt_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header that +// consumers pull into their global module fragment. The bodies expand at the use +// site, where the imported names are in scope, so this header includes nothing. + +#define PyGetFloat(param) PyFloat_FromDouble(param) +#define PyGetBool(param) param ? Py_True : Py_False diff --git a/scripting/ladderlogic.cpp b/scripting/ladderlogic.cpp index b86aba6f..86464853 100644 --- a/scripting/ladderlogic.cpp +++ b/scripting/ladderlogic.cpp @@ -1,4 +1,14 @@ -/* +module; +#include +#include "utilities/utilities_macros.h" +#include +#include + +module eu07.scripting.ladderlogic; +import eu07.utilities.parser; +import eu07.utilities.utilities; +import eu07.utilities.logs; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,12 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "scripting/ladderlogic.h" -#include "utilities/parser.h" -#include "utilities/utilities.h" -#include "utilities/Logs.h" namespace plc { diff --git a/scripting/ladderlogic.h b/scripting/ladderlogic.cppm similarity index 93% rename from scripting/ladderlogic.h rename to scripting/ladderlogic.cppm index 075e4b0d..75251c73 100644 --- a/scripting/ladderlogic.h +++ b/scripting/ladderlogic.cppm @@ -1,4 +1,16 @@ -/* +module; +#include +#include +#include +#include +#include + +export module eu07.scripting.ladderlogic; +import eu07.utilities.parser; +import eu07.utilities.classes; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,13 +19,12 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "utilities/Classes.h" namespace plc { -using element_handle = short; +// element_handle is declared and exported by eu07.utilities.classes; redeclaring it +// here would attach a second, conflicting alias to this module. // basic logic element. class basic_element { @@ -167,3 +178,5 @@ auto basic_controller::find_or_insert( std::string const &Name, basic_element::t } } // plc + +} // export diff --git a/scripting/lua.cpp b/scripting/lua.cpp index 58cdd41a..d9a86047 100644 --- a/scripting/lua.cpp +++ b/scripting/lua.cpp @@ -1,10 +1,13 @@ -#include "stdafx.h" -#include "scripting/lua.h" -#include "world/Event.h" -#include "utilities/Logs.h" -#include "world/MemCell.h" -#include "vehicle/Driver.h" -#include "simulation/simulation.h" +module; +#include +#include +#include + +module eu07.scripting.lua; +import eu07.utilities.utilities; +import eu07.simcore; +import eu07.utilities.logs; +import eu07.simulation.simulation; lua::lua() { diff --git a/scripting/lua.h b/scripting/lua.cppm similarity index 94% rename from scripting/lua.h rename to scripting/lua.cppm index 07d72926..8583b517 100644 --- a/scripting/lua.h +++ b/scripting/lua.cppm @@ -1,10 +1,12 @@ -#pragma once +module; #include -#include +#include + +export module eu07.scripting.lua; +import eu07.simcore; + +export { -class basic_event; -class TMemCell; -class TDynamicObject; struct memcell_values { const char *str; double num1; double num2; }; class lua @@ -47,3 +49,5 @@ public: static void push_memcell_values(lua_State *L, const TMemCell *mc); static memcell_values get_memcell_values(lua_State *L, int idx); }; + +} // export diff --git a/scripting/pythonscreenviewer.cpp b/scripting/pythonscreenviewer.cpp index fa15e9fa..d1b76d71 100644 --- a/scripting/pythonscreenviewer.cpp +++ b/scripting/pythonscreenviewer.cpp @@ -1,9 +1,23 @@ -#include "stdafx.h" -#include "scripting/pythonscreenviewer.h" -#include "application/application.h" -#include "gl/shader.h" -#include "gl/vao.h" -#include "utilities/Logs.h" +module; +#include "utilities/Globals_macros.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "glad/glad.h" + +module eu07.scripting.pythonscreenviewer; +import eu07.utilities.globals; +import eu07.gl.buffer; +import eu07.glm; +import eu07.application.application; +import eu07.gl.shader; +import eu07.gl.vao; +import eu07.utilities.logs; void texture_window_resize(GLFWwindow *win, int w, int h) { diff --git a/scripting/pythonscreenviewer.h b/scripting/pythonscreenviewer.cppm similarity index 76% rename from scripting/pythonscreenviewer.h rename to scripting/pythonscreenviewer.cppm index bd0634c3..7b7bc15b 100644 --- a/scripting/pythonscreenviewer.h +++ b/scripting/pythonscreenviewer.cppm @@ -1,7 +1,22 @@ -#include "rendering/renderer.h" -#include "scripting/PyInt.h" +module; +#include +#include +#include +#include +#include +#include "scripting/PyInt_macros.h" #include +export module eu07.scripting.pythonscreenviewer; +import eu07.glm; +import eu07.gl.shader; +import eu07.gl.ubo; +import eu07.gl.bindable; +import eu07.rendering.renderer; +import eu07.scripting.pyint; + +export { + class python_screen_viewer { struct window_state { @@ -43,3 +58,5 @@ public: void notify_cursor_pos(GLFWwindow *window, double x, double y); void notify_click(GLFWwindow *window, int button, int action); }; + +} // export diff --git a/simcore/simcore-fwd.cppm b/simcore/simcore-fwd.cppm new file mode 100644 index 00000000..32340f08 --- /dev/null +++ b/simcore/simcore-fwd.cppm @@ -0,0 +1,45 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +// Declarations shared by the simulation core partitions. +// +// These types point at each other -- a vehicle has a driver, a driver has a +// vehicle, a track carries events -- so they cannot live in separate modules: a +// forward declaration may not cross a module boundary. Inside one module it works +// as it always did, which is what this partition is for. It is the old +// utilities/Classes.h, except the declarations now attach to the same module as +// the definitions. + +export module eu07.simcore:fwd; + +export { + +class TDynamicObject; +class TController; +class TTrack; +class TTraction; +class TMoverParameters; +class TMemCell; +class TEventLauncher; +class TModel3d; +class TSubModel; +class TAnimModel; +class TAnimContainer; +class basic_event; +class editor_ui; + +namespace scene { +class basic_node; +class shape_node; +class basic_cell; +class basic_section; +class basic_region; +} + +} // export diff --git a/simcore/simcore.cppm b/simcore/simcore.cppm new file mode 100644 index 00000000..14df2653 --- /dev/null +++ b/simcore/simcore.cppm @@ -0,0 +1,36 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +// Primary interface unit for the simulation core. It only re-exports the +// partitions; every declaration still lives in the file it always lived in. +// These pieces reference each other in both directions, so C++20 modules require +// them to share a module -- see :fwd for why. + +export module eu07.simcore; + +export import :fwd; +export import :mover; +export import :model3d; +export import :animmodel; +export import :scenenode; +export import :scene; +export import :event; +export import :memcell; +export import :evlaunch; +export import :segment; +export import :trkfoll; +export import :track; +export import :traction; +export import :driver; +export import :aircoupler; +export import :button; +export import :tractionpower; +export import :dynobj; +export import :editoruipanels; +export import :editoruilayer; diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index a1493f63..1ec3d7d1 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -1,4 +1,26 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.simulation.simulation; +import eu07.utilities.logs; +import eu07.application.application; +import eu07.input.command; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationenvironment; +import eu07.simcore; +import eu07.rendering.lightarray; +import eu07.vehicle.train; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,27 +29,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationenvironment.h" -#include "utilities/Globals.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "world/Track.h" -#include "world/Traction.h" -#include "world/TractionPower.h" -#include "audio/sound.h" -#include "model/AnimModel.h" -#include "vehicle/DynObj.h" -#include "rendering/lightarray.h" -#include "rendering/particles.h" -#include "scene/scene.h" -#include "vehicle/Train.h" -#include "application/application.h" -#include "utilities/Logs.h" -#include "vehicle/Driver.h" namespace simulation { diff --git a/simulation/simulation.h b/simulation/simulation.cppm similarity index 85% rename from simulation/simulation.h rename to simulation/simulation.cppm index 09ea4d42..6e0e4834 100644 --- a/simulation/simulation.h +++ b/simulation/simulation.cppm @@ -1,4 +1,23 @@ -/* +module; +#include +#include +#include + +export module eu07.simulation.simulation; +import eu07.utilities.classes; +import eu07.glm; +import eu07.audio.sound; +import eu07.rendering.lightarray; +import eu07.rendering.particles; +import eu07.scripting.lua; +import eu07.simulation.simulationstateserializer; +import eu07.simcore; +import eu07.vehicle.train; +#ifdef WITH_LUA +#endif + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,16 +26,9 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "simulation/simulationstateserializer.h" -#include "utilities/Classes.h" -#include "world/Event.h" -#include "vehicle/Train.h" -#include "rendering/particles.h" #ifdef WITH_LUA -#include "scripting/lua.h" #endif namespace simulation { @@ -80,7 +92,6 @@ extern instance_table Instances; extern vehicle_table Vehicles; extern train_table Trains; extern light_array Lights; -extern sound_table Sounds; extern particle_manager Particles; #ifdef WITH_LUA extern lua Lua; @@ -92,8 +103,9 @@ extern TTrain *Train; extern uint16_t prev_train_id; extern bool is_ready; -struct deserializer_state; } // simulation //--------------------------------------------------------------------------- + +} // export diff --git a/simulation/simulationenvironment.cpp b/simulation/simulationenvironment.cpp index 9837e0e8..43a2937b 100644 --- a/simulation/simulationenvironment.cpp +++ b/simulation/simulationenvironment.cpp @@ -1,4 +1,20 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" + +module eu07.simulation.simulationenvironment; +import eu07.simcore; +import eu07.utilities.color; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.simulation.simulationsounds; +import eu07.utilities.timer; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,12 +23,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "simulation/simulationenvironment.h" -#include "simulation/simulationsounds.h" -#include "utilities/Globals.h" -#include "utilities/Timer.h" namespace simulation { diff --git a/simulation/simulationenvironment.h b/simulation/simulationenvironment.cppm similarity index 78% rename from simulation/simulationenvironment.h rename to simulation/simulationenvironment.cppm index f4114d53..15e0a4ac 100644 --- a/simulation/simulationenvironment.h +++ b/simulation/simulationenvironment.cppm @@ -1,4 +1,16 @@ -/* +module; + +export module eu07.simulation.simulationenvironment; +import eu07.audio.sound; +import eu07.environment.moon; +import eu07.environment.sky; +import eu07.environment.skydome; +import eu07.environment.stars; +import eu07.environment.sun; +import eu07.rendering.precipitation; +import eu07.glm; +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,25 +19,11 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "environment/sky.h" -#include "environment/sun.h" -#include "environment/moon.h" -#include "environment/stars.h" -#include "environment/skydome.h" -#include "rendering/precipitation.h" -#include "audio/sound.h" -class opengl_renderer; -class opengl33_renderer; // wrapper for environment elements -- sky, sun, stars, clouds etc class world_environment { - - friend opengl_renderer; - friend opengl33_renderer; - public: // methods void init(); @@ -80,13 +78,18 @@ private: // methods void update_wind(); // members +public: +// The renderers reach straight into these; they used to be friends, but a friend +// declaration would make this module the first declarer of classes defined in the +// renderer modules, which C++20 modules reject. Same treatment as in sky/stars. CSkyDome m_skydome; cStars m_stars; cSun m_sun; cMoon m_moon; - float m_lightintensity { 1.f }; TSky m_clouds; basic_precipitation m_precipitation; +private: + float m_lightintensity { 1.f }; sound_source m_rainsound { sound_placement::external, -1 }; basic_wind m_wind; }; @@ -98,3 +101,5 @@ extern world_environment Environment; } // simulation //--------------------------------------------------------------------------- + +} // export diff --git a/simulation/simulationsounds.cpp b/simulation/simulationsounds.cpp index fc11fc84..70349d7f 100644 --- a/simulation/simulationsounds.cpp +++ b/simulation/simulationsounds.cpp @@ -1,4 +1,7 @@ -/* +module; + +module eu07.simulation.simulationsounds; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,8 +10,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "simulation/simulationsounds.h" namespace simulation { diff --git a/simulation/simulationsounds.h b/simulation/simulationsounds.cppm similarity index 75% rename from simulation/simulationsounds.h rename to simulation/simulationsounds.cppm index b1ef7bbd..af18c1ba 100644 --- a/simulation/simulationsounds.h +++ b/simulation/simulationsounds.cppm @@ -1,4 +1,11 @@ -/* +module; +#include +#include + +export module eu07.simulation.simulationsounds; +import eu07.audio.sound; +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +14,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "audio/sound.h" namespace simulation { @@ -21,3 +26,5 @@ extern sound_table Sounds; } // simulation //--------------------------------------------------------------------------- + +} // export diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index ef7cd7db..67d8925c 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -1,4 +1,37 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" +#include "utilities/crashreporter_macros.h" + +module eu07.simulation.simulationstateserializer; +import eu07.utilities.utilities; +import eu07.utilities.classes; +import eu07.glm; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationsounds; +import eu07.simulation.simulationenvironment; +import eu07.scene.scenenodegroups; +import eu07.rendering.particles; +import eu07.simcore; +import eu07.rendering.lightarray; +import eu07.application.application; +import eu07.rendering.renderer; +import eu07.utilities.logs; +import eu07.editor.editorterrainstreamer; +import eu07.utilities.crashreporter; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,27 +40,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "simulation/simulationstateserializer.h" -#include "utilities/Globals.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationsounds.h" -#include "simulation/simulationenvironment.h" -#include "scene/scenenodegroups.h" -#include "rendering/particles.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "vehicle/Driver.h" -#include "vehicle/DynObj.h" -#include "model/AnimModel.h" -#include "rendering/lightarray.h" -#include "world/TractionPower.h" -#include "application/application.h" -#include "rendering/renderer.h" -#include "utilities/Logs.h" -#include "editor/editorTerrainStreamer.hpp" namespace simulation { diff --git a/simulation/simulationstateserializer.h b/simulation/simulationstateserializer.cppm similarity index 95% rename from simulation/simulationstateserializer.h rename to simulation/simulationstateserializer.cppm index a5d6f2dc..b20cd839 100644 --- a/simulation/simulationstateserializer.h +++ b/simulation/simulationstateserializer.cppm @@ -6,11 +6,20 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include + +export module eu07.simulation.simulationstateserializer; +import eu07.glm; +import eu07.audio.sound; +import eu07.utilities.parser; +import eu07.simcore; + +export { -#pragma once -#include "utilities/parser.h" -#include "scene/scene.h" namespace simulation { @@ -94,3 +103,5 @@ private: } // simulation //--------------------------------------------------------------------------- + +} // export diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp index 52886709..6d64d5d6 100644 --- a/simulation/simulationtime.cpp +++ b/simulation/simulationtime.cpp @@ -1,4 +1,16 @@ -/* +module; +#include +#include +#include "winheaders.h" +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.simulation.simulationtime; +import eu07.utilities.globals; +import eu07.utilities.utilities; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +19,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "simulation/simulationtime.h" -#include "utilities/Globals.h" -#include "utilities/utilities.h" namespace simulation { diff --git a/simulation/simulationtime.h b/simulation/simulationtime.cppm similarity index 96% rename from simulation/simulationtime.h rename to simulation/simulationtime.cppm index 49e1a012..1d33adc3 100644 --- a/simulation/simulationtime.h +++ b/simulation/simulationtime.cppm @@ -1,4 +1,11 @@ -/* +module; +#include +#include "winheaders.h" + +export module eu07.simulation.simulationtime; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,11 +14,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include "winheaders.h" // wrapper for scenario time class scenario_time { @@ -87,3 +91,5 @@ extern scenario_time Time; } // simulation //--------------------------------------------------------------------------- + +} // export diff --git a/stdafx.cpp b/stdafx.cpp deleted file mode 100644 index 948e1249..00000000 --- a/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// kernel.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/stdafx.h b/stdafx.h deleted file mode 100644 index f2b37719..00000000 --- a/stdafx.h +++ /dev/null @@ -1,134 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef STDAFX_H -#define STDAFX_H - -#ifdef __APPLE__ -#ifndef __unix__ -#define __unix__ 1 -#endif -#endif - -#define _USE_MATH_DEFINES -#define NOMINMAX -#include -#ifdef _MSC_VER -// memory debug functions -#define _CRTDBG_MAP_ALLOC -#include -#include -#endif -// operating system -#ifdef _WIN32 -#include "targetver.h" -#define NOMINMAX -#define WIN32_LEAN_AND_MEAN -#include -#include -#undef NOMINMAX -#endif -#ifdef __unix__ -#include -#endif -// stl -#define _USE_MATH_DEFINES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "glad/glad.h" - -#define GLFW_INCLUDE_NONE -#include - -#ifndef GLFW_TRUE -#define GLFW_FALSE 0 -#define GLFW_TRUE 1 -#define glfwGetKeyName(a, b) ("") -#define glfwFocusWindow(w) -#endif - -#if defined(__aarch64__) || defined(__arm64__) -#define GLM_FORCE_NEON -#else -#define GLM_FORCE_AVX2 -#endif -#define GLM_FORCE_SWIZZLE -#define GLM_ENABLE_EXPERIMENTAL -#define GLM_FORCE_CTOR_INIT -#ifdef _MSC_VER -#define GLM_FORCE_INLINE -#endif -#define GLM_FORCE_INTRINSICS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef PACKED_VEC3_DEFINED -#define PACKED_VEC3_DEFINED -// 12-byte vec3 that stays packed regardless of GLM_FORCE_DEFAULT_ALIGNED_GENTYPES. -// Use in structs that must match an exact binary layout (UBOs, vertex data, serialized formats). -using packed_vec3 = glm::vec<3, float, glm::packed_highp>; -#endif - - -#include "rendering/openglmatrixstack.h" -#define STRINGIZE_DETAIL(x) #x -#define STRINGIZE(x) STRINGIZE_DETAIL(x) -#define glDebug(x) if (GLAD_GL_GREMEDY_string_marker) glStringMarkerGREMEDY(0, __FILE__ ":" STRINGIZE(__LINE__) ": " x); - -#include "imgui/imgui.h" -#define ImVec2S(a, b) ImVec2(a * Global.ui_scale, b * Global.ui_scale) - -#include "utilities/crashreporter.h" - -#endif diff --git a/targetver.h b/targetver.h deleted file mode 100644 index a5a1d131..00000000 --- a/targetver.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include -#ifndef _WIN32_WINNT -//#define _WIN32_WINNT 0x0600 // _WIN32_WINNT_VISTA -#define _WIN32_WINNT 0x0601 // _WIN32_WINNT_WINXP -#endif - -#include diff --git a/utilities/Classes.h b/utilities/Classes.cppm similarity index 56% rename from utilities/Classes.h rename to utilities/Classes.cppm index f79cb851..038a5241 100644 --- a/utilities/Classes.h +++ b/utilities/Classes.cppm @@ -7,64 +7,30 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef ClassesH -#define ClassesH //--------------------------------------------------------------------------- // Ra: zestaw klas do robienia wskaźników, aby uporządkować nagłówki //--------------------------------------------------------------------------- -class opengl_renderer; -class opengl33_renderer; -class TTrack; // odcinek trajektorii -class basic_event; -class TTrain; // pojazd sterowany -class TDynamicObject; // pojazd w scenerii -struct material_data; -class TAnimModel; // opakowanie egzemplarz modelu -class TAnimContainer; // fragment opakowania egzemplarza modelu -class TModel3d; //siatka modelu wspólna dla egzemplarzy -class TSubModel; // fragment modelu (tu do wyświetlania terenu) -class TMemCell; // komórka pamięci -class cParser; -class sound_source; -class TEventLauncher; -class TTraction; // drut -class TTractionPowerSource; // zasilanie drutów -class TCamera; -class scenario_time; -class TMoverParameters; -class ui_layer; -class editor_ui; -class itemproperties_panel; -class event_manager; -class memory_table; -class powergridsource_table; -class instance_table; -class vehicle_table; -class train_table; -struct light_array; -class particle_manager; -struct dictionary_source; -class trainset_desc; -class scenery_desc; +module; +#include +#include + +export module eu07.utilities.classes; + +export { namespace plc { using element_handle = short; -class basic_controller; } namespace scene { -struct node_data; -class basic_node; using group_handle = std::size_t; } namespace Mtable { -class TTrainParameters; // rozkład jazdy class TMtableTime; // czas dla danego posterunku }; -class TController; // obiekt sterujący pociągiem (AI) enum class TCommandType { // binarne odpowiedniki komend w komórce pamięci @@ -91,4 +57,5 @@ struct invalid_scenery_exception : std::runtime_error { invalid_scenery_exception() : std::runtime_error("cannot load scenery") {} }; -#endif + +} // export diff --git a/utilities/Float3d.cpp b/utilities/Float3d.cpp index 29a63456..04944a52 100644 --- a/utilities/Float3d.cpp +++ b/utilities/Float3d.cpp @@ -1,3 +1,9 @@ +module; +#include +#include + +module eu07.utilities.float3d; +import eu07.scene.sn_utils; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,9 +13,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "utilities/Float3d.h" -#include "scene/sn_utils.h" //--------------------------------------------------------------------------- diff --git a/utilities/Float3d.cppm b/utilities/Float3d.cppm new file mode 100644 index 00000000..dd7c1092 --- /dev/null +++ b/utilities/Float3d.cppm @@ -0,0 +1,348 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +//--------------------------------------------------------------------------- +module; +#include +#include +#include + +export module eu07.utilities.float3d; +import eu07.glm; + +// Deklaracje klas +export class float3 { +public: + float x, y, z; + float3(void) : x(0), y(0), z(0) {}; + float3(float a, float b, float c) : x(a), y(b), z(c) {}; + float Length() const; + float LengthSquared() const; + + operator glm::vec3() const { + return glm::vec3(x, y, z); + } +}; + +export class float4 { +public: + float x, y, z, w; + float4() : x(0), y(0), z(0), w(1) {}; + float4(float a, float b, float c, float d) : x(a), y(b), z(c), w(d) {}; + float inline LengthSquared() const { + return x * x + y * y + z * z + w * w; + }; + float inline Length() const { + return sqrt(x * x + y * y + z * z + w * w); + }; +}; + +export struct float8 { + float3 Point; + float3 Normal; + float tu, tv; +}; + +export class float4x4 { +public: + float e[16]; + + void deserialize_float32(std::istream&); + void deserialize_float64(std::istream&); + void serialize_float32(std::ostream&); + float4x4(void) { + Identity(); + }; + float4x4(const float f[16]) { + for (int i = 0; i < 16; ++i) + e[i] = f[i]; + }; + float * operator()(int i) { + return &e[i << 2]; + } + const float * readArray(void) const { + return e; + } + void Identity() { + for (int i = 0; i < 16; ++i) + e[i] = 0; + e[0] = e[5] = e[10] = e[15] = 1.0f; + } + const float *operator[](int i) const { + return &e[i << 2]; + }; + void InitialRotate() { + float f; + for (int i = 0; i < 16; i += 4) { + e[i] = -e[i]; + f = e[i + 1]; + e[i + 1] = e[i + 2]; + e[i + 2] = f; + } + }; + float4x4 &Rotation(float const angle, float3 const &axis); + bool IdentityIs() { + for (int i = 0; i < 16; ++i) + if (e[i] != (i % 5 ? 0.0 : 1.0)) + return false; + return true; + } + void Quaternion(float4 *q); + float3 *TranslationGet() { + return (float3 *)(e + 12); + } +}; + +// Funkcje globalne - każda z osobnym export +export inline bool operator==(const float3 &v1, const float3 &v2); +export inline float3 &operator+=(float3 &v1, const float3 &v2); +export inline float3 operator-(const float3 &v); +export inline float3 operator-(const float3 &v1, const float3 &v2); +export inline float3 operator+(const float3 &v1, const float3 &v2); +export inline float3 operator*(float3 const &v, float const k); +export inline float3 operator/(float3 const &v, float const k); +export inline float3 SafeNormalize(const float3 &v); +export inline float3 CrossProduct(float3 const &v1, float3 const &v2); +export inline float DotProduct(float3 const &v1, float3 const &v2); +export inline float3 Interpolate(float3 const &First, float3 const &Second, float const Factor); +export inline float4 operator*(const float4 &q1, const float4 &q2); +export inline float4 operator-(const float4 &q); +export inline float4 operator-(const float4 &q1, const float4 &q2); +export inline float4 operator+(const float4 &v1, const float4 &v2); +export inline float4 operator/(const float4 &v, float const k); +export inline float4 Normalize(const float4 &v); +export inline float Dot(const float4 &q1, const float4 &q2); +export inline float4 &operator*=(float4 &v1, float const d); +export inline float4 Slerp(const float4 &q0, const float4 &q1, float t); +export inline float3 operator*(const float4x4 &m, const float3 &v); +inline glm::vec3 operator*(const float4x4 &m, const glm::vec3 &v); +export inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2); +export inline float Det2x2(float a, float b, float c, float d); +export inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3); +export inline float Det(const float4x4 &m); +export inline bool operator==(const float4x4& v1, const float4x4& v2); + +// Definicje funkcji składowych +inline float float3::Length() const { + return std::sqrt(LengthSquared()); +}; + +inline float float3::LengthSquared() const { + return x * x + y * y + z * z; +} + +inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis) { + auto const c = std::cos(Angle); + auto const s = std::sin(Angle); + auto const omc = 1.f - c; + auto const axis = SafeNormalize(Axis); + auto const xs = axis.x * s; + auto const ys = axis.y * s; + auto const zs = axis.z * s; + auto const xyomc = axis.x * axis.y * omc; + auto const xzomc = axis.x * axis.z * omc; + auto const yzomc = axis.y * axis.z * omc; + e[0] = axis.x * axis.x * omc + c; + e[1] = xyomc + zs; + e[2] = xzomc - ys; + e[3] = 0; + e[4] = xyomc - zs; + e[5] = axis.y * axis.y * omc + c; + e[6] = yzomc + xs; + e[7] = 0; + e[8] = xzomc + ys; + e[9] = yzomc - xs; + e[10] = axis.z * axis.z * omc + c; + e[11] = 0; + e[12] = 0; + e[13] = 0; + e[14] = 0; + e[15] = 1; + return *this; +}; + +// Definicje funkcji globalnych +export inline bool operator==(const float3 &v1, const float3 &v2) { + return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z; +} + +export inline float3 &operator+=(float3 &v1, const float3 &v2) { + v1.x += v2.x; + v1.y += v2.y; + v1.z += v2.z; + return v1; +} + +export inline float3 operator-(const float3 &v) { + return float3(-v.x, -v.y, -v.z); +} + +export inline float3 operator-(const float3 &v1, const float3 &v2) { + return float3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); +} + +export inline float3 operator+(const float3 &v1, const float3 &v2) { + return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); +} + +export inline float3 operator*(float3 const &v, float const k) { + return float3(v.x * k, v.y * k, v.z * k); +} + +export inline float3 operator/(float3 const &v, float const k) { + return float3(v.x / k, v.y / k, v.z / k); +} + +export inline float3 SafeNormalize(const float3 &v) { + auto const l = v.Length(); + float3 retVal; + if (l == 0) + retVal.x = retVal.y = retVal.z = 0; + else + retVal = v / l; + return retVal; +} + +export inline float3 CrossProduct(float3 const &v1, float3 const &v2) { + return float3(v1.y * v2.z - v1.z * v2.y, + v2.x * v1.z - v2.z * v1.x, + v1.x * v2.y - v1.y * v2.x); +} + +export inline float DotProduct(float3 const &v1, float3 const &v2) { + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; +} + +export inline float3 Interpolate(float3 const &First, float3 const &Second, float const Factor) { + return First * (1.0f - Factor) + Second * Factor; +} + +export inline float4 operator*(const float4 &q1, const float4 &q2) { + return float4(q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, + q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, + q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x, + q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z); +} + +export inline float4 operator-(const float4 &q) { + return float4(-q.x, -q.y, -q.z, q.w); +} + +export inline float4 operator-(const float4 &q1, const float4 &q2) { + return -q1 * q2; +} + +export inline float4 operator+(const float4 &v1, const float4 &v2) { + return float4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w); +} + +export inline float4 operator/(const float4 &v, float const k) { + return float4(v.x / k, v.y / k, v.z / k, v.w / k); +} + +export inline float4 Normalize(const float4 &v) { + auto const lengthsquared = v.LengthSquared(); + if (lengthsquared == 1.0) + return v; + if (lengthsquared == 0.0) + return float4(); + else + return v / std::sqrt(lengthsquared); +} + +export inline float Dot(const float4 &q1, const float4 &q2) { + return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; +} + +export inline float4 &operator*=(float4 &v1, float const d) { + v1.x *= d; + v1.y *= d; + v1.z *= d; + v1.w *= d; + return v1; +} + +export inline float4 Slerp(const float4 &q0, const float4 &q1, float t) { + float cosOmega = Dot(q0, q1); + float4 new_q1(q1); + if (cosOmega < 0.0f) { + new_q1.x = -new_q1.x; + new_q1.y = -new_q1.y; + new_q1.z = -new_q1.z; + new_q1.w = -new_q1.w; + cosOmega = -cosOmega; + } + float k0, k1; + if (cosOmega > 0.9999f) { + k0 = 1.0f - t; + k1 = t; + } + else { + auto const sinOmega = std::sqrt(1.0f - cosOmega * cosOmega); + auto const omega = std::atan2(sinOmega, cosOmega); + auto const oneOverSinOmega = 1.0f / sinOmega; + k0 = sin((1.0f - t) * omega) * oneOverSinOmega; + k1 = sin(t * omega) * oneOverSinOmega; + } + return float4(q0.x * k0 + new_q1.x * k1, + q0.y * k0 + new_q1.y * k1, + q0.z * k0 + new_q1.z * k1, + q0.w * k0 + new_q1.w * k1); +} + +export inline float3 operator*(const float4x4 &m, const float3 &v) { + return float3(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0], + v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1], + v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]); +} + +inline glm::vec3 operator*(const float4x4 &m, const glm::vec3 &v) { + return glm::vec3( + v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0], + v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1], + v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]); +} + +export inline bool operator==(const float4x4& v1, const float4x4& v2) { + for (size_t i = 0; i < 16; i++) { + if (v1.e[i] != v2.e[i]) + return false; + } + return true; +} + +export inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2) { + float4x4 retVal; + for (int x = 0; x < 4; ++x) + for (int y = 0; y < 4; ++y) { + retVal(x)[y] = 0; + for (int i = 0; i < 4; ++i) + retVal(x)[y] += m1[i][y] * m2[x][i]; + } + return retVal; +} + +export inline float Det2x2(float a, float b, float c, float d) { + return a * d - b * c; +} + +export inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) { + return +a1 * Det2x2(b2, b3, c2, c3) - b1 * Det2x2(a2, a3, c2, c3) + c1 * Det2x2(a2, a3, b2, b3); +} + +export inline float Det(const float4x4 &m) { + float a1 = m[0][0], a2 = m[1][0], a3 = m[2][0], a4 = m[3][0]; + float b1 = m[0][1], b2 = m[1][1], b3 = m[2][1], b4 = m[3][1]; + float c1 = m[0][2], c2 = m[1][2], c3 = m[2][2], c4 = m[3][2]; + float d1 = m[0][3], d2 = m[1][3], d3 = m[2][3], d4 = m[3][3]; + return +a1 * Det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) - + b1 * Det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) + + c1 * Det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) - + d1 * Det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); +} \ No newline at end of file diff --git a/utilities/Float3d.h b/utilities/Float3d.h deleted file mode 100644 index 1e5e9892..00000000 --- a/utilities/Float3d.h +++ /dev/null @@ -1,356 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include -//--------------------------------------------------------------------------- - -class float3 -{ // wapółrzędne wierchołka 3D o pojedynczej precyzji - public: - float x, y, z; - float3(void){}; - float3(float a, float b, float c) - { - x = a; - y = b; - z = c; - }; - float Length() const; - float LengthSquared() const; - - operator glm::vec3() const - { - return glm::vec3(x, y, z); - } -}; - -inline bool operator==(const float3 &v1, const float3 &v2) -{ - return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z; -}; -inline float3 &operator+=(float3 &v1, const float3 &v2) -{ - v1.x += v2.x; - v1.y += v2.y; - v1.z += v2.z; - return v1; -}; -inline float3 operator-(const float3 &v) -{ - return float3(-v.x, -v.y, -v.z); -}; -inline float3 operator-(const float3 &v1, const float3 &v2) -{ - return float3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); -}; -inline float3 operator+(const float3 &v1, const float3 &v2) -{ - return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); -}; -inline float float3::Length() const -{ - return std::sqrt(LengthSquared()); -}; -inline float float3::LengthSquared() const { - return x * x + y * y + z * z; -} -inline float3 operator*( float3 const &v, float const k ) { - return float3( v.x * k, v.y * k, v.z * k ); -}; -inline float3 operator/( float3 const &v, float const k ) -{ - return float3(v.x / k, v.y / k, v.z / k); -}; -inline float3 SafeNormalize(const float3 &v) -{ // bezpieczna normalizacja (wektor długości 1.0) - auto const l = v.Length(); - float3 retVal; - if (l == 0) - retVal.x = retVal.y = retVal.z = 0; - else - retVal = v / l; - return retVal; -}; -inline float3 CrossProduct( float3 const &v1, float3 const &v2 ) -{ - return float3(v1.y * v2.z - v1.z * v2.y, v2.x * v1.z - v2.z * v1.x, v1.x * v2.y - v1.y * v2.x); -} -inline float DotProduct( float3 const &v1, float3 const &v2 ) { - - return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; -} - -inline float3 Interpolate( float3 const &First, float3 const &Second, float const Factor ) { - - return First * (1.0f - Factor) + Second * Factor; -} - -class float4 -{ // kwaternion obrotu - public: - float x, y, z, w; - float4() - { - x = y = z = 0.f; - w = 1.f; - }; - float4(float a, float b, float c, float d) - { - x = a; - y = b; - z = c; - w = d; - }; - float inline LengthSquared() const - { - return x * x + y * y + z * z + w * w; - }; - float inline Length() const - { - return sqrt(x * x + y * y + z * z + w * w); - }; -}; -inline float4 operator*(const float4 &q1, const float4 &q2) -{ // mnożenie to prawie jak mnożenie macierzy - return float4(q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, - q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, - q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x, - q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z); -} -inline float4 operator-(const float4 &q) -{ // sprzężony; odwrotny tylko dla znormalizowanych! - return float4(-q.x, -q.y, -q.z, q.w); -}; -inline float4 operator-(const float4 &q1, const float4 &q2) -{ // z odejmowaniem nie ma lekko - return -q1 * q2; // inwersja tylko dla znormalizowanych! -}; -inline float4 operator+(const float4 &v1, const float4 &v2) -{ - return float4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w); -}; -inline float4 operator/(const float4 &v, float const k) -{ - return float4(v.x / k, v.y / k, v.z / k, v.w / k); -}; -inline float4 Normalize(const float4 &v) -{ // bezpieczna normalizacja (wektor długości 1.0) - auto const lengthsquared = v.LengthSquared(); - if (lengthsquared == 1.0) - return v; - if (lengthsquared == 0.0) - return float4(); // wektor zerowy, w=1 - else - return v / std::sqrt(lengthsquared); // pierwiastek liczony tylko jeśli trzeba wykonać dzielenia -}; -inline -float Dot(const float4 &q1, const float4 &q2) -{ // iloczyn skalarny - return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; -} -inline float4 &operator*=(float4 &v1, float const d) -{ // mnożenie przez skalar, jaki ma sens? - v1.x *= d; - v1.y *= d; - v1.z *= d; - v1.w *= d; - return v1; -}; -inline float4 Slerp(const float4 &q0, const float4 &q1, float t) -// void Slerp(QUATERNION *Out, const QUATERNION &q0, const QUATERNION &q1, float t) -{ // interpolacja sweryczna - float cosOmega = Dot(q0, q1); - float4 new_q1(q1); - if (cosOmega < 0.0f) - { // jeżeli są niezgodne kierunki, jeden z nich trzeba zanegować - new_q1.x = -new_q1.x; - new_q1.y = -new_q1.y; - new_q1.z = -new_q1.z; - new_q1.w = -new_q1.w; - cosOmega = -cosOmega; - } - float k0, k1; - if (cosOmega > 0.9999f) - { // jeśli jesteśmy z (t) na maksimum kosinusa, to tam prawie liniowo jest - k0 = 1.0f - t; - k1 = t; - } - else - { // a w ogólnym przypadku trzeba liczyć na trygonometrię - auto const sinOmega = std::sqrt(1.0f - cosOmega * cosOmega); // sinus z jedynki tryg. - auto const omega = std::atan2(sinOmega, cosOmega); // wyznaczenie kąta - auto const oneOverSinOmega = 1.0f / sinOmega; // odwrotność sinusa, bo sinus w mianowniku - k0 = sin((1.0f - t) * omega) * oneOverSinOmega; - k1 = sin(t * omega) * oneOverSinOmega; - } - return float4(q0.x * k0 + new_q1.x * k1, q0.y * k0 + new_q1.y * k1, q0.z * k0 + new_q1.z * k1, - q0.w * k0 + new_q1.w * k1); -} - -struct float8 -{ // wierchołek 3D z wektorem normalnym i mapowaniem, pojedyncza precyzja - public: - float3 Point; - float3 Normal; - float tu, tv; -}; - -class float4x4 -{ // macierz transformacji pojedynczej precyzji -public: - float e[16]; - - void deserialize_float32(std::istream&); - void deserialize_float64(std::istream&); - void serialize_float32(std::ostream&); - float4x4(void){}; - float4x4(const float f[16]) - { - for (int i = 0; i < 16; ++i) - e[i] = f[i]; - }; - float * operator()(int i) - { - return &e[i << 2]; - } - const float * readArray(void) const - { - return e; - } - void Identity() - { - for (int i = 0; i < 16; ++i) - e[i] = 0; - e[0] = e[5] = e[10] = e[15] = 1.0f; - } - const float *operator[](int i) const - { - return &e[i << 2]; - }; - void InitialRotate() - { // taka specjalna rotacja, nie ma co ciągać trygonometrii - float f; - for (int i = 0; i < 16; i += 4) - { - e[i] = -e[i]; // zmiana znaku X - f = e[i + 1]; - e[i + 1] = e[i + 2]; - e[i + 2] = f; // zamiana Y i Z - } - }; - inline float4x4 &Rotation(float const angle, float3 const &axis); - inline bool IdentityIs() - { // sprawdzenie jednostkowości - for (int i = 0; i < 16; ++i) - if (e[i] != (i % 5 ? 0.0 : 1.0)) // jedynki tylko na 0, 5, 10 i 15 - return false; - return true; - } - void Quaternion(float4 *q); - inline float3 *TranslationGet() - { - return (float3 *)(e + 12); - } -}; - -inline float3 operator*(const float4x4 &m, const float3 &v) -{ // mnożenie wektora przez macierz - return float3(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0], - v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1], - v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]); -} - -inline glm::vec3 operator*( const float4x4 &m, const glm::vec3 &v ) { // mnożenie wektora przez macierz - return glm::vec3( - v.x * m[ 0 ][ 0 ] + v.y * m[ 1 ][ 0 ] + v.z * m[ 2 ][ 0 ] + m[ 3 ][ 0 ], - v.x * m[ 0 ][ 1 ] + v.y * m[ 1 ][ 1 ] + v.z * m[ 2 ][ 1 ] + m[ 3 ][ 1 ], - v.x * m[ 0 ][ 2 ] + v.y * m[ 1 ][ 2 ] + v.z * m[ 2 ][ 2 ] + m[ 3 ][ 2 ] ); -} - -inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis) -{ - auto const c = std::cos(Angle); - auto const s = std::sin(Angle); - // One minus c (short name for legibility of formulai) - auto const omc = 1.f - c; - auto const axis = SafeNormalize(Axis); - auto const xs = axis.x * s; - auto const ys = axis.y * s; - auto const zs = axis.z * s; - auto const xyomc = axis.x * axis.y * omc; - auto const xzomc = axis.x * axis.z * omc; - auto const yzomc = axis.y * axis.z * omc; - e[0] = axis.x * axis.x * omc + c; - e[1] = xyomc + zs; - e[2] = xzomc - ys; - e[3] = 0; - e[4] = xyomc - zs; - e[5] = axis.y * axis.y * omc + c; - e[6] = yzomc + xs; - e[7] = 0; - e[8] = xzomc + ys; - e[9] = yzomc - xs; - e[10] = axis.z * axis.z * omc + c; - e[11] = 0; - e[12] = 0; - e[13] = 0; - e[14] = 0; - e[15] = 1; - return *this; -}; - -inline bool operator==(const float4x4& v1, const float4x4& v2) -{ - for (size_t i = 0; i < 16; i++) - { - if (v1.e[i] != v2.e[i]) - return false; - } - return true; -} - -inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2) -{ // iloczyn macierzy - float4x4 retVal; - for (int x = 0; x < 4; ++x) - for (int y = 0; y < 4; ++y) - { - retVal(x)[y] = 0; - for (int i = 0; i < 4; ++i) - retVal(x)[y] += m1[i][y] * m2[x][i]; - } - return retVal; -}; - -// From code in Graphics Gems; p. 766 -inline float Det2x2(float a, float b, float c, float d) -{ // obliczenie wyznacznika macierzy 2×2 - return a * d - b * c; -}; - -inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, - float c3) -{ // obliczenie wyznacznika macierzy 3×3 - return +a1 * Det2x2(b2, b3, c2, c3) - b1 * Det2x2(a2, a3, c2, c3) + c1 * Det2x2(a2, a3, b2, b3); -}; - -inline -float Det(const float4x4 &m) -{ // obliczenie wyznacznika macierzy 4×4 - float a1 = m[0][0], a2 = m[1][0], a3 = m[2][0], a4 = m[3][0]; - float b1 = m[0][1], b2 = m[1][1], b3 = m[2][1], b4 = m[3][1]; - float c1 = m[0][2], c2 = m[1][2], c3 = m[2][2], c4 = m[3][2]; - float d1 = m[0][3], d2 = m[1][3], d3 = m[2][3], d4 = m[3][3]; - return +a1 * Det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) - - b1 * Det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) + - c1 * Det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) - - d1 * Det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); -}; diff --git a/utilities/Globals.cpp b/utilities/Globals.cpp index 0ab064b4..aadce154 100644 --- a/utilities/Globals.cpp +++ b/utilities/Globals.cpp @@ -1,3 +1,21 @@ +module; +#include +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "scripting/PyInt_macros.h" + +module eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.simulation.simulationenvironment; +import eu07.simcore; +import eu07.utilities.logs; +import eu07.utilities.timer; +import eu07.gl.vao; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -11,17 +29,7 @@ http://mozilla.org/MPL/2.0/. Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others */ -#include "stdafx.h" -#include "utilities/Globals.h" -#include "simulation/simulation.h" -#include "simulation/simulationenvironment.h" -#include "vehicle/Driver.h" -#include "utilities/Logs.h" -#include "Console.h" -#include "scripting/PyInt.h" -#include "utilities/Timer.h" -#include "vao.h" void global_settings::LoadIniFile(std::string asFileName) { diff --git a/utilities/Globals.h b/utilities/Globals.cppm similarity index 95% rename from utilities/Globals.h rename to utilities/Globals.cppm index c4bd26f6..f7113fb2 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.cppm @@ -6,22 +6,38 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - -#include "utilities/Classes.h" -#include "vehicle/Camera.h" -#include "utilities/Float3d.h" -#include "rendering/light.h" -#include "utilities/utilities.h" -#include "utilities/motiontelemetry.h" +module; +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" #include +#include "glad/glad.h" +#include +#include + +export module eu07.utilities.globals; +import eu07.glm; +import eu07.utilities.motiontelemetry; +import eu07.utilities.parser; +import eu07.utilities.classes; +import eu07.vehicle.camera; +import eu07.utilities.float3d; +import eu07.rendering.light; +import eu07.utilities.utilities; +#ifdef WITH_UART +import eu07.utilities.uart; +#endif +#ifdef WITH_ZMQ +#endif + +export { + + #ifdef WITH_UART -#include "utilities/uart.h" #endif #ifdef WITH_ZMQ -#include "input/zmq_input.h" #endif struct global_settings { @@ -376,6 +392,9 @@ global_settings::export_as_text( std::ostream &Output, std::string const Key, Ty Output << Key << " " << Value << "\n"; } +} // export -- out-of-line member definitions and explicit +// specialisations are not namespace-scope declarations, so they cannot +// carry `export`; the class itself is exported and that is what counts. template <> void global_settings::export_as_text( std::ostream &Output, std::string const Key, std::string const &Value ) const; @@ -383,7 +402,9 @@ global_settings::export_as_text( std::ostream &Output, std::string const Key, st template <> void global_settings::export_as_text( std::ostream &Output, std::string const Key, bool const &Value ) const; +export { extern global_settings& GetGlobalSettings(); -#define Global (GetGlobalSettings()) + +} // export diff --git a/utilities/Globals_macros.h b/utilities/Globals_macros.h new file mode 100644 index 00000000..1e166003 --- /dev/null +++ b/utilities/Globals_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define Global (GetGlobalSettings()) diff --git a/utilities/Logs.cpp b/utilities/Logs.cpp index 554a77b9..2affc652 100644 --- a/utilities/Logs.cpp +++ b/utilities/Logs.cpp @@ -1,3 +1,15 @@ +module; +#include +#include "utilities/Globals_macros.h" +#include "winheaders.h" +#include "utilities/utilities_macros.h" +#include +#include +#include + +module eu07.utilities.logs; +import eu07.utilities.globals; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +19,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "utilities/Logs.h" -#include "utilities/Globals.h" -#include "winheaders.h" -#include "utilities/utilities.h" -#include "application/uilayer.h" -#include std::ofstream output; // standardowy "log.txt", można go wyłączyć std::ofstream errors; // lista błędów "errors.txt", zawsze działa diff --git a/utilities/Logs.h b/utilities/Logs.cppm similarity index 90% rename from utilities/Logs.h rename to utilities/Logs.cppm index 93276d65..c46f79eb 100644 --- a/utilities/Logs.h +++ b/utilities/Logs.cppm @@ -6,8 +6,14 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include + +export module eu07.utilities.logs; + +export { -#pragma once enum class logtype : unsigned int { @@ -33,3 +39,5 @@ void CommLog( const char *str ); void CommLog( const std::string &str ); extern std::deque log_scrollback; + +} // export diff --git a/utilities/Names.h b/utilities/Names.cppm similarity index 96% rename from utilities/Names.h rename to utilities/Names.cppm index 0533c696..6d7601e7 100644 --- a/utilities/Names.h +++ b/utilities/Names.cppm @@ -6,11 +6,17 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; #include #include +#include +#include + +export module eu07.utilities.names; + +export { + + template class basic_table { @@ -100,3 +106,5 @@ public: return m_items; } }; + +} // export diff --git a/utilities/Timer.cpp b/utilities/Timer.cpp index 5cc9f93a..0d5faca1 100644 --- a/utilities/Timer.cpp +++ b/utilities/Timer.cpp @@ -1,3 +1,10 @@ +module; +#include +#include "utilities/Globals_macros.h" +#include "winheaders.h" + +module eu07.utilities.timer; +import eu07.utilities.globals; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,10 +14,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "utilities/Timer.h" -#include "utilities/Globals.h" -#include "winheaders.h" namespace Timer { diff --git a/utilities/Timer.h b/utilities/Timer.cppm similarity index 95% rename from utilities/Timer.h rename to utilities/Timer.cppm index 0e47e14c..c5e99038 100644 --- a/utilities/Timer.h +++ b/utilities/Timer.cppm @@ -6,8 +6,13 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include + +export module eu07.utilities.timer; + +export { -#pragma once namespace Timer { @@ -71,3 +76,5 @@ extern subsystem_stopwatches subsystem; }; //--------------------------------------------------------------------------- + +} // export diff --git a/utilities/U8.cppm b/utilities/U8.cppm new file mode 100644 index 00000000..54d8a0fd --- /dev/null +++ b/utilities/U8.cppm @@ -0,0 +1,9 @@ +module; +#include "utilities/U8_macros.h" + +export module eu07.utilities.u8; + +export { + + +} // export diff --git a/utilities/U8.h b/utilities/U8.h deleted file mode 100644 index a0a94381..00000000 --- a/utilities/U8.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define U8(str) (const char *)u8##str \ No newline at end of file diff --git a/utilities/U8_macros.h b/utilities/U8_macros.h new file mode 100644 index 00000000..184f48b2 --- /dev/null +++ b/utilities/U8_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define U8(str) (const char *)u8##str \ No newline at end of file diff --git a/utilities/color.h b/utilities/color.cppm similarity index 96% rename from utilities/color.h rename to utilities/color.cppm index 76aecf16..35fe117d 100644 --- a/utilities/color.h +++ b/utilities/color.cppm @@ -1,4 +1,11 @@ -#pragma once +module; +#include +#include + +export module eu07.utilities.color; +import eu07.glm; + +export { namespace colors { @@ -126,3 +133,5 @@ HSVtoRGB( glm::vec3 const &HSV ) { } } // namespace colors + +} // export diff --git a/utilities/comparison.h b/utilities/comparison.cppm similarity index 96% rename from utilities/comparison.h rename to utilities/comparison.cppm index 84f797a5..0fdce4d3 100644 --- a/utilities/comparison.h +++ b/utilities/comparison.cppm @@ -1,4 +1,10 @@ -/* +module; +#include + +export module eu07.utilities.comparison; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,7 +13,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once enum class comparison_operator { equal, // == @@ -76,3 +81,5 @@ comparison_operator_from_string( std::string const Input ) { //--------------------------------------------------------------------------- + +} // export diff --git a/utilities/crashreporter.cpp b/utilities/crashreporter.cpp index e6f6efc4..469c5eb4 100644 --- a/utilities/crashreporter.cpp +++ b/utilities/crashreporter.cpp @@ -1,3 +1,4 @@ +module; #include #include #include @@ -8,6 +9,8 @@ #include #include "version_info.h" +module eu07.utilities.crashreporter; + #if defined __has_attribute # if __has_attribute (init_priority) # define INITPRIO_CLASS __attribute__ ((init_priority (5000))) diff --git a/utilities/crashreporter.h b/utilities/crashreporter.cppm similarity index 54% rename from utilities/crashreporter.h rename to utilities/crashreporter.cppm index f7e9461e..c295fd28 100644 --- a/utilities/crashreporter.h +++ b/utilities/crashreporter.cppm @@ -1,3 +1,12 @@ +module; +#include "utilities/crashreporter_macros.h" +#include + +export module eu07.utilities.crashreporter; + +export { + + #ifdef WITH_CRASHPAD void crashreport_add_info(const char *name, const std::string &value); const std::string& crashreport_get_provider(); @@ -6,10 +15,6 @@ bool crashreport_is_pending(); void crashreport_upload_reject(); void crashreport_upload_accept(); #else -#define crashreport_add_info(a,b) -#define crashreport_get_provider() (std::string("")) -#define crashreport_set_autoupload() -#define crashreport_is_pending() (false) -#define crashreport_upload_reject() -#define crashreport_upload_accept() #endif + +} // export diff --git a/utilities/crashreporter_macros.h b/utilities/crashreporter_macros.h new file mode 100644 index 00000000..2e419a69 --- /dev/null +++ b/utilities/crashreporter_macros.h @@ -0,0 +1,13 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define crashreport_add_info(a,b) +#define crashreport_get_provider() (std::string("")) +#define crashreport_set_autoupload() +#define crashreport_is_pending() (false) +#define crashreport_upload_reject() +#define crashreport_upload_accept() diff --git a/utilities/dictionary.cpp b/utilities/dictionary.cpp index 70739847..617a2b27 100644 --- a/utilities/dictionary.cpp +++ b/utilities/dictionary.cpp @@ -1,3 +1,13 @@ +module; +#include +#include +#include "vehicle/DynObj_macros.h" + +module eu07.utilities.dictionary; +import eu07.utilities.utilities; +import eu07.simulation.simulation; +import eu07.simcore; +import eu07.world.mtable; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,13 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "utilities/dictionary.h" -#include "simulation/simulation.h" -#include "vehicle/DynObj.h" -#include "vehicle/Driver.h" -#include "world/mtable.h" dictionary_source::dictionary_source( std::string const &Input ) { diff --git a/utilities/dictionary.h b/utilities/dictionary.cppm similarity index 91% rename from utilities/dictionary.h rename to utilities/dictionary.cppm index 1532b492..c8b817ae 100644 --- a/utilities/dictionary.h +++ b/utilities/dictionary.cppm @@ -7,10 +7,17 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once // collection of keyword-value pairs // NOTE: since our python dictionary operates on a few types, most of the class was hardcoded for simplicity +module; +#include +#include + +export module eu07.utilities.dictionary; +import eu07.glm; + +export { struct dictionary_source { // types template @@ -31,3 +38,5 @@ struct dictionary_source { inline void insert( std::string const &Key, std::string const Value ) { strings.emplace_back( Key, Value ); } inline void insert( std::string const &Key, std::vector const Value ) { vec2_lists.emplace_back( Key, Value ); } }; + +} // export diff --git a/utilities/glmHelpers.h b/utilities/glmHelpers.cppm similarity index 84% rename from utilities/glmHelpers.h rename to utilities/glmHelpers.cppm index b784f2d3..618bdbef 100644 --- a/utilities/glmHelpers.h +++ b/utilities/glmHelpers.cppm @@ -1,5 +1,10 @@ -#pragma once -#include +module; +#include + +export module eu07.utilities.glmhelpers; +import eu07.glm; + +export { inline glm::dmat4 BasisChange(glm::dvec3 u, glm::dvec3 v, glm::dvec3 n) { @@ -19,3 +24,5 @@ template inline glm::vec<3, T> RotateY(const glm::vec<3, T> &v, T a return glm::vec<3, T>(c * v.x + s * v.z, v.y, c * v.z - s * v.x); } + +} // export diff --git a/utilities/glm_module.cppm b/utilities/glm_module.cppm new file mode 100644 index 00000000..fc8c0fea --- /dev/null +++ b/utilities/glm_module.cppm @@ -0,0 +1,71 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +module; + +// Everything glm reaches for from the standard library and the intrinsics headers +// is included here, in the global module fragment. Their include guards then turn +// glm's own #includes into no-ops, so only glm's declarations land in the purview +// below -- otherwise the export block would try to export system functions that +// have internal linkage, which is ill-formed. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +export module eu07.glm; + +// glm is header-only. Including it inside the module purview attaches its +// declarations to this module, which is what lets them be exported. Every other +// module imports this one instead of including glm directly: GCC 16 rejects the +// merge when the same glm declarations arrive from several different modules +// ("conflicting imported declaration" on glm::detail::storage), so glm has to be +// compiled into exactly one module. +export { +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// gtx/string_cast is deliberately absent: it defines static label constants, +// and an export block may not export entities with internal linkage. The two +// call sites of glm::to_string include it in their own module fragment. +#include +} + +export { +// 12-byte vec3 that stays packed regardless of GLM_FORCE_DEFAULT_ALIGNED_GENTYPES. +// Use in structs that must match an exact binary layout (UBOs, vertex data, +// serialized formats). +using packed_vec3 = glm::vec<3, float, glm::packed_highp>; +} diff --git a/utilities/headtrack.cpp b/utilities/headtrack.cpp index caf62bee..e4555416 100644 --- a/utilities/headtrack.cpp +++ b/utilities/headtrack.cpp @@ -1,7 +1,11 @@ -#include "stdafx.h" -#include "utilities/headtrack.h" -#include "utilities/Globals.h" +module; +#include +#include "utilities/Globals_macros.h" +#include +module eu07.utilities.headtrack; +import eu07.utilities.globals; +import eu07.glm; headtrack::headtrack() { diff --git a/utilities/headtrack.h b/utilities/headtrack.cppm similarity index 71% rename from utilities/headtrack.h rename to utilities/headtrack.cppm index e22cbe79..28b15373 100644 --- a/utilities/headtrack.h +++ b/utilities/headtrack.cppm @@ -1,4 +1,8 @@ -#pragma once +module; + +export module eu07.utilities.headtrack; + +export { class headtrack { @@ -12,3 +16,5 @@ public: void update(); }; + +} // export diff --git a/utilities/motiontelemetry.cpp b/utilities/motiontelemetry.cpp index 473970d7..26ac3e64 100644 --- a/utilities/motiontelemetry.cpp +++ b/utilities/motiontelemetry.cpp @@ -1,23 +1,48 @@ -#include "stdafx.h" -#include "utilities/motiontelemetry.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "vehicle/Train.h" -#include "utilities/Timer.h" -#include "vehicle/Driver.h" -#include "simulation/simulation.h" - +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" #ifdef _WIN32 #include +#endif +#ifdef _WIN32 #include +#endif +#ifdef _WIN32 #else #include +#endif +#ifdef _WIN32 +#else #include +#endif +#ifdef _WIN32 +#else #include +#endif +#ifdef _WIN32 +#else #include +#endif +#ifdef _WIN32 +#else #include #endif +module eu07.utilities.motiontelemetry; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.vehicle.train; +import eu07.utilities.timer; +import eu07.simcore; +import eu07.simulation.simulation; + +#ifdef _WIN32 +#else +#endif + motiontelemetry::motiontelemetry() { conf = Global.motiontelemetry_conf; diff --git a/utilities/motiontelemetry.h b/utilities/motiontelemetry.cppm similarity index 84% rename from utilities/motiontelemetry.h rename to utilities/motiontelemetry.cppm index 1fb42ad9..dee376c7 100644 --- a/utilities/motiontelemetry.h +++ b/utilities/motiontelemetry.cppm @@ -1,8 +1,13 @@ -#pragma once - +module; #include #include +export module eu07.utilities.motiontelemetry; +import eu07.glm; + +export { + + class motiontelemetry { public: @@ -32,3 +37,5 @@ public: ~motiontelemetry(); void update(); }; + +} // export diff --git a/utilities/parser.cpp b/utilities/parser.cpp index 7209df01..55517579 100644 --- a/utilities/parser.cpp +++ b/utilities/parser.cpp @@ -1,3 +1,19 @@ +module; +#include "utilities/Globals_macros.h" +#include +#include +#include +#include +#include +#include +#include + +module eu07.utilities.parser; +import eu07.scene.scenenodegroups; +import eu07.utilities.globals; +import eu07.utilities.logs; +import eu07.utilities.utilities; +import eu07.simcore; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,11 +23,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "utilities/parser.h" -#include "utilities/Logs.h" -#include "scene/scenenodegroups.h" /* MaSzyna EU07 locomotive simulator parser diff --git a/utilities/parser.h b/utilities/parser.cppm similarity index 94% rename from utilities/parser.h rename to utilities/parser.cppm index 0cf51d8c..e68ff68c 100644 --- a/utilities/parser.h +++ b/utilities/parser.cppm @@ -7,16 +7,23 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once + +///////////////////////////////////////////////////////////////////////////////////////////////////// +// cParser -- generic class for parsing text data, either from file or provided string +module; #include #include #include #include #include +#include +#include -///////////////////////////////////////////////////////////////////////////////////////////////////// -// cParser -- generic class for parsing text data, either from file or provided string +export module eu07.utilities.parser; +import eu07.glm; + +export { class cParser //: public std::stringstream { @@ -129,6 +136,9 @@ class cParser //: public std::stringstream }; +} // export -- out-of-line member definitions and explicit +// specialisations are not namespace-scope declarations, so they cannot +// carry `export`; the class itself is exported and that is what counts. template <> glm::vec3 cParser::getToken( bool const ToLower, const char *Break ); @@ -158,3 +168,6 @@ cParser::operator>>( bool &Right ); template<> bool cParser::getToken( bool const ToLower, const char *Break ); +export { + +} // export diff --git a/utilities/translation.cpp b/utilities/translation.cpp index 0885ab7c..1f2c7c7c 100644 --- a/utilities/translation.cpp +++ b/utilities/translation.cpp @@ -1,3 +1,19 @@ +module; +#include +#include +#include +#include +#include "utilities/translation_macros.h" +#include "utilities/Globals_macros.h" +#include "McZapkie/MOVER_macros.h" +#include "utilities/crashreporter_macros.h" + +module eu07.utilities.translation; +import eu07.utilities.logs; +import eu07.utilities.globals; +import eu07.simcore; +import eu07.rendering.geometrybank; +import eu07.utilities.crashreporter; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -11,11 +27,6 @@ http://mozilla.org/MPL/2.0/. Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others */ -#include "stdafx.h" -#include "utilities/translation.h" -#include "utilities/Logs.h" -#include "utilities/Globals.h" -#include "MOVER.h" void locale::init() { diff --git a/utilities/translation.h b/utilities/translation.cppm similarity index 87% rename from utilities/translation.h rename to utilities/translation.cppm index 5a48f711..f349eef9 100644 --- a/utilities/translation.h +++ b/utilities/translation.cppm @@ -6,12 +6,17 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include "utilities/translation_macros.h" #include #include +export module eu07.utilities.translation; + +export { + + + class locale { public: void init(); @@ -31,8 +36,7 @@ private: extern locale Translations; -#define STR(x) Translations.lookup_s(x, false) -#define STR_C(x) Translations.lookup_c(x, true) -#define STRN(x) x //find . -name "*.cpp" | xargs xgettext --from-code="UTF-8" -k --keyword=STR --keyword=STR_C --keyword=STRN + +} // export diff --git a/utilities/translation_macros.h b/utilities/translation_macros.h new file mode 100644 index 00000000..fc5df764 --- /dev/null +++ b/utilities/translation_macros.h @@ -0,0 +1,10 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define STR(x) Translations.lookup_s(x, false) +#define STR_C(x) Translations.lookup_c(x, true) +#define STRN(x) x diff --git a/utilities/uart.cpp b/utilities/uart.cpp index cac7a198..97921e7a 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -1,15 +1,26 @@ -#include "stdafx.h" -#include "utilities/uart.h" - -#include "utilities/Globals.h" -#include "simulation/simulation.h" -#include "vehicle/Train.h" -#include "utilities/parser.h" -#include "utilities/Logs.h" -#include "utilities/utilities.h" -#include "simulation/simulationtime.h" -#include "application/application.h" +module; +#include +#include "winheaders.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +module eu07.utilities.uart; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.utilities.logs; +import eu07.gl.buffer; +import eu07.utilities.parser; +import eu07.utilities.utilities; +import eu07.simulation.simulationtime; const char* uart_baudrates_list[] = { "300", "1200", diff --git a/utilities/uart.h b/utilities/uart.cppm similarity index 95% rename from utilities/uart.h rename to utilities/uart.cppm index 1a0f344b..6fde2322 100644 --- a/utilities/uart.h +++ b/utilities/uart.cppm @@ -1,7 +1,13 @@ -#pragma once - +module; #include -#include "input/command.h" +#include +#include +#include + +export module eu07.utilities.uart; +import eu07.input.command; +export { + extern const char* uart_baudrates_list[]; extern const size_t uart_baudrates_list_num; @@ -111,3 +117,5 @@ private: }; extern uart_status UartStatus; + +} // export diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index 156d16cc..506814e2 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -1,4 +1,20 @@ -/* +module; +#include +#include +#include +#include +#include "utilities/utilities_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/U8_macros.h" +#include +#include +#include + +module eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.utilities.parser; +import eu07.utilities.u8; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -11,11 +27,9 @@ MaSzyna EU07 - SPKS Brakes. Copyright (C) 2007-2014 Maciej Cierniak */ -//#include "stdafx.h" // //#include //#include -#include //#ifndef WIN32 //#include //#endif @@ -24,10 +38,6 @@ Copyright (C) 2007-2014 Maciej Cierniak //#define stat _stat //#endif -#include "utilities/utilities.h" -#include "utilities/Globals.h" -#include "utilities/parser.h" -#include "utilities/U8.h" //#include "utilities/Logs.h" diff --git a/utilities/utilities.h b/utilities/utilities.cppm similarity index 97% rename from utilities/utilities.h rename to utilities/utilities.cppm index bc38b125..ab3a1145 100644 --- a/utilities/utilities.h +++ b/utilities/utilities.cppm @@ -7,13 +7,24 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "stdafx.h" -#include "utilities/parser.h" /*rozne takie duperele do operacji na stringach w paszczalu, pewnie w delfi sa lepsze*/ /*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/ +module; +#include "utilities/utilities_macros.h" +#include +#include +#include +#include +#include +#include + +export module eu07.utilities.utilities; +import eu07.glm; +import eu07.utilities.parser; + +export { template T sign(T x) { @@ -40,7 +51,6 @@ inline constexpr const char *sounds = "sounds/"; inline constexpr const char *data = "data/"; } -#define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a)) extern bool DebugModeFlag; extern bool FreeFlyModeFlag; @@ -360,7 +370,7 @@ template typename VecType_::value_type nearest_segment_point return c1 / c2; } -glm::dvec3 LoadPoint(class cParser &Input); +glm::dvec3 LoadPoint(cParser &Input); // extracts a group of tokens from provided data stream std::string deserialize_random_set(cParser &Input, char const *Break = "\n\r\t ;"); @@ -433,3 +443,5 @@ class condition_variable } // namespace threading //--------------------------------------------------------------------------- + +} // export diff --git a/utilities/utilities_macros.h b/utilities/utilities_macros.h new file mode 100644 index 00000000..2d2378d1 --- /dev/null +++ b/utilities/utilities_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a)) diff --git a/utilities/uuid.hpp b/utilities/uuid.cppm similarity index 96% rename from utilities/uuid.hpp rename to utilities/uuid.cppm index d94fd0cc..3a20bb70 100644 --- a/utilities/uuid.hpp +++ b/utilities/uuid.cppm @@ -1,4 +1,4 @@ -#pragma once +module; #include #include #include @@ -7,6 +7,10 @@ #include #include +export module eu07.utilities.uuid; + +export { + class UID { public: std::array bytes; @@ -66,4 +70,5 @@ public: bool operator!=(const UID &other) const noexcept { return !(*this == other); } -}; \ No newline at end of file +}; +} // export diff --git a/vehicle/AirCoupler.cpp b/vehicle/AirCoupler.cpp index 81253d60..8e503982 100644 --- a/vehicle/AirCoupler.cpp +++ b/vehicle/AirCoupler.cpp @@ -1,3 +1,8 @@ +module; +#include + +module eu07.simcore; +import eu07.utilities.parser; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,11 +12,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/AirCoupler.h" -#include "model/Model3d.h" -#include "utilities/parser.h" AirCoupler::AirCoupler() { diff --git a/vehicle/AirCoupler.h b/vehicle/AirCoupler.cppm similarity index 90% rename from vehicle/AirCoupler.h rename to vehicle/AirCoupler.cppm index 3f860e63..5cc2892c 100644 --- a/vehicle/AirCoupler.h +++ b/vehicle/AirCoupler.cppm @@ -6,10 +6,17 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include + +export module eu07.simcore:aircoupler; +import :fwd; +import eu07.utilities.parser; +import eu07.utilities.classes; + +export { -#pragma once -#include "utilities/Classes.h" class AirCoupler { @@ -78,3 +85,5 @@ public: }; }; + +} // export diff --git a/vehicle/Button.cpp b/vehicle/Button.cpp index d4d31877..0e039d06 100644 --- a/vehicle/Button.cpp +++ b/vehicle/Button.cpp @@ -1,3 +1,15 @@ +module; +#include +#include +#include +#include "vehicle/DynObj_macros.h" + +module eu07.simcore; +import eu07.utilities.parser; +import eu07.simulation.simulation; +import eu07.console; +import eu07.utilities.logs; +import eu07.rendering.renderer; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,14 +19,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/Button.h" -#include "utilities/parser.h" -#include "model/Model3d.h" -#include "vehicle/DynObj.h" -#include "Console.h" -#include "utilities/Logs.h" -#include "rendering/renderer.h" void TButton::Clear(int i) { diff --git a/vehicle/Button.h b/vehicle/Button.cppm similarity index 89% rename from vehicle/Button.h rename to vehicle/Button.cppm index e2eb38cb..382a4e95 100644 --- a/vehicle/Button.h +++ b/vehicle/Button.cppm @@ -7,12 +7,21 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "utilities/Classes.h" -#include "audio/sound.h" // animacja dwustanowa, włącza jeden z dwóch submodeli (jednego z nich może nie być) +module; +#include +#include + +export module eu07.simcore:button; +import :fwd; +import eu07.utilities.parser; +import eu07.glm; +import eu07.utilities.classes; +import eu07.audio.sound; + +export { class TButton { public: @@ -59,3 +68,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp index 3186030e..b5e18921 100644 --- a/vehicle/Camera.cpp +++ b/vehicle/Camera.cpp @@ -1,3 +1,19 @@ +module; +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" +#include "vehicle/DynObj_macros.h" +#include "McZapkie/MOVER_macros.h" + +module eu07.vehicle.camera; +import eu07.utilities.globals; +import eu07.utilities.utilities; +import eu07.utilities.glmhelpers; +import eu07.utilities.timer; +import eu07.simcore; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,17 +23,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/Camera.h" -#include "utilities/Globals.h" -#include "utilities/utilities.h" -#include "utilities/glmHelpers.h" -#include "Console.h" -#include "utilities/Timer.h" -#include "vehicle/Driver.h" -#include "vehicle/DynObj.h" -#include "MOVER.h" //--------------------------------------------------------------------------- diff --git a/vehicle/Camera.h b/vehicle/Camera.cppm similarity index 89% rename from vehicle/Camera.h rename to vehicle/Camera.cppm index 4b91caf2..16bddc1d 100644 --- a/vehicle/Camera.h +++ b/vehicle/Camera.cppm @@ -7,12 +7,17 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "input/command.h" -#include "vehicle/DynObj.h" //--------------------------------------------------------------------------- +module; +#include "vehicle/DynObj_macros.h" + +export module eu07.vehicle.camera; +import eu07.glm; +import eu07.input.command; +import eu07.simcore; +export { class TCamera { @@ -46,3 +51,5 @@ struct viewport_proj_config { glm::vec3 pc; // screen upper left corner glm::vec3 pe; // eye position }; + +} // export diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 43f2f924..b5cc29c7 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -1,3 +1,33 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.simcore; +import eu07.utilities.translation; +import eu07.simulation.simulation; +import eu07.world.station; +import :evlaunch; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.world.mtable; +import eu07.simulation.simulationtime; +using namespace Mtable; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,22 +42,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/Driver.h" -#include "utilities/Globals.h" -#include "utilities/translation.h" -#include "utilities/Logs.h" -#include "vehicle/Train.h" -#include "world/mtable.h" -#include "vehicle/DynObj.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "world/Track.h" -#include "world/station.h" -#include "input/keyboardinput.h" #define LOGVELOCITY 0 #define LOGORDERS 1 @@ -1865,7 +1880,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, // if (TrainParams) // asNextStop=TrainParams.NextStop(); // else - TrainParams = TTrainParameters("none"); // rozkład jazdy + TrainParams = Mtable::TTrainParameters("none"); // rozkład jazdy // OrderCommand=""; // OrderValue=0; OrdersClear(); @@ -4421,7 +4436,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N #if LOGSTOPS WriteLog("New timetable for " + pVehicle->asName + ": " + NewCommand); // informacja #endif - TrainParams = TTrainParameters(NewCommand); // rozkład jazdy + TrainParams = Mtable::TTrainParameters(NewCommand); // rozkład jazdy tsGuardSignal = sound_source { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // wywalenie kierownika m_lastexchangestop.clear(); if (NewCommand != "none") diff --git a/vehicle/Driver.h b/vehicle/Driver.cppm similarity index 94% rename from vehicle/Driver.h rename to vehicle/Driver.cppm index e7c4fac0..4ffc765d 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.cppm @@ -6,18 +6,30 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include +#include +#include +#include #include -#include "utilities/Classes.h" -#include "utilities/utilities.h" -#include "MOVER.h" -#include "audio/sound.h" -#include "vehicle/DynObj.h" -#include "world/mtable.h" -#include "utilities/translation.h" -#include "application/driverhints.h" +#include "utilities/utilities_macros.h" +#include "McZapkie/MOVER_macros.h" +#include "vehicle/DynObj_macros.h" +#include "utilities/translation_macros.h" + +export module eu07.simcore:driver; +import :fwd; +import :dynobj; +import eu07.glm; +import :mover; +import eu07.application.driverhints; +import eu07.audio.sound; +import eu07.utilities.classes; +import eu07.utilities.utilities; +import eu07.world.mtable; +export { + + auto const EU07_AI_ACCELERATION = 0.05; auto const EU07_AI_NOACCELERATION = -0.05; @@ -184,29 +196,24 @@ class TSpeedPos }; //---------------------------------------------------------------------------- -static const bool Aggressive = true; -static const bool Easyman = false; -static const bool AIdriver = true; -static const bool Humandriver = false; -static const int maxorders = 64; // ilość rozkazów w tabelce -static const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie +inline const bool Aggressive = true; +inline const bool Easyman = false; +inline const bool AIdriver = true; +inline const bool Humandriver = false; +inline const int maxorders = 64; // ilość rozkazów w tabelce +inline const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie extern bool WriteLogFlag; // logowanie parametrów fizycznych -static const int BrakeAccTableSize = 20; +inline const int BrakeAccTableSize = 20; -static const int gbh_NP = -2; //odciecie w hamulcu ogolnym -static const int gbh_RP = 0; //jazda w hamulcu ogolnym -static const int gbh_FS = -1; //napelnianie uderzeniowe w hamulcu ogolnym -static const int gbh_MIN = -2; //minimalna pozycja w hamulcu ogolnym -static const int gbh_MAX = 6; //maksymalna pozycja w hamulcu ogolnym +inline const int gbh_NP = -2; //odciecie w hamulcu ogolnym +inline const int gbh_RP = 0; //jazda w hamulcu ogolnym +inline const int gbh_FS = -1; //napelnianie uderzeniowe w hamulcu ogolnym +inline const int gbh_MIN = -2; //minimalna pozycja w hamulcu ogolnym +inline const int gbh_MAX = 6; //maksymalna pozycja w hamulcu ogolnym //---------------------------------------------------------------------------- class TController { // TBD: few authorized inspectors, or bunch of public getters? - friend class TTrain; - friend class drivingaid_panel; - friend class timetable_panel; - friend class scenario_panel; - friend class debug_panel; friend class whois_event; public: @@ -297,16 +304,11 @@ private: void DirectionForward( bool forward ); void ZeroDirection(); int OrderDirectionChange( int newdir, TMoverParameters *Vehicle ); - void sync_consist_reversers(); void Lights( int head, int rear ); std::string StopReasonText() const; - double BrakeAccFactor() const; // modifies brake distance for low target speeds, to ease braking rate in such situations float braking_distance_multiplier( float const Targetvelocity ) const; - inline - int DrivigFlags() const { - return iDrivigFlags; }; inline double DirectionalVel() const { return mvOccupied->Vel * sign( iDirection * mvOccupied->V ); } @@ -376,30 +378,16 @@ public: double fMedAmax = 0.8; //maximum decceleration when using ep/med brake private: bool Psyche = false; - int HelperState = 0; //stan pomocnika maszynisty - TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący - TMoverParameters *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT) TMoverParameters *mvOccupied = nullptr; // jakim pojazdem hamuje TMoverParameters *mvPantographUnit = nullptr; //pantograph equipped vehicle in the occupied/controlled set std::string VehicleName; std::array m_lighthints = { -1, -1 }; // suggested light patterns double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji) - double AccDesired = 0.0; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj) - double VelDesired = 0.0; // predkość, z jaką ma jechać, wynikająca z analizy tableki; <=VelSignal double fAccDesiredAv = 0.0; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby ograniczyć migotanie double VelforDriver = -1.0; // prędkość, używana przy zmianie kierunku (ograniczenie przy nieznajmości szlaku?) double VelSignal = 0.0; // ograniczenie prędkości z kompilacji znaków i sygnałów // normalnie na początku ma stać, no chyba że jedzie double VelLimit = -1.0; // predkość zadawana przez event jednokierunkowego ograniczenia prędkości // -1: brak ograniczenia prędkości - double VelSignalLast = -1.0; // prędkość zadana na ostatnim semaforze // ostatni semafor też bez ograniczenia - double VelSignalNext = 0.0; // prędkość zadana na następnym semaforze - double VelLimitLast = -1.0; // prędkość zadana przez ograniczenie // ostatnie ograniczenie bez ograniczenia - double VelRoad = -1.0; // aktualna prędkość drogowa (ze znaku W27) (PutValues albo komendą) // prędkość drogowa bez ograniczenia - double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist - double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora - double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia - std::pair VelLimitLastDist { 0.0, 0.0 }; // distance to velocity change point - double SwitchClearDist { 0.0 }; // distance to point after farthest detected switch int iDirection = 0; // kierunek jazdy względem sprzęgów pojazdu, w którym siedzi AI (1=przód,-1=tył) int iDirectionOrder = 0; //żadany kierunek jazdy (służy do zmiany kierunku) std::optional iDirectionBackup; // consist direction to be restored after coupling/uncoupling and similar direction-changing operations @@ -411,7 +399,6 @@ private: // bool Need_BrakeRelease = true; bool IsHeatingTemperatureOK{ true }; bool IsHeatingTemperatureTooLow{ false }; - bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post bool IsScheduledPassengerStopVisible{ false }; double fMinProximityDist = 30.0; // stawanie między 30 a 60 m przed przeszkodą // minimalna oległość do przeszkody, jaką należy zachować double fOverhead1 = 3000.0; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!) @@ -425,9 +412,6 @@ private: double WaitingTime = 0.0; // zliczany czas oczekiwania do samoistnego ruszenia double WaitingExpireTime = 31.0; // tyle ma czekać, zanim się ruszy // maksymlany czas oczekiwania do samoistnego ruszenia double IdleTime{}; // keeps track of time spent at a stop - double fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku) - float ExchangeTime{ 0.0 }; // time needed to finish current load exchange - double fShuntVelocity = 40.0; // prędkość manewrowania, zależy m.in. od składu int iDrivigFlags = // flagi bitowe ruchu moveStopPoint | // podjedź do W4 możliwie blisko moveStopHere | // nie podjeżdżaj do semafora, jeśli droga nie jest wolna @@ -435,16 +419,11 @@ private: double fDriverBraking = 0.0; // po pomnożeniu przez v^2 [km/h] daje ~drogę hamowania [m] double fDriverDist = 0.0; // dopuszczalna odległość podjechania do przeszkody double fVelMax = -1.0; // maksymalna prędkość składu (sprawdzany każdy pojazd) - double fBrakeDist = 0.0; // przybliżona droga hamowania double fBrakeReaction = 1.0; //opóźnienie zadziałania hamulca - czas w s / (km/h) double fNominalAccThreshold = 0.0; // nominalny próg opóźnienia dla zadziałania hamulca - double fAccThreshold = 0.0; // aktualny próg opóźnienia dla zadziałania hamulca - double AbsAccS = 0.0; // próg opóźnienia dla zadziałania hamulca // dla fBrake_aX: // indeks [0] - wartości odpowiednie dla aktualnej prędkości // a potem jest 20 wartości dla różnych prędkości zmieniających się co 5 % Vmax pojazdu obsadzonego - double fBrake_a0[ BrakeAccTableSize + 1 ] = { 0.0 }; // opóźnienia hamowania przy ustawieniu zaworu maszynisty w pozycji 1.0 - double fBrake_a1[ BrakeAccTableSize + 1 ] = { 0.0 }; // przyrost opóźnienia hamowania po przestawieniu zaworu maszynisty o 0,25 pozycji double BrakingInitialLevel{ 1.0 }; double BrakingLevelIncrease{ 0.25 }; double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI @@ -452,19 +431,13 @@ private: double BrakeChargingCooldown{}; // prevents the ai from trying to charge the train brake too frequently TBrakeSystem BrakeSystem = TBrakeSystem::Individual; //type of main brake bool ForcePNBrake = false; //is it necessary to use PN brake instead of EP brake - int DynamicBrakeTest = 0; //is it necessary to make brake test while driving - double DBT_VelocityBrake = 0; - double DBT_VelocityRelease = 0; - double DBT_VelocityFinish = 0; double DBT_BrakingTime = 0; double DBT_ReleasingTime = 0; double DBT_MidPointAcc = 0; int StaticBrakeTest = 0; //is it necessary to make brake test while standing double LastReactionTime = 0.0; - double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations TAction eAction{ TAction::actUnknown }; // aktualny stan - std::list< std::tuple > m_hints; // queued ai operations // orders // methods @@ -481,19 +454,16 @@ private: void JumpToFirstOrder(); void OrderPush( TOrders NewOrder ); void OrderNext( TOrders NewOrder ); - inline TOrders OrderCurrentGet() const; inline TOrders OrderNextGet() const; void OrderCheck(); void OrdersInit( double fVel ); void OrdersClear(); void OrdersDump( std::string const Neworder, bool const Verbose = true ); - std::string Order2Str( TOrders Order ) const; // members std::string m_assignment; glm::dvec3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego odnosi sie komenda // NOTE: not used TOrders OrderList[ maxorders ]; // lista rozkazów - int OrderPos = 0, - OrderTop = 0; // rozkaz aktualny oraz wolne miejsce do wstawiania nowych + int OrderTop = 0; // wolne miejsce do wstawiania nowych // scantable // methods @@ -513,7 +483,6 @@ private: bool TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, double const Signaldistance ); bool TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPos &Point, double &Signaldistance, int const Pointindex ); // returns most recently calculated distance to potential obstacle ahead - double TrackObstacle() const; void TablePurger(); void TableSort(); inline double MoveDistanceGet() const { @@ -522,7 +491,6 @@ private: inline void MoveDistanceReset() { dMoveLen = 0.0; } - std::size_t TableSize() const { return sSpeedTable.size(); } void TableClear(); int TableDirection() { return iTableDirection; } // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu @@ -531,7 +499,6 @@ private: TTrack *BackwardTraceRoute( double &fDistance, double &fDirection, TDynamicObject *Vehicle, basic_event *&Event, int const Eventdirection = 1, end const End = end::rear, bool const Untiloccupied = true ); void SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos ); TCommandType BackwardScan( double const Range ); - std::string TableText( std::size_t const Index ) const; /* void RouteSwitch(int d); */ @@ -545,8 +512,6 @@ private: std::size_t SemNextIndex{ std::size_t( -1 ) }; std::size_t SemNextStopIndex{ std::size_t( -1 ) }; double dMoveLen = 0.0; // odległość przejechana od ostatniego sprawdzenia tabelki - basic_event *eSignNext = nullptr; // sygnał zmieniający prędkość, do pokazania na [F2] - neighbour_data Obstacle; // nearest vehicle detected ahead on current route // timetable // methods @@ -554,22 +519,18 @@ public: const std::string &TrainName() const; Mtable::TTrainParameters const & TrainTimetable() const; private: - std::string Relation() const; int StationIndex() const; int StationCount() const; bool IsStop() const; - std::string NextStop() const; // tests whether the train is delayed and sets accordingly a driving flag void UpdateDelayFlag(); // members - Mtable::TTrainParameters TrainParams; // rozkład jazdy zawsze jest, nawet jeśli pusty std::string asNextStop; // nazwa następnego punktu zatrzymania wg rozkładu // int iStationStart = 0; // numer pierwszej stacji pokazywanej na podglądzie rozkładu std::string m_lastexchangestop; // HACK: safeguard to prevent multiple load exchanges per station int m_lastexchangeplatforms { 0 }; // cached station platforms for last exchange int m_lastexchangedirection { 0 }; // double fLastStopExpDist = -1.0; // odległość wygasania ostateniego przystanku - int iRadioChannel = 1; // numer aktualnego kanału radiowego int iGuardRadio = 0; // numer kanału radiowego kierownika (0, gdy nie używa radia) sound_source tsGuardSignal{ sound_placement::internal }; announcement_t m_lastannouncement{ announcement_t::idle }; @@ -589,30 +550,16 @@ private: void AutoRewident(); // ustawia hamulce w składzie void announce( announcement_t const Announcement ); // members - double fLength = 0.0; // długość składu (do wyciągania z ograniczeń) - double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji - double fAccGravity = 0.0; // przyspieszenie składowej stycznej grawitacji - int iVehicles = 0; // ilość pojazdów w składzie - int ControlledEnginesCount{ 0 }; // number of powered vehicles under driver's control - bool iEngineActive{ false }; // ABu: Czy silnik byl juz zalaczony - bool IsPassengerTrain{ false }; bool IsCargoTrain{ false }; bool IsHeavyCargoTrain{ false }; - double fReady = 0.0; // poziom odhamowania wagonów - bool Ready = false; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow bool IsConsistBraked { false }; double ConsistShade{ 1.0 }; // averaged amount of sunlight received by the consist TDynamicObject *pVehicles[ 2 ]; // skrajne pojazdy w składzie (niekoniecznie bezpośrednio sterowane) bool DoesAnyDoorNeedOpening{ false }; - bool IsAnyDoorOpen[ 2 ]; // state of door in the consist - bool IsAnyDoorOnlyOpen[ 2 ]; // state of door in the consist regardless of step - bool IsAnyDoorPermitActive[ 2 ]; // state of door permit in the consist bool IsAnyLineBreakerOpen{ false }; // state of line breaker in all powered vehicles under control - bool IsAnyConverterOverloadRelayOpen{ false }; // state of converter overload relays in all vehicles under control bool IsAnyMotorOverloadRelayOpen{ false }; // state of motor overload relays in all vehicles under control bool IsAnyGroundRelayOpen{ false }; bool IsAnyCompressorPresent { false }; - bool IsAnyCompressorEnabled{ false }; bool IsAnyCompressorExplicitlyEnabled{ false }; // only takes into account manually controlled devices bool IsAnyConverterPresent{ false }; bool IsAnyConverterEnabled{ false }; @@ -635,13 +582,81 @@ public: TDynamicObject *Vehicle( end const Side ) const { return pVehicles[ Side ]; } private: - std::string OwnerName() const; // leftovers /* int iRouteWanted = 3; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala migacz lub czeka na stan zwrotnicy */ +public: +// Formerly private, reached through friendship by TTrain and the ui panels. +// Those live in other modules, and a friend declaration would make TController +// the first declarer of a class defined elsewhere, which C++20 modules reject. +// The class TODO above ("few authorized inspectors, or bunch of public getters?") +// is still open; until it is answered these are plain public members. + void sync_consist_reversers(); + float ExchangeTime{ 0.0 }; // time needed to finish current load exchange + std::list< std::tuple > m_hints; // queued ai operations + double TrackObstacle() const; + double fShuntVelocity = 40.0; // prędkość manewrowania, zależy m.in. od składu + Mtable::TTrainParameters TrainParams; // rozkład jazdy zawsze jest, nawet jeśli pusty + TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący + double BrakeAccFactor() const; + int DrivigFlags() const { return iDrivigFlags; } + int HelperState = 0; //stan pomocnika maszynisty + TMoverParameters *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT) + double AccDesired = 0.0; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj) + double VelDesired = 0.0; // predkość, z jaką ma jechać, wynikająca z analizy tableki; <=VelSignal + double VelSignalLast = -1.0; // prędkość zadana na ostatnim semaforze // ostatni semafor też bez ograniczenia + double VelSignalNext = 0.0; // prędkość zadana na następnym semaforze + double VelLimitLast = -1.0; // prędkość zadana przez ograniczenie // ostatnie ograniczenie bez ograniczenia + double VelRoad = -1.0; // aktualna prędkość drogowa (ze znaku W27) (PutValues albo komendą) // prędkość drogowa bez ograniczenia + double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist + double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop + double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia + std::pair VelLimitLastDist { 0.0, 0.0 }; // distance to velocity change point + double SwitchClearDist { 0.0 }; // distance to point after farthest detected switch + bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post + double fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku) + double fBrakeDist = 0.0; // przybliżona droga hamowania + double fAccThreshold = 0.0; // aktualny próg opóźnienia dla zadziałania hamulca + double AbsAccS = 0.0; // próg opóźnienia dla zadziałania hamulca + double fBrake_a0[ BrakeAccTableSize + 1 ] = { 0.0 }; // opóźnienia hamowania przy ustawieniu zaworu maszynisty w pozycji 1.0 + double fBrake_a1[ BrakeAccTableSize + 1 ] = { 0.0 }; // przyrost opóźnienia hamowania po przestawieniu zaworu maszynisty o 0,25 pozycji + int DynamicBrakeTest = 0; //is it necessary to make brake test while driving + double DBT_VelocityBrake = 0; + double DBT_VelocityRelease = 0; + double DBT_VelocityFinish = 0; + double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi + inline TOrders OrderCurrentGet() const; + std::string Order2Str( TOrders Order ) const; + int OrderPos = 0; // rozkaz aktualny + std::size_t TableSize() const { return sSpeedTable.size(); } + std::string TableText( std::size_t const Index ) const; + basic_event *eSignNext = nullptr; // sygnał zmieniający prędkość, do pokazania na [F2] + neighbour_data Obstacle; // nearest vehicle detected ahead on current route + int iRadioChannel = 1; // numer aktualnego kanału radiowego + double fLength = 0.0; // długość składu (do wyciągania z ograniczeń) + double fAccGravity = 0.0; // przyspieszenie składowej stycznej grawitacji + double fReady = 0.0; // poziom odhamowania wagonów + bool Ready = false; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow + bool IsAnyDoorOpen[ 2 ]; // state of door in the consist + bool IsAnyDoorOnlyOpen[ 2 ]; // state of door in the consist regardless of step + bool IsAnyDoorPermitActive[ 2 ]; // state of door permit in the consist + bool IsAnyConverterOverloadRelayOpen{ false }; // state of converter overload relays in all vehicles under control + bool IsAnyCompressorEnabled{ false }; +public: +// Read by the ui panels, which are no longer friends: a friend declaration +// would make this module the first declarer of a class defined elsewhere, +// which C++20 modules reject. + std::string Relation() const; + std::string NextStop() const; + double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji + int iVehicles = 0; // ilość pojazdów w składzie + int ControlledEnginesCount{ 0 }; // number of powered vehicles under driver's control + bool iEngineActive{ false }; // ABu: Czy silnik byl juz zalaczony + bool IsPassengerTrain{ false }; + std::string OwnerName() const; }; inline TOrders TController::OrderCurrentGet() const { @@ -651,3 +666,5 @@ inline TOrders TController::OrderCurrentGet() const { inline TOrders TController::OrderNextGet() const { return OrderList[ OrderPos + 1 ]; } + +} // export diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index 184d432a..79440677 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -1,4 +1,29 @@ -/* +module; +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "vehicle/DynObj_macros.h" +#include "utilities/Globals_macros.h" + +module eu07.simcore; +import eu07.input.messaging; +import eu07.rendering.renderer; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.model.mdlmngr; +import eu07.glm; +import eu07.rendering.lightarray; +import eu07.vehicle.camera; +import eu07.vehicle.train; +import eu07.utilities.timer; +import eu07.utilities.glmhelpers; +import eu07.application.uitranscripts; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -12,27 +37,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/DynObj.h" -#include "simulation/simulation.h" -#include "rendering/lightarray.h" -#include "vehicle/Camera.h" -#include "vehicle/Train.h" -#include "vehicle/Driver.h" -#include "utilities/Globals.h" -#include "utilities/Timer.h" -#include "utilities/Logs.h" -#include "utilities/glmHelpers.h" -#include "Console.h" -#include "world/Traction.h" -#include "audio/sound.h" -#include "model/MdlMngr.h" -#include "model/Model3d.h" -#include "rendering/renderer.h" -#include "application/uitranscripts.h" -#include "input/messaging.h" -#include "vehicle/Driver.h" // Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny #define vWorldFront glm::vec3(0, 0, 1) diff --git a/vehicle/DynObj.h b/vehicle/DynObj.cppm similarity index 98% rename from vehicle/DynObj.h rename to vehicle/DynObj.cppm index f8f2ce78..066f992e 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.cppm @@ -7,28 +7,41 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once + + + + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +module; +#include +#include +#include "vehicle/DynObj_macros.h" #include #include - -#include "utilities/Classes.h" -#include "interfaces/IMaterial.h" -#include "MOVER.h" -#include "world/TrkFoll.h" -#include "vehicle/Button.h" -#include "vehicle/AirCoupler.h" -#include "interfaces/ITexture.h" -#include "audio/sound.h" -#include "world/Spring.h" - +#include "McZapkie/MOVER_macros.h" +#include "global_include/interfaces/ITexture_macros.h" #include +#include -#define EU07_SOUND_BOGIESOUNDS +export module eu07.simcore:dynobj; +import :fwd; +import :aircoupler; +import :button; +import :trkfoll; +import :mover; +import eu07.audio.sound; +import eu07.utilities.parser; +import :traction; +import eu07.glm; +import eu07.utilities.classes; +import eu07.global_include.interfaces.imaterial; +import eu07.global_include.interfaces.itexture; +import eu07.world.spring; -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- +export { int const ANIM_WHEELS = 0; // koła int const ANIM_DOORS = 1; // drzwi int const ANIM_LEVERS = 2; // elementy obracane (wycieraczki, koła skrętne, przestawiacze, klocki ham.) @@ -187,10 +200,6 @@ struct material_data { }; class TDynamicObject { // klasa pojazdu - - friend opengl_renderer; - friend opengl33_renderer; - public: static bool bDynamicRemove; // moved from ground @@ -883,6 +892,8 @@ private: }; +} // export -- out-of-line member definitions are not namespace-scope +// declarations, so they cannot carry `export`; the class itself is exported. template auto TDynamicObject::find_vehicle( coupling const Coupling, Predicate_ const Predicate ) -> TDynamicObject * { @@ -917,5 +928,8 @@ TDynamicObject::for_each( coupling const Coupling, UnaryFunction_ const Function while( ( vehicle = vehicle->Prev( Coupling ) ) != nullptr ) { Function( vehicle ); } } +export { //--------------------------------------------------------------------------- + +} // export diff --git a/vehicle/DynObj_macros.h b/vehicle/DynObj_macros.h new file mode 100644 index 00000000..f6c135a6 --- /dev/null +++ b/vehicle/DynObj_macros.h @@ -0,0 +1,8 @@ +#pragma once + +// Macros cannot cross a module boundary, so they live in a plain header +// that consumers pull into their global module fragment. The bodies are +// expanded at the use site, where the imported names are in scope, so this +// header deliberately includes nothing. + +#define EU07_SOUND_BOGIESOUNDS diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index a510b05f..7a07d51d 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -1,3 +1,23 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vehicle/DynObj_macros.h" + +module eu07.vehicle.gauge; +import eu07.utilities.float3d; +import eu07.widgets.map_objects; +import eu07.utilities.parser; +import eu07.simcore; +import eu07.utilities.timer; +import eu07.utilities.logs; +import eu07.rendering.renderer; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,14 +33,6 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/Gauge.h" -#include "utilities/parser.h" -#include "model/Model3d.h" -#include "vehicle/DynObj.h" -#include "utilities/Timer.h" -#include "utilities/Logs.h" -#include "rendering/renderer.h" TGauge::TGauge( sound_source const &Soundtemplate ) : m_soundtemplate( Soundtemplate ) diff --git a/vehicle/Gauge.h b/vehicle/Gauge.cppm similarity index 95% rename from vehicle/Gauge.h rename to vehicle/Gauge.cppm index bf0f83c3..5eae4f95 100644 --- a/vehicle/Gauge.h +++ b/vehicle/Gauge.cppm @@ -6,11 +6,20 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include + +export module eu07.vehicle.gauge; +import eu07.simcore; +import eu07.utilities.parser; +import eu07.glm; +import eu07.utilities.classes; +import eu07.audio.sound; + +export { -#pragma once -#include "utilities/Classes.h" -#include "audio/sound.h" enum class TGaugeAnimation { // typ ruchu @@ -116,3 +125,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 8d2117c4..4738c18c 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -1,3 +1,36 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" +#include +#include +#include +#include +#include + +module eu07.vehicle.train; +import eu07.global_include.interfaces.itexture; +import eu07.model.mdlmngr; +import eu07.rendering.renderer; +import eu07.utilities.logs; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.application.application; +import eu07.utilities.utilities; +import eu07.mczapkie.hamulce; +import eu07.simcore; +import eu07.simulation.simulationtime; +import eu07.utilities.timer; +import eu07.world.mtable; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,27 +45,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "vehicle/Train.h" -#include "utilities/Globals.h" -#include "simulation/simulation.h" -#include "world/Event.h" -#include "simulation/simulationtime.h" -#include "vehicle/Camera.h" -#include "utilities/Logs.h" -#include "model/MdlMngr.h" -#include "model/Model3d.h" -#include "utilities/Timer.h" -#include "vehicle/Driver.h" -#include "vehicle/DynObj.h" -#include "world/mtable.h" -#include "Console.h" -#include "application/application.h" -#include "rendering/renderer.h" -#include -#include -#include /* namespace input { @@ -12398,8 +12411,6 @@ uint16_t TTrain::id() return vid; } -#include -#include void train_table::updateAsync(double dt) { diff --git a/vehicle/Train.h b/vehicle/Train.cppm similarity index 98% rename from vehicle/Train.h rename to vehicle/Train.cppm index 7627bbf8..71ecf0b4 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.cppm @@ -6,19 +6,36 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include "utilities/Globals_macros.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include "vehicle/DynObj.h" -#include "vehicle/Driver.h" -#include "vehicle/Button.h" -#include "vehicle/Gauge.h" -#include "audio/sound.h" -#include "scripting/PyInt.h" -#include "input/command.h" -#include "scripting/pythonscreenviewer.h" -#include "utilities/dictionary.h" +#include "vehicle/DynObj_macros.h" +#include "scripting/PyInt_macros.h" + +export module eu07.vehicle.train; +import eu07.utilities.globals; +import eu07.glm; +import eu07.utilities.parser; +import eu07.vehicle.gauge; +import eu07.simcore; +import eu07.scripting.pyint; +import eu07.scripting.pythonscreenviewer; +import eu07.utilities.dictionary; +import eu07.input.command; +import eu07.audio.sound; +import eu07.utilities.names; +export { + + #undef snprintf // pyint.h->python @@ -76,7 +93,6 @@ public: class TTrain { - friend class drivingaid_panel; public: // types @@ -859,11 +875,6 @@ public: // reszta może by?publiczna // McZapkie: do poruszania sie po kabinie glm::dvec3 pMechSittingPosition; // ABu 180404 glm::dvec3 MirrorPosition(bool lewe); - glm::dvec3 pMechOffset; // base position of the driver in the cab - glm::vec2 pMechViewAngle { 0.0, 0.0 }; // camera pitch and yaw values, preserved while in external view - -private: - double fBlinkTimer; float fHaslerTimer; float fConverterTimer; // hunter-261211: dla przekaznika float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem @@ -943,6 +954,13 @@ private: uint16_t id(); bool pending_delete = false; +public: +// Read by the ui panels, which are no longer friends: a friend declaration +// would make this module the first declarer of a class defined elsewhere, +// which C++20 modules reject. + glm::dvec3 pMechOffset; // base position of the driver in the cab + glm::vec2 pMechViewAngle { 0.0, 0.0 }; // camera pitch and yaw values, preserved while in external view + double fBlinkTimer; }; class train_table : public basic_table { @@ -953,3 +971,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 088fd5b5..fa8601fc 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -1,10 +1,19 @@ -#include "stdafx.h" -#include "openvr_imp.h" -#include "utilities/Logs.h" -#include "utilities/Globals.h" -#include "rendering/renderer.h" -#include "simulation/simulation.h" -#include "application/application.h" +module; +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include +#include +#include +#include +#include +#include + +module eu07.vr.openvr_imp; +import eu07.utilities.logs; +import eu07.utilities.globals; +import eu07.rendering.renderer; +import eu07.simulation.simulation; +import eu07.application.application; vr_openvr::vr_openvr() { diff --git a/vr/openvr_imp.h b/vr/openvr_imp.cppm similarity index 89% rename from vr/openvr_imp.h rename to vr/openvr_imp.cppm index 0b148e86..6d442898 100644 --- a/vr/openvr_imp.h +++ b/vr/openvr_imp.cppm @@ -1,6 +1,18 @@ -#pragma once -#include "vr_interface.h" +module; #include +#include +#include +#include +#include +#include +#include +#include +#include + +export module eu07.vr.openvr_imp; +import eu07.vr.vr_interface; + +export { class vr_openvr : vr_interface { @@ -65,3 +77,5 @@ public: private: static bool backend_register; }; + +} // export diff --git a/vr/vr_interface.cpp b/vr/vr_interface.cpp index 9f9ff4e4..ed8a4eab 100644 --- a/vr/vr_interface.cpp +++ b/vr/vr_interface.cpp @@ -1,6 +1,9 @@ -#include "stdafx.h" -#include "vr_interface.h" -#include "utilities/Logs.h" +module; +#include +#include + +module eu07.vr.vr_interface; +import eu07.utilities.logs; vr_interface::~vr_interface() {} diff --git a/vr/vr_interface.h b/vr/vr_interface.cppm similarity index 79% rename from vr/vr_interface.h rename to vr/vr_interface.cppm index ccfa4510..96c640be 100644 --- a/vr/vr_interface.h +++ b/vr/vr_interface.cppm @@ -1,7 +1,16 @@ -#pragma once -#include "vehicle/Camera.h" -#include "model/Model3d.h" -#include "model/Texture.h" +module; +#include +#include +#include +#include + +export module eu07.vr.vr_interface; +import eu07.glm; +import eu07.vehicle.camera; +import eu07.simcore; +import eu07.model.texture; + +export { class vr_interface { @@ -36,3 +45,5 @@ private: std::unordered_map backends; static vr_interface_factory *instance; }; + +} // export diff --git a/widgets/cameraview_extcam.cpp b/widgets/cameraview_extcam.cpp index 80deddbe..d94393fa 100644 --- a/widgets/cameraview_extcam.cpp +++ b/widgets/cameraview_extcam.cpp @@ -1,13 +1,20 @@ +module; +#include "glad/glad.h" +#include "stb/stb_image.h" +#include "utilities/Globals_macros.h" +#include "utilities/translation_macros.h" +#include "imgui/imgui.h" +#include +#include + +module eu07.widgets.cameraview_extcam; +import eu07.utilities.globals; +import eu07.utilities.translation; +import eu07.extras.piped_proc; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "widgets/cameraview_extcam.h" -#include "stb/stb_image.h" -#include "utilities/Globals.h" -#include "utilities/translation.h" -#include "extras/piped_proc.h" ui::cameraview_panel::cameraview_panel() : ui_panel(STR_C("Camera preview"), false) diff --git a/widgets/cameraview_extcam.h b/widgets/cameraview_extcam.cppm similarity index 79% rename from widgets/cameraview_extcam.h rename to widgets/cameraview_extcam.cppm index 520fcdda..770d9dc8 100644 --- a/widgets/cameraview_extcam.h +++ b/widgets/cameraview_extcam.cppm @@ -1,11 +1,20 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include +#include +#include + +export module eu07.widgets.cameraview_extcam; +import eu07.model.texture; +import eu07.application.uilayer; + +export { -#pragma once -#include "stdafx.h" -#include "application/uilayer.h" namespace ui { @@ -50,3 +59,5 @@ private: std::string rec_name; }; } // namespace ui + +} // export diff --git a/widgets/imgui_scale.h b/widgets/imgui_scale.h new file mode 100644 index 00000000..262df615 --- /dev/null +++ b/widgets/imgui_scale.h @@ -0,0 +1,17 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "imgui/imgui.h" + +// ImVec2 scaled by the user's ui scale factor. +// Global comes from utilities/Globals_macros.h and resolves at the expansion +// site, so this header must not pull the settings module in itself. +#define ImVec2S(a, b) ImVec2(a * Global.ui_scale, b * Global.ui_scale) diff --git a/widgets/map.cpp b/widgets/map.cpp index 25beb794..f385b973 100644 --- a/widgets/map.cpp +++ b/widgets/map.cpp @@ -1,13 +1,33 @@ -#include "stdafx.h" -#include "widgets/map.h" -#include "widgets/map_objects.h" -#include "utilities/Logs.h" -#include "vehicle/Train.h" -#include "vehicle/Camera.h" -#include "simulation/simulation.h" -#include "vehicle/Driver.h" -#include "model/AnimModel.h" -#include "application/application.h" +module; +#include "utilities/translation_macros.h" +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "global_include/interfaces/ITexture_macros.h" +#include "imgui/imgui.h" + +module eu07.widgets.map; +import eu07.utilities.translation; +import eu07.rendering.renderer; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.widgets.map_objects; +import eu07.utilities.logs; +import eu07.vehicle.train; +import eu07.vehicle.camera; +import eu07.simulation.simulation; +import eu07.simcore; +import eu07.application.application; ui::map_panel::map_panel() : ui_panel(STR_C("Map"), false) { diff --git a/widgets/map.h b/widgets/map.cppm similarity index 83% rename from widgets/map.h rename to widgets/map.cppm index 9cb8a064..e0dd18f4 100644 --- a/widgets/map.h +++ b/widgets/map.cppm @@ -1,14 +1,31 @@ -#pragma once +module; +#include +#include +#include +#include "imgui/imgui.h" + +export module eu07.widgets.map; +import eu07.gl.bindable; +import eu07.glm; +import eu07.global_include.interfaces.itexture; +import eu07.input.command; +import eu07.simcore; +import eu07.gl.shader; +import eu07.gl.renderbuffer; +import eu07.gl.ubo; +import eu07.rendering.geometrybank; +import eu07.model.texture; +import eu07.application.uilayer; +import eu07.widgets.map_objects; +import eu07.gl.framebuffer; +import eu07.rendering.frustum; +#ifdef WITH_OPENGL_MODERN +import eu07.rendering.opengl33renderer; +#endif + +export { -#include "gl/shader.h" -#include "model/Texture.h" -#include "application/uilayer.h" -#include "widgets/map_objects.h" -#include "widgets/popup.h" -#include "gl/framebuffer.h" -#include "rendering/frustum.h" #ifdef WITH_OPENGL_MODERN -#include "rendering/opengl33renderer.h" #endif namespace ui @@ -139,3 +156,5 @@ class map_panel : public ui_panel void handle_map_object_click(ui_panel &parent, std::shared_ptr &obj); void handle_map_object_hover(std::shared_ptr &obj); } // namespace ui + +} // export diff --git a/widgets/map_objects.cpp b/widgets/map_objects.cpp index d67c73f5..19f97b93 100644 --- a/widgets/map_objects.cpp +++ b/widgets/map_objects.cpp @@ -1,8 +1,9 @@ -#include "stdafx.h" -#include "widgets/map_objects.h" -#include "simulation/simulation.h" -#include "vehicle/DynObj.h" +module; +#include +#include "vehicle/DynObj_macros.h" +module eu07.widgets.map_objects; +import eu07.simulation.simulation; map::objects map::Objects; map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distance) diff --git a/widgets/map_objects.h b/widgets/map_objects.cppm similarity index 90% rename from widgets/map_objects.h rename to widgets/map_objects.cppm index f5d07ebf..28a60866 100644 --- a/widgets/map_objects.h +++ b/widgets/map_objects.cppm @@ -1,9 +1,17 @@ -#pragma once +module; +#include +#include +#include +#include +#include + +export module eu07.widgets.map_objects; +import eu07.glm; +import eu07.rendering.geometrybank; +import eu07.simcore; + +export { -#include "simulation/simulation.h" -#include "world/Event.h" -#include "scene/scene.h" -#include "world/MemCell.h" namespace map { @@ -92,3 +100,5 @@ struct objects extern objects Objects; } // namespace map + +} // export diff --git a/widgets/perfgraphs.cpp b/widgets/perfgraphs.cpp index 574cc7ef..7d7a1adc 100644 --- a/widgets/perfgraphs.cpp +++ b/widgets/perfgraphs.cpp @@ -1,7 +1,11 @@ -#include "stdafx.h" -#include "widgets/perfgraphs.h" -#include "utilities/Timer.h" -#include "utilities/translation.h" +module; +#include +#include "utilities/translation_macros.h" +#include "imgui/imgui.h" + +module eu07.widgets.perfgraphs; +import eu07.utilities.timer; +import eu07.utilities.translation; perfgraph_panel::perfgraph_panel() : ui_panel(STR("Performance"), false) {} diff --git a/widgets/perfgraphs.h b/widgets/perfgraphs.cppm similarity index 83% rename from widgets/perfgraphs.h rename to widgets/perfgraphs.cppm index d3ddb3c6..997da29b 100644 --- a/widgets/perfgraphs.h +++ b/widgets/perfgraphs.cppm @@ -1,4 +1,11 @@ -#include "application/uilayer.h" +module; +#include +#include + +export module eu07.widgets.perfgraphs; +import eu07.application.uilayer; + +export { class perfgraph_panel : public ui_panel { @@ -45,3 +52,5 @@ class perfgraph_panel : public ui_panel void render_contents() override; }; + +} // export diff --git a/widgets/popup.cpp b/widgets/popup.cpp index 75633c38..1454ed11 100644 --- a/widgets/popup.cpp +++ b/widgets/popup.cpp @@ -1,5 +1,8 @@ -#include "stdafx.h" -#include "widgets/popup.h" +module; +#include "imgui/imgui.h" +#include + +module eu07.application.uilayer; ui::popup::popup(ui_panel &panel) : m_parent(panel) {} diff --git a/widgets/popup.h b/widgets/popup.h deleted file mode 100644 index 82c3f258..00000000 --- a/widgets/popup.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -class ui_panel; - -namespace ui -{ - -class popup -{ - std::string m_id; - static int id; - - public: - popup(ui_panel &panel); - virtual ~popup(); - - virtual bool render(); - - protected: - ui_panel &m_parent; - virtual void render_content() = 0; -}; - -} // namespace ui diff --git a/widgets/time.cpp b/widgets/time.cpp index d299d17b..8e7e5794 100644 --- a/widgets/time.cpp +++ b/widgets/time.cpp @@ -1,7 +1,12 @@ -#include "stdafx.h" -#include "widgets/time.h" -#include "simulation/simulationtime.h" -#include "utilities/Globals.h" +module; +#include "utilities/Globals_macros.h" +#include "imgui/imgui.h" +#include "utilities/translation_macros.h" + +module eu07.widgets.time; +import eu07.simulation.simulationtime; +import eu07.utilities.translation; +import eu07.utilities.globals; ui::time_panel::time_panel() : ui_panel(STR_C("Time and environment"), false) { diff --git a/widgets/time.h b/widgets/time.cppm similarity index 55% rename from widgets/time.h rename to widgets/time.cppm index 748093ea..a69e5f4e 100644 --- a/widgets/time.h +++ b/widgets/time.cppm @@ -1,6 +1,12 @@ -#include "application/uilayer.h" -#include "utilities/translation.h" -#include "input/command.h" +module; +#include "utilities/translation_macros.h" + +export module eu07.widgets.time; +import eu07.application.uilayer; +import eu07.utilities.translation; +import eu07.input.command; + +export { namespace ui { @@ -21,3 +27,5 @@ class time_panel : public ui_panel void open(); }; } // namespace ui + +} // export diff --git a/widgets/trainingcard.cpp b/widgets/trainingcard.cpp index d4d11e5b..60215b59 100644 --- a/widgets/trainingcard.cpp +++ b/widgets/trainingcard.cpp @@ -1,12 +1,23 @@ -#include "stdafx.h" -#include "widgets/trainingcard.h" -#include "simulation/simulation.h" - +module; +#include "imgui/imgui.h" +#include +#include +#include +#include +#include #ifdef __linux__ #include +#endif +#ifdef __linux__ #include #endif +module eu07.widgets.trainingcard; +import eu07.simulation.simulation; + +#ifdef __linux__ +#endif + trainingcard_panel::trainingcard_panel() : ui_panel("Raport szkolenia", false) { // size = {400, 500}; diff --git a/widgets/trainingcard.h b/widgets/trainingcard.cppm similarity index 81% rename from widgets/trainingcard.h rename to widgets/trainingcard.cppm index 9e4eafe9..90c905bb 100644 --- a/widgets/trainingcard.h +++ b/widgets/trainingcard.cppm @@ -1,4 +1,12 @@ -#include "application/uilayer.h" +module; +#include +#include +#include + +export module eu07.widgets.trainingcard; +import eu07.application.uilayer; + +export { class trainingcard_panel : public ui_panel { @@ -35,3 +43,5 @@ class trainingcard_panel : public ui_panel std::string recording_timestamp; }; + +} // export diff --git a/widgets/vehiclelist.cpp b/widgets/vehiclelist.cpp index e8ee1e12..bdfb242e 100644 --- a/widgets/vehiclelist.cpp +++ b/widgets/vehiclelist.cpp @@ -1,8 +1,16 @@ -#include "stdafx.h" -#include "widgets/vehiclelist.h" -#include "simulation/simulation.h" -#include "vehicle/Driver.h" -#include "widgets/vehicleparams.h" +module; +#include "imgui/imgui.h" +#include "utilities/translation_macros.h" +#include +#include "utilities/Globals_macros.h" + +module eu07.widgets.vehiclelist; +import eu07.utilities.utilities; +import eu07.utilities.translation; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.simcore; +import eu07.widgets.vehicleparams; ui::vehiclelist_panel::vehiclelist_panel(ui_layer &parent) : ui_panel(STR_C("Vehicle list"), false), m_parent(parent) diff --git a/widgets/vehiclelist.h b/widgets/vehiclelist.cppm similarity index 67% rename from widgets/vehiclelist.h rename to widgets/vehiclelist.cppm index b1dd509a..65de1c46 100644 --- a/widgets/vehiclelist.h +++ b/widgets/vehiclelist.cppm @@ -1,4 +1,9 @@ -#include "application/uilayer.h" +module; + +export module eu07.widgets.vehiclelist; +import eu07.application.uilayer; + +export { namespace ui { @@ -13,3 +18,5 @@ class vehiclelist_panel : public ui_panel void render_contents() override; }; } // namespace ui + +} // export diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index 51ad7a07..f9aa9432 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -1,9 +1,24 @@ -#include "stdafx.h" -#include "widgets/vehicleparams.h" -#include "simulation/simulation.h" -#include "application/driveruipanels.h" -#include "vehicle/Driver.h" -#include "vehicle/Train.h" +module; +#include "utilities/translation_macros.h" +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "global_include/interfaces/ITexture_macros.h" +#include "imgui/imgui.h" + +module eu07.widgets.vehicleparams; +import eu07.mczapkie.hamulce; +import eu07.utilities.utilities; +import eu07.gl.buffer; +import eu07.utilities.globals; +import eu07.glm; +import eu07.simulation.simulation; +import eu07.simcore; +import eu07.vehicle.train; ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle) : ui_panel(std::string(STR("Vehicle parameters")) + ": " + vehicle, false), m_vehicle_name(vehicle) { diff --git a/widgets/vehicleparams.h b/widgets/vehicleparams.cppm similarity index 55% rename from widgets/vehicleparams.h rename to widgets/vehicleparams.cppm index 787e1e81..676e505a 100644 --- a/widgets/vehicleparams.h +++ b/widgets/vehicleparams.cppm @@ -1,9 +1,18 @@ -#pragma once +module; +#include +#include "utilities/translation_macros.h" +#include "imgui/imgui.h" + +export module eu07.widgets.vehicleparams; +import eu07.global_include.interfaces.itexture; +import eu07.simcore; +import eu07.application.uilayer; +import eu07.utilities.translation; +import eu07.input.command; +import eu07.rendering.renderer; + +export { -#include "application/uilayer.h" -#include "utilities/translation.h" -#include "input/command.h" -#include "rendering/renderer.h" namespace ui { @@ -21,3 +30,5 @@ class vehicleparams_panel : public ui_panel void render_contents() override; }; } // namespace ui + +} // export diff --git a/windows.cpp b/windows.cpp index df036435..01726037 100644 --- a/windows.cpp +++ b/windows.cpp @@ -1,6 +1,6 @@ -#include "stdafx.h" -#include "input/messaging.h" -#include "utilities/utilities.h" +#include "utilities/utilities_macros.h" +import eu07.input.messaging; +import eu07.utilities.utilities; #pragma warning (disable: 4091) diff --git a/world/Curve.h b/world/Curve.cppm similarity index 91% rename from world/Curve.h rename to world/Curve.cppm index fbb10866..475e261d 100644 --- a/world/Curve.h +++ b/world/Curve.cppm @@ -6,13 +6,16 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CurveH -#define CurveH - +module; #include "QueryParserComp.hpp" #include "usefull.h" +export module eu07.world.curve; + +export { + + + class TCurve { public: @@ -32,4 +35,5 @@ class TCurve float **Values; }; //--------------------------------------------------------------------------- -#endif + +} // export diff --git a/world/EvLaunch.cpp b/world/EvLaunch.cpp index 29c3104f..fa928463 100644 --- a/world/EvLaunch.cpp +++ b/world/EvLaunch.cpp @@ -1,3 +1,20 @@ +module; +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include + +module eu07.simcore; +import eu07.console; +import eu07.utilities.utilities; +import eu07.widgets.map_objects; +import eu07.utilities.globals; +import eu07.utilities.timer; +import eu07.utilities.parser; +import eu07.simulation.simulationtime; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,17 +30,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/EvLaunch.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "utilities/Timer.h" -#include "utilities/parser.h" -#include "Console.h" -#include "simulation/simulationtime.h" //--------------------------------------------------------------------------- diff --git a/world/EvLaunch.h b/world/EvLaunch.cppm similarity index 92% rename from world/EvLaunch.h rename to world/EvLaunch.cppm index a38e9e4a..9b365aa1 100644 --- a/world/EvLaunch.h +++ b/world/EvLaunch.cppm @@ -7,14 +7,19 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include -#include "utilities/Classes.h" -#include "scene/scenenode.h" // radio-transmitted event launch messages +module; +#include + +export module eu07.simcore:evlaunch; +import :fwd; +import eu07.utilities.parser; +import :memcell; +import eu07.utilities.classes; +export { enum radio_message { call3 = -3, call1 = -1 @@ -73,3 +78,5 @@ private: }; //--------------------------------------------------------------------------- + +} // export diff --git a/world/Event.cpp b/world/Event.cpp index 4e042b29..a3fbfde8 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -1,3 +1,34 @@ +module; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.simcore; +import eu07.input.messaging; +import eu07.simulation.simulation; +import eu07.rendering.renderer; +import eu07.scripting.lua; +import eu07.utilities.utilities; +import :evlaunch; +import eu07.utilities.globals; +import eu07.simulation.simulationtime; +import eu07.simulation.simulationsounds; +import eu07.utilities.timer; +import eu07.widgets.map_objects; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,26 +44,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/Event.h" -#include "simulation/simulation.h" -#include "simulation/simulationtime.h" -#include "simulation/simulationsounds.h" -#include "input/messaging.h" -#include "utilities/Globals.h" -#include "world/MemCell.h" -#include "world/Track.h" -#include "world/Traction.h" -#include "world/TractionPower.h" -#include "audio/sound.h" -#include "model/AnimModel.h" -#include "vehicle/DynObj.h" -#include "vehicle/Driver.h" -#include "rendering/renderer.h" -#include "utilities/Timer.h" -#include "utilities/Logs.h" -#include "widgets/map_objects.h" void basic_event::event_conditions::bind( basic_event::node_sequence *Nodes ) { diff --git a/world/Event.h b/world/Event.cppm similarity index 98% rename from world/Event.h rename to world/Event.cppm index 52ee3468..362621fa 100644 --- a/world/Event.h +++ b/world/Event.cppm @@ -6,19 +6,32 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include +#include + +export module eu07.simcore:event; +import :fwd; +import eu07.utilities.logs; +import eu07.utilities.classes; +import :scene; +import eu07.utilities.names; +import :evlaunch; +import eu07.utilities.comparison; +#ifdef WITH_LUA +#endif + +export { -#pragma once -#include "utilities/Classes.h" -#include "scene/scene.h" -#include "utilities/Names.h" -#include "world/EvLaunch.h" -#include "utilities/Logs.h" -#include "input/command.h" -#include "utilities/comparison.h" #ifdef WITH_LUA -#include "scripting/lua.h" #endif // common event interface @@ -750,3 +763,5 @@ basic_event::init_targets( TableType_ &Repository, std::string const &Targettype } //--------------------------------------------------------------------------- + +} // export diff --git a/world/MemCell.cpp b/world/MemCell.cpp index 76e9e4f1..e6b5b4fb 100644 --- a/world/MemCell.cpp +++ b/world/MemCell.cpp @@ -1,3 +1,10 @@ +module; +#include +#include +#include + +module eu07.simcore; +import eu07.simulation.simulation; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,13 +20,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/MemCell.h" -#include "simulation/simulation.h" -#include "vehicle/Driver.h" -#include "world/Event.h" -#include "utilities/Logs.h" //--------------------------------------------------------------------------- diff --git a/world/MemCell.h b/world/MemCell.cppm similarity index 90% rename from world/MemCell.h rename to world/MemCell.cppm index c2960f27..25d43c71 100644 --- a/world/MemCell.h +++ b/world/MemCell.cppm @@ -6,13 +6,24 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include +#include + +export module eu07.simcore:memcell; +import eu07.glm; +import :fwd; +import eu07.utilities.parser; +import :driver; +import :track; +import eu07.utilities.classes; +import eu07.utilities.names; +import eu07.utilities.comparison; + +export { -#pragma once -#include "utilities/Classes.h" -#include "scene/scenenode.h" -#include "utilities/Names.h" -#include "utilities/comparison.h" class TMemCell : public scene::basic_node { @@ -92,3 +103,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/world/Segment.cpp b/world/Segment.cpp index 2afa264e..4e8c0b2e 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -1,3 +1,20 @@ +module; +#include +#include +#include +#include +#include +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.simcore; +import eu07.utilities.globals; +import eu07.simulation.simulation; +import eu07.utilities.logs; +import eu07.utilities.parser; +import eu07.utilities.utilities; +import eu07.rendering.renderer; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,15 +24,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/Segment.h" -#include "utilities/Globals.h" -#include "utilities/Logs.h" -#include "utilities/parser.h" -#include "utilities/utilities.h" -#include "world/Track.h" -#include "rendering/renderer.h" void segment_data::deserialize( cParser &Input, glm::dvec3 const &Offset ) { diff --git a/world/Segment.h b/world/Segment.cppm similarity index 95% rename from world/Segment.h rename to world/Segment.cppm index 645e5663..fb2d31ac 100644 --- a/world/Segment.h +++ b/world/Segment.cppm @@ -6,12 +6,20 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include + +export module eu07.simcore:segment; +import eu07.utilities.parser; +import :fwd; +import eu07.glm; +import eu07.utilities.classes; +import eu07.rendering.geometrybank; + +export { -#pragma once -#include "utilities/Classes.h" -#include "rendering/geometrybank.h" -#include struct map_colored_paths { std::vector switches; @@ -145,3 +153,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/world/Spring.cpp b/world/Spring.cpp index b58d8859..d07970e6 100644 --- a/world/Spring.cpp +++ b/world/Spring.cpp @@ -1,3 +1,7 @@ +module; + +module eu07.world.spring; +import eu07.glm; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,8 +11,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/Spring.h" void TSpring::Init(double nKs, double nKd) { Ks = nKs; diff --git a/world/Spring.h b/world/Spring.cppm similarity index 93% rename from world/Spring.h rename to world/Spring.cppm index 6800ba29..23d9d5ad 100644 --- a/world/Spring.h +++ b/world/Spring.cppm @@ -7,8 +7,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef ParticlesH -#define ParticlesH /* #define STATIC_THRESHOLD 0.17f @@ -20,6 +18,12 @@ const double m_Ksd = 0.1f; // SPRING DAMPING CONSTANT const double m_Csf = 0.9f; // Default Static Friction const double m_Ckf = 0.7f; // Default Kinetic Friction */ +module; + +export module eu07.world.spring; +import eu07.glm; + +export { class TSpring { public: @@ -38,4 +42,5 @@ public: }; //--------------------------------------------------------------------------- -#endif + +} // export diff --git a/world/Track.cpp b/world/Track.cpp index 6155116c..f872f052 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -1,3 +1,28 @@ +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.simcore; +import eu07.simulation.simulation; +import eu07.rendering.renderer; +import eu07.input.messaging; +import eu07.model.mdlmngr; +import eu07.utilities.utilities; +import eu07.utilities.globals; +import eu07.utilities.timer; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,22 +37,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/Track.h" -#include "simulation/simulation.h" -#include "utilities/Globals.h" -#include "world/Event.h" -#include "world/MemCell.h" -#include "input/messaging.h" -#include "vehicle/DynObj.h" -#include "vehicle/Driver.h" -#include "model/AnimModel.h" -#include "model/MdlMngr.h" -#include "model/Model3d.h" -#include "utilities/Timer.h" -#include "utilities/Logs.h" -#include "rendering/renderer.h" // 101206 Ra: trapezoidalne drogi i tory // 110720 Ra: rozprucie zwrotnicy i odcinki izolowane diff --git a/world/Track.h b/world/Track.cppm similarity index 97% rename from world/Track.h rename to world/Track.cppm index 9bf38e0a..a93d2175 100644 --- a/world/Track.h +++ b/world/Track.cppm @@ -6,24 +6,34 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include #include #include #include +#include + +export module eu07.simcore:track; +import :fwd; +import :editoruilayer; +import :editoruipanels; +import :animmodel; +import :model3d; +import eu07.rendering.geometrybank; +import :scenenode; +import eu07.utilities.parser; +import :dynobj; +import eu07.glm; +import eu07.utilities.classes; +import eu07.utilities.names; + +export { + + -#include -#include -#include "utilities/Classes.h" -#include "world/Segment.h" -#include "model/material.h" -#include "scene/scenenode.h" -#include "utilities/Names.h" namespace scene { -class basic_cell; } enum TTrackType { @@ -47,11 +57,9 @@ enum TEnvironmentType { }; // Ra: opracować alternatywny system cieni/świateł z definiowaniem koloru oświetlenia w halach -class basic_event; class TTrack; class TGroundNode; class TSubRect; -class TTraction; class TSwitchExtension { // dodatkowe dane do toru, który jest zwrotnicą @@ -150,8 +158,6 @@ private: // trajektoria ruchu - opakowanie class TTrack : public scene::basic_node { - friend opengl_renderer; - friend opengl33_renderer; // NOTE: temporary arrangement friend itemproperties_panel; @@ -395,3 +401,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/world/Traction.cpp b/world/Traction.cpp index ef0c85bd..00774c79 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -1,3 +1,21 @@ +module; +#include "glad/glad.h" +#include +#include +#include +#include +#include +#include +#include +#include "global_include/interfaces/ITexture_macros.h" +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.simcore; +import eu07.rendering.renderer; +import eu07.simulation.simulation; +import eu07.utilities.globals; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -12,15 +30,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/Traction.h" -#include "simulation/simulation.h" -#include "utilities/Globals.h" -#include "world/TractionPower.h" -#include "utilities/Logs.h" -#include "rendering/renderer.h" -#include "utilities/utilities.h" //--------------------------------------------------------------------------- /* diff --git a/world/Traction.h b/world/Traction.cppm similarity index 93% rename from world/Traction.h rename to world/Traction.cppm index 638f46b0..1038cd4f 100644 --- a/world/Traction.h +++ b/world/Traction.cppm @@ -6,23 +6,26 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; +#include #include -#include "scene/scenenode.h" -#include "world/Segment.h" -#include "model/material.h" -#include "utilities/Names.h" +export module eu07.simcore:traction; +import :fwd; +import :tractionpower; +import :scenenode; +import eu07.glm; +import :editoruilayer; +import eu07.utilities.names; + +export { + + + -class TTractionPowerSource; class TTraction : public scene::basic_node { - friend opengl_renderer; - friend opengl33_renderer; - public: // na razie TTractionPowerSource *psPower[ 2 ] { nullptr, nullptr }; // najbliższe zasilacze z obu kierunków TTractionPowerSource *psPowered { nullptr }; // ustawione tylko dla bezpośrednio zasilanego przęsła @@ -74,9 +77,11 @@ class TTraction : public scene::basic_node void PowerSet(TTractionPowerSource *ps); double VoltageGet(double u, double i); +public: + // the legacy renderer asks for the wire colour directly + glm::vec3 wire_color() const; private: // methods - glm::vec3 wire_color() const; // radius() subclass details, calculates node's bounding radius float radius_(); // serialize() subclass details, sends content of the subclass to provided stream @@ -100,3 +105,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/world/TractionPower.cpp b/world/TractionPower.cpp index 7d816e21..3483394e 100644 --- a/world/TractionPower.cpp +++ b/world/TractionPower.cpp @@ -1,3 +1,9 @@ +module; +#include +#include + +module eu07.simcore; +import eu07.utilities.parser; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,11 +19,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/TractionPower.h" -#include "utilities/parser.h" -#include "utilities/Logs.h" //--------------------------------------------------------------------------- diff --git a/world/TractionPower.h b/world/TractionPower.cppm similarity index 84% rename from world/TractionPower.h rename to world/TractionPower.cppm index d1faa037..ad7f464e 100644 --- a/world/TractionPower.h +++ b/world/TractionPower.cppm @@ -6,16 +6,23 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +module; +#include +#include + +export module eu07.simcore:tractionpower; +import :fwd; +import :scenenode; +import eu07.utilities.parser; +import eu07.utilities.classes; +import eu07.utilities.names; + +export { -#pragma once -#include "utilities/Classes.h" -#include "scene/scenenode.h" -#include "utilities/Names.h" class TTractionPowerSource : public scene::basic_node { - friend class debug_panel; public: // constructor @@ -35,6 +42,17 @@ public: bool bSection = false; // czy jest sekcją bool IsAutogenerated { false }; // indicates autogenerated source for individual traction piece +public: +// Read by the debug panel, which is no longer a friend: a friend declaration +// would make this module the first declarer of a class defined elsewhere, +// which C++20 modules reject. + double NominalVoltage = 0.0; + double TotalCurrent = 0.0; + double OutputVoltage = 0.0; + bool FastFuse = false; + bool SlowFuse = false; + double FuseTimer = 0.0; + int FuseCounter = 0; private: // methods // serialize() subclass details, sends content of the subclass to provided stream @@ -45,7 +63,6 @@ private: void export_as_text_( std::ostream &Output ) const; // members - double NominalVoltage = 0.0; double VoltageFrequency = 0.0; double InternalRes = 0.2; double MaxOutputCurrent = 0.0; @@ -54,14 +71,8 @@ private: double SlowFuseTimeOut = 60.0; bool Recuperation = false; - double TotalCurrent = 0.0; double TotalAdmitance = 1e-10; // 10Mom - jakaś tam upływność double TotalPreviousAdmitance = 1e-10; // zero jest szkodliwe - double OutputVoltage = 0.0; - bool FastFuse = false; - bool SlowFuse = false; - double FuseTimer = 0.0; - int FuseCounter = 0; }; @@ -77,3 +88,5 @@ public: }; //--------------------------------------------------------------------------- + +} // export diff --git a/world/TrkFoll.cpp b/world/TrkFoll.cpp index b1884896..043fd67b 100644 --- a/world/TrkFoll.cpp +++ b/world/TrkFoll.cpp @@ -1,3 +1,12 @@ +module; +#include +#include "utilities/Globals_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.simcore; +import eu07.simulation.simulation; +import eu07.utilities.globals; +import eu07.utilities.logs; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,14 +22,7 @@ http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/TrkFoll.h" -#include "simulation/simulation.h" -#include "utilities/Globals.h" -#include "vehicle/DynObj.h" -#include "vehicle/Driver.h" -#include "utilities/Logs.h" TTrackFollower::~TTrackFollower() { diff --git a/world/TrkFoll.h b/world/TrkFoll.cppm similarity index 93% rename from world/TrkFoll.h rename to world/TrkFoll.cppm index bba97681..4cfe46d3 100644 --- a/world/TrkFoll.h +++ b/world/TrkFoll.cppm @@ -7,13 +7,19 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef TrkFollH -#define TrkFollH -#include "utilities/Classes.h" -#include "world/Segment.h" // oś poruszająca się po torze +module; +#include + +export module eu07.simcore:trkfoll; +import :fwd; +import eu07.glm; +import :segment; +import eu07.utilities.classes; + +export { class TTrackFollower { public: @@ -60,4 +66,5 @@ public: int iSegment = 0; // który segment toru jest używany (żeby nie przeskakiwało po przestawieniu zwrotnicy pod taborem) }; //--------------------------------------------------------------------------- -#endif + +} // export diff --git a/world/mtable.cpp b/world/mtable.cpp index cec54f87..bc6a1b06 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -1,3 +1,12 @@ +module; +#include +#include "utilities/Globals_macros.h" +#include "utilities/utilities_macros.h" + +module eu07.world.mtable; +import eu07.utilities.globals; +import eu07.simulation.simulationtime; +import eu07.utilities.utilities; /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -7,12 +16,6 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/mtable.h" -#include "utilities/Globals.h" -#include "simulation/simulationtime.h" -#include "utilities/dictionary.h" -#include "utilities/utilities.h" double TTrainParameters::CheckTrainLatency() { diff --git a/world/mtable.h b/world/mtable.cppm similarity index 92% rename from world/mtable.h rename to world/mtable.cppm index c58d120f..6d85db02 100644 --- a/world/mtable.h +++ b/world/mtable.cppm @@ -6,19 +6,24 @@ distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - +module; #include -#include "utilities/Classes.h" -#include "audio/sound.h" +export module eu07.world.mtable; +import eu07.audio.sound; +import eu07.utilities.dictionary; +import eu07.simulation.simulationtime; +import eu07.utilities.classes; +export { + + + namespace Mtable { -static int const MaxTTableSize = 100; // można by to robić dynamicznie -static char const *hrsd = "."; +inline int const MaxTTableSize = 100; // można by to robić dynamicznie +inline char const *hrsd = "."; // Ra: pozycja zerowa rozkładu chyba nie ma sensu // Ra: numeracja przystanków jest 1..StationCount @@ -116,5 +121,7 @@ class TMTableTime } #if !defined(NO_IMPLICIT_NAMESPACE_USE) -using namespace Mtable; #endif + +} // export +using namespace Mtable; diff --git a/world/station.cpp b/world/station.cpp index eae81d9e..84398305 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -1,4 +1,14 @@ -/* +module; +#include +#include +#include "utilities/utilities_macros.h" +#include "vehicle/DynObj_macros.h" + +module eu07.world.station; +import eu07.utilities.utilities; +import eu07.simcore; +import eu07.world.mtable; +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,12 +17,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#include "stdafx.h" -#include "world/station.h" -#include "utilities/utilities.h" -#include "vehicle/DynObj.h" -#include "world/mtable.h" namespace simulation { diff --git a/world/station.h b/world/station.cppm similarity index 82% rename from world/station.h rename to world/station.cppm index ecc60992..b4450f7f 100644 --- a/world/station.h +++ b/world/station.cppm @@ -1,4 +1,12 @@ -/* +module; + +export module eu07.world.station; +import eu07.simcore; +import eu07.world.mtable; +import eu07.utilities.classes; + +export { +/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not @@ -7,9 +15,7 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#pragma once -#include "utilities/Classes.h" // a simple station, performs freight and passenger exchanges with visiting consists class basic_station { @@ -27,3 +33,5 @@ extern basic_station Station; // temporary object, for station functionality tes } // simulation + +} // export