Repository navigation
Conversation
Starburst replaces its intrusive collision grid with one spatial.Hash shared by bullet circle queries and auto-aim nearest-target queries, and the rts2d template's fighters find sighted enemies through a lazily rebuilt spatial.Hash instead of scanning every entity. Both keep the old insertion-order tie preference now that the spatial package provides the queries. Fixes #1515
This branch has not been deployed
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
Issue #1515's spatial queries landed in two earlier PRs, but its final acceptance item — Starburst and the rts2d template actually using the new queries — was still open. Starburst's auto-aim scanned every enemy and kept a separate intrusive 16×9 collision grid; the RTS template's
nearestEnemyscanned every entity for each fighter. This change replaces the Starburst grid with onespatial.Hash[uint64], rebuilt once after enemy movement and shared by the bullets'QueryCirclebroad-phase probes and the auto-aimNearestquery, with stable enemy ids and a slot map kept current through compaction. The rts2d template indexes entities by pointer in aspatial.Hash[*entity]rebuilt once per step on the first fighter query, with team, alive and fog-visibility checks in theNearestaccept callback. Ties keep the old preference for the first entity in spawn order, and distances follow the package contract of measuring to entry bounds.Related issue
Fixes #1515
Verification
gofmt -l .produces no outputgo tool nsgo test ./...passes from the repository root — not run as a whole; the scoped runs below passedgo tool nsgo check -target macos,windows,linux,android,webpasses from the repository root —go tool nsgo check(default targets) passedgo tool nsgo check -target ios,ios_simulatorpasses (if on macOS with Xcode) — not runbun run buildpasses (fordocs/orwebsite/changes) — no docs or website changedocs/en/anddocs/zh/updated (when applicable) — not applicable; the queries are already documented equivalently indocs/en/spatial.mdanddocs/zh/spatial.mdTests and checks that passed:
go tool nsgo check(catalogs and vet)go tool nsgo test ./examples/starburst— 26 passed, 1 skipped, including the steady-state 1000-sprite zero-allocation stepgo tool nsgo test ./template/rts2d/...— 33 passed, including the deterministic skirmish and both playthroughsgo tool nsgo test ./pkg/spatial— 15 passedgo run ./tools/changelog checkandbun run verify-notesScreenshots
None: no visible UI change. The template's targeting is the only behavior that moved, and no view code changed.