@@ -12,18 +12,20 @@ use godot_ffi as sys;
12
12
use sys:: { ffi_methods, GodotFfi } ;
13
13
14
14
use crate :: builtin:: math:: { GlamConv , GlamType } ;
15
- use crate :: builtin:: { inner, real, RVec3 , Vector3 , Vector3Axis } ;
15
+ use crate :: builtin:: { inner, real, RVec3 , Vector2i , Vector3 , Vector3Axis } ;
16
16
17
17
/// Vector used for 3D math using integer coordinates.
18
18
///
19
19
/// 3-element structure that can be used to represent discrete positions or directions in 3D space,
20
20
/// as well as any other triple of numeric values.
21
21
///
22
- /// It uses integer coordinates and is therefore preferable to [`Vector3`] when exact precision is
22
+ /// `Vector3i` uses integer coordinates and is therefore preferable to [`Vector3`] when exact precision is
23
23
/// required. Note that the values are limited to 32 bits, and unlike `Vector3` this cannot be
24
24
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`][crate::builtin::PackedInt64Array]
25
25
/// if 64-bit values are needed.
26
26
///
27
+ #[ doc = shared_vector_docs ! ( ) ]
28
+ ///
27
29
/// ### Navigation to `impl` blocks within this page
28
30
///
29
31
/// - [Constants](#constants)
@@ -40,6 +42,8 @@ use crate::builtin::{inner, real, RVec3, Vector3, Vector3Axis};
40
42
/// | 3D | [`Vector3`][crate::builtin::Vector3] | **`Vector3i`** |
41
43
/// | 4D | [`Vector4`][crate::builtin::Vector4] | [`Vector4i`][crate::builtin::Vector4i] |
42
44
///
45
+ /// <br>You can convert to 2D vectors using [`to_2d()`][Self::to_2d], and to `Vector3` using [`cast_float()`][Self::cast_float].
46
+ ///
43
47
/// # Godot docs
44
48
///
45
49
/// [`Vector3i` (stable)](https://docs.godotengine.org/en/stable/classes/class_vector3i.html)
@@ -68,17 +72,13 @@ impl_vector_fns!(Vector3i, glam::IVec3, i32, (x, y, z));
68
72
69
73
/// # Specialized `Vector3i` functions
70
74
impl Vector3i {
71
- /// Constructs a new `Vector3i` from a [` Vector3`]. The floating point coordinates will be truncated.
75
+ # [ deprecated = "Moved to ` Vector3::cast_int()`" ]
72
76
#[ inline]
73
77
pub const fn from_vector3 ( v : Vector3 ) -> Self {
74
- Self {
75
- x : v. x as i32 ,
76
- y : v. y as i32 ,
77
- z : v. z as i32 ,
78
- }
78
+ v. cast_int ( )
79
79
}
80
80
81
- inline_impl_integer_vector_fns ! ( x, y, z) ;
81
+ inline_impl_integer_vector_fns ! ( Vector3 , x, y, z) ;
82
82
83
83
/// Converts `self` to the corresponding [`real`] `glam` type.
84
84
#[ doc( hidden) ]
@@ -94,7 +94,7 @@ impl Vector3i {
94
94
}
95
95
}
96
96
97
- impl_vector3x_fns ! ( Vector3i , i32 ) ;
97
+ impl_vector3x_fns ! ( Vector3i , Vector2i , i32 ) ;
98
98
99
99
impl_vector_operators ! ( Vector3i , i32 , ( x, y, z) ) ;
100
100
0 commit comments