From 1332b6a26e94c79d7fda7dad56172540e471a114 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Tue, 6 Feb 2024 23:10:46 +1300 Subject: [PATCH] WIP --- codegen/templates/mat.rs.tera | 32 +++++++++++++++++++++--- codegen/templates/vec.rs.tera | 46 +++++++++++++++++++++++++---------- src/f32.rs | 1 + src/f32/coresimd/mat3a.rs | 6 ++++- src/f32/coresimd/mat4a.rs | 12 +++++++++ src/f32/coresimd/vec3a.rs | 12 +-------- src/f32/coresimd/vec4a.rs | 14 ++++++++--- src/f32/mat4.rs | 12 +++++++++ src/f32/scalar/mat3a.rs | 6 ++++- src/f32/scalar/mat4a.rs | 12 +++++++++ src/f32/scalar/vec3a.rs | 20 +-------------- src/f32/scalar/vec4a.rs | 12 ++++++--- src/f32/sse2/mat3a.rs | 6 ++++- src/f32/sse2/mat4a.rs | 12 +++++++++ src/f32/sse2/vec3a.rs | 12 +-------- src/f32/sse2/vec4a.rs | 14 ++++++++--- src/f32/vec3.rs | 6 +---- src/f32/vec4.rs | 14 ++++++++--- src/f32/wasm32/mat3a.rs | 6 ++++- src/f32/wasm32/mat4a.rs | 12 +++++++++ src/f32/wasm32/vec3a.rs | 12 +-------- src/f32/wasm32/vec4a.rs | 14 ++++++++--- src/f64/dvec3.rs | 6 +---- src/f64/dvec4.rs | 3 +-- src/i16/i16vec3.rs | 6 +---- src/i16/i16vec4.rs | 3 +-- src/i32/ivec3.rs | 6 +---- src/i32/ivec4.rs | 3 +-- src/i64/i64vec3.rs | 6 +---- src/i64/i64vec4.rs | 3 +-- src/u16/u16vec3.rs | 6 +---- src/u16/u16vec4.rs | 3 +-- src/u32/uvec3.rs | 6 +---- src/u32/uvec4.rs | 3 +-- src/u64/u64vec3.rs | 6 +---- src/u64/u64vec4.rs | 3 +-- 36 files changed, 214 insertions(+), 142 deletions(-) diff --git a/codegen/templates/mat.rs.tera b/codegen/templates/mat.rs.tera index 57974f8c..2f375c77 100644 --- a/codegen/templates/mat.rs.tera +++ b/codegen/templates/mat.rs.tera @@ -451,9 +451,9 @@ impl {{ self_t }} { pub fn from_mat4(m: {{ mat4_t }}) -> Self { {% if self_t == "Mat3A" %} Self::from_cols( - m.x_axis.into(), - m.y_axis.into(), - m.z_axis.into(), + m.x_axis.xyz().into(), + m.y_axis.xyz().into(), + m.z_axis.xyz().into(), ) {% else %} Self::from_cols( @@ -2278,6 +2278,32 @@ impl From for Mat3A { } {% endif %} +{% if self_t == "Mat4" %} +impl From for Mat4 { + #[inline] + fn from(m: Mat4A) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} +{% elif self_t == "Mat4A" %} +impl From for Mat4A { + #[inline] + fn from(m: Mat4) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} +{% endif %} + impl Sum for {{ self_t }} { fn sum(iter: I) -> Self where diff --git a/codegen/templates/vec.rs.tera b/codegen/templates/vec.rs.tera index b33c5a73..de7d620e 100644 --- a/codegen/templates/vec.rs.tera +++ b/codegen/templates/vec.rs.tera @@ -30,7 +30,6 @@ {% endif %} {% set vec2_t = "Vec2" %} {% set vec3_t = "Vec3" %} - {% set vec3a_t = "Vec3A" %} {% set vec4_t = "Vec4" %} {% elif scalar_t == "f64" %} {% set self_t = "DVec" ~ dim %} @@ -144,8 +143,11 @@ {% if self_t != vec3_t %} {{ vec3_t }}, {% endif %} - {% if dim == 4 and scalar_t == "f32" %} - {{ vec3a_t }}, + {% if self_t == "Vec4A" or self_t == "Vec4" %} + Vec3A, + {% endif %} + {% if self_t == "Vec4" %} + Vec4A, {% endif %} {% if dim > 2 and self_t != vec4_t %} {{ vec4_t }}, @@ -478,11 +480,7 @@ impl {{ self_t }} { #[inline] #[must_use] pub(crate) fn from_vec4(v: {{ vec4_t }}) -> Self { - {% if is_scalar %} - Self { x: v.x, y: v.y, z: v.z } - {% else %} - Self(v.0) - {% endif %} + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. @@ -512,8 +510,7 @@ impl {{ self_t }} { #[inline] #[must_use] pub fn truncate(self) -> {{ vec3_t }} { - use crate::swizzles::Vec4Swizzles; - self.xyz() + {{ vec3_t }}::new(self.x, self.y, self.z) } {% endif %} @@ -3066,12 +3063,13 @@ impl From for Vec3A { } } -impl From for Vec3A { +{# +impl From for Vec3A { /// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. /// /// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. #[inline] - fn from(v: Vec4) -> Self { + fn from(v: Vec4A) -> Self { {% if is_scalar %} Self { x: v.x, @@ -3083,6 +3081,7 @@ impl From for Vec3A { {% endif %} } } +#} impl From for Vec3 { #[inline] @@ -3116,7 +3115,13 @@ impl From for Vec3 { impl From<(Vec3A, f32)> for {{ self_t }} { #[inline] fn from((v, w): (Vec3A, f32)) -> Self { - v.extend(w) + {% if is_simd %} + let v = Self(v.0); + v.w = w; + v + {% else %} + Self::new(v.x, v.y, v.z, w) + {% endif %} } } @@ -3126,6 +3131,21 @@ impl From<(f32, Vec3A)> for {{ self_t }} { Self::new(x, v.x, v.y, v.z) } } +{% if is_align %} +impl From for Vec4A { + #[inline] + fn from(v: Vec4) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} +{% else %} +impl From for Vec4 { + #[inline] + fn from(v: Vec4A) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} +{% endif %} {% endif %} {% if dim == 3 %} diff --git a/src/f32.rs b/src/f32.rs index f1d2a058..7885fad2 100644 --- a/src/f32.rs +++ b/src/f32.rs @@ -66,6 +66,7 @@ pub use mat2::{mat2, Mat2}; pub use mat3::{mat3, Mat3}; pub use mat3a::{mat3a, Mat3A}; pub use mat4::{mat4, Mat4}; +pub use mat4a::{mat4a, Mat4A}; pub use quat::{quat, Quat}; pub use vec2::{vec2, Vec2}; pub use vec3::{vec3, Vec3}; diff --git a/src/f32/coresimd/mat3a.rs b/src/f32/coresimd/mat3a.rs index 3c0645d8..a4139821 100644 --- a/src/f32/coresimd/mat3a.rs +++ b/src/f32/coresimd/mat3a.rs @@ -152,7 +152,11 @@ impl Mat3A { #[inline] #[must_use] pub fn from_mat4(m: Mat4) -> Self { - Self::from_cols(m.x_axis.into(), m.y_axis.into(), m.z_axis.into()) + Self::from_cols( + m.x_axis.xyz().into(), + m.y_axis.xyz().into(), + m.z_axis.xyz().into(), + ) } /// Creates a 3D rotation matrix from the given quaternion. diff --git a/src/f32/coresimd/mat4a.rs b/src/f32/coresimd/mat4a.rs index 8cc01aa7..c41d7fc0 100644 --- a/src/f32/coresimd/mat4a.rs +++ b/src/f32/coresimd/mat4a.rs @@ -1334,6 +1334,18 @@ impl MulAssign for Mat4A { } } +impl From for Mat4A { + #[inline] + fn from(m: Mat4) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} + impl Sum for Mat4A { fn sum(iter: I) -> Self where diff --git a/src/f32/coresimd/vec3a.rs b/src/f32/coresimd/vec3a.rs index 45d5675d..13c42fa5 100644 --- a/src/f32/coresimd/vec3a.rs +++ b/src/f32/coresimd/vec3a.rs @@ -143,7 +143,7 @@ impl Vec3A { #[inline] #[must_use] pub(crate) fn from_vec4(v: Vec4) -> Self { - Self(v.0) + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. @@ -1209,16 +1209,6 @@ impl From for Vec3A { } } -impl From for Vec3A { - /// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. - /// - /// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. - #[inline] - fn from(v: Vec4) -> Self { - Self(v.0) - } -} - impl From for Vec3 { #[inline] fn from(v: Vec3A) -> Self { diff --git a/src/f32/coresimd/vec4a.rs b/src/f32/coresimd/vec4a.rs index c19a1fa2..46af06cc 100644 --- a/src/f32/coresimd/vec4a.rs +++ b/src/f32/coresimd/vec4a.rs @@ -149,8 +149,7 @@ impl Vec4A { #[inline] #[must_use] pub fn truncate(self) -> Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. @@ -1117,7 +1116,9 @@ impl From for (f32, f32, f32, f32) { impl From<(Vec3A, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3A, f32)) -> Self { - v.extend(w) + let v = Self(v.0); + v.w = w; + v } } @@ -1128,6 +1129,13 @@ impl From<(f32, Vec3A)> for Vec4A { } } +impl From for Vec4A { + #[inline] + fn from(v: Vec4) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} + impl From<(Vec3, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3, f32)) -> Self { diff --git a/src/f32/mat4.rs b/src/f32/mat4.rs index 375b0454..70c6546b 100644 --- a/src/f32/mat4.rs +++ b/src/f32/mat4.rs @@ -1240,6 +1240,18 @@ impl MulAssign for Mat4 { } } +impl From for Mat4 { + #[inline] + fn from(m: Mat4A) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} + impl Sum for Mat4 { fn sum(iter: I) -> Self where diff --git a/src/f32/scalar/mat3a.rs b/src/f32/scalar/mat3a.rs index b443ae0b..d1bd2294 100644 --- a/src/f32/scalar/mat3a.rs +++ b/src/f32/scalar/mat3a.rs @@ -153,7 +153,11 @@ impl Mat3A { #[inline] #[must_use] pub fn from_mat4(m: Mat4) -> Self { - Self::from_cols(m.x_axis.into(), m.y_axis.into(), m.z_axis.into()) + Self::from_cols( + m.x_axis.xyz().into(), + m.y_axis.xyz().into(), + m.z_axis.xyz().into(), + ) } /// Creates a 3D rotation matrix from the given quaternion. diff --git a/src/f32/scalar/mat4a.rs b/src/f32/scalar/mat4a.rs index ab85c2f0..6b91c2c0 100644 --- a/src/f32/scalar/mat4a.rs +++ b/src/f32/scalar/mat4a.rs @@ -1247,6 +1247,18 @@ impl MulAssign for Mat4A { } } +impl From for Mat4A { + #[inline] + fn from(m: Mat4) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} + impl Sum for Mat4A { fn sum(iter: I) -> Self where diff --git a/src/f32/scalar/vec3a.rs b/src/f32/scalar/vec3a.rs index b123a1e2..f02e6e2c 100644 --- a/src/f32/scalar/vec3a.rs +++ b/src/f32/scalar/vec3a.rs @@ -150,11 +150,7 @@ impl Vec3A { #[inline] #[must_use] pub(crate) fn from_vec4(v: Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. @@ -1327,20 +1323,6 @@ impl From for Vec3A { } } -impl From for Vec3A { - /// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. - /// - /// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. - #[inline] - fn from(v: Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } - } -} - impl From for Vec3 { #[inline] fn from(v: Vec3A) -> Self { diff --git a/src/f32/scalar/vec4a.rs b/src/f32/scalar/vec4a.rs index 6287e403..0d0dd368 100644 --- a/src/f32/scalar/vec4a.rs +++ b/src/f32/scalar/vec4a.rs @@ -172,8 +172,7 @@ impl Vec4A { #[inline] #[must_use] pub fn truncate(self) -> Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. @@ -1331,7 +1330,7 @@ impl From for (f32, f32, f32, f32) { impl From<(Vec3A, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3A, f32)) -> Self { - v.extend(w) + Self::new(v.x, v.y, v.z, w) } } @@ -1342,6 +1341,13 @@ impl From<(f32, Vec3A)> for Vec4A { } } +impl From for Vec4A { + #[inline] + fn from(v: Vec4) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} + impl From<(Vec3, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3, f32)) -> Self { diff --git a/src/f32/sse2/mat3a.rs b/src/f32/sse2/mat3a.rs index 56f762ee..2440488d 100644 --- a/src/f32/sse2/mat3a.rs +++ b/src/f32/sse2/mat3a.rs @@ -155,7 +155,11 @@ impl Mat3A { #[inline] #[must_use] pub fn from_mat4(m: Mat4) -> Self { - Self::from_cols(m.x_axis.into(), m.y_axis.into(), m.z_axis.into()) + Self::from_cols( + m.x_axis.xyz().into(), + m.y_axis.xyz().into(), + m.z_axis.xyz().into(), + ) } /// Creates a 3D rotation matrix from the given quaternion. diff --git a/src/f32/sse2/mat4a.rs b/src/f32/sse2/mat4a.rs index bb314edc..9d917c21 100644 --- a/src/f32/sse2/mat4a.rs +++ b/src/f32/sse2/mat4a.rs @@ -1343,6 +1343,18 @@ impl MulAssign for Mat4A { } } +impl From for Mat4A { + #[inline] + fn from(m: Mat4) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} + impl Sum for Mat4A { fn sum(iter: I) -> Self where diff --git a/src/f32/sse2/vec3a.rs b/src/f32/sse2/vec3a.rs index d442702a..87a7f61d 100644 --- a/src/f32/sse2/vec3a.rs +++ b/src/f32/sse2/vec3a.rs @@ -156,7 +156,7 @@ impl Vec3A { #[inline] #[must_use] pub(crate) fn from_vec4(v: Vec4) -> Self { - Self(v.0) + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. @@ -1291,16 +1291,6 @@ impl From for Vec3A { } } -impl From for Vec3A { - /// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. - /// - /// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. - #[inline] - fn from(v: Vec4) -> Self { - Self(v.0) - } -} - impl From for Vec3 { #[inline] fn from(v: Vec3A) -> Self { diff --git a/src/f32/sse2/vec4a.rs b/src/f32/sse2/vec4a.rs index 7804e71a..d7199fe3 100644 --- a/src/f32/sse2/vec4a.rs +++ b/src/f32/sse2/vec4a.rs @@ -162,8 +162,7 @@ impl Vec4A { #[inline] #[must_use] pub fn truncate(self) -> Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. @@ -1203,7 +1202,9 @@ impl From for (f32, f32, f32, f32) { impl From<(Vec3A, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3A, f32)) -> Self { - v.extend(w) + let v = Self(v.0); + v.w = w; + v } } @@ -1214,6 +1215,13 @@ impl From<(f32, Vec3A)> for Vec4A { } } +impl From for Vec4A { + #[inline] + fn from(v: Vec4) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} + impl From<(Vec3, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3, f32)) -> Self { diff --git a/src/f32/vec3.rs b/src/f32/vec3.rs index 447d5717..30afaee7 100644 --- a/src/f32/vec3.rs +++ b/src/f32/vec3.rs @@ -141,11 +141,7 @@ impl Vec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/f32/vec4.rs b/src/f32/vec4.rs index 02fb7a38..0f9d2140 100644 --- a/src/f32/vec4.rs +++ b/src/f32/vec4.rs @@ -1,6 +1,6 @@ // Generated from vec.rs.tera template. Edit the template, not the generated file. -use crate::{f32::math, BVec4, Vec2, Vec3, Vec3A}; +use crate::{f32::math, BVec4, Vec2, Vec3, Vec3A, Vec4A}; #[cfg(not(target_arch = "spirv"))] use core::fmt; @@ -162,8 +162,7 @@ impl Vec4 { #[inline] #[must_use] pub fn truncate(self) -> Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. @@ -1321,7 +1320,7 @@ impl From for (f32, f32, f32, f32) { impl From<(Vec3A, f32)> for Vec4 { #[inline] fn from((v, w): (Vec3A, f32)) -> Self { - v.extend(w) + Self::new(v.x, v.y, v.z, w) } } @@ -1332,6 +1331,13 @@ impl From<(f32, Vec3A)> for Vec4 { } } +impl From for Vec4 { + #[inline] + fn from(v: Vec4A) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} + impl From<(Vec3, f32)> for Vec4 { #[inline] fn from((v, w): (Vec3, f32)) -> Self { diff --git a/src/f32/wasm32/mat3a.rs b/src/f32/wasm32/mat3a.rs index 96c039b4..72a984e3 100644 --- a/src/f32/wasm32/mat3a.rs +++ b/src/f32/wasm32/mat3a.rs @@ -152,7 +152,11 @@ impl Mat3A { #[inline] #[must_use] pub fn from_mat4(m: Mat4) -> Self { - Self::from_cols(m.x_axis.into(), m.y_axis.into(), m.z_axis.into()) + Self::from_cols( + m.x_axis.xyz().into(), + m.y_axis.xyz().into(), + m.z_axis.xyz().into(), + ) } /// Creates a 3D rotation matrix from the given quaternion. diff --git a/src/f32/wasm32/mat4a.rs b/src/f32/wasm32/mat4a.rs index 73ade1d6..851c39bd 100644 --- a/src/f32/wasm32/mat4a.rs +++ b/src/f32/wasm32/mat4a.rs @@ -1334,6 +1334,18 @@ impl MulAssign for Mat4A { } } +impl From for Mat4A { + #[inline] + fn from(m: Mat4) -> Self { + Self { + x_axis: m.x_axis.into(), + y_axis: m.y_axis.into(), + z_axis: m.z_axis.into(), + w_axis: m.w_axis.into(), + } + } +} + impl Sum for Mat4A { fn sum(iter: I) -> Self where diff --git a/src/f32/wasm32/vec3a.rs b/src/f32/wasm32/vec3a.rs index c89fb1a3..4ce946b0 100644 --- a/src/f32/wasm32/vec3a.rs +++ b/src/f32/wasm32/vec3a.rs @@ -148,7 +148,7 @@ impl Vec3A { #[inline] #[must_use] pub(crate) fn from_vec4(v: Vec4) -> Self { - Self(v.0) + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. @@ -1243,16 +1243,6 @@ impl From for Vec3A { } } -impl From for Vec3A { - /// Creates a [`Vec3A`] from the `x`, `y` and `z` elements of `self` discarding `w`. - /// - /// On architectures where SIMD is supported such as SSE2 on `x86_64` this conversion is a noop. - #[inline] - fn from(v: Vec4) -> Self { - Self(v.0) - } -} - impl From for Vec3 { #[inline] fn from(v: Vec3A) -> Self { diff --git a/src/f32/wasm32/vec4a.rs b/src/f32/wasm32/vec4a.rs index 8195f24a..29f62d12 100644 --- a/src/f32/wasm32/vec4a.rs +++ b/src/f32/wasm32/vec4a.rs @@ -154,8 +154,7 @@ impl Vec4A { #[inline] #[must_use] pub fn truncate(self) -> Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. @@ -1162,7 +1161,9 @@ impl From for (f32, f32, f32, f32) { impl From<(Vec3A, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3A, f32)) -> Self { - v.extend(w) + let v = Self(v.0); + v.w = w; + v } } @@ -1173,6 +1174,13 @@ impl From<(f32, Vec3A)> for Vec4A { } } +impl From for Vec4A { + #[inline] + fn from(v: Vec4) -> Self { + Self::new(v.x, v.y, v.z, v.w) + } +} + impl From<(Vec3, f32)> for Vec4A { #[inline] fn from((v, w): (Vec3, f32)) -> Self { diff --git a/src/f64/dvec3.rs b/src/f64/dvec3.rs index ba7f93d2..5f5776af 100644 --- a/src/f64/dvec3.rs +++ b/src/f64/dvec3.rs @@ -141,11 +141,7 @@ impl DVec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: DVec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/f64/dvec4.rs b/src/f64/dvec4.rs index 29175c81..ba853229 100644 --- a/src/f64/dvec4.rs +++ b/src/f64/dvec4.rs @@ -160,8 +160,7 @@ impl DVec4 { #[inline] #[must_use] pub fn truncate(self) -> DVec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + DVec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. diff --git a/src/i16/i16vec3.rs b/src/i16/i16vec3.rs index 2717065c..d5e8823b 100644 --- a/src/i16/i16vec3.rs +++ b/src/i16/i16vec3.rs @@ -133,11 +133,7 @@ impl I16Vec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: I16Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/i16/i16vec4.rs b/src/i16/i16vec4.rs index 9b23b915..22f5e13b 100644 --- a/src/i16/i16vec4.rs +++ b/src/i16/i16vec4.rs @@ -152,8 +152,7 @@ impl I16Vec4 { #[inline] #[must_use] pub fn truncate(self) -> I16Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + I16Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. diff --git a/src/i32/ivec3.rs b/src/i32/ivec3.rs index dde78cab..e01f2172 100644 --- a/src/i32/ivec3.rs +++ b/src/i32/ivec3.rs @@ -133,11 +133,7 @@ impl IVec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: IVec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/i32/ivec4.rs b/src/i32/ivec4.rs index 48bff1e1..5bb2e9c6 100644 --- a/src/i32/ivec4.rs +++ b/src/i32/ivec4.rs @@ -152,8 +152,7 @@ impl IVec4 { #[inline] #[must_use] pub fn truncate(self) -> IVec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + IVec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. diff --git a/src/i64/i64vec3.rs b/src/i64/i64vec3.rs index 8ac88c3d..4cae9a6c 100644 --- a/src/i64/i64vec3.rs +++ b/src/i64/i64vec3.rs @@ -133,11 +133,7 @@ impl I64Vec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: I64Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/i64/i64vec4.rs b/src/i64/i64vec4.rs index 4456cc0a..4045f8f3 100644 --- a/src/i64/i64vec4.rs +++ b/src/i64/i64vec4.rs @@ -152,8 +152,7 @@ impl I64Vec4 { #[inline] #[must_use] pub fn truncate(self) -> I64Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + I64Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. diff --git a/src/u16/u16vec3.rs b/src/u16/u16vec3.rs index 7e5db691..ba000ce5 100644 --- a/src/u16/u16vec3.rs +++ b/src/u16/u16vec3.rs @@ -121,11 +121,7 @@ impl U16Vec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: U16Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/u16/u16vec4.rs b/src/u16/u16vec4.rs index a6390acc..2d7981ab 100644 --- a/src/u16/u16vec4.rs +++ b/src/u16/u16vec4.rs @@ -137,8 +137,7 @@ impl U16Vec4 { #[inline] #[must_use] pub fn truncate(self) -> U16Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + U16Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. diff --git a/src/u32/uvec3.rs b/src/u32/uvec3.rs index 3dadd7ca..114186d8 100644 --- a/src/u32/uvec3.rs +++ b/src/u32/uvec3.rs @@ -121,11 +121,7 @@ impl UVec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: UVec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/u32/uvec4.rs b/src/u32/uvec4.rs index 5158c93a..b55864fc 100644 --- a/src/u32/uvec4.rs +++ b/src/u32/uvec4.rs @@ -137,8 +137,7 @@ impl UVec4 { #[inline] #[must_use] pub fn truncate(self) -> UVec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + UVec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`. diff --git a/src/u64/u64vec3.rs b/src/u64/u64vec3.rs index 72ba129e..94f1691f 100644 --- a/src/u64/u64vec3.rs +++ b/src/u64/u64vec3.rs @@ -121,11 +121,7 @@ impl U64Vec3 { #[inline] #[must_use] pub(crate) fn from_vec4(v: U64Vec4) -> Self { - Self { - x: v.x, - y: v.y, - z: v.z, - } + Self::new(v.x, v.y, v.z) } /// Creates a 4D vector from `self` and the given `w` value. diff --git a/src/u64/u64vec4.rs b/src/u64/u64vec4.rs index 56743149..c6495a97 100644 --- a/src/u64/u64vec4.rs +++ b/src/u64/u64vec4.rs @@ -137,8 +137,7 @@ impl U64Vec4 { #[inline] #[must_use] pub fn truncate(self) -> U64Vec3 { - use crate::swizzles::Vec4Swizzles; - self.xyz() + U64Vec3::new(self.x, self.y, self.z) } /// Computes the dot product of `self` and `rhs`.