Improve Robustness and Clarity of FastQuadTree Implementation#67
Closed
JaskRendix wants to merge 3 commits intobitcraft:masterfrom
Closed
Improve Robustness and Clarity of FastQuadTree Implementation#67JaskRendix wants to merge 3 commits intobitcraft:masterfrom
FastQuadTree Implementation#67JaskRendix wants to merge 3 commits intobitcraft:masterfrom
Conversation
Owner
|
could you elaborate on what the changes are for damage detection? |
Contributor
Author
|
@bitcraft sure, the |
Owner
|
have you verified there are no regressions to the visuals? |
305729a to
73c4d93
Compare
FastQuadTree Implementation
Contributor
Author
|
I bailed on the visuals side for now, figured I’d zero in on just cleaning up the FastQuadTree class |
eaea280 to
d1c5c32
Compare
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.
PR improves the
FastQuadTreeclass for quadtree collision detection in the following ways:itemslist is not empty, avoiding cryptic errors and improving API safetyget_recthelper function to cleanly support objects with a.rectattribute, ensuring consistency throughoutboundary.colliderect(rect)before checking children quadrantsTypeErrorin__iter__by chaining only non-None quadrant listsifstatements for quadrant placement rather than short-circuitingand, reorders logic for readability and consistency and applies correct type annotations usingOptionaland explicitlist[Rect]quadtree_vs_brute_benchmark.py, a performance comparison script between brute-force collision detection andFastQuadTree, including detailed timing metrics for build and query operationsquadtree_depth_benchmark.py, a benchmarking tool using CLI arguments to assess the impact of quadtree depth on build and query performance, outputs timing results across multiple depth levels to assist with fine-tuning configurationsquadtree_visualizer.py, a standalone tool for visually inspecting FastQuadTree query behavior, it renders tile rectangles, highlights collision hits from spatial queries, and includes an interactive toggle for displaying resultsthis shows increasing build time with depth, and a sweet spot around depth 3 where query time is lowest.
FastQuadTree is ~35% faster for querying under these conditions.