Skip to content

feat: add reusable Polygon abstraction - #454

Merged
Frotty merged 2 commits into
wurstscript:masterfrom
Donach:feat/polygon
Aug 4, 2026
Merged

feat: add reusable Polygon abstraction#454
Frotty merged 2 commits into
wurstscript:masterfrom
Donach:feat/polygon

Conversation

@Donach

@Donach Donach commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an arbitrary-size Polygon class with builder and vararg construction
  • cache and own the polygon boundary rect after sealing
  • accelerate exact classification with a 32-world-unit pathing-cell grid: uniform cells answer in O(1), mixed cells inspect only their horizontal-band edge candidates, bounded by O(n)
  • expose O(1) vec2 / vec3 to global pathingCell conversion and cell bounds/center
  • keep classifyLinear beside the accelerated classify as the exact reference and safe fallback
  • store grid data in a reusable 32-array sharded integer arena, avoiding the single JASS-array limit
  • provide exact even-odd behavior for convex, concave, degenerate, reversed, and self-intersecting paths
  • add overridable debug rendering with optional color, caller-owned handles, and timed automatic cleanup
  • retain and deprecate the existing vec2.isInPolygon and vec3.isInPolygon2d APIs for source compatibility

Cell semantics

A cell is INSIDE only when its entire area is inside without touching an edge, OUTSIDE only when disjoint from the polygon, and MIXED when any polygon edge touches or crosses it. classify resolves MIXED cells exactly.

10,000-query evaluation

The accelerated and linear implementations returned identical relations for all 10,000 deterministic points against a 64-edge polygon. The linear path considered 506,048 edges for in-bounds queries; the accelerated path considered 22,486 candidate edges (about 22.5x fewer). 1,978 queries needed edge candidates, so 8,022 were answered without an exact edge scan.

Ownership

Polygon owns its cached bounds and grid allocation. Untimed debug rendering returns a caller-owned ArrayList<lightning>; timed rendering owns and cleans its handles.

Verification

Run inside nix develop /home/daniel/Repositories/tever/tever_main:

  • grill typecheck --quiet — passed
  • grill test PathingGridTests — 3/3 passed
  • grill test ShardedIntStorageTests — 3/3 passed
  • grill test PolygonTests — 20/20 passed
  • grill test testIsInPolygon — 1/1 passed
  • grill test --quiet — passed
  • GitHub Actions Build — passed
  • git diff --check upstream/master...HEAD — passed

The non-quiet compiler output intentionally reports six deprecation warnings from the restored legacy API test. Warcraft-native lightning creation, coloring, and timed destruction are compile-checked but not Warcraft-runtime verified because Grill cannot execute those natives.

@Donach
Donach force-pushed the feat/polygon branch 9 times, most recently from 427e299 to 11b6d11 Compare August 3, 2026 05:44
@Donach
Donach marked this pull request as ready for review August 3, 2026 05:53
@Frotty

Frotty commented Aug 3, 2026

Copy link
Copy Markdown
Member

@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: 11b6d117f8

ℹ️ 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 thread wurst/math/Vectors.wurst
@Frotty

Frotty commented Aug 3, 2026

Copy link
Copy Markdown
Member

@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: 0c17c1f11e

ℹ️ 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 thread wurst/math/Polygon.wurst Outdated
@Frotty

Frotty commented Aug 4, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: d9ff9a48ee

ℹ️ 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 merged commit a49ae73 into wurstscript:master Aug 4, 2026
1 check passed
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.

2 participants