chore: Add a collision benchmark for Path contour hitboxes - #3
Merged
Merged
Conversation
Runs the collision detection system with a hitbox sampled from a Path contour against circles, rectangles, hand-written polygons, and itself, next to the same scenes with a hand-written polygon of the same shape. The polygon scenes also compile on main, so the two can be compared by running the file on both branches.
Owner
|
Very cool benchmark! |
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
Adds
path_collision_benchmark.dart, a harness benchmark that runs the collision detection system with a hitbox built byPolygonHitbox.contouragainst circles, rectangles, a hand-written polygon, and itself. Each scene has 50 moving, rotating shapes of the subject kind and 50 of the other kind in an 800 by 800 world, and hitboxes only narrow-phase against the partner kind so a scene measures exactly that pairing. The subject is the flame logo path frompath_contour_shapes.dart, 37 vertices at 60 pixels. The baseline is the same logo hand-written from its 10 anchor points, which is what a game on main has to use today. The polygon scenes compile on main as well, so the two branches can be compared by running the file on both.Results on this branch, milliseconds per 20 ticks in JIT through
flutter test:Two conclusions from that: the branch does not slow down existing polygons, and the path hitbox pays for its vertex count quadratically against other polygons. #4 fixes most of that in the narrow phase and brings path vs path down to 11.4, and #5 takes it further to 7.7 by making the global vertex and circle computations allocation free.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?