Browse Source

Fix render scaling to match simulation coordinates

🤖 Generated with Claude Code - Co-Authored-By: Claude Sonnet 4.5
main
cinnaboot 6 months ago
parent
commit
4e2f00a581
  1. 19
      src/renderer.cpp

19
src/renderer.cpp

@ -22,9 +22,9 @@ void setup_camera(RenderState* render_state) {
render_state->camera.fovy = 45.0f; render_state->camera.fovy = 45.0f;
render_state->camera.projection = CAMERA_PERSPECTIVE; render_state->camera.projection = CAMERA_PERSPECTIVE;
// Set scaling factors // Set scaling factors (same scale for distances and sizes)
render_state->distance_scale = 1e-9; // Meters to scaled units (1 unit = 1 billion meters) render_state->distance_scale = 1e-9; // Meters to scaled units (1 unit = 1 billion meters)
render_state->size_scale = 5e-7; // Make bodies visible render_state->size_scale = 1e-9; // Same scale for body sizes (minimum size still applies)
render_state->show_info = true; render_state->show_info = true;
} }
@ -92,19 +92,10 @@ void render_body(CelestialBody* body, RenderState* render_state) {
Vector3 position = sim_to_render(body->position, render_state->distance_scale); Vector3 position = sim_to_render(body->position, render_state->distance_scale);
float radius = scale_radius(body->radius, render_state->size_scale); float radius = scale_radius(body->radius, render_state->size_scale);
float r = body->color[0];
float g = body->color[1];
float b = body->color[2];
if (body->parent_index == -1) {
float gray = (r + g + b) / 3.0f * 0.3f;
r = g = b = gray;
}
Color color = { Color color = {
(unsigned char)(r * 255), (unsigned char)(body->color[0] * 255),
(unsigned char)(g * 255), (unsigned char)(body->color[1] * 255),
(unsigned char)(b * 255), (unsigned char)(body->color[2] * 255),
255 255
}; };

Loading…
Cancel
Save