-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Return a Result from Camera::viewport_to_world #9770
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Good stuff: I really like the direction that this is going. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit unfortunate that it makes the code more verbose but I think these changes make sense.
I wonder if the new is_nan checks can affect performance though. Probably not, but I'm still a bit curious.
ndc: Vec3, | ||
) -> Result<Vec3, NdcToWorldError> { | ||
let cam_trans_mat = camera_transform.compute_matrix(); | ||
if cam_trans_mat.is_nan() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maybe check for is_finite instead of is_nan? I'm not sure if infinite makes sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think; Do we want infinite anywhere? Can/Should I use is_finite everywhere instead of is_nan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have done some effort to judge when to do this, but unfortunately I've all but forgotten all the graphics-related knowledge I acquired for the first PR and I'm to lazy to go back to the YouTube videos. Hope I got it right 😅
My limited knowledge says that since the numbers being checked are probably in a fast CPU cache it should be pretty fast, but you never know. EDIT: Just realized that this doesn't help if the code to check for nulls is not also in the CPU cache... I guess this would vary based on usage. |
c809f75
to
f2aba94
Compare
68f78a4
to
f0196cc
Compare
@Selene-Amanita Fixed some of the stuff you remarked on in #8841 |
I've tried to apply a bit of common sense as to where infinity should be allowed and not (almost nowhere), but I'm honestly fumbling in the dark, so please give that a quick scan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, the code quality is up to snuff now :) This is a much nicer and more informative approach to error handling here, but I need to defer to people with more rendering expertise to know if the edge cases are all handled correctly.
Same lol |
3817ed0
to
3eedaff
Compare
ad4acd5
to
78afe0a
Compare
…tly named. This addresses bevyengine#9770 (comment)
78afe0a
to
c5fd79a
Compare
…tly named. This addresses bevyengine#9770 (comment)
c5fd79a
to
43ffaa2
Compare
…tly named. This addresses bevyengine#9770 (comment)
43ffaa2
to
40563fc
Compare
…tly named. This addresses bevyengine#9770 (comment)
…tly named. This addresses bevyengine#9770 (comment)
40563fc
to
3d90c02
Compare
Appreciate it. Have never rebased on top of an entire year's worth of changes before 😅 |
Bah, still listing merge conflicts 🤔 Ping me when this is ready please! |
It's getting late here, so the rest will have to be done later. I've gotten to June. |
Oof :( Feel free to remake the PR if it's easier: rebasing can be quite painful. |
Adopted in #14931. |
Objective
This is a follow-up to 8841
The objective is to create a better UX when something goes wrong in Camera::viewport_to_world and related methods.
Solution
Move from using Option to detailed Result variants. The user no longer has to guess what the error was.
Changelog
Improve errors related to functions converting coordinates between camera, viewport, and world.
Migration Guide
Replace code that expects Option with code that expects Result. An easy way is to append a
.ok()
to the returned Result to transform it into an Option.Change references to Camera::projection_matrix to Camera::projection_matrix_unchecked.