aevyrie / bevy_mod_picking

Picking and pointer events for Bevy.
https://crates.io/crates/bevy_mod_picking
Apache License 2.0
791 stars 174 forks source link

Incorrect handling of cameras with custom viewports in the rapier backend. #212

Closed TheRawMeatball closed 1 year ago

TheRawMeatball commented 1 year ago

In the rapier backend, the ray_from_screenspace function does not correctly translate coordinates in the target camera s screen space to its viewport space before mapping to a world-space ray, leading to incorrect results. This can be fixed by adapting the ray_from_screenspace function to be closer to Ray3d::from_screenspace from bevy_mod_raycast: https://docs.rs/bevy_mod_raycast/latest/src/bevy_mod_raycast/primitives.rs.html#240-262

aevyrie commented 1 year ago

Can be fixed by using bevy's Camera::viewport_to_world.