[Merged by Bors] - simplified API to get NDC from camera and world position#4041
[Merged by Bors] - simplified API to get NDC from camera and world position#4041mockersf wants to merge 5 commits intobevyengine:mainfrom
Conversation
superdump
left a comment
There was a problem hiding this comment.
Code-wise fine. Just @alice-i-cecile 's documentation comment to address.
|
nevermind, it's already there |
|
@mockersf here are some proposed changes to this PR: mockersf#78 I was experimenting with using a trait to remove the need for passing both If you have a camera.world_to_screen(window, global_transform, world_pos)If you have a let sized_target = camera.target.as_sized_target(windows, images);
camera.world_to_screen(sized_target, global_transform, world_pos) |
|
I like aevyrie's changes quite a bit here. Do you agree @mockersf? |
|
after playing with the changes from @aevyrie, I disagree with them as they make it possible to use invalid parameters by using a different camera for the target as the one used for the projection matrix |
|
Relevant to some of the general sentiment expressed here: in my "high level render targets" changes i'm experimenting with syncing render target logical and physical width/height to Camera fields, which makes methods like "world_to_screen" much nicer to use (and cleans up internals in a number of places). That wouldn't block anything here, just something to start thinking about / developing opinions on. |
The main complaint I have here is the need for |
|
For my use case, having a |
|
bors r+ |
# Objective - After #3412, `Camera::world_to_screen` got a little bit uglier to use by needing to provide both `Windows` and `Assets<Image>`, even though only one would be needed https://github.com/bevyengine/bevy/blob/b697e73c3d861c209152ccfb140ae00fbc6e9925/crates/bevy_render/src/camera/camera.rs#L117-L123 - Some time, exact coordinates are not needed but normalized device coordinates is enough ## Solution - Add a function to just get NDC
…4041) # Objective - After bevyengine#3412, `Camera::world_to_screen` got a little bit uglier to use by needing to provide both `Windows` and `Assets<Image>`, even though only one would be needed https://github.com/bevyengine/bevy/blob/b697e73c3d861c209152ccfb140ae00fbc6e9925/crates/bevy_render/src/camera/camera.rs#L117-L123 - Some time, exact coordinates are not needed but normalized device coordinates is enough ## Solution - Add a function to just get NDC
…4041) # Objective - After bevyengine#3412, `Camera::world_to_screen` got a little bit uglier to use by needing to provide both `Windows` and `Assets<Image>`, even though only one would be needed https://github.com/bevyengine/bevy/blob/b697e73c3d861c209152ccfb140ae00fbc6e9925/crates/bevy_render/src/camera/camera.rs#L117-L123 - Some time, exact coordinates are not needed but normalized device coordinates is enough ## Solution - Add a function to just get NDC
Objective
Camera::world_to_screengot a little bit uglier to use by needing to provide bothWindowsandAssets<Image>, even though only one would be neededbevy/crates/bevy_render/src/camera/camera.rs
Lines 117 to 123 in b697e73
Solution