add a quadtree to find neighbouring atoms faster #94
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.
Hi, very nice project! I implemented a quadtree to make use of the effect radius being limited. This way finding nearby atoms is much faster, as long as the radii aren't huge. This quadtree only queries rectangles, so the distance check in applyRules is still neccessary, but this should still be faster than checking for circular intersections.
One could add gui-controlls for this, but this is only for performance and has nothing to do with the core functionality. But there is one case, where this would be slower than the current way. If the radii are large, so that nearly all atoms have to be checked anyways, this just adds overhead.
For large numbers of atoms with the default radius, this is a 3-5 times improvement in fps.