Repository navigation
Give tile map layers a spatial hash by default - #2956
Merged
Merged
Conversation
load_tilemap() and TileMap left spatial hashing off unless asked, and forgetting it on a wall layer made collision checks much slower: 100 bullets against 2,000 wall tiles took 48 ms per frame without it and 0.6 ms with it. An unneeded hash costs much less, mostly when a layer's sprites move, so it's now on by default (#2663). Layers whose sprites move a lot, such as moving platforms, can turn it off in layer_options. layer_options silently ignored option names it didn't know, and the performance tips page named the option "use_spatial_hashing" instead of "use_spatial_hash". Unknown names now give a warning, and the page is fixed and describes the new default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pvcraven
force-pushed
the
tilemap-spatial-hash-default
branch
from
October 8, 2026 19:27
94ce8b2 to
e934758
Compare
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.
Summary
Fixes #2663:
arcade.load_tilemap()andTileMapnow give every layer's sprite list a spatial hash by default.Why
Forgetting the hash on a wall layer is easy to do and expensive. An unneeded hash usually costs little, as Cleptomania pointed out in the issue. Measured on one desktop:
Changes
The default:
use_spatial_hashdefaults toTrueinload_tilemap()andTileMap().layer_options={"Moving Platforms": {"use_spatial_hash": False}}, or for the whole map withuse_spatial_hash=False.Unknown
layer_optionskeys now warn. They used to be silently ignored. The warning names the layer and lists the valid options, and points at the code callingload_tilemap():It doesn't warn about layer names the map doesn't have, because one
layer_optionsdict is often reused across several level maps.Docs:
"use_spatial_hashing", but the option is"use_spatial_hash", so anyone who followed the sentence got no hash and no error. The section now describes the new default and how to turn it off."use_spatial_hash": True, is unchanged so the page's line numbers still match.Breaking: games that relied on the old default get hashed layers. That's usually faster, but slower for layers with many moving sprites. The changelog entry is under Unreleased → Breaking Changes.
Tests
New
tests/unit/tilemap/test_spatial_hash_default.py:3 of the 5 fail on development.
Checks
🤖 Generated with Claude Code