Skip to content

spnr.GameEngine.Entity.globalPosition is slow #1

@ThatCoolCoder

Description

@ThatCoolCoder

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIssue with performance/idea for improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions