Fix findNode method by scaling node radius with viewport transform
#62
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.


I noticed that when using a custom symbol radius / size, the
onNodeTappedwas sometimes hitting the wrong nodes. After investigating a bit more, I found that there was an error in the calculation that finds the node at a specific location.The method
findNodeuses a size value for the nodes that is not affected by the viewport scale, while the note symbols are scaled in practice. Additionally, I found thatiRadius2is not actually the symbol radius squared (as the name would suggest), but double of the square of double of the radius 😄 I'm not sure if that should be the case, but I didn't change anything there, as I'm not sure what might be affected.This PR addresses specifically the issue with
findNodeby talking into account the viewport scale, essentially performing this calculation, and then usingscaledRadius2as maximum distance:In practice, this can be simplified to:
which is more efficient.
It might very well be that the problem should really be solved at the root, i.e. when calculating iRadius in the first place, or a combination of the two.