-
-
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
Add Box::from_min_max method #3322
Conversation
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.
Thanks, looks useful.
One concern I have is e.g. if you pass (1, 0, 1), (0, 1, 0)
, then the given box would potentially be weird. I don't know if there are any troubles with this case (which can also be reached manually or when using Box::new
with negative numbers).
I wonder if it would make more sense to either rename it, or to automatically work out the minimum for each axis. It might be worth renaming new
to from_side_lengths
?
To be honest, I think Box
could easily just be defined as min: Vec3, max: Vec3
. I'm not sure why it wasn't defined as such in #883.
Yeah, I can code to work out the minimum, or asserts perhaps. It perhaps violates principal of least surprise to swap out if the minimums. Perhaps returning an Option is the best option. However, this kind of stuff is already in the shape primitives PR, and perhaps effort is best concentrated there..? Cheers |
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.
@rezural I like this, but I'd like to see:
- Basic doc strings.
- Assertions that min < max in all cases.
I'd rather just use |
Closing in favor of #6672. |
# Objective This add a ctor to `Box` to aid the creation of non-centred boxes. The PR adopts @rezural's work on PR #3322, taking into account the feedback on that PR from @james7132. ## Solution `Box::from_corners()` creates a `Box` from two opposing corners and automatically determines the min and max extents to ensure that the `Box` is well-formed. Co-authored-by: rezural <rezural@protonmail.com>
# Objective This add a ctor to `Box` to aid the creation of non-centred boxes. The PR adopts @rezural's work on PR bevyengine#3322, taking into account the feedback on that PR from @james7132. ## Solution `Box::from_corners()` creates a `Box` from two opposing corners and automatically determines the min and max extents to ensure that the `Box` is well-formed. Co-authored-by: rezural <rezural@protonmail.com>
# Objective This add a ctor to `Box` to aid the creation of non-centred boxes. The PR adopts @rezural's work on PR bevyengine#3322, taking into account the feedback on that PR from @james7132. ## Solution `Box::from_corners()` creates a `Box` from two opposing corners and automatically determines the min and max extents to ensure that the `Box` is well-formed. Co-authored-by: rezural <rezural@protonmail.com>
# Objective This add a ctor to `Box` to aid the creation of non-centred boxes. The PR adopts @rezural's work on PR bevyengine#3322, taking into account the feedback on that PR from @james7132. ## Solution `Box::from_corners()` creates a `Box` from two opposing corners and automatically determines the min and max extents to ensure that the `Box` is well-formed. Co-authored-by: rezural <rezural@protonmail.com>
Objective
Solution