Selection range is +/-7 pixels to actual clicked position, but strip selection
was biased towards rightmost strip.
To make selection more intuitive, select closest strip to clicked position, and
stop iterating when strip intersects clicked pixel.
Differential D15728
Fix T100491: Mouse selection is inaccurate in NLA Editor Authored by Richard Antalik (ISS) on Aug 19 2022, 7:12 AM.
Details Selection range is +/-7 pixels to actual clicked position, but strip selection To make selection more intuitive, select closest strip to clicked position, and
Diff Detail
Event TimelineComment Actions Good change, I would just suggest to add a comment to explain that block since it isn't immediately obvious what it's doing.
Comment Actions Will modify that, also realized, that BKE_nlastrip_within_bounds(strip, (int)mouse_x, mouse_x) wont work if you manage to click on exact frame value, so this will need own function probably. Comment Actions I think overall the approach is ok, but I have the feeling there are more computations done than necessary. How about changing BKE_nlastrip_intersects_frame() to float BKE_nlastrip_distance_to_frame(strip, frame) that returns the actual distance of the frame number to the strip itself? I'm thinking something like (untested and badly formatted): float BKE_nlastrip_distance_to_frame(const NlaStrip *strip, const float timeline_frame) { if (timeline_frame < strip->start) return strip->start - timeline_frame; if (strip->end < timeline_frame) return timeline_frame - strip->end; return 0.0f; } You can then use this distance to find the closest, and when distance == 0.0f you're sure that it intersects -- no further processing necessary. This also provides a better separation of abstraction -- rather than having the loop itself doing some computations and deferring others to a separate function, with my suggested approach only one function is responsible for computing that distance. As a request for future passes, before submitting please do a pass to verify that all parameter and local variables that can be const actually are declared as such.
Comment Actions Sorry for non-constness, normally I sculpt code instead of writing, so ensuring constness is discrete cleanup pass for me. Here I forgot to do it :/
Comment Actions
From the in-line comments, I get the impression that you're more careful with the VSE code than with the NLA code. That's a bit of a dubious attitude, and I hope I'm interpreting things incorrectly. Anyway, the patch looks almost good to go. Just a little nag about the documentation of BKE_nlastrip_distance_to_frame().
Comment Actions That is incorrect. I have said, that here I wrote statement in a way I would have done in VSE. It would be pretty mad to say "I don't care about this editor, lets improve it" :) Comment Actions Yup, I'm happy to have been wrong here :) Just one small note, no need to re-review after addressing it.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||