Repository navigation
Fix rotation-invariant gesture matching - #9420
Conversation
Signed-off-by: Charan Rathore <[email protected]>
|
Thanks for the PR and for the tests. The fix looks correct to me. I'd like to share a general note about priorities, because maintainer review time is limited. This PR doesn't link to an issue, and I couldn't find a user report for this bug. A change like this still costs a full review. If you'd like to contribute more, these are the most useful places to put your effort:
I'm not asking you to close this PR. If you'd like to keep going with it, please add a short reproducer (wrong result on master, right result with the fix) and a note about the behavior change. Thanks again for helping out. Please add a migration note.
At the default Optional: dst = dstpts.strokes[0].points[0]
target = Vector([dst.x, dst.y])
src = self.strokes[0].points[0]
source = Vector([src.x, src.y])
return source.angle(target) |
…oints Add a migration note and a versionchanged on find(): matching is now rotation-invariant by default, and rotation_invariant=False keeps the old behavior. Rename the reused p variable to dst/src for readability. Signed-off-by: Charan Rathore <[email protected]>
|
All three in 923b1a3: migration note added to doc/sources/migration.rst, a versionchanged on find() documenting the new default, and the p rename is now dst/src exactly as you sketched. On the reproducer: the tests in kivy/tests/test_gesture.py double as one. On master, test_rotation_invariant_score fails (a 90-degree rotated copy scores well under 1.0 because the rotation is never compensated) and test_database_finds_rotated_gesture_by_default fails to find the stored gesture at all; with the fix both pass, and your swipe table matches what the fix produces. Behavior change, stated plainly: gestures that differ only by rotation now match under the defaults (minscore 0.9), so an app that told a swipe left from a swipe right this way will now see them as the same gesture. That is what the API always promised; rotation_invariant=False keeps the old behavior, and the migration note says so. Point taken on priorities. I will link future PRs to user-reported issues or the 3.0 list. |
|
The migration note renders incorrectly. The trailing ``` line (it was already at the end of the file upstream) swallows the next line: docutils joins it to the "For complete documentation" paragraph, shows literal backticks, and warns "Inline literal start-string without end-string". The note also has no section heading, so it ends up inside "Application Storage Directories". Please delete the stray fence and give the note its own section, in the same layout as the other entries: |
Please ping me when it's done. |
|
The other component sections (AliasProperty, Mouse Input Provider, SVG, ...) use an overline and an underline, so please use the same style. The "Application Storage Directories" heading just above is missing its overline, which is why it currently renders as a top-level section next to the page title. Please add it in this PR too, otherwise docutils reports "Title level inconsistent" for the new heading: ================================
Application Storage Directories
================================Thanks! |
Drop the stray trailing fence that swallowed the next paragraph, add the missing overline to "Application Storage Directories", and place the rotation-invariance note under its own overline/underlined Gestures heading with Behavior Changes and Migration Impact subsections. Signed-off-by: Charan Rathore <[email protected]>
|
Thanks @ElliotGarbus - both fixed in 644bf98:
Local docutils pass no longer reports the inline-literal warning, and heading levels are consistent now. |
1 similar comment
|
Thanks @ElliotGarbus - both fixed in 644bf98:
Local docutils pass no longer reports the inline-literal warning, and heading levels are consistent now. |
|
@kuzeyron This is ready to merge. |
Gesture.get_rotation()always returned 0 degrees: it built both the target and the source vector from the other gesture's first point, so it measured the angle between that point and itself instead of the angle between the two gestures' first points. Rotation-invariant matching therefore treated every gesture as unrotated.Fix
kivy/gesture.py: use this gesture's own first point as the source vector. One line; no API change.Testing
kivy/tests/test_gesture.pycover identical gestures, rotation-sensitive and rotation-invariant scores, rigid rotation using both gestures, database matching of a rotated gesture by default and empty gestures.