-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Removed conversion from pointer physical coordinates to viewport local coordinates in bevy_picking make_ray function #18870
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
…ion. It's handled in camera.viewport_to_world
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
this should also be tested on a screen that doesn't have a scale of 1 |
I tried changing my display scale to 50%, 100%, 150%, 200%, and testing again with simple_picking, split_screen, and mesh_picking both on master and after my changes. In all those cases after my fix picking worked predictably while master didn't work with splitscreen/viewport offset as described. Is setting display scale a good way to test this? I was printing out window.scale_factor, and for ex. 200% scale I got scale factor of 2 so I assumed it will be enough. |
sounds good, thanks! |
…l coordinates in bevy_picking make_ray function (bevyengine#18870) # Objective - Fixes bevyengine#18856. ## Solution After PR bevyengine#17633, `Camera::viewport_to_world` method corrects `viewport_position` passed in that input so that it's offset by camera's viewport. `Camera::viewport_to_world` is used by `make_ray` function which in turn also offsets pointer position by viewport position, which causes picking objects to be shifted by viewport position, and it wasn't removed in the aforementioned PR. This second offsetting in `make_ray` was removed. ## Testing - I tested simple_picking example by applying some horizontal offset to camera's viewport. - I tested my application that displayed a single rectangle with picking on two cameras arranged in a row. When using local bevy with this fix, both cameras can be used for picking correctly. - I modified split_screen example: I added observer to ground plane that changes color on hover, and removed UI as it interfered with picking both on master and my branch. On master, only top left camera was triggering the observer, and on my branch all cameras could change plane's color on hover. - I added viewport offset to mesh_picking, with my changes it works correctly, while on master picking ray is shifted. - Sprite picking with viewport offset doesn't work both on master and on this branch. These are the only scenarios I tested. I think other picking functions that use this function should be tested but I couldn't track more uses of it. Co-authored-by: Krzysztof Zywiecki <krzysiu@pop-os.Dlink>
…l coordinates in bevy_picking make_ray function (bevyengine#18870) # Objective - Fixes bevyengine#18856. ## Solution After PR bevyengine#17633, `Camera::viewport_to_world` method corrects `viewport_position` passed in that input so that it's offset by camera's viewport. `Camera::viewport_to_world` is used by `make_ray` function which in turn also offsets pointer position by viewport position, which causes picking objects to be shifted by viewport position, and it wasn't removed in the aforementioned PR. This second offsetting in `make_ray` was removed. ## Testing - I tested simple_picking example by applying some horizontal offset to camera's viewport. - I tested my application that displayed a single rectangle with picking on two cameras arranged in a row. When using local bevy with this fix, both cameras can be used for picking correctly. - I modified split_screen example: I added observer to ground plane that changes color on hover, and removed UI as it interfered with picking both on master and my branch. On master, only top left camera was triggering the observer, and on my branch all cameras could change plane's color on hover. - I added viewport offset to mesh_picking, with my changes it works correctly, while on master picking ray is shifted. - Sprite picking with viewport offset doesn't work both on master and on this branch. These are the only scenarios I tested. I think other picking functions that use this function should be tested but I couldn't track more uses of it. Co-authored-by: Krzysztof Zywiecki <krzysiu@pop-os.Dlink>
…l coordinates in bevy_picking make_ray function (bevyengine#18870) # Objective - Fixes bevyengine#18856. ## Solution After PR bevyengine#17633, `Camera::viewport_to_world` method corrects `viewport_position` passed in that input so that it's offset by camera's viewport. `Camera::viewport_to_world` is used by `make_ray` function which in turn also offsets pointer position by viewport position, which causes picking objects to be shifted by viewport position, and it wasn't removed in the aforementioned PR. This second offsetting in `make_ray` was removed. ## Testing - I tested simple_picking example by applying some horizontal offset to camera's viewport. - I tested my application that displayed a single rectangle with picking on two cameras arranged in a row. When using local bevy with this fix, both cameras can be used for picking correctly. - I modified split_screen example: I added observer to ground plane that changes color on hover, and removed UI as it interfered with picking both on master and my branch. On master, only top left camera was triggering the observer, and on my branch all cameras could change plane's color on hover. - I added viewport offset to mesh_picking, with my changes it works correctly, while on master picking ray is shifted. - Sprite picking with viewport offset doesn't work both on master and on this branch. These are the only scenarios I tested. I think other picking functions that use this function should be tested but I couldn't track more uses of it. Co-authored-by: Krzysztof Zywiecki <krzysiu@pop-os.Dlink>
…l coordinates in bevy_picking make_ray function (#18870) # Objective - Fixes #18856. ## Solution After PR #17633, `Camera::viewport_to_world` method corrects `viewport_position` passed in that input so that it's offset by camera's viewport. `Camera::viewport_to_world` is used by `make_ray` function which in turn also offsets pointer position by viewport position, which causes picking objects to be shifted by viewport position, and it wasn't removed in the aforementioned PR. This second offsetting in `make_ray` was removed. ## Testing - I tested simple_picking example by applying some horizontal offset to camera's viewport. - I tested my application that displayed a single rectangle with picking on two cameras arranged in a row. When using local bevy with this fix, both cameras can be used for picking correctly. - I modified split_screen example: I added observer to ground plane that changes color on hover, and removed UI as it interfered with picking both on master and my branch. On master, only top left camera was triggering the observer, and on my branch all cameras could change plane's color on hover. - I added viewport offset to mesh_picking, with my changes it works correctly, while on master picking ray is shifted. - Sprite picking with viewport offset doesn't work both on master and on this branch. These are the only scenarios I tested. I think other picking functions that use this function should be tested but I couldn't track more uses of it. Co-authored-by: Krzysztof Zywiecki <krzysiu@pop-os.Dlink>
Objective
Solution
After PR #17633,
Camera::viewport_to_world
method correctsviewport_position
passed in that input so that it's offset by camera's viewport.Camera::viewport_to_world
is used bymake_ray
function which in turn also offsets pointer position by viewport position, which causes picking objects to be shifted by viewport position, and it wasn't removed in the aforementioned PR. This second offsetting inmake_ray
was removed.Testing
These are the only scenarios I tested. I think other picking functions that use this function should be tested but I couldn't track more uses of it.