aevyrie / bevy_mod_raycast

A little mesh raycasting plugin for Bevy
https://crates.io/crates/bevy_mod_raycast
MIT License
303 stars 92 forks source link

Ray3d::from_screenspace() implementation from Camera.viewport_to_world() #76

Closed rosingrind closed 1 year ago

rosingrind commented 1 year ago

Summary

https://github.com/bevyengine/bevy/pull/8306 introduces consistent coordinates for every entity without .y flipping. The changes are not rolled out yet, but current main of bevy_mod_raycast is not working well with bevy's main. In attempt to fix this, I found a simple but questionable solution:

https://github.com/aevyrie/bevy_mod_raycast/blob/bd84951952f58a36c8144725f6539e7b3f60ed0f/src/primitives.rs#L240-L262

is equal to

https://github.com/bevyengine/bevy/blob/585baf0a66b855cef1f0568a4af44b666cfee076/crates/bevy_render/src/camera/camera.rs#L250-L270

Solution

It seems that there's no reason not to utilize Camera::viewport_to_world() as it's available since https://github.com/bevyengine/bevy/commit/37860a09de897218e6698eaf16dcc7836525a9fb from v0.9.0. I propose to utilize Camera.viewport_to_world() under the hood of Ray3d::from_screenspace() as their purposes seems identical. Changes doesn't seem to break any examples functionality on my end

rosingrind commented 1 year ago

Closing this in favor of #78 and #83