Repository navigation
fix: Remove and move hitboxes correctly after QuadTree.optimize - #4287
Open
turalbabayev wants to merge 1 commit into
Open
turalbabayev wants to merge 1 commit into
turalbabayev wants to merge 1 commit into
Conversation
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.
Description
QuadTreekeeps a map from each hitbox to the node that holds it, andremoveuses that map to find the hitbox. Whenoptimize()merges the children of a node, it moves their hitboxes into the parent but doesn't update the map, so those hitboxes still point to the child nodes that were dropped. After that:queryandhitboxes.updateTransformcallsremoveand thenadd) adds it a second time, so the tree holds it twice.optimize()now points the moved hitboxes to the node they were merged into.New test in
test/collisions/quadtree_test.dart: withmaxObjects: 1, two blocks split the root. The test removes one block, callsoptimize(), then moves and removes the other one, and checkstree.hitboxesafter each step. Onmainthe moved hitbox is listed twice. With this change the test passes.Checked locally on macOS with Flutter 3.50.1:
dart formatreports no changes,flutter analyzereports no issues, cspell finds nothing, andflutter testinpackages/flamepasses except for the same 8 golden tests that also fail onmainon this machine.Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
None.