Skip to content

Commit 3aefb03

Browse files
committed
Remove vector to_2d() + to_3d() methods
Semantics aren't obvious -- while Z component is the mathematically natural extension, in Godot Y would be more typical (being the up/down axis in 3D). There's also the topic of +/- signs... Maybe it can be re-added once there are clearer use cases. Alternatively, a more flexible swizzle! macro supporting 0 when extending is possible.
1 parent 4c283d4 commit 3aefb03

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use sys::{ffi_methods, GodotFfi};
1111

1212
use crate::builtin::math::{FloatExt, GlamConv, GlamType};
1313
use crate::builtin::vectors::Vector2Axis;
14-
use crate::builtin::{inner, real, RAffine2, RVec2, Vector2i, Vector3};
14+
use crate::builtin::{inner, real, RAffine2, RVec2, Vector2i};
1515

1616
use std::fmt;
1717

@@ -44,7 +44,7 @@ use std::fmt;
4444
/// | 3D | [`Vector3`][crate::builtin::Vector3] | [`Vector3i`][crate::builtin::Vector3i] |
4545
/// | 4D | [`Vector4`][crate::builtin::Vector4] | [`Vector4i`][crate::builtin::Vector4i] |
4646
///
47-
/// <br>You can convert to 3D vectors using [`to_3d(z)`][Self::to_3d], and to `Vector2i` using [`cast_int()`][Self::cast_int].
47+
/// <br>You can convert to `Vector2i` using [`cast_int()`][Self::cast_int].
4848
///
4949
/// # Godot docs
5050
///

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::cmp::Ordering;
1010
use sys::{ffi_methods, GodotFfi};
1111

1212
use crate::builtin::math::{GlamConv, GlamType};
13-
use crate::builtin::{inner, real, RVec2, Vector2, Vector2Axis, Vector3i};
13+
use crate::builtin::{inner, real, RVec2, Vector2, Vector2Axis};
1414

1515
use std::fmt;
1616

@@ -42,7 +42,7 @@ use std::fmt;
4242
/// | 3D | [`Vector3`][crate::builtin::Vector3] | [`Vector3i`][crate::builtin::Vector3i] |
4343
/// | 4D | [`Vector4`][crate::builtin::Vector4] | [`Vector4i`][crate::builtin::Vector4i] |
4444
///
45-
/// <br>You can convert to 3D vectors using [`to_3d(z)`][Self::to_3d], and to `Vector2` using [`cast_float()`][Self::cast_float].
45+
/// <br>You can convert to `Vector2` using [`cast_float()`][Self::cast_float].
4646
///
4747
/// # Godot docs
4848
///

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use std::fmt;
4545
/// | 3D | **`Vector3`** | [`Vector3i`][crate::builtin::Vector3i] |
4646
/// | 4D | [`Vector4`][crate::builtin::Vector4] | [`Vector4i`][crate::builtin::Vector4i] |
4747
///
48-
/// <br>You can convert to 2D vectors using [`to_2d()`][Self::to_2d], and to `Vector3i` using [`cast_int()`][Self::cast_int].
48+
/// <br>You can convert to `Vector3i` using [`cast_int()`][Self::cast_int].
4949
///
5050
/// # Godot docs
5151
///

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use godot_ffi as sys;
1212
use sys::{ffi_methods, GodotFfi};
1313

1414
use crate::builtin::math::{GlamConv, GlamType};
15-
use crate::builtin::{inner, real, RVec3, Vector2i, Vector3, Vector3Axis};
15+
use crate::builtin::{inner, real, RVec3, Vector3, Vector3Axis};
1616

1717
/// Vector used for 3D math using integer coordinates.
1818
///
@@ -42,7 +42,7 @@ use crate::builtin::{inner, real, RVec3, Vector2i, Vector3, Vector3Axis};
4242
/// | 3D | [`Vector3`][crate::builtin::Vector3] | **`Vector3i`** |
4343
/// | 4D | [`Vector4`][crate::builtin::Vector4] | [`Vector4i`][crate::builtin::Vector4i] |
4444
///
45-
/// <br>You can convert to 2D vectors using [`to_2d()`][Self::to_2d], and to `Vector3` using [`cast_float()`][Self::cast_float].
45+
/// <br>You can convert to `Vector3` using [`cast_float()`][Self::cast_float].
4646
///
4747
/// # Godot docs
4848
///

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,6 @@ macro_rules! impl_vector2x_fns {
791791
/// # 2D functions
792792
/// The following methods are only available on 2D vectors (for both float and int).
793793
impl $Vector {
794-
/// Increases dimension to 3D, accepting a new value for the Z component.
795-
#[inline]
796-
pub fn to_3d(self, z: $Scalar) -> $Vector3D {
797-
<$Vector3D>::new(self.x, self.y, z)
798-
}
799-
800794
/// Returns the aspect ratio of this vector, the ratio of [`Self::x`] to [`Self::y`].
801795
#[inline]
802796
pub fn aspect(self) -> real {
@@ -853,15 +847,6 @@ macro_rules! impl_vector3x_fns {
853847
/// # 3D functions
854848
/// The following methods are only available on 3D vectors (for both float and int).
855849
impl $Vector {
856-
/// Reduces dimension to 2D, discarding the Z component.
857-
///
858-
/// See also [`swizzle!`][crate::builtin::swizzle] for a more general way to extract components.
859-
/// `self.to_2d()` is equivalent to `swizzle!(self => x, y)`.
860-
#[inline]
861-
pub fn to_2d(self) -> $Vector2D {
862-
<$Vector2D>::new(self.x, self.y)
863-
}
864-
865850
/// Returns the axis of the vector's highest value. See [`Vector3Axis`] enum. If all components are equal, this method returns [`None`].
866851
///
867852
/// To mimic Godot's behavior, unwrap this function's result with `unwrap_or(Vector3Axis::X)`.

0 commit comments

Comments
 (0)