Compare commits

...

3 Commits

Author SHA1 Message Date
cinnaboot 2205b1b202 Update docs for library/visualizer split 3 months ago
cinnaboot d694f508dc update manual TODO 3 months ago
cinnaboot e8167a90f5 Split visualizer into example/ sub-project 3 months ago
  1. 10
      .gitmodules
  2. 9
      AGENTS.md
  3. 78
      Makefile
  4. 16
      README.md
  5. 3
      docs/TODO
  6. 29
      docs/technical_reference.md
  7. 42
      example/Makefile
  8. 1
      example/ext/raygui
  9. 1
      example/ext/raylib
  10. 0
      example/src/main.cpp
  11. 0
      example/src/renderer.cpp
  12. 0
      example/src/renderer.h
  13. 2
      example/src/ui_renderer.cpp
  14. 0
      example/src/ui_renderer.h
  15. 1
      ext/raygui
  16. 1
      ext/raylib

10
.gitmodules vendored

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

9
AGENTS.md

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

78
Makefile

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

16
README.md

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

3
docs/TODO

@ -10,9 +10,6 @@ If you see modifications to this file in git status, IGNORE them and do not comm
- SOI boundary testing - SOI boundary testing
- draw SOI boundry in graphical sim - 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 tests/informational/*
- remove RK4 integration implementation? - remove RK4 integration implementation?
- refactor tests and check logic for edge cases - refactor tests and check logic for edge cases

29
docs/technical_reference.md

@ -2,20 +2,20 @@
## Overview ## 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, impulsive burns, and 3D visualization via Raylib. 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/`.
## Architecture ## Architecture
Modular C-style C++ (structs/functions, no classes). Module dependencies: Modular C-style C++ (structs/functions, no classes). Module dependencies:
``` ```
Main → Simulation → Orbital Mechanics → Physics Core Library → Simulation → Orbital Mechanics → Physics
→ Maneuver → Maneuver
→ Rendezvous → Rendezvous
→ Config Loader → Config Loader
``` ```
Renderer and UI Renderer depend on Config Loader for display data. Test Utilities are standalone. The core library (`liborbit.a`) contains all simulation code. 3D rendering (Raylib/raygui) is in `example/src/`. Test Utilities are standalone.
## Coordinate Frame System ## Coordinate Frame System
@ -250,9 +250,22 @@ All satisfy vis-viva: v² = μ(2/r - 1/a).
## Build System ## Build System
**Targets**: make / make all (build + ctags), make raylib, make test, make test-build, make clean, make clean-all, make rebuild. The project is split into a core simulation library and a visualizer example.
**Dependencies**: g++ (C++14), raylib (git submodule), raygui (header-only), tomlc17, Catch2 (tests only). **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.
**Testing**: **Testing**:
```bash ```bash

42
example/Makefile

@ -0,0 +1,42 @@
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

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

1
example/ext/raylib

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

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

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

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

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

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

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

1
ext/raygui

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

1
ext/raylib

@ -1 +0,0 @@
Subproject commit ca89934ed5af9161f781a9b35b808b765dc40f3a
Loading…
Cancel
Save