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.
4.8 KiB
4.8 KiB
Rendering Cleanup Plan - Texture Management and Code Simplification
Objective
Clean up rendering code by removing unused spacecraft texture system, consolidating texture loading to initialization, and simplifying other rendering functions.
Background
The renderer has several inefficiencies:
ensure_textures_loaded()called every frame instead of once during initialization- Spacecraft texture system now redundant with
render_child_indicators()providing visibility - Unused
render_body()function with FIXME comment - Hardcoded constants scattered throughout rendering code
- Documentation inconsistency between RenderState and UIState
Implementation
Step 1: Save Plan (Current)
- Create this plan document in docs/planning/
- PAUSE for user review
Step 2: Move Texture Loading to Initialization [COMPLETED]
- Modify
init_renderer()orsetup_camera()to callensure_textures_loaded()once - Remove
ensure_textures_loaded()calls from:render_spacecraft_screen_space()(renderer.cpp:385)render_maneuver_marker_screen_space()(renderer.cpp:420)
- Update docs/technical_reference.md if it references texture loading behavior
- PAUSE for user review
Step 3: Remove Spacecraft Texture System [COMPLETED]
Remove all spacecraft texture-related code:
- From RenderState struct (renderer.h:19):
Texture2D spacecraft_texture; - From renderer.cpp:
generate_spacecraft_texture()function (lines 112-124)calculate_spacecraft_angle()function (lines 156-164)render_spacecraft_screen_space()function (lines 373-402)- Texture initialization in
setup_camera()(line 178) - Texture unloading in
close_renderer()(line 103)
- Remove spacecraft rendering from main loop in
render_simulation()(lines 694-697) - Remove from renderer.h:
- Function declaration for
generate_spacecraft_texture()(line 29) - Function declaration for
calculate_spacecraft_angle()(line 36) - Function declaration for
render_spacecraft_screen_space()(line 45)
- Function declaration for
- Update docs/rendering.md to remove spacecraft texture references
- PAUSE for user review
Step 4: Remove Unused render_body() Function [COMPLETED]
- Remove
render_body()function from renderer.cpp (lines 359-371) - Remove function declaration from renderer.h (line 44)
- Remove FIXME comment on line 357
- Update docs/rendering.md line 315 (references to render_body)
- Update docs/technical_reference.md line 531 (references to render_body)
- PAUSE for user review
Step 5: Simplify Maneuver Texture Selection [COMPLETED]
- Replace switch statement (renderer.cpp:426-449) with direct array indexing
- Since BurnDirection enum values are sequential (0-5), use
maneuver->directiondirectly as texture_index - Handle BURN_CUSTOM case separately if needed
- PAUSE for user review
Step 6: Extract UI Panel Constants [COMPLETED]
- Add constants to ui_renderer.cpp:
INFO_PANEL_WIDTH = 300INFO_PANEL_HEIGHT = 300BODY_LIST_WIDTH = 200BODY_LIST_HEIGHT = 400BODY_INFO_WIDTH = 250BODY_INFO_HEIGHT = 300MANEUVER_LIST_WIDTH = 300MANEUVER_LIST_HEIGHT = 400MANEUVER_LIST_Y_OFFSET = 320
- Replace magic numbers in all UI rendering functions
- PAUSE for user review
Step 7: Extract Child Indicator Constants [COMPLETED]
- Add constants to renderer.cpp:
CHILD_INDICATOR_RADIUS = 20.0fCHILD_INDICATOR_FONT_SIZE = 10
- Replace magic numbers in
draw_child_indicator()function - PAUSE for user review
Step 8: Fix Documentation Inconsistency [COMPLETED]
- Update docs/rendering.md line 16 to reflect that
selected_craft_indexis in UIState, not RenderState - Update any other documentation that references this field location
- PAUSE for user review
Step 9: Final Testing [COMPLETED]
- Build project:
make- Build successful - Run simulation:
make run- Application starts correctly, no texture errors - Verify spacecraft still visible via child indicators - Child indicators working
- Verify maneuver markers still render correctly - Texture indexing working
- Verify UI panels still display correctly - Panel constants working
- Check for any texture-related warnings or errors - None found
- PAUSE for user review
Testing Plan
- Build succeeds without errors
- Spacecraft visible in child indicators when parent body selected
- Maneuver markers display with correct colors and sizes
- UI panels render with correct dimensions
- No memory leaks from texture cleanup
- Performance improvement (fewer function calls per frame)
References
- docs/rendering.md - Rendering system documentation
- docs/technical_reference.md - Technical reference
- src/renderer.cpp/h - Main rendering code
- src/ui_renderer.cpp/h - UI rendering code
- AGENTS.md - Coding rules (no comments, C-style)
Date
Created: 2026-01-30