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.
Implementing some of the ideas from #1568
So far, what I have is incomplete, but it shows that we can skip a ton of hash remove/add operations for sprite movements, when those movements don't change the sprite's hash. This makes hashing viable for very dynamic sprites.
Initial benchmark results
Sorry these results are hard to read.
Without this optimization, adding spatial hashing to the moving bullets slows it down. Compare rows 2 and 4 to see this.
But with this optimization, adding spatial hashing to the moving bullets gets much faster. Compare rows 1 and 3 to see this.
With spatial hashing of moving bullets
Without spatial hashing of moving bullets
TODOs
_hit_box_max_dimension
to be a tuple describing the max extent of the hitbox along each axis