Skip to content

Add spatial queries for destructables and rects - #469

Merged
Frotty merged 6 commits into
masterfrom
codex/spatial-enum-index
Aug 25, 2026
Merged

Add spatial queries for destructables and rects#469
Frotty merged 6 commits into
masterfrom
codex/spatial-enum-index

Conversation

@Frotty

@Frotty Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an opt-in static Lua spatial index for destructables.
  • Add native-less destructablesInRect and destructablesInRange SparseSet queries.
  • Add unitsInRect on top of the existing unit spatial index, preserving native rect lower-bound semantics.
  • Add destructable SparseSet key support and grid tests.

Checks

  • grill typecheck --quiet — passed.
  • grill test --quiet — passed.
  • git diff --cached --check — passed.

The full grill build could not run because the Wurst compiler is not installed in the environment.

Scope and known gaps

  • The new APIs are opt-in, matching the existing unit spatial-query design.
  • Preplaced destructables are indexed during initialization; runtime-created destructables must call registerSpatialIndex() and unregister before removal.
  • Per-player secondary SparseSets are intentionally deferred; the existing player query remains a linear registry scan.

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 0f36120e2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 15931e0ec7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c523c0bed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +68 to +70
function createCellLists()
for i = 0 to gridWidth * gridHeight - 1
cellContents.add(new ArrayList<DestructableSpatialRecord>(4))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allocate empty cell buckets lazily

On large maps, initialization executes this allocation once for every grid cell, even when most cells contain no destructables. Each ArrayList(4) creates an object and advances the specialized backing store by four slots, so the default 256-unit cells can produce tens of thousands of objects and substantial Lua startup/memory overhead based solely on map dimensions. Store null buckets initially and instantiate a cell list only when the first record is added.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d38e529: cellContents now starts with null entries, and each bucket is allocated only when its first destructable is registered. Empty map cells no longer allocate ArrayLists.

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: d38e5298a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 3a399c9b1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

Codex review loop complete.

  • Latest head: 3a399c9
  • Codex review: clean on the current head.
  • CI: 2 checks passed, 0 failed.
  • Local host-toolchain validation: grill typecheck --quiet and grill test --quiet both passed.
  • Fixed CI/compiler issues found during the loop, plus one valid P2 review finding by switching to lazy cell-bucket allocation.
  • Per-player secondary indexing remains intentionally deferred and documented as out of scope for this iteration.

PR #469 is ready to merge; merging remains a maintainer decision.

@Frotty
Frotty merged commit c17b5ec into master Aug 25, 2026
2 checks passed
@Frotty
Frotty deleted the codex/spatial-enum-index branch August 25, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant