You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5.2 KiB
5.2 KiB
Session Summary: Config Display, Compiler Warnings, Orbit Rendering Fix, and Camera Initialization
Date
2026-01-18
Overview
Fixed multiple UI and rendering issues: added config file name display, resolved compiler warnings, corrected orbit rendering for nested bodies (moons), and initialized camera to follow root body on startup.
Key Features Implemented
1. Config File Name Display
- Added
char config_name[256]field toSimulationStatestruct - Config file path now stored when loaded via
load_system_config() - Displayed in simulation info panel under "Config:" label
- Eliminates hardcoded "solar_system.txt" reference
Before: Info panel always showed "solar_system.txt" regardless of actual config After: Shows actual loaded config path (e.g., "tests/configs/solar_system.toml")
2. Compiler Warning Fixes
- Removed unused
departure_periodvariable fromcalculate_hohmann_transfer() - Removed unused
sunvariable fromspawn_spacecraft_on_transfer() - Increased
temp_buffersize from 256 to 512 inrender_info()to prevent truncation warning
Result: Clean build with zero compiler warnings
3. Orbit Rendering Fix for Nested Bodies
- Changed
render_orbit()to uselocal_velocityinstead of globalvelocity - Critical fix for correct moon and satellite orbit paths
Technical Details:
- Planets:
local_velocity ≈ global_velocity(orbits around Sun) - Moons:
local_velocityis velocity relative to parent planet - Prior fix:
local_velocityused for physics integration, butglobal_velocityused for orbit rendering - Current fix: Both physics and rendering now use
local_velocity
Impact:
- Moon orbits now render correctly around their parent planets
- Future satellites will render correctly around moons
- Parabolic and hyperbolic orbit types also fixed
4. Camera Initialization on Root Body
- Camera now automatically selects root body (star) on startup
- Camera follow mode enabled by default for root body
body_list_activesynchronized withselected_body_index- Default camera offset (0, 50, 100) applied relative to root body
Before: No body selected, camera in neutral position After: Camera follows root body (e.g., Sun) immediately on startup
Technical Details
SimulationState Structure Changes
struct SimulationState {
CelestialBody* bodies;
int body_count;
int max_bodies;
double time;
double dt;
char config_name[256]; // NEW: name of the config file loaded
};
Config Loading
// In load_system_config()
strncpy(sim->config_name, filepath, sizeof(sim->config_name) - 1);
sim->config_name[sizeof(sim->config_name) - 1] = '\0';
Orbit Rendering Fix
// Before (incorrect for moons)
Vec3 r_vec = vec3_sub(body->position, parent->position);
double v = vec3_magnitude(body->velocity); // Global velocity
double r_dot_v = r_vec.x * body->velocity.x + ...
// After (correct for all bodies)
Vec3 r_vec = vec3_sub(body->position, parent->position);
Vec3 v_vec = body->local_velocity; // Local velocity relative to parent
double v = vec3_magnitude(v_vec);
double r_dot_v = r_vec.x * v_vec.x + ...
Camera Initialization
// Find root body
int root_body_index = -1;
for (int i = 0; i < sim->body_count; i++) {
if (sim->bodies[i].parent_index == -1) {
root_body_index = i;
break;
}
}
// Initialize with root body selected
render_state.selected_body_index = root_body_index >= 0 ? root_body_index : -1;
render_state.body_list_active = root_body_index >= 0 ? root_body_index : -1;
render_state.camera_follow_body = root_body_index >= 0;
Files Modified
Core Implementation
src/simulation.h- Addedconfig_namefield toSimulationStatesrc/simulation.cpp- Initializeconfig_nameto empty string increate_simulation()src/config_loader.cpp- Store config filepath insim->config_namesrc/renderer.h- Removedconfig_nameparameter fromrender_info()src/renderer.cpp- Display config name, uselocal_velocityfor orbit rendering, increase buffer sizesrc/main.cpp- Find root body and initialize camera selection/follow state
Commits Summary
c4262ab- Store and display config file name in simulation state8f60ba5- Fix compiler warnings: remove unused variables, increase buffer size8278cb0- Fix orbit rendering to use local_velocity for nested orbitsc3a4606- Initialize camera to follow root body on startup
Testing Status
All changes compiled and tested:
- ✅ Config file name displayed correctly in UI
- ✅ Zero compiler warnings in full rebuild
- ✅ Moon orbit paths render correctly around parent planets
- ✅ Planet orbit paths remain correct
- ✅ Camera follows root body on startup
- ✅ Tests pass (23/24, with 1 pre-existing Hohmann transfer test failure)
Branch Status
Working branch: main
Clean working tree ready for next session.
Future Enhancements
Potential Improvements
- Visual highlighting of selected body in 3D view
- Camera focus indicator (show which body is being followed)
- Search/filter functionality in body list
- Reference frame switching (view from body's perspective)
Bug Follow-ups
- Investigate Hohmann transfer test failure (energy drift > 200%)