-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Implement correct orthographic projection #22985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
final Matrix4 transform = getTransformTo(ancestor); | ||
final double det = transform.invert(); | ||
if (det == 0.0) | ||
return Offset.zero; | ||
return MatrixUtils.transformPoint(transform, point); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should transformPoint itself be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like transformPoint is used by some code that doesn't expect unprojection (see localToGlobal). So we would probably keep transformPoint as is, and create new function perspectiveTransformPoint. We could do this change incrementally if people find more problems with various hit testing.
final Vector3 o = Vector3(0.0, 0.0, 0.0); | ||
final Vector3 n = Vector3(0.0, 0.0, 1.0); | ||
final Vector3 p = s + d * (n.dot(o - s) / n.dot(d)); | ||
return Offset(p.x, p.y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the likely performance impact of this change? (This code is potentially hot in certain cases.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and optimized it slightly, but it shouldn't be bad either way since it's still relatively light weight (only four divisions) and is only called O(1) times per frame. It could be optimized further, but likely not worth it.
Consider updating https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/painting/matrix_utils.dart#L122 instead (or add an explanation there saying why it's different). Assuming the performance implications aren't dire, LGTM modulo suggested changes. |
Doc comment updated to explain that. |
This fixes gestures in InkWell and WebView (#6080).