Skip to content

Commit

Permalink
Fix clippy lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitshifter committed Jun 13, 2022
1 parent 55678c6 commit eb349af
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
20 changes: 15 additions & 5 deletions codegen/templates/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl {{ self_t }} {
#[inline(always)]
pub fn from_scale(scale: {{ vec3_t }}) -> Self {
Self {
matrix3: {{ mat_t }}::from_diagonal(scale.into()),
matrix3: {{ mat_t }}::from_diagonal(scale),
translation: {{ col_t }}::ZERO,
}
}
Expand Down Expand Up @@ -353,6 +353,7 @@ impl {{ self_t }} {
/// Creates an affine transformation from the given 3D `translation`.
#[inline(always)]
pub fn from_translation(translation: {{ vec3_t }}) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: {{ mat_t }}::IDENTITY,
translation: translation.into(),
Expand All @@ -363,6 +364,7 @@ impl {{ self_t }} {
/// rotation)
#[inline(always)]
pub fn from_mat3(mat3: {{ mat3_t }}) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: mat3.into(),
translation: {{ col_t }}::ZERO,
Expand All @@ -375,6 +377,7 @@ impl {{ self_t }} {
/// Equivalent to `{{ self_t }}::from_translation(translation) * {{ self_t }}::from_mat3(mat3)`
#[inline(always)]
pub fn from_mat3_translation(mat3: {{ mat3_t }}, translation: {{ vec3_t }}) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: mat3.into(),
translation: translation.into(),
Expand All @@ -393,6 +396,7 @@ impl {{ self_t }} {
translation: {{ vec3_t }},
) -> Self {
let rotation = {{ mat_t }}::from_quat(rotation);
#[allow(clippy::useless_conversion)]
Self {
matrix3: {{ mat_t }}::from_cols(
rotation.x_axis * scale.x,
Expand All @@ -408,8 +412,9 @@ impl {{ self_t }} {
/// Equivalent to `{{ self_t }}::from_translation(translation) * {{ self_t }}::from_quat(rotation)`
#[inline(always)]
pub fn from_rotation_translation(rotation: {{ quat_t }}, translation: {{ vec3_t }}) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: {{ mat_t }}::from_quat(rotation.into()),
matrix3: {{ mat_t }}::from_quat(rotation),
translation: translation.into(),
}
}
Expand All @@ -418,6 +423,7 @@ impl {{ self_t }} {
/// i.e. contain no perspective transform.
#[inline]
pub fn from_mat4(m: {{ mat4_t }}) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: {{ mat_t }}::from_cols(
{{ col_t }}(m.x_axis.0.into()),
Expand Down Expand Up @@ -453,12 +459,14 @@ impl {{ self_t }} {

let inv_scale = scale.recip();

#[allow(clippy::useless_conversion)]
let rotation = {{ quat_t }}::from_mat3(&{{ mat3_t }}::from_cols(
(self.matrix3.x_axis * inv_scale.x).into(),
(self.matrix3.y_axis * inv_scale.y).into(),
(self.matrix3.z_axis * inv_scale.z).into(),
));

#[allow(clippy::useless_conversion)]
(scale, rotation, self.translation.into())
}

Expand All @@ -469,9 +477,9 @@ impl {{ self_t }} {
let u = f.cross(s);
Self {
matrix3: {{ mat_t }}::from_cols(
{{ vec3_t }}::new(s.x, u.x, f.x).into(),
{{ vec3_t }}::new(s.y, u.y, f.y).into(),
{{ vec3_t }}::new(s.z, u.z, f.z).into(),
{{ col_t }}::new(s.x, u.x, f.x),
{{ col_t }}::new(s.y, u.y, f.y),
{{ col_t }}::new(s.z, u.z, f.z),
),
translation: {{ col_t }}::new(-s.dot(eye), -u.dot(eye), -f.dot(eye)),
}
Expand Down Expand Up @@ -508,6 +516,7 @@ impl {{ self_t }} {
/// Transforms the given 3D points, applying shear, scale, rotation and translation.
#[inline(always)]
pub fn transform_point3(&self, other: {{ vec3_t }}) -> {{ vec3_t }} {
#[allow(clippy::useless_conversion)]
((self.matrix3.x_axis * other.x)
+ (self.matrix3.y_axis * other.y)
+ (self.matrix3.z_axis * other.z)
Expand All @@ -521,6 +530,7 @@ impl {{ self_t }} {
/// To also apply translation, use [`Self::transform_point3`] instead.
#[inline(always)]
pub fn transform_vector3(&self, other: {{ vec3_t }}) -> {{ vec3_t }} {
#[allow(clippy::useless_conversion)]
((self.matrix3.x_axis * other.x)
+ (self.matrix3.y_axis * other.y)
+ (self.matrix3.z_axis * other.z))
Expand Down
2 changes: 2 additions & 0 deletions src/f32/affine2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Generated from affine.rs template. Edit the template, not the generated file.

use crate::core::storage::Columns3;
use crate::{Mat2, Mat3, Mat3A, Vec2, Vec3A};
use core::ops::{Add, Deref, DerefMut, Mul, Sub};
Expand Down
20 changes: 15 additions & 5 deletions src/f32/affine3a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Affine3A {
#[inline(always)]
pub fn from_scale(scale: Vec3) -> Self {
Self {
matrix3: Mat3A::from_diagonal(scale.into()),
matrix3: Mat3A::from_diagonal(scale),
translation: Vec3A::ZERO,
}
}
Expand Down Expand Up @@ -180,6 +180,7 @@ impl Affine3A {
/// Creates an affine transformation from the given 3D `translation`.
#[inline(always)]
pub fn from_translation(translation: Vec3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: Mat3A::IDENTITY,
translation: translation.into(),
Expand All @@ -190,6 +191,7 @@ impl Affine3A {
/// rotation)
#[inline(always)]
pub fn from_mat3(mat3: Mat3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: mat3.into(),
translation: Vec3A::ZERO,
Expand All @@ -202,6 +204,7 @@ impl Affine3A {
/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)`
#[inline(always)]
pub fn from_mat3_translation(mat3: Mat3, translation: Vec3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: mat3.into(),
translation: translation.into(),
Expand All @@ -216,6 +219,7 @@ impl Affine3A {
#[inline(always)]
pub fn from_scale_rotation_translation(scale: Vec3, rotation: Quat, translation: Vec3) -> Self {
let rotation = Mat3A::from_quat(rotation);
#[allow(clippy::useless_conversion)]
Self {
matrix3: Mat3A::from_cols(
rotation.x_axis * scale.x,
Expand All @@ -231,8 +235,9 @@ impl Affine3A {
/// Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)`
#[inline(always)]
pub fn from_rotation_translation(rotation: Quat, translation: Vec3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: Mat3A::from_quat(rotation.into()),
matrix3: Mat3A::from_quat(rotation),
translation: translation.into(),
}
}
Expand All @@ -241,6 +246,7 @@ impl Affine3A {
/// i.e. contain no perspective transform.
#[inline]
pub fn from_mat4(m: Mat4) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: Mat3A::from_cols(
Vec3A(m.x_axis.0.into()),
Expand Down Expand Up @@ -276,12 +282,14 @@ impl Affine3A {

let inv_scale = scale.recip();

#[allow(clippy::useless_conversion)]
let rotation = Quat::from_mat3(&Mat3::from_cols(
(self.matrix3.x_axis * inv_scale.x).into(),
(self.matrix3.y_axis * inv_scale.y).into(),
(self.matrix3.z_axis * inv_scale.z).into(),
));

#[allow(clippy::useless_conversion)]
(scale, rotation, self.translation.into())
}

Expand All @@ -292,9 +300,9 @@ impl Affine3A {
let u = f.cross(s);
Self {
matrix3: Mat3A::from_cols(
Vec3::new(s.x, u.x, f.x).into(),
Vec3::new(s.y, u.y, f.y).into(),
Vec3::new(s.z, u.z, f.z).into(),
Vec3A::new(s.x, u.x, f.x),
Vec3A::new(s.y, u.y, f.y),
Vec3A::new(s.z, u.z, f.z),
),
translation: Vec3A::new(-s.dot(eye), -u.dot(eye), -f.dot(eye)),
}
Expand Down Expand Up @@ -331,6 +339,7 @@ impl Affine3A {
/// Transforms the given 3D points, applying shear, scale, rotation and translation.
#[inline(always)]
pub fn transform_point3(&self, other: Vec3) -> Vec3 {
#[allow(clippy::useless_conversion)]
((self.matrix3.x_axis * other.x)
+ (self.matrix3.y_axis * other.y)
+ (self.matrix3.z_axis * other.z)
Expand All @@ -344,6 +353,7 @@ impl Affine3A {
/// To also apply translation, use [`Self::transform_point3`] instead.
#[inline(always)]
pub fn transform_vector3(&self, other: Vec3) -> Vec3 {
#[allow(clippy::useless_conversion)]
((self.matrix3.x_axis * other.x)
+ (self.matrix3.y_axis * other.y)
+ (self.matrix3.z_axis * other.z))
Expand Down
20 changes: 15 additions & 5 deletions src/f64/daffine3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl DAffine3 {
#[inline(always)]
pub fn from_scale(scale: DVec3) -> Self {
Self {
matrix3: DMat3::from_diagonal(scale.into()),
matrix3: DMat3::from_diagonal(scale),
translation: DVec3::ZERO,
}
}
Expand Down Expand Up @@ -180,6 +180,7 @@ impl DAffine3 {
/// Creates an affine transformation from the given 3D `translation`.
#[inline(always)]
pub fn from_translation(translation: DVec3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: DMat3::IDENTITY,
translation: translation.into(),
Expand All @@ -190,6 +191,7 @@ impl DAffine3 {
/// rotation)
#[inline(always)]
pub fn from_mat3(mat3: DMat3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: mat3.into(),
translation: DVec3::ZERO,
Expand All @@ -202,6 +204,7 @@ impl DAffine3 {
/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)`
#[inline(always)]
pub fn from_mat3_translation(mat3: DMat3, translation: DVec3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: mat3.into(),
translation: translation.into(),
Expand All @@ -220,6 +223,7 @@ impl DAffine3 {
translation: DVec3,
) -> Self {
let rotation = DMat3::from_quat(rotation);
#[allow(clippy::useless_conversion)]
Self {
matrix3: DMat3::from_cols(
rotation.x_axis * scale.x,
Expand All @@ -235,8 +239,9 @@ impl DAffine3 {
/// Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)`
#[inline(always)]
pub fn from_rotation_translation(rotation: DQuat, translation: DVec3) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: DMat3::from_quat(rotation.into()),
matrix3: DMat3::from_quat(rotation),
translation: translation.into(),
}
}
Expand All @@ -245,6 +250,7 @@ impl DAffine3 {
/// i.e. contain no perspective transform.
#[inline]
pub fn from_mat4(m: DMat4) -> Self {
#[allow(clippy::useless_conversion)]
Self {
matrix3: DMat3::from_cols(
DVec3(m.x_axis.0.into()),
Expand Down Expand Up @@ -280,12 +286,14 @@ impl DAffine3 {

let inv_scale = scale.recip();

#[allow(clippy::useless_conversion)]
let rotation = DQuat::from_mat3(&DMat3::from_cols(
(self.matrix3.x_axis * inv_scale.x).into(),
(self.matrix3.y_axis * inv_scale.y).into(),
(self.matrix3.z_axis * inv_scale.z).into(),
));

#[allow(clippy::useless_conversion)]
(scale, rotation, self.translation.into())
}

Expand All @@ -296,9 +304,9 @@ impl DAffine3 {
let u = f.cross(s);
Self {
matrix3: DMat3::from_cols(
DVec3::new(s.x, u.x, f.x).into(),
DVec3::new(s.y, u.y, f.y).into(),
DVec3::new(s.z, u.z, f.z).into(),
DVec3::new(s.x, u.x, f.x),
DVec3::new(s.y, u.y, f.y),
DVec3::new(s.z, u.z, f.z),
),
translation: DVec3::new(-s.dot(eye), -u.dot(eye), -f.dot(eye)),
}
Expand Down Expand Up @@ -335,6 +343,7 @@ impl DAffine3 {
/// Transforms the given 3D points, applying shear, scale, rotation and translation.
#[inline(always)]
pub fn transform_point3(&self, other: DVec3) -> DVec3 {
#[allow(clippy::useless_conversion)]
((self.matrix3.x_axis * other.x)
+ (self.matrix3.y_axis * other.y)
+ (self.matrix3.z_axis * other.z)
Expand All @@ -348,6 +357,7 @@ impl DAffine3 {
/// To also apply translation, use [`Self::transform_point3`] instead.
#[inline(always)]
pub fn transform_vector3(&self, other: DVec3) -> DVec3 {
#[allow(clippy::useless_conversion)]
((self.matrix3.x_axis * other.x)
+ (self.matrix3.y_axis * other.y)
+ (self.matrix3.z_axis * other.z))
Expand Down

0 comments on commit eb349af

Please sign in to comment.