diff --git a/src/renderer.cpp b/src/renderer.cpp index 17dc9fa..779a447 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -548,17 +548,32 @@ void render_body_info_ui(SimulationState* sim, RenderState* render_state) { strcat(info_text, "\n"); strcat(info_text, temp_buffer); - // Position - snprintf(temp_buffer, sizeof(temp_buffer), "Position: (%.2e, %.2e, %.2e)", - body->position.x, body->position.y, body->position.z); - strcat(info_text, "\n"); - strcat(info_text, temp_buffer); + if (body->parent_index <= 0) { + // Position + snprintf(temp_buffer, sizeof(temp_buffer), "Position: (%.2e, %.2e, %.2e)", + body->position.x, body->position.y, body->position.z); + strcat(info_text, "\n"); + strcat(info_text, temp_buffer); - // Velocity - double vel_mag = vec3_magnitude(body->velocity); - snprintf(temp_buffer, sizeof(temp_buffer), "Velocity: %.2f m/s", vel_mag); - strcat(info_text, "\n"); - strcat(info_text, temp_buffer); + // Velocity + double vel_mag = vec3_magnitude(body->velocity); + snprintf(temp_buffer, sizeof(temp_buffer), "Velocity: %.2f m/s", vel_mag); + strcat(info_text, "\n"); + strcat(info_text, temp_buffer); + } else { + // Position (Local) + snprintf(temp_buffer, sizeof(temp_buffer), "local_position: (%.2e, %.2e, %.2e)", + body->local_position.x, body->local_position.y, body->local_position.z); + strcat(info_text, "\n"); + strcat(info_text, temp_buffer); + + // Velocity (Local) + double parent_vel_mag = vec3_magnitude(sim->bodies[body->parent_index].velocity); + double vel_mag = vec3_magnitude(body->velocity) - parent_vel_mag; + snprintf(temp_buffer, sizeof(temp_buffer), "local_velocity: %.2f m/s", vel_mag); + strcat(info_text, "\n"); + strcat(info_text, temp_buffer); + } // Orbital elements snprintf(temp_buffer, sizeof(temp_buffer), "Eccentricity: %.3f", body->eccentricity);