How lokestrom/rocketsim-code works
Purpose and Entry Points
This is a C++23 desktop rigid-body/rocket simulation using SI units. The active application combines a threaded physics simulator with OpenGL rendering and Dear ImGui editing windows. Root build orchestration is in CMakeLists.txt; executable startup is Simulation/main.cpp, with runtime launch/control in Simulation/run.cpp and Simulation/run.hpp.
Application Lifecycle and UI
The OpenGL application owns windowing, frame processing, camera/render setup, and ImGui integration. Startup creates a launcher/new-simulation workflow; after creation, editor windows expose time controls, entities, rendering, and a test body-adder.
• Simulation/ui/openGL/OpenGLApp.cpp
• Simulation/ui/openGL/windows/startup/Launcher.cpp
• Simulation/ui/openGL/windows/editor/testAdder.cpp
Simulation Core
The ECS-oriented simulation owns entity state, registered component data, integration, and force generation. Its documented primary force is Newtonian universal gravitation, advanced with RK4. Simulation execution is separated from UI/rendering so physics can progress independently.
• Simulation/Simulation/ECS/Simulation.cpp
• Simulation/Simulation/ECS/Integrator.cpp
• Simulation/Simulation/ECS/forceGenerators.hpp
Entity and Physics Model
Entities provide the simulation-facing identity/state model; PhysicsBody represents rigid-body physical properties. Rocket-domain classes model composable rockets, stages, engines, tanks, fuel maps, and planets, allowing the same core simulation to support generic bodies and rocket assemblies.
• Simulation/Simulation/ECS/Entity.cpp
• Simulation/Simulation/Entities/PhysicsBody.cpp
• Simulation/rocket/Rocket.cpp
• Simulation/rocket/RocketStage.cpp
• Simulation/rocket/Engine.cpp
Threading, Commands, and Render Boundary
UI-side changes are placed through a command queue rather than directly mutating active simulation state. The simulation publishes state through a rendering cache; rendering consumes that cache asynchronously. Cache frame depth trades simulation throughput against how quickly newly added bodies become visible.
• Simulation/Simulation/CommandQueue.cpp
• Simulation/Simulation/RenderingCache.cpp
• Simulation/Simulation/Container.hpp
Rendering Pipeline
Rendering is OpenGL-based, using GLFW for window/context behavior, GLAD for API loading, GLM as an external math dependency, and bundled Dear ImGui for UI. Models, shaders, camera state, and render-object adapters translate cached simulation entities into GPU draw calls.
• Simulation/ui/openGL/OpenGLApp.hpp
• Simulation/ui/openGL/Model.cpp
• Simulation/ui/openGL/Shader.cpp
• Simulation/ui/openGL/RenderObjects/vector.cpp
Data, Assets, and Persistence Boundary
A filesystem layer loads simulation configuration and rocket instructions. Default text-based definitions provide settings, planets, rocket components, stages, and models; OBJ assets are used for visual meshes. This is input/config loading rather than a complete save/load workflow.
• Simulation/FileSystem/LoadManager.cpp
• Simulation/FileSystem/RocketInstructions.cpp
• Simulation/FileSystem/default/config/rocket/rocket/saturnv.txt
• Simulation/FileSystem/default/config/planet/earth.txt
Legacy Code
Old/ contains prior standalone flight simulations and a Vulkan renderer/UI implementation. It is not the current OpenGL application path; the README identifies Vulkan support only at a historical commit.
• Old/Vulkan/App.cpp
• Old/3dFullRocketSim/main.cpp
Components 23
Current Application
- CMake build
CMakeLists.txt - Executable startup
Simulation/main.cpp - Runtime control
Simulation/run.cpp
Simulation Core
- ECS simulation · Owns entities, component state, and simulation execution.
Simulation/Simulation/ECS/Simulation.cpp - RK4 integrator
Simulation/Simulation/ECS/Integrator.cpp - Force generators · Provides Newtonian universal gravitation.
Simulation/Simulation/ECS/forceGenerators.hpp - Entity model
Simulation/Simulation/ECS/Entity.cpp - Physics body
Simulation/Simulation/Entities/PhysicsBody.cpp - Command queue · Queues UI mutations for simulation-side application.
Simulation/Simulation/CommandQueue.cpp - Rendering cache · Buffers simulation snapshots for asynchronous rendering.
Simulation/Simulation/RenderingCache.cpp - Simulation container
Simulation/Simulation/Container.hpp - Rocket assembly · Composable rocket model.
Simulation/rocket/Rocket.cpp - Rocket stage
Simulation/rocket/RocketStage.cpp - Engine
Simulation/rocket/Engine.cpp
UI and Rendering
- OpenGL application · Owns windowing, frames, camera setup, and ImGui integration.
Simulation/ui/openGL/OpenGLApp.cpp - Launcher workflow
Simulation/ui/openGL/windows/startup/Launcher.cpp - Editor body adder
Simulation/ui/openGL/windows/editor/testAdder.cpp - OpenGL render pipeline · Adapts cached entities through models, shaders, and render objects into draw calls.
Simulation/ui/openGL/Model.cpp
Input Data
- Load manager · Loads simulation configuration and rocket instructions.
Simulation/FileSystem/LoadManager.cpp - Rocket instructions
Simulation/FileSystem/RocketInstructions.cpp - Default definitions · Provides default rocket and planet definitions.
Simulation/FileSystem/default/config/rocket/rocket/saturnv.txt
Legacy
Historical code outside the active application path.
- Legacy Vulkan app
Old/Vulkan/App.cpp - Legacy flight simulation
Old/3dFullRocketSim/main.cpp
Connections 22
- CMake build → Executable startup: builds
- Executable startup → Runtime control: starts
- Runtime control → OpenGL application: launches
- Runtime control → Simulation container: controls
- Simulation container → ECS simulation: runs independently
- ECS simulation → RK4 integrator: advances via
- RK4 integrator → Force generators: evaluates
- ECS simulation → Entity model: owns
- Entity model → Physics body: carries
- ECS simulation → Rendering cache: publishes snapshots
- OpenGL application → Launcher workflow: shows at startup
- OpenGL application → Editor body adder: hosts
- Editor body adder → Command queue: queues body changes
- Command queue → ECS simulation: applies mutations
- Rendering cache → OpenGL render pipeline: supplies render state
- OpenGL application → OpenGL render pipeline: drives frames
- Load manager → Rocket instructions: uses
- Rocket instructions → Default definitions: reads
- Load manager → ECS simulation: initializes
- Rocket assembly → Rocket stage: composes
- Rocket stage → Engine: contains
- Rocket assembly → Physics body: participates as