-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Bugfix - Vector3::sign gives incorrect results due to i32 conversion #865
Conversation
f039636
to
053c5d4
Compare
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-865 |
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 a lot! 👍
#[test] | ||
fn sign() { | ||
let vector = Vector3::new(0.2, -0.5, 0.0); | ||
assert_eq_approx!(vector.sign(), Vector3::new(1., -1., 0.)); |
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 could be assert_eq!
, no? Since the numbers can be precisely represented...
In other places too
fn f(x: $Scalar) -> $Scalar { | ||
let r = x.partial_cmp(&(0 as $Scalar)).unwrap_or_else(|| panic!("Vector component {x} isn't signed!")); | ||
match r { | ||
Ordering::Equal => 0 as $Scalar, | ||
Ordering::Greater => 1 as $Scalar, | ||
Ordering::Less => -1 as $Scalar, |
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.
Maybe while at it, rename x
to c
for component. It's a bit misleading otherwise.
053c5d4
to
6d77c68
Compare
fixes #864