Architecture & libraries
Shift Engine is a strictly acyclic stack of C++20 libraries under libs/ feeding thin application hosts under apps/. Every domain library (fh1data, shift_data, shift_cars, shift_drive, shift_audio, shift_world, shift_traffic, shift_garage, shift_freeroam, shift_race, shift_profile, shift_setup) is headless-first: zero Vulkan, DirectX 12, Metal, or SDL3 dependencies.
Shift Engine 6-Tier Acyclic C++20 Library Dependency DAG: Tier 5 — Applications & Presentation (SDL3 / GPU Hosts): apps/carview (carview_render + carview_hud + carview), apps/launcher (shift-launcher), apps/carbake, apps/soundbake, apps/profile-import, apps/drive --- Headless Domain Boundary (zero SDL3 or windowing dependencies; shift_rhi isolated) --- Tier 4 — Game Modes, Persistence & Platform: shift_freeroam (signs, barns, outposts, 1000 Club) shift_race (events, career flow, showcases, Rally) shift_profile (atomic saves, backups, PinyonShift/Xenia import, LAN sync) shift_rhi (Vulkan 1.3, DirectX 12, Metal 3, RenderGraph, vis_buffer, clustered lights) shift_setup (GDFX/XISO extractor, STFS installer, mods, Mesa Turnip) Tier 3 — World, Traffic, Garage & Cutscenes: shift_world (Colorado streaming, collision, 24h ToD sky, smashables, VFX) shift_traffic (road graph, free-roam traffic AI, GPS routing) shift_garage (garage inventory, upgrades, tuning, PI calculator) shift_cutscene (cinematic tracks and rig evaluation) Tier 2 — Core Simulation & Real-Time Audio: shift_drive (120 Hz / 360 Hz vehicle physics, tyres, 4x4 LSD/AWD, BVH4/8, voxel damage, AI, FFB, UDP) shift_audio (lock-free 48 kHz RT thread, XMA2/FSB4, engine DSP, FEV1, 3D acoustics, radio, VO) Tier 1 — Asset Resolution & Layering: shift_cars (disc + Title Update v4 + DLC resolver, merged catalog, direct-from-disc & .shiftbake loader, mods.toml overlay) Tier 0 — Format Readers & Rules (zero internal dependencies): fh1data (ZIP/LZX, .xds, .carbin, HEXY/.pvsz, UI4 .bgf/.bsg/.fbf, VFont/CJK, SPA, NativeCache, WorkerPool) shift_data (read-only gamedb.slt SQLite rules & event restrictions)
Design highlights#
Headless-first C++20 libraries
Link shift_drive, fh1data, or shift_audio directly in CLI tools or ctest suites with no GPU or windowing system.
Hot car swaps (~213 ms)
DriveWorldHost outlives DriveSession. Swapping cars in My Garage keeps the Vulkan device, pipeline cache, world arenas, and BVH resident.
Bounded explicit concurrency
4 clear thread roles: Main/Render, fh1::WorkerPool streaming/AI, deferred GPU resource reaper (0 vkDeviceWaitIdle stalls), and lock-free RT audio.
Clean-room provenance
Independently authored from format and behavioral specs; every push is verified by tools/check-provenance.py.
Embedding a headless library#
Link any domain target in CMake to run physics sweeps, inspect archives, or render offline audio with zero game data required for synthetic defaults:
add_executable(my_physics_probe main.cpp)
target_link_libraries(my_physics_probe PRIVATE shift_drive)
#include <cstdio>
#include "drive/vehicle.h"
int main() {
drive::CarParams params; // default-constructed synthetic car
drive::Vehicle car(params);
drive::FlatGround ground(0.0);
car.reset({0.0, 0.0, 0.0}, 0.0);
car.settle_on_ground(ground);
drive::Input in{};
in.throttle = 1.0;
for (int i = 0; i < 120 * 5; ++i) car.step(in, ground);
std::printf("5s launch: %.1f km/h, gear %d, %.0f rpm\n",
car.speed() * 3.6, car.gear(), car.rpm());
}
With a local disc mounted, drive::params_from_physics() loads per-car tables from gamedb.slt + physics.zip, and drive::MeshGround replaces FlatGround with Colorado's SIMD BVH mesh.
Library & runtime map#
| Target | Path | Role |
|---|---|---|
fh1data / shift_data | libs/fh1data, libs/data | Format readers (ZIP/LZX, .xds, .carbin, HEXY/.pvsz, UI4, VFont/CJK, SPA) and read-only gamedb.slt rules. |
shift_cars | libs/cars | Disc + TU v4 + DLC resolver, direct-from-disc & .shiftbake car loader, mods.toml overlay. |
shift_drive | libs/drive | 360 Hz vehicle physics, tyres, 4×4 LSD/AWD, BVH4/BVH8 collision, voxel damage, AI, cameras, FFB, UDP telemetry. |
shift_audio | libs/audio | Lock-free 48 kHz RT audio thread, in-process XMA2/FSB4, engine DSP, FEV1, 3D acoustics, radio, VO. |
shift_world / traffic / garage | libs/world, traffic, garage | Colorado cell streaming, collision, 24h sky, VFX, road graph & traffic AI, upgrades/tuning/PI solver. |
shift_freeroam / race / profile | libs/freeroam, race, profile | Collectibles, barn finds, 1000 Club, race events, Horizon Rally, atomic saves, PinyonShift/Xenia import. |
shift_rhi / shift_setup | libs/rhi, libs/setup | Multi-API RHI (Vulkan 1.3, DX12, Metal 3) + clean-room GDFX/ISO, STFS, mod, and Turnip installers. |
carview / shift-launcher | apps/carview, apps/launcher | Main runtime (carview_render + carview_hud + carview), native GUI launcher, and CLI tools. |