Release v5.0.1#28
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make stages with hundreds of sprites run at a usable frame rate.
Four things were costing more than they had to, all of them growing with the
number of sprites:
resetShader(), which flushes therenderer. That turned what could be a few batched draw calls into one per
sprite. The shader is now only reset when one was actually set.
getHitbox()rebuilt the sprite's collision shape from scratch on every call,and collision checks call it once per pair - so a stage with 200 sprites built
40,000 shapes a frame. A sprite that has not moved, turned, resized or changed
costume now reuses the shape it had.
Shape.intersectscompared two outlines by building ajava.awt.geom.Areaforeach. Sprite hitboxes are convex, so they are now compared with separating
axes instead, which gives the same answer about 30x faster.
Polygonfrom a list of corners rebuilt its path once per corner.A benchmark of 200 sprites moving, bouncing off the edges and checking collisions
against each other every frame went from 96ms per frame to 25ms.