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.
2.5 KiB
2.5 KiB
2026-01-30 Camera Zoom and UI Cleanup
Changes Made
Camera System Improvements
- Extracted hardcoded camera control values to #define constants (CAMERA_ORBIT_ANGLE_SPEED, CAMERA_ZOOM_DELTA, CAMERA_MIN_DISTANCE, etc.)
- Implemented dynamic camera zoom with percentage-based speed (7% of current distance per keypress)
- Added delta clamping (ZOOM_MIN_DELTA 0.05, ZOOM_MAX_DELTA 5.0f) to prevent too-slow or too-fast zooming
- Fixed camera culling by accounting for raylib's near cull plane (0.05) in minimum distance calculation
- Camera minimum distance now uses max(average_children_distance, body_radius * 100) when children exist
- Camera minimum distance uses body_radius * 100 when no children exist (prevents clipping for bodies like Sun)
Camera Targeting Simplification
- Removed
selected_craft_indexfrom RenderState struct - camera now only tracks bodies - Moved spacecraft selection tracking to UIState struct (
selected_craft_indexfield) - Camera now always focuses on bodies (directly selected or parent of selected spacecraft)
- Eliminated ~30 lines of duplicate/special-case code from renderer module
- All renderer functions now use single body-focused code path
Bug Fixes
- Fixed camera distance when switching from Sun (large radius) to Earth (small radius) - camera no longer clips inside Earth
- Fixed spacecraft panel showing for 1 frame then disappearing -
ui_state.selected_craft_indexnow persists across frames instead of being reset
Commits
- Extract camera control constants to #define macros
- Implement dynamic camera zoom with percentage-based speed and distance clamping
- Fix camera culling by accounting for near cull plane in minimum distance calculation
- Simplify camera targeting by removing spacecraft selection from renderer
- Fix camera distance to account for body size when switching targets
- Fix spacecraft panel showing for 1 frame then disappearing
Results
- Net line count: -56 lines (44 insertions, 100 deletions)
- Files modified: 5 (src/renderer.cpp, src/renderer.h, src/ui_renderer.cpp, src/ui_renderer.h, src/main.cpp)
- Build status: Successful, no errors
- Test status: Camera zoom and minimum distance verified, spacecraft panel persistence confirmed
Next Steps
- Consider extracting remaining hardcoded rendering constants (grid parameters, spacecraft rendering, maneuver markers, orbit rendering, child indicators)
- Consider using parent's SOI radius instead of radius for more physically meaningful minimum distances