UIGrid: don't attempt to render every Entity every frame #52

Open
opened 2024-03-09 20:00:32 +00:00 by john · 1 comment
Owner

12 refactor: UIGrid should skip entities that are not in bounds [Depends on next feature and the feature after that]

Depends on:

  • #10, visibility functionality on UIDrawable base class
  • #51, derive UIEntity from UIDrawable
12 refactor: UIGrid should skip entities that are not in bounds \[Depends on next feature and the feature after that] Depends on: * #10, visibility functionality on UIDrawable base class * #51, derive UIEntity from UIDrawable
john added the
Tiny Feature
label 2024-03-09 20:00:32 +00:00
Author
Owner

Desirable behavior in conjunction with #63 (Z-order):

Entities are a list of shared pointers. Can use something like partial_sort_copy to go through the list to sort (based on Z-order) into a vector.

But at the risk of prematurely optimizing, we could use a sort method that:

  • ignores visible() == false entities

  • filters out of render bounds entities

  • yoinks the sprites to draw out of the UIEntity objects, and just holds on to sprite and on-grid render coordinates

  • Possibly: Cache this rendering vector until it's invalidated by changes to center_x, center_y, zoom, or the cached entities.

problems with caching:

  • how to track what entities are visibly on-grid? Maybe we can't copy coordinate data, and just have to keep pointers to them (so they can move themselves)?
  • what if another entity moves into view?
  • changes to center_x, center_y or zoom would always invalidate the cache
  • It may not be worth the optimization of tracking all entity motion just to provide this
  • for high entity count experiments, a quadtree is a possibility
Desirable behavior in conjunction with #63 (Z-order): Entities are a list of shared pointers. Can use something like [partial_sort_copy](https://en.cppreference.com/w/cpp/algorithm/partial_sort_copy) to go through the list to sort (based on Z-order) into a vector. But at the risk of prematurely optimizing, we could use a sort method that: * ignores `visible() == false` entities * filters out of render bounds entities * yoinks the sprites to draw out of the UIEntity objects, and just holds on to sprite and on-grid render coordinates * *Possibly*: Cache this rendering vector until it's invalidated by changes to center_x, center_y, zoom, or the cached entities. problems with caching: * how to track what entities are visibly on-grid? Maybe we can't copy coordinate data, and just have to keep pointers to them (so they can move themselves)? * what if another entity moves into view? * changes to center_x, center_y or zoom would always invalidate the cache * It may not be worth the optimization of tracking all entity motion just to provide this * for high entity count experiments, a quadtree is a possibility
john added this to the Alpha Release Targets milestone 2024-03-13 14:45:21 +00:00
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: john/McRogueFace#52
No description provided.