@@ -532,6 +532,8 @@ pub(super) fn snap_one(mut value: i32, step: i32) -> i32 {
532
532
/// Implements functions that are present only on integer vectors.
533
533
macro_rules! inline_impl_integer_vector_fns {
534
534
(
535
+ // Name of the float-equivalent vector type.
536
+ $VectorFloat: ty,
535
537
// Names of the components, for example `x, y`.
536
538
$( $comp: ident) ,*
537
539
) => {
@@ -551,20 +553,38 @@ macro_rules! inline_impl_integer_vector_fns {
551
553
) ,*
552
554
)
553
555
}
556
+
557
+ /// Converts to a vector with floating-point [`real`](type.real.html) components, using `as` casts.
558
+ pub fn to_float_vector( self ) -> $VectorFloat {
559
+ <$VectorFloat>:: new( $( self . $comp as real) ,* )
560
+ }
554
561
} ;
555
562
}
556
563
557
564
macro_rules! impl_float_vector_fns {
558
565
(
559
566
// Name of the vector type.
560
567
$Vector: ty,
568
+ // Name of the integer-equivalent vector type.
569
+ $VectorInt: ty,
561
570
// Names of the components, with parentheses, for example `(x, y)`.
562
571
( $( $comp: ident) ,* )
563
572
) => {
564
573
/// # Float-specific functions
565
574
///
566
575
/// The following methods are only available on floating-point vectors.
567
576
impl $Vector {
577
+ /// Converts to a vector with integer components, using `as` casts.
578
+ pub fn to_int_vector( self ) -> $VectorInt {
579
+ <$VectorInt>:: new( $( self . $comp as i32 ) ,* )
580
+ }
581
+
582
+ /// Returns a new vector with all components rounded down (towards negative infinity).
583
+ #[ inline]
584
+ pub fn floor( self ) -> Self {
585
+ Self :: from_glam( self . to_glam( ) . floor( ) )
586
+ }
587
+
568
588
/// Returns a new vector with all components rounded up (towards positive infinity).
569
589
#[ inline]
570
590
pub fn ceil( self ) -> Self {
@@ -649,12 +669,6 @@ macro_rules! impl_float_vector_fns {
649
669
self . to_glam( ) . dot( with. to_glam( ) )
650
670
}
651
671
652
- /// Returns a new vector with all components rounded down (towards negative infinity).
653
- #[ inline]
654
- pub fn floor( self ) -> Self {
655
- Self :: from_glam( self . to_glam( ) . floor( ) )
656
- }
657
-
658
672
/// Returns true if each component of this vector is finite.
659
673
#[ inline]
660
674
pub fn is_finite( self ) -> bool {
0 commit comments