MartinHowarth/shimmer

Performance of highly nested cocosnodes is terrible for mouse events

Opened this issue · 0 comments

The problem here is transforming from world to local coordinates. This currently does a matrix multiplication for every parent all the way up to the top. This is really slow.

A good example of this is the ResolutionDropDown menu - something that is highly nested because of using a viewport; and has many buttons (mouse event listeners) that all separately calculate the coordinate transform.

Specific solutions to fix this for specific classes is doable with caching, but a generic solution for all cocosnodes would be better. Some ideas (not mutually exclusive!):

  • #3 - hand out events based on position rather than tree to reduce effective number of listeners
  • Change cocos to use numpy matrices (written in C) rather than their homebrew.
  • Add ability to mark a node as "static" which means users can trigger a box to cache its world rect and use that. That means users can choose boxes which won't move and improve their performance.

The third option seems like it will provide the best bang for buck.