Compare commits

..

No commits in common. '2205b1b202c1fad7349fc06a06f64e75c1f23477' and 'eade44a245409a337ccdf0bfdff8f67c0d5aff10' have entirely different histories.

  1. 10
      .gitmodules
  2. 9
      AGENTS.md
  3. 78
      Makefile
  4. 16
      README.md
  5. 3
      docs/TODO
  6. 23
      docs/technical_reference.md
  7. 42
      example/Makefile
  8. 1
      example/ext/raygui
  9. 1
      example/ext/raylib
  10. 1
      ext/raygui
  11. 1
      ext/raylib
  12. 0
      src/main.cpp
  13. 0
      src/renderer.cpp
  14. 0
      src/renderer.h
  15. 2
      src/ui_renderer.cpp
  16. 0
      src/ui_renderer.h

10
.gitmodules vendored

@ -1,9 +1,9 @@
[submodule "ext/raylib"]
path = ext/raylib
url = https://github.com/raysan5/raylib.git
[submodule "ext/tomlc17"]
path = ext/tomlc17
url = https://github.com/cktan/tomlc17
[submodule "example/ext/raylib"]
path = example/ext/raylib
url = https://github.com/raysan5/raylib.git
[submodule "example/ext/raygui"]
path = example/ext/raygui
[submodule "ext/raygui"]
path = ext/raygui
url = https://github.com/raysan5/raygui.git

9
AGENTS.md

@ -6,8 +6,7 @@
## Architecture
- C-style C++ (structs/functions, NO classes/templates)
- Core library (`liborbit.a`) in `src/` — simulation, physics, maneuvers, config
- Visualizer in `example/src/` — Raylib/raygui rendering (moved from core)
- Raylib (git submodule) for 3D - chose over SFML (no 3D support)
- See docs/technical_reference.md for data structures reference
- See docs/rendering.md for rendering system reference
@ -43,9 +42,7 @@
- Always ask the user if we want to update the technical_reference after generating a summary
## Common Commands
- Build all (lib + tests + visualizer): make
- Build library only: make lib
- Build visualizer example: make example
- Build: make
- Test (build + run all): make test
- Test (rebuild only): make test-build
- Test (specific tag): ./build/orbit_test '[tag_name]'
@ -54,7 +51,7 @@
- See docs/technical_reference.md for full build target reference
## Simulation
The core simulation library is built at `build/liborbit.a`. The visualizer binary is at `./build/orbit_sim`. Agents should NOT attempt to run the graphical simulation. Focus on testing and code changes only.
The simulation binary is built at `./build/orbit_sim`. Agents should NOT attempt to run the graphical simulation. Focus on testing and code changes only.
## Testing Guidelines
- Always use `WithinAbs()` for floating-point comparisons

78
Makefile

@ -1,57 +1,87 @@
# Compiler and flags
CXX = g++
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
-I./src \
-isystem./ext/tomlc17/src
LDFLAGS = -lm
-isystem./ext/tomlc17/src \
-isystem./ext/raylib/src \
-isystem./ext/raygui/src \
-isystem./ext/raygui/styles
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11
# Directories
SRC_DIR = src
BUILD_DIR ?= build
RAYLIB_DIR = ext/raylib/src
TARGET = ${BUILD_DIR}/orbit_sim
TEST_DIR = tests
TEST_TARGET = ${BUILD_DIR}/orbit_test
# Source files (exclude old mission planning files)
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
C_SOURCES = ext/tomlc17/src/tomlc17.c
TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp)
# Object files
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
C_OBJECTS = $(BUILD_DIR)/tomlc17.o
TEST_OBJECTS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SOURCES))
LIBRARY = $(BUILD_DIR)/liborbit.a
# Default target (updates ctags if available)
all: raylib $(BUILD_DIR) $(TARGET)
@command -v ctags >/dev/null 2>&1 && ctags -R tests/ src/ || true
all: lib test-build example
# Build raylib
raylib:
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \
echo "Building raylib..."; \
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \
fi
# Create build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Link the executable
$(TARGET): $(C_OBJECTS) $(CPP_OBJECTS) raylib
$(CXX) $(C_OBJECTS) $(CPP_OBJECTS) -o $(TARGET) $(LDFLAGS)
# Compile C++ source files
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Compile C source files
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(C_SOURCES)
$(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src -c $< -o $@
lib: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS)
ar rcs $(LIBRARY) $(C_OBJECTS) $(CPP_OBJECTS)
@echo "Built $(LIBRARY)"
$(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
test-build: lib $(BUILD_DIR) $(TEST_OBJECTS)
$(CXX) $(TEST_OBJECTS) -o $(BUILD_DIR)/orbit_test -L$(BUILD_DIR) -lorbit -lCatch2Main -lCatch2 -lm
test: test-build
./$(BUILD_DIR)/orbit_test
example: lib
$(MAKE) -C example all BUILD_DIR=../$(BUILD_DIR)
# Clean build files
clean:
rm -rf $(BUILD_DIR) $(LIBRARY)
$(MAKE) -C example clean
rm -rf $(BUILD_DIR) $(TARGET) $(TEST_TARGET)
# Clean everything including raylib
clean-all: clean
$(MAKE) -C example clean-all
cd $(RAYLIB_DIR) && $(MAKE) clean
# Rebuild
rebuild: clean all
.PHONY: all lib test-build test example clean clean-all rebuild
$(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Build automated test suite
test-build: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS) $(TEST_OBJECTS)
$(CXX) $(C_OBJECTS) $(TEST_OBJECTS) \
build/test_utilities.o \
build/physics.o \
build/orbital_mechanics.o \
build/simulation.o \
build/config_loader.o \
build/config_validator.o \
build/maneuver.o \
build/rendezvous.o \
-o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm
# Run automated test suite
test: test-build
./$(TEST_TARGET)
.PHONY: all clean clean-all rebuild test test-build raylib ctags

16
README.md

@ -17,8 +17,6 @@ cd claudes_game
git submodule update --init --recursive # If already cloned without --recursive
```
This initializes submodules in both `ext/` (tomlc17) and `example/ext/` (raylib, raygui).
### Dependencies (Debian 13)
```bash
@ -31,23 +29,17 @@ sudo apt install -y build-essential g++ make libx11-dev libxcursor-dev \
### Building
```bash
make # Build library (liborbit.a), tests, and visualizer example
make lib # Build library only
make example # Build visualizer only
make rebuild # Clean and rebuild all
make clean-all # Clean everything
make # Build raylib (first time) and compile sources
make rebuild # Clean and rebuild
make clean-all # Clean everything including raylib
```
The visualizer (`./build/orbit_sim`) links against the core simulation library.
## Running
```bash
./build/orbit_sim # Run visualizer with default config
./orbit_sim # Run with the default solar system configuration
```
Pass a config file as argument: `./build/orbit_sim tests/test_moon_orbits.toml`
## Documentation
- **[Technical Reference](docs/technical_reference.md)** - Data structures and module overview

3
docs/TODO

@ -10,6 +10,9 @@ If you see modifications to this file in git status, IGNORE them and do not comm
- SOI boundary testing
- draw SOI boundry in graphical sim
- reorganize project into static library. easier for testing/llm doc generation,
and will be easier to try out new graphics/UI libraries
- can then better work on code cleaning issues, FIXMEs etc
- remove tests/informational/*
- remove RK4 integration implementation?
- refactor tests and check logic for edge cases

23
docs/technical_reference.md

@ -2,20 +2,20 @@
## Overview
2-body orbital mechanics simulator using **analytical propagation** for precise Keplerian trajectories. Supports elliptical, parabolic, and hyperbolic orbits with dynamic Sphere of Influence (SOI) transitions and impulsive burns. 3D visualization via Raylib is provided as a separate example project in `example/`.
2-body orbital mechanics simulator using **analytical propagation** for precise Keplerian trajectories. Supports elliptical, parabolic, and hyperbolic orbits with dynamic Sphere of Influence (SOI) transitions, impulsive burns, and 3D visualization via Raylib.
## Architecture
Modular C-style C++ (structs/functions, no classes). Module dependencies:
```
Core Library → Simulation → Orbital Mechanics → Physics
Main → Simulation → Orbital Mechanics → Physics
→ Maneuver
→ Rendezvous
→ Config Loader
```
The core library (`liborbit.a`) contains all simulation code. 3D rendering (Raylib/raygui) is in `example/src/`. Test Utilities are standalone.
Renderer and UI Renderer depend on Config Loader for display data. Test Utilities are standalone.
## Coordinate Frame System
@ -250,22 +250,9 @@ All satisfy vis-viva: v² = μ(2/r - 1/a).
## Build System
The project is split into a core simulation library and a visualizer example.
**Targets**: make / make all (build + ctags), make raylib, make test, make test-build, make clean, make clean-all, make rebuild.
**Root Makefile** (simulation library + tests):
- `make all` — build library, tests, and example (default)
- `make lib` — build `build/liborbit.a` static library
- `make test` — build and run all tests
- `make test-build` — rebuild test executable only
- `make clean` — clean build artifacts
- `make clean-all` — clean everything including example
- `make rebuild` — clean and rebuild all
**Example Makefile** (visualizer):
- `make all` — build `build/orbit_sim` (recursive from root via `make example`)
- `make clean` — clean example build artifacts
**Dependencies**: g++ (C++14), tomlc17 (root submodule), Catch2 (tests only). Raylib/raygui are in `example/ext/` submodules.
**Dependencies**: g++ (C++14), raylib (git submodule), raygui (header-only), tomlc17, Catch2 (tests only).
**Testing**:
```bash

42
example/Makefile

@ -1,42 +0,0 @@
CXX = g++
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \
-I./src \
-I../src \
-isystem./ext/raylib/src \
-isystem./ext/raygui/src \
-isystem./ext/raygui/styles
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11
SRC_DIR = src
BUILD_DIR ?= build
RAYLIB_DIR = ext/raylib/src
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
TARGET = ${BUILD_DIR}/orbit_sim
raylib:
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \
fi
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(TARGET): $(CPP_OBJECTS) raylib
$(CXX) $(CPP_OBJECTS) -o $(TARGET) -L$(BUILD_DIR) -lorbit $(LDFLAGS)
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f $(TARGET)
@for f in $(CPP_SOURCES); do rm -f $(BUILD_DIR)/$$(basename $${f%.cpp}.o); done
rebuild: clean all
all: raylib $(BUILD_DIR) $(TARGET)
.PHONY: all clean raylib rebuild

1
example/ext/raygui

@ -1 +0,0 @@
Subproject commit 3b2855842ab578a034f827c38cf8f62c042fc983

1
example/ext/raylib

@ -1 +0,0 @@
Subproject commit 72a341a37fbd9ccc1d8ec284ff20aeb5b991ad75

1
ext/raygui

@ -0,0 +1 @@
Subproject commit 9a1c183d8539e2470635b22f92bdaefaf5218aaa

1
ext/raylib

@ -0,0 +1 @@
Subproject commit ca89934ed5af9161f781a9b35b808b765dc40f3a

0
example/src/main.cpp → src/main.cpp

0
example/src/renderer.cpp → src/renderer.cpp

0
example/src/renderer.h → src/renderer.h

2
example/src/ui_renderer.cpp → src/ui_renderer.cpp

@ -1045,7 +1045,7 @@ void render_maneuver_dialog(SimulationState* sim, RenderState* render_state, UIS
return;
}
char* tabs[] = {(char*)"Create Maneuver", (char*)"Hohmann Transfer", (char*)"Edit Maneuver"};
const char* tabs[] = {"Create Maneuver", "Hohmann Transfer", "Edit Maneuver"};
int tab_count = 3;
Rectangle tab_bounds = {x + 8, y + 30, width - 16, 25};
GuiTabBar(tab_bounds, tabs, tab_count, (int*)&ui_state->maneuver_dialog.active_tab);

0
example/src/ui_renderer.h → src/ui_renderer.h

Loading…
Cancel
Save