Skip to content

Optimize matrix recomputation #3544

@ACrazyTown

Description

@ACrazyTown

See my original comments for a more detailed explanation: #2978 (comment), #2978 (comment)

TL;DR: Matrix recalculations every frame, per sprite, take up a significant chunk of time in the draw() call (~60%), which can get problematic with many sprites displayed

I've played around with it a bit, and with some tricks I've managed to shave down the time taken by around ~90%. It's quite hacky though: ACrazyTown@fda8f29. I've managed to do so by querying the screen position only once per draw() (with a helper point) instead of twice in both isOnScreen() and prepareComplexMatrix(), and avoiding various FlxPoint helper methods and getters/setters.

What I haven't played around with is recalculating the matrix on demand, i.e. only doing it when the sprite is moved or rotated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions