@@ -532,6 +532,8 @@ pub(super) fn snap_one(mut value: i32, step: i32) -> i32 {
532532/// Implements functions that are present only on integer vectors.
533533macro_rules! inline_impl_integer_vector_fns {
534534 (
535+ // Name of the float-equivalent vector type.
536+ $VectorFloat: ty,
535537 // Names of the components, for example `x, y`.
536538 $( $comp: ident) ,*
537539 ) => {
@@ -542,6 +544,7 @@ macro_rules! inline_impl_integer_vector_fns {
542544 /// On under- or overflow:
543545 /// - If any component of `self` is [`i32::MIN`] while the same component on `step` is `-1`.
544546 /// - If any component of `self` plus half of the same component of `step` is not in range on [`i32`].
547+ #[ inline]
545548 pub fn snapped( self , step: Self ) -> Self {
546549 use crate :: builtin:: vectors:: vector_macros:: snap_one;
547550
@@ -551,20 +554,39 @@ macro_rules! inline_impl_integer_vector_fns {
551554 ) ,*
552555 )
553556 }
557+
558+ /// Converts to a vector with floating-point [`real`](type.real.html) components, using `as` casts.
559+ #[ inline]
560+ pub const fn cast_float( self ) -> $VectorFloat {
561+ <$VectorFloat>:: new( $( self . $comp as real) ,* )
562+ }
554563 } ;
555564}
556565
557566macro_rules! impl_float_vector_fns {
558567 (
559568 // Name of the vector type.
560569 $Vector: ty,
570+ // Name of the integer-equivalent vector type.
571+ $VectorInt: ty,
561572 // Names of the components, with parentheses, for example `(x, y)`.
562573 ( $( $comp: ident) ,* )
563574 ) => {
564575 /// # Float-specific functions
565576 ///
566577 /// The following methods are only available on floating-point vectors.
567578 impl $Vector {
579+ /// Converts to a vector with integer components, using `as` casts.
580+ pub const fn cast_int( self ) -> $VectorInt {
581+ <$VectorInt>:: new( $( self . $comp as i32 ) ,* )
582+ }
583+
584+ /// Returns a new vector with all components rounded down (towards negative infinity).
585+ #[ inline]
586+ pub fn floor( self ) -> Self {
587+ Self :: from_glam( self . to_glam( ) . floor( ) )
588+ }
589+
568590 /// Returns a new vector with all components rounded up (towards positive infinity).
569591 #[ inline]
570592 pub fn ceil( self ) -> Self {
@@ -649,12 +671,6 @@ macro_rules! impl_float_vector_fns {
649671 self . to_glam( ) . dot( with. to_glam( ) )
650672 }
651673
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-
658674 /// Returns true if each component of this vector is finite.
659675 #[ inline]
660676 pub fn is_finite( self ) -> bool {
0 commit comments