Calling the recursive getter spnr.GameEngine.Entity.globalPosition is very slow, even for relatively shallow hierarchies.
To speed it up, I suggest a caching system. When globalPosition is called, it returns a cached value. Every time an Entity is moved, it tells all of its children to clear their caches and recalculate. Tests with a simple version of this have give substantial speed boosts, such as improving FPS from 10 to 30. This would be extremely beneficial in situations with lots of DrawableEntitys as they call globalPosition once each frame to update their sprite.
The same could also be applied to spnr.GameEngine.Entity.getGlobalAngle.
Calling the recursive getter
spnr.GameEngine.Entity.globalPositionis very slow, even for relatively shallow hierarchies.To speed it up, I suggest a caching system. When
globalPositionis called, it returns a cached value. Every time an Entity is moved, it tells all of its children to clear their caches and recalculate. Tests with a simple version of this have give substantial speed boosts, such as improving FPS from 10 to 30. This would be extremely beneficial in situations with lots ofDrawableEntitys as they callglobalPositiononce each frame to update their sprite.The same could also be applied to
spnr.GameEngine.Entity.getGlobalAngle.