From 1e31e6ba69625cbb5ed9eae14f990953b7290e3e Mon Sep 17 00:00:00 2001 From: devil-ira Date: Sat, 23 Jul 2022 17:39:59 +0200 Subject: [PATCH 1/2] Add feature `convert-glam021`. --- Cargo.toml | 2 ++ src/third_party/glam/mod.rs | 2 ++ src/third_party/glam/v021/mod.rs | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/third_party/glam/v021/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 732676ec..faee3029 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ convert-glam017 = [ "glam017" ] convert-glam018 = [ "glam018" ] convert-glam019 = [ "glam019" ] convert-glam020 = [ "glam020" ] +convert-glam021 = [ "glam021" ] # Serialization ## To use serde in a #[no-std] environment, enable the @@ -95,6 +96,7 @@ glam017 = { package = "glam", version = "0.17", optional = true } glam018 = { package = "glam", version = "0.18", optional = true } glam019 = { package = "glam", version = "0.19", optional = true } glam020 = { package = "glam", version = "0.20", optional = true } +glam021 = { package = "glam", version = "0.21", optional = true } cust_core = { version = "0.1", optional = true } diff --git a/src/third_party/glam/mod.rs b/src/third_party/glam/mod.rs index ae2c4514..06bdcfb7 100644 --- a/src/third_party/glam/mod.rs +++ b/src/third_party/glam/mod.rs @@ -12,3 +12,5 @@ mod v018; mod v019; #[cfg(feature = "glam020")] mod v020; +#[cfg(feature = "glam021")] +mod v021; diff --git a/src/third_party/glam/v021/mod.rs b/src/third_party/glam/v021/mod.rs new file mode 100644 index 00000000..d0168923 --- /dev/null +++ b/src/third_party/glam/v021/mod.rs @@ -0,0 +1,18 @@ +#[path = "../common/glam_isometry.rs"] +mod glam_isometry; +#[path = "../common/glam_matrix.rs"] +mod glam_matrix; +#[path = "../common/glam_point.rs"] +mod glam_point; +#[path = "../common/glam_quaternion.rs"] +mod glam_quaternion; +#[path = "../common/glam_rotation.rs"] +mod glam_rotation; +#[path = "../common/glam_similarity.rs"] +mod glam_similarity; +#[path = "../common/glam_translation.rs"] +mod glam_translation; +#[path = "../common/glam_unit_complex.rs"] +mod glam_unit_complex; + +pub(self) use glam021 as glam; From 238750fb30a5f3785e37fbf4a4ebc5af48e55dd3 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Sat, 23 Jul 2022 23:55:40 +0200 Subject: [PATCH 2/2] Use `From` trait to convert glam types to arrays. --- src/third_party/glam/common/glam_matrix.rs | 6 +++--- src/third_party/glam/common/glam_point.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/third_party/glam/common/glam_matrix.rs b/src/third_party/glam/common/glam_matrix.rs index fa9f713f..26f58803 100644 --- a/src/third_party/glam/common/glam_matrix.rs +++ b/src/third_party/glam/common/glam_matrix.rs @@ -14,7 +14,7 @@ macro_rules! impl_vec_conversion( impl From<$Vec2> for Vector2<$N> { #[inline] fn from(e: $Vec2) -> Vector2<$N> { - (*e.as_ref()).into() + <[$N;2]>::from(e).into() } } @@ -31,7 +31,7 @@ macro_rules! impl_vec_conversion( impl From<$Vec3> for Vector3<$N> { #[inline] fn from(e: $Vec3) -> Vector3<$N> { - (*e.as_ref()).into() + <[$N;3]>::from(e).into() } } @@ -48,7 +48,7 @@ macro_rules! impl_vec_conversion( impl From<$Vec4> for Vector4<$N> { #[inline] fn from(e: $Vec4) -> Vector4<$N> { - (*e.as_ref()).into() + <[$N;4]>::from(e).into() } } diff --git a/src/third_party/glam/common/glam_point.rs b/src/third_party/glam/common/glam_point.rs index b15a6c6d..205986b8 100644 --- a/src/third_party/glam/common/glam_point.rs +++ b/src/third_party/glam/common/glam_point.rs @@ -9,7 +9,7 @@ macro_rules! impl_point_conversion( impl From<$Vec2> for Point2<$N> { #[inline] fn from(e: $Vec2) -> Point2<$N> { - (*e.as_ref()).into() + <[$N;2]>::from(e).into() } } @@ -23,7 +23,7 @@ macro_rules! impl_point_conversion( impl From<$Vec3> for Point3<$N> { #[inline] fn from(e: $Vec3) -> Point3<$N> { - (*e.as_ref()).into() + <[$N;3]>::from(e).into() } } @@ -37,7 +37,7 @@ macro_rules! impl_point_conversion( impl From<$Vec4> for Point4<$N> { #[inline] fn from(e: $Vec4) -> Point4<$N> { - (*e.as_ref()).into() + <[$N;4]>::from(e).into() } }