Skip to content
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

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

Yarwin
Copy link
Contributor

@Yarwin Yarwin commented Aug 19, 2024

fixes #864

@Yarwin Yarwin force-pushed the bugfix/fix_vector_sign branch 3 times, most recently from f039636 to 053c5d4 Compare August 19, 2024 09:14
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-865

@godot-rust godot-rust deleted a comment from GodotRust Aug 19, 2024
@godot-rust godot-rust deleted a comment from GodotRust Aug 19, 2024
Copy link
Member

@Bromeon Bromeon left a 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.));
Copy link
Member

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

Comment on lines 487 to 492
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,
Copy link
Member

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.

@Bromeon Bromeon added bug c: core Core components labels Aug 19, 2024
@Bromeon Bromeon added this pull request to the merge queue Aug 19, 2024
Merged via the queue into godot-rust:master with commit 406a5d9 Aug 19, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: core Core components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vector3::sign gives incorrect results due to i32 conversion
3 participants