Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scratch spends a fair bit of time in getFencedPosition, can it be faster? #365

Open
mzgoddard opened this issue Oct 29, 2018 · 0 comments
Open

Comments

@mzgoddard
Copy link
Contributor

Scratch projects change the positions of their sprites very regularly. Since Scratch keeps Sprites within the visible bounds of the rendered stage, getFencedPositionOfDrawable is called for every position change.

There are a few things that could be changed to possibly speed up getFencedPositionOfDrawable.

  • getFencedPositionOfDrawable in the convex hull points path creates approximately 8 objects (assuming the hull has 3 points). Most or all of these could use preexisting or cached objects reduce object creation and garbage collection.
  • getFencedPositionOfDrawable in the aabb path creates 10 objects.
  • getFastBounds could just ensure u_modelMatrix is up to date instead of both it and _inverseMatrix. (In fact both getBounds and getAABB already make sure that u_modelMatrix is up to date.)
  • getFastBounds could be assigned to getBounds or getAabb by setConvexHullDirty and setConvexHullPoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants