From b9d325acd3b384a7fc798cf118c076654dd00d42 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Mon, 26 Jan 2026 09:42:59 -0500 Subject: [PATCH] feat: implement logarithmic radius scaling for body sizes - Changed scale_radius() from linear to logarithmic: scale * log10(radius) - Adjusted size_scale from 1e-9 to 0.02 for better visual hierarchy - Lowered min_radius from 0.5f to 0.01f for fine-grained visibility - Updated rendering documentation with new scaling values This handles extreme radius ranges (1.5M to 700M meters) while maintaining visible size differences between Sun, planets, and moons. --- docs/rendering.md | 13 ++++++++----- src/renderer.cpp | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/rendering.md b/docs/rendering.md index 55f06c3..47ee8ba 100644 --- a/docs/rendering.md +++ b/docs/rendering.md @@ -47,19 +47,22 @@ Vector3 sim_to_render(Vec3 pos, double scale) { - Optimized for solar system scale - Used for position transformations -**Size Scale:** `1e-9` (same as distance scale) -- Applied to body radii -- Minimum visible radius: 0.5 units (ensures tiny bodies are visible) +**Size Scale:** `0.02` (logarithmic radius scaling factor) +- Applied to body radii using logarithmic scaling +- Minimum visible radius: 0.01 units (ensures tiny bodies are visible) **Radius Scaling:** ```cpp float scale_radius(double radius, double scale) { - float scaled = (float)(radius * scale); - float min_radius = 0.5f; + float scaled = (float)(scale * log10(radius)); + float min_radius = 0.01f; return (scaled > min_radius) ? scaled : min_radius; } ``` +Uses logarithmic scaling to handle extreme radius ranges (1.5M to 700M meters). +Scale factor 0.02 produces: Sun ~0.18, planets 0.13-0.16, moons 0.12-0.13 render units. + ## Camera System ### Camera Setup diff --git a/src/renderer.cpp b/src/renderer.cpp index 230f817..acbdd63 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -87,7 +87,7 @@ void setup_camera(RenderState* render_state) { render_state->camera.projection = CAMERA_PERSPECTIVE; render_state->distance_scale = 1e-9; - render_state->size_scale = 1e-9; + render_state->size_scale = 0.02f; render_state->texture_loaded = false; render_state->spacecraft_texture = (Texture2D){0, 0, 0, 0, 0}; @@ -248,8 +248,8 @@ Vector3 sim_to_render(Vec3 pos, double scale) { // Scale a radius for rendering (with minimum visible size) float scale_radius(double radius, double scale) { - float scaled = (float)(radius * scale); - float min_radius = 0.5f; // Minimum visible radius + float scaled = (float)(scale * log10(radius)); + float min_radius = 0.01f; // Minimum visible radius return (scaled > min_radius) ? scaled : min_radius; }