openOMSI GitHub Discord

Docs / The project

Architecture

Crates, threads, memory, coordinate frames and the layering of targets.

26 min readEdit this pagedocs/ARCHITECTURE.md

openOMSI mirrors the unit structure of the original Delphi program so that every subsystem has an obvious counterpart, but replaces its architecture where the original was limited: 64-bit, data loading and tessellation on a worker pool, a modern renderer, no global mutable state (the aim; see "Known debt" below for where the code stands).

How it got here, round by round, is in HISTORY.md; how a change that must not change behaviour is checked is in REFACTOR_CHECKS.md.

Original unit(s) Crate / module Status
file readers (TTextfile) omsi-cfg done, 100 % of stock content; content roots and mounted .zip archives through omsi-cfg::vfs
mc_exprcalc (scripts) omsi-script done (compiler + VM), 245/245 stock script sets
mc_o3dfiles, .x meshes omsi-o3d done incl. v4/v5 unscrambling and .x frame transforms
mc_complobj, mc_MatlMan omsi-model parser done; materials drawn as Direct3D draws them (one-sided, envmap mask, bump map, noZcheck/Zbias, dynamic slots)
mc_complMapObj, mc_splines omsi-scenery parser done
mc_mapclass, mc_terrain_2, mc_chrono, mc_fahrstrasse omsi-map parser done; chrono folders applied (records patched by ID, lines taken off a date)
mc_roadvehicle, mc_vehicle, mc_train, mc_passcabin, mc_sound omsi-vehicle parser done
- (no original counterpart: OMSI 2 runs its trolleybus wire in a plugin) omsi-trolley the overhead wire network with its sections and switches, the poles' mechanics, the rheostat and asynchronous traction, arcs; used by omsi-vehicle (the [trolley_*] blocks), run on a vehicle by omsi-sim (vehicle/trolley.rs) and drawn by omsi-scene::trolley_view; see TROLLEYBUS.md
mc_timetable, mc_station omsi-timetable parser done; the runtime (duties, trips, layovers, departure boards) is omsi-sim::timetable_run (ScheduleSim), its buses put on the road by omsi-app::schedule
mc_weather, mc_himmel, mc_font, mc_language, mc_money, mc_human, mc_driver, mc_situation, mc_input, options omsi-content parsers done
mc_texMan omsi-texture loading done incl. seasonal and _LOW variants; BC1-3 on the GPU (DXT as is, others compressed) and a texture budget
mc_sound runtime, DirectSound omsi-audio (cpal) mixer, WAV, loop/one-shot sounds with volcurves, conditions, triggers, 3D
mc_font text textures omsi-sim::texttex [texttexture] rendering from .oft fonts
tessellation, spline geometry omsi-geometry splines, terrain, placement done; the ground cut under flush surfaces and [terrainhole]
mc_d3d_classes (Direct3D 9) omsi-render (wgpu) the vanilla picture complete (materials, lights, night maps, reflections, mirrors, shadow cascades); enhanced is a physically based renderer of its own
mc_Form_Main, main loop omsi-app offscreen + window, start menu, HUD, tile streaming; the original's dialogs are the launcher
vehicle runtime (TRoadVehicleInst) omsi-sim scripts, animations, dynamic materials, keyboard/mouse input, IBIS typing, coupled parts
AI (mc_path, mc_pathrule), humans, physics (ODE) omsi-sim traffic + ai_motion (rules, light programs, following, passing), human + crowd (poses, queues, avoidance), rigid + physics (wheels, collisions)
Optionen and the start dialogs launcher/ (Tauri) + omsi-launcher-core, omsi-launcher-api, omsi-launcher-model the desktop launcher, a program of its own (its page also in Android's web view; SwiftUI on Apple's systems): profile, bus, map, duty, weather, settings, mods, running games; the game has no launcher window
- (no original counterpart) omsi-net, omsi-lan, omsi-app::lan LAN play: UDP session, bit-packed vehicle states, chat

Chapters

1CratesThe workspace is layered; scripts/arch-guard.sh (rules in scripts/arch-rules.txt, run on every pull request) keeps each crate off the layers above it,…2 min
2ThreadingTile loading (.map parse, terrain, spline tessellation, object type loading) runs on the rayon pool; GPU upload happens on the main thread. Object and…5 min
3MemoryA 16 GB Mac shares its memory between the CPU and the GPU, so both count against the same budget. Textures are kept compressed on the GPU (see FORMATS…4 min
4Coordinate framesWorld: x east, y north, z up, metres; headings in degrees clockwise from north. .cfg files (cameras, positions, animations): x right, y forward, z up.…1 min
5Start guardA release that breaks the start must not strand anyone (it happened: the updater lives in the launcher, and a launcher that never drew its window neve…1 min
6Target layeringWhere the code is going (new code follows it, refactors move old code towards it): Parsers (omsi-cfg, omsi-script, omsi-o3d, omsi-model, omsi-scenery,…1 min
7Known debtWhat is already in place. The frame is a declared list of stages run by one runner (omsi-app/src/frame_stages.rs: app_events::WINDOW_FRAME for the win…9 min

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open