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.
3.1 KiB
3.1 KiB
2025-02-06-ui-buffer-caching-optimization
Changes Made
Commit 1: 79a972a - Fix GuiDropdownBox behavior with static edit mode variables
- Fixed 7 dropdown controls that were incorrectly sharing edit mode variables
- Each dropdown now has its own static
editModevariable - Affected controls: orbit type, body/craft selection, burn direction, trigger type
- Updated maneuver dialog progress documentation
Commit 2: b37497a - Implement UIState buffer caching to eliminate per-frame malloc/free calls
- Implemented comprehensive buffer caching system in UIState
- Cached 4 buffer types:
- Body names list (for object selection dropdown)
- Spacecraft names list (for object selection dropdown)
- Maneuver names list (for maneuver info display)
- Maneuver status strings list
- Added
needs_updateflags for each cached buffer - Added
last_countsto track when buffers need invalidation - Eliminated all per-frame malloc/free calls in ui_render_info_panel_objects()
- Eliminated all per-frame malloc/free calls in ui_render_info_panel_selected()
- Integrated cache invalidation into main loop and maneuver execution
Commit 3: 028b8a8 - Fix UI buffer caching: remove dead code, use count-based invalidation, fix update bug
- Removed dead code from simulation.cpp/h (52 lines removed, 16 lines from header)
- Simplified invalidation logic: removed
buffer_validflag in favor of count-based checks - Fixed bug where maneuver status cache was not being updated after maneuver execution
- Separated concerns: ui_renderer handles UI cache, simulation module no longer has UI code
Commit 4: c76380f - Fix UI: maneuver status updates, ZII initialization, helper functions for cache checks
- Fixed maneuver status update bug: status strings now properly update after execution
- Fixed ZII initialization in ui_render_info_panel_selected: all state variables now use
= {0} - Added helper functions:
check_needs_update_simcount()- checks if cache needs update based on body countcheck_needs_update_craftcount()- checks if cache needs update based on craft countcheck_needs_update_maneuvercount()- checks if cache needs update based on maneuver count
- Refactored buffer update logic to use helper functions for clarity
- Updated AGENTS.md with command reference for testing
Results
Net line count changes:
- Insertions: 322
- Deletions: 179
- Net: +143 lines
Functionality Implemented
Buffer Caching System
- Dynamic array allocation only when counts change
- Automatic cache invalidation based on body/craft/maneuver counts
- Helper functions for count-based cache invalidation checks
- Integration points:
main_loop()- invalidates caches before renderingexecute_maneuver()- invalidates maneuver cache after execution
UI Improvements
- Fixed all dropdown controls with static edit mode variables
- Proper separation of concerns between UI and simulation modules
- Cleaner, more maintainable cache update logic
Code Quality
- ZII (Zero Is Initialization) pattern applied to UIState
- Removed 52 lines of dead code from simulation module
- Better code organization with helper functions