-
-
Notifications
You must be signed in to change notification settings - Fork 883
core: Return false for shape hitTests on zero-scale graphics #10330
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
7a6e444
to
9d3a873
Compare
I decided on a more thorough way to solve this by making |
0edddf7
to
a19940e
Compare
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.
Thanks for your work on this. This looks good to me based on testing, I haven't found any issue or regression.
Mentioning that this game now works would be a nice addition to ruffle-rs/ruffle-rs.github.io#132. 😉
* Add `Matrix::determinant`. * Rename `Matrix::invert` to `inverse`. * `Matrix::inverse` return an `Option`, with `None` returned for non-invertible matrices. * AMV `Matrix::invert` duplicates the code as the behavior is different (works in f64 and not twips, etc.)
This will return `None` if the object is zero scale, and callers can handle this appropriately.
* `global_to_local` returns `None` if the object has zero scale. * Adjust AVM `globalToLocal` methods to return the untransformed point on failure. * Add `DisplayObject::mouse_to_local` to handle AVM `mouseX` and `mouseY` coordinates. For zero scale objects, these end up returning values based on the twips-to-pixels scale, divided by 20.
a19940e
to
a2d8caa
Compare
|
If a graphic has a
scaleX
orscaleY
of 0, a shapehitTest(x, y, true)
should return false, even on the exact location of the object. Note that a boundshitTest(x, y, false)
still returns true on the exact location of the object. Bail out on the hitTest immediately when we detect no width or height.Fix with the following changes:
Matrix::invert
toMatrix::inverse
and make it fallible, returningNone
for non-invertible matrices. (An object with zero scale will have a non-invertible matrix for its transform).DisplayObject::global_to_local_matrix
andDisplayObject::global_to_local
fallible. These returnNone
when the object has zero scale.core
that used these to properly handle these methods returningNone
. All overrides ofhit_test_shape
will return false in this case.Bonus:
clip.globalToLocal(point)
when the clip has zero scale: point will be unaffected.clip._xmouse
/_ymouse
/etc. when the clip has zero scale: a 1/20 scale matrix (twips-to-pixels) is used.DisplayObject::mouse_to_local
to handle these cases.Fixes #6906.