Motorsport Telemetry & Physics Simulator
Executive Summary
This project is an interactive, low-level race simulation built from scratch in procedural C to model dynamic vehicle behavior, non-linear tire wear physics, and mass variation during high-speed stint execution. Designed as a systems-level exploration of real-time graphics and applied mathematics, the engine evaluates mathematical degradation curves across multi-lap sessions while streaming live performance metrics directly to a custom dashboard interface.
Leveraging pure C for tight memory control and Raylib for lightweight hardware-accelerated rendering, the engine operates on a fixed-timestep execution loop. By eliminating high-level garbage collection and managing state transitions through stack and heap memory structures, the application maintains a rock-solid 60+ FPS rendering pipeline while calculating continuous mathematical transformations frame-by-frame.
Architecture & Workflow
- Simulation Timestep & State Input: The execution loop captures discrete frame deltas, updating continuous simulation parameters including throttle, braking force, steering vectors, and track position state.
- Physics & Mathematical Evaluation Engine: Evaluates non-linear physics models, calculating dynamic linear mass reduction (fuel burn rate per kilometer) and compound grip loss using a cubic tire degradation mathematical curve.
- State Persistence & Stint Memory Management: Appends frame metrics and sector lap times into contiguous C struct arrays, storing historical telemetry snapshots for real-time comparative analysis.
- Telemetry Calculation & Metrics Pipeline: Aggregates raw vehicle telemetry into visual-ready data streams, computing real-time delta times, speed sweeps, compound wear percentages, and fuel-adjusted lap time estimates.
- Raylib Render Loop & Dashboard Draw Calls: Renders visual elements via a custom Raylib GUI layer, drawing live telemetry gauges, historical degradation curves, and real-time lap status on top of the simulation window with minimal CPU overhead.
Key Technical Challenges Resolved
Non-Linear Physics Modeling & Numerical Stability
Simulating realistic compound degradation required implementing a cubic decay function that accurately reflects the sharp cliff in grip loss typical of high-performance racing tires. Balancing these non-linear mathematical equations within a frame-rate-dependent update loop required decoupling the physics evaluation tick from the rendering cycle to prevent floating-point drift and numerical instability across varying frame rates.
Deterministic Memory Management & Frame-Budget Overhead
Continuous telemetry collection across hundreds of simulated laps introduced potential memory fragmentation and reallocation latency. By pre-allocating struct buffers on initialization and utilizing strict C pointer arithmetic, the application maintains zero heap allocations during the active simulation loop, eliminating garbage collection pauses and guaranteeing steady frame delivery under tight execution budgets.