Browse Source

Rename bodies.h/cpp to simulation.h/cpp

- Renamed src/bodies.h to src/simulation.h
- Renamed src/bodies.cpp to src/simulation.cpp
- Updated all include references in src/ and tests/
- Updated Makefile to reference simulation.cpp
- Updated documentation references

Claude
main
cinnaboot 6 months ago
parent
commit
81e799c2ec
  1. 1
      CLAUDE.md
  2. 6
      Makefile
  3. 8
      docs/implementation_plan.md
  4. 4
      docs/session_summaries/2026-01-04-refactor-orbital-elements.md
  5. 2
      src/config_loader.h
  6. 2
      src/main.cpp
  7. 2
      src/physics.cpp
  8. 2
      src/renderer.h
  9. 2
      src/simulation.cpp
  10. 0
      src/simulation.h
  11. 2
      src/test_utilities.h
  12. 2
      tests/test_comet_orbit.cpp
  13. 2
      tests/test_energy.cpp
  14. 2
      tests/test_orbital_period.cpp

1
CLAUDE.md

@ -7,7 +7,6 @@
## 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) - Raylib (git submodule) for 3D - chose over SFML (no 3D support)
- See docs/verbose_project_overview.md for detailed technical architecture
- See docs/implementation_plan.md for data structures reference - See docs/implementation_plan.md for data structures reference
## Coding Rules ## Coding Rules

6
Makefile

@ -14,7 +14,7 @@ TEST_TARGET = orbit_test
# Source files # Source files
CPP_SOURCES = $(SRC_DIR)/main.cpp \ CPP_SOURCES = $(SRC_DIR)/main.cpp \
$(SRC_DIR)/physics.cpp \ $(SRC_DIR)/physics.cpp \
$(SRC_DIR)/bodies.cpp \ $(SRC_DIR)/simulation.cpp \
$(SRC_DIR)/config_loader.cpp \ $(SRC_DIR)/config_loader.cpp \
$(SRC_DIR)/renderer.cpp $(SRC_DIR)/renderer.cpp
@ -86,12 +86,12 @@ test-build:
$(CXX) $(CXXFLAGS) \ $(CXX) $(CXXFLAGS) \
-c $(SRC_DIR)/physics.cpp -o build/test_physics.o -c $(SRC_DIR)/physics.cpp -o build/test_physics.o
$(CXX) $(CXXFLAGS) \ $(CXX) $(CXXFLAGS) \
-c $(SRC_DIR)/bodies.cpp -o build/test_bodies.o -c $(SRC_DIR)/simulation.cpp -o build/test_simulation.o
$(CXX) $(CXXFLAGS) \ $(CXX) $(CXXFLAGS) \
-c $(SRC_DIR)/config_loader.cpp -o build/test_config_loader.o -c $(SRC_DIR)/config_loader.cpp -o build/test_config_loader.o
$(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src \ $(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src \
-c $(SRC_DIR)/../ext/tomlc17/src/tomlc17.c -o build/test_tomlc17.o -c $(SRC_DIR)/../ext/tomlc17/src/tomlc17.c -o build/test_tomlc17.o
$(CXX) build/test_main.o build/test_integration.o build/test_energy.o build/test_orbital_period.o build/test_comet_orbit.o build/test_utilities.o build/test_physics.o build/test_bodies.o build/test_config_loader.o build/test_tomlc17.o \ $(CXX) build/test_main.o build/test_integration.o build/test_energy.o build/test_orbital_period.o build/test_comet_orbit.o build/test_utilities.o build/test_physics.o build/test_simulation.o build/test_config_loader.o build/test_tomlc17.o \
-o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm -o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm
# Run automated test suite # Run automated test suite

8
docs/implementation_plan.md

@ -18,7 +18,7 @@ struct Vec3 {
}; };
``` ```
### CelestialBody (bodies.h) ### CelestialBody (simulation.h)
```cpp ```cpp
struct CelestialBody { struct CelestialBody {
char name[64]; char name[64];
@ -34,7 +34,7 @@ struct CelestialBody {
}; };
``` ```
### SimulationState (bodies.h) ### SimulationState (simulation.h)
```cpp ```cpp
struct SimulationState { struct SimulationState {
CelestialBody* bodies; CelestialBody* bodies;
@ -55,7 +55,7 @@ struct RenderState {
}; };
``` ```
### OrbitalElements (bodies.h) ### OrbitalElements (simulation.h)
```cpp ```cpp
struct OrbitalElements { struct OrbitalElements {
double time_days; double time_days;
@ -82,7 +82,7 @@ struct AccelerationContext {
### Physics (physics.cpp/h) ### Physics (physics.cpp/h)
Vector math and gravity calculations. RK4 (Runge-Kutta 4th order) integration with `rk4_step()`. Vector math and gravity calculations. RK4 (Runge-Kutta 4th order) integration with `rk4_step()`.
### Bodies (bodies.cpp/h) ### Simulation (simulation.cpp/h)
Simulation state management and updates. SOI detection using Hill sphere: `r_soi = a * (m/M)^(2/5)`. Simulation state management and updates. SOI detection using Hill sphere: `r_soi = a * (m/M)^(2/5)`.
**Key functions:** **Key functions:**

4
docs/session_summaries/2026-01-04-refactor-orbital-elements.md

@ -3,8 +3,8 @@
## Changes Made ## Changes Made
Refactored orbital elements calculation from test-specific to reusable code: Refactored orbital elements calculation from test-specific to reusable code:
- Moved `OrbitalElements` struct from test file to `src/bodies.h` - Moved `OrbitalElements` struct from test file to `src/simulation.h`
- Moved `calculate_orbital_elements()` function to `src/bodies.cpp` - Moved `calculate_orbital_elements()` function to `src/simulation.cpp`
- Created `tests/test_comet_orbit.cpp` with SOI transition tracking - Created `tests/test_comet_orbit.cpp` with SOI transition tracking
- Added `ParentChange` tracking to detect when comet switches gravitational parent - Added `ParentChange` tracking to detect when comet switches gravitational parent
- Removed `tests/test_soi_transitions.cpp` (not useful for detecting actual transitions) - Removed `tests/test_soi_transitions.cpp` (not useful for detecting actual transitions)

2
src/config_loader.h

@ -1,7 +1,7 @@
#ifndef CONFIG_LOADER_H #ifndef CONFIG_LOADER_H
#define CONFIG_LOADER_H #define CONFIG_LOADER_H
#include "bodies.h" #include "simulation.h"
#include "../ext/tomlc17/src/tomlc17.h" #include "../ext/tomlc17/src/tomlc17.h"
// Load a system configuration from a file (TOML format) // Load a system configuration from a file (TOML format)

2
src/main.cpp

@ -1,5 +1,5 @@
#include "physics.h" #include "physics.h"
#include "bodies.h" #include "simulation.h"
#include "config_loader.h" #include "config_loader.h"
#include "renderer.h" #include "renderer.h"
#include <cstdio> #include <cstdio>

2
src/physics.cpp

@ -1,5 +1,5 @@
#include "physics.h" #include "physics.h"
#include "bodies.h" #include "simulation.h"
#include <cmath> #include <cmath>
// Vector addition // Vector addition

2
src/renderer.h

@ -1,7 +1,7 @@
#ifndef RENDERER_H #ifndef RENDERER_H
#define RENDERER_H #define RENDERER_H
#include "bodies.h" #include "simulation.h"
#include "raylib.h" #include "raylib.h"
// Rendering state // Rendering state

2
src/bodies.cpp → src/simulation.cpp

@ -1,4 +1,4 @@
#include "bodies.h" #include "simulation.h"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <cstdio> #include <cstdio>

0
src/bodies.h → src/simulation.h

2
src/test_utilities.h

@ -1,7 +1,7 @@
#ifndef TEST_UTILITIES_H #ifndef TEST_UTILITIES_H
#define TEST_UTILITIES_H #define TEST_UTILITIES_H
#include "bodies.h" #include "simulation.h"
#include "physics.h" #include "physics.h"
struct OrbitalMetrics { struct OrbitalMetrics {

2
tests/test_comet_orbit.cpp

@ -1,6 +1,6 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "../src/physics.h" #include "../src/physics.h"
#include "../src/bodies.h" #include "../src/simulation.h"
#include "../src/config_loader.h" #include "../src/config_loader.h"
#include "../src/test_utilities.h" #include "../src/test_utilities.h"
#include <cmath> #include <cmath>

2
tests/test_energy.cpp

@ -1,6 +1,6 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "../src/physics.h" #include "../src/physics.h"
#include "../src/bodies.h" #include "../src/simulation.h"
#include "../src/config_loader.h" #include "../src/config_loader.h"
#include "../src/test_utilities.h" #include "../src/test_utilities.h"
#include <cmath> #include <cmath>

2
tests/test_orbital_period.cpp

@ -1,6 +1,6 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "../src/physics.h" #include "../src/physics.h"
#include "../src/bodies.h" #include "../src/simulation.h"
#include "../src/config_loader.h" #include "../src/config_loader.h"
#include "../src/test_utilities.h" #include "../src/test_utilities.h"
#include <cmath> #include <cmath>

Loading…
Cancel
Save