Skip to content

Commit 90665f8

Browse files
committed
Fix sign for float vectors
1 parent 064511f commit 90665f8

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

godot-core/src/builtin/vectors/vector4.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8+
use core::cmp::Ordering;
89
use godot_ffi as sys;
910
use sys::{ffi_methods, GodotFfi};
1011

godot-core/src/builtin/vectors/vector4i.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8+
use core::cmp::Ordering;
89
use godot_ffi as sys;
910
use sys::{ffi_methods, GodotFfi};
1011

godot-core/src/builtin/vectors/vector_macros.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,18 @@ macro_rules! impl_vector_fns {
440440
/// Returns a new vector with each component set to 1 if it's positive, -1 if it's negative, and 0 if it's zero.
441441
#[inline]
442442
pub fn sign(self) -> Self {
443-
Self::from_glam(self.to_glam().signum())
443+
#[inline]
444+
fn f(x: i32) -> i32 {
445+
match x.cmp(&0) {
446+
Ordering::Equal => 0,
447+
Ordering::Greater => 1,
448+
Ordering::Less => -1,
449+
}
450+
}
451+
452+
Self::new(
453+
$( f(self.$comp as i32) as $Scalar ),*
454+
)
444455
}
445456
}
446457
}

0 commit comments

Comments
 (0)