-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
DisplayObject.hitTest could bail out early when localPoint has a negative coordinate #43
Comments
Mmm not sure if i understand this one... bounds should be transformed based on a coordinate space (display object container), based on their "pivot" points, the origin ( 0,0 ) of each display object. What are u trying to achieve? |
I am trying to have some relative positioning instead of absolute ones, and this is actually working just fine. So for example, I create in my scene
Then I attach some children to that
And ultimately whenever a component want to draw in any given area, it can use a local coordinate system of that area without any computation or translation of coordinates. So in the example above, If i click at (50, 200) in the canvas, when the GPoint is converted to a local coordinate of the Actually my assumption is that the area is clipped from (0,0) so you cannot draw outside of it but that actually might not be true so maybe we can do this optimization only when we have a rect clipping and we use its leftTop point as a comparison point. |
As a general rule of thumb, bounding boxes are processed for hit test when they are on the stage. Btw, if by clipping you refer to the entire Scene, Canvas are not clipped by default, and you are free to draw anywhere. I think there is a stage.maskBoundRect that clips the stage area, if thats what u need. |
Right now I am clipping some containers(sprites) to make sure their children cannot paint outside of them. To do this clipping, i use: Also I have many The conversation helped me frame better the ask, to illustrate the proposal, let's say we have this in the stage:
When the container receives the mouse event and transforms it to local coordinates, if the container has a mask and the point is outside of it, we should not try to hitTest the children, this is potentially expensive when they uses shapes for hitTesting and it's a waste of resources given we already know they cant match. |
Now I understood ... yep, you are correct. |
As it can be seen in the image above, if the local point has either
x
ory
negative, it's impossible to have a hit test so we should bail as early as possible.For context, this is happening because I compute a layout of my background scene and then place each container / sprite using
sprite.setPosition(x,y)
to that their children are positioned in relative position to their parent.The text was updated successfully, but these errors were encountered: