Browse Source

Initialize camera to follow root body on startup

main
cinnaboot 6 months ago
parent
commit
c3a46062d7
  1. 15
      src/main.cpp

15
src/main.cpp

@ -36,12 +36,21 @@ void run_gui_simulation(SimulationState* sim) {
RenderState render_state;
setup_camera(&render_state);
// Find root body (body with parent_index == -1)
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 UI state
render_state.selected_body_index = -1; // No selection initially
render_state.selected_body_index = root_body_index >= 0 ? root_body_index : -1;
render_state.previous_selected_body = -1; // Previous selected body index
render_state.body_list_scroll = 0; // Initial scroll position
render_state.body_list_active = -1; // No active item initially
render_state.camera_follow_body = false; // Camera not following initially
render_state.body_list_active = root_body_index >= 0 ? root_body_index : -1; // Sync with selected body
render_state.camera_follow_body = root_body_index >= 0; // Follow root body if found
render_state.camera_offset = (Vector3){ 0, 50, 100 }; // Default offset
render_state.was_following_body = false;

Loading…
Cancel
Save