perf: Compose one transform for polygon global vertices and hoist the circle center out of the edge loop - #5
Merged
adario merged 1 commit intoSep 13, 2026
Conversation
… circle center out of the edge loop PolygonComponent.globalVertices walked the ancestor chain once per vertex with an allocation per level and validated its cache with three more ancestor walks. It now composes a single 2D affine transform, writes the vertices into the preallocated list, and keys the cache on the transform values and the size. CirclePolygonIntersections computed the absolute center and scaled radius of the circle for every polygon edge; they are now computed once per pair, and edges whose bounding box is farther than the radius from the center are skipped.
This was referenced Sep 13, 2026
Owner
|
Looks great! |
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.
Description
The same changes as flame-engine#4046, cherry-picked onto #4 so the path contour hitboxes get them right away. Stacked on #4 because the circle change touches the intersection code that PR changed.
Compose one transform for the global vertices.
PolygonComponent.globalVerticeswalked the ancestors once per vertex with an allocation per level, and validated its cache with three more ancestor walks. It now composes a single 2D affine transform, writes the vertices into the preallocated list, and keys the cache on the transform values and size. For the 37-vertex flame contour under a rotating parent one call went from 1.24 to 0.19 microseconds.Hoist the circle center and radius out of the edge loop. Circle-versus-polygon computed
absoluteCenterandscaledRadiusper polygon edge. They are now computed once per pair, and edges whose bounding box is farther than the radius from the center are skipped.Measured with the benchmark from #3 on this branch, milliseconds per 20 ticks in JIT, 50 hitboxes of each kind, starting from #4:
For reference, path vs path was 92.0 before #4.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?