Fix some clippy warnings
This commit is contained in:
parent
7a0ebdf1e6
commit
fb205c0fc9
5 changed files with 50 additions and 54 deletions
|
@ -99,7 +99,7 @@ impl<A> Euler<A> {
|
|||
/// * `y` - The angle to apply around the _y_ axis. Also known at the _yaw_.
|
||||
/// * `z` - The angle to apply around the _z_ axis. Also known at the _roll_.
|
||||
pub const fn new(x: A, y: A, z: A) -> Euler<A> {
|
||||
Euler { x: x, y: y, z: z }
|
||||
Euler { x, y, z }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -354,9 +354,9 @@ impl<S: BaseFloat> Matrix4<S> {
|
|||
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
Matrix4::new(
|
||||
s.x.clone(), u.x.clone(), -f.x.clone(), S::zero(),
|
||||
s.y.clone(), u.y.clone(), -f.y.clone(), S::zero(),
|
||||
s.z.clone(), u.z.clone(), -f.z.clone(), S::zero(),
|
||||
s.x, u.x, -f.x, S::zero(),
|
||||
s.y, u.y, -f.y, S::zero(),
|
||||
s.z, u.z, -f.z, S::zero(),
|
||||
-eye.dot(s), -eye.dot(u), eye.dot(f), S::one(),
|
||||
)
|
||||
}
|
||||
|
@ -370,9 +370,9 @@ impl<S: BaseFloat> Matrix4<S> {
|
|||
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
Matrix4::new(
|
||||
s.x.clone(), u.x.clone(), -f.x.clone(), S::zero(),
|
||||
s.y.clone(), u.y.clone(), -f.y.clone(), S::zero(),
|
||||
s.z.clone(), u.z.clone(), -f.z.clone(), S::zero(),
|
||||
s.x, u.x, -f.x, S::zero(),
|
||||
s.y, u.y, -f.y, S::zero(),
|
||||
s.z, u.z, -f.z, S::zero(),
|
||||
-eye.dot(s), -eye.dot(u), eye.dot(f), S::one(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ pub fn perspective<S: BaseFloat, A: Into<Rad<S>>>(
|
|||
) -> Matrix4<S> {
|
||||
PerspectiveFov {
|
||||
fovy: fovy.into(),
|
||||
aspect: aspect,
|
||||
near: near,
|
||||
far: far,
|
||||
aspect,
|
||||
near,
|
||||
far,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ pub fn perspective<S: BaseFloat, A: Into<Rad<S>>>(
|
|||
/// [`glFrustum`]: http://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml
|
||||
pub fn frustum<S: BaseFloat>(left: S, right: S, bottom: S, top: S, near: S, far: S) -> Matrix4<S> {
|
||||
Perspective {
|
||||
left: left,
|
||||
right: right,
|
||||
bottom: bottom,
|
||||
top: top,
|
||||
near: near,
|
||||
far: far,
|
||||
left,
|
||||
right,
|
||||
bottom,
|
||||
top,
|
||||
near,
|
||||
far,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -66,12 +66,12 @@ pub fn frustum<S: BaseFloat>(left: S, right: S, bottom: S, top: S, near: S, far:
|
|||
/// [`glOrtho`]: http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml
|
||||
pub fn ortho<S: BaseFloat>(left: S, right: S, bottom: S, top: S, near: S, far: S) -> Matrix4<S> {
|
||||
Ortho {
|
||||
left: left,
|
||||
right: right,
|
||||
bottom: bottom,
|
||||
top: top,
|
||||
near: near,
|
||||
far: far,
|
||||
left,
|
||||
right,
|
||||
bottom,
|
||||
top,
|
||||
near,
|
||||
far,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ impl<S: BaseFloat> PerspectiveFov<S> {
|
|||
right: xmax,
|
||||
bottom: -ymax,
|
||||
top: ymax,
|
||||
near: self.near.clone(),
|
||||
far: self.far.clone(),
|
||||
near: self.near,
|
||||
far: self.far,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
use std::iter;
|
||||
use std::mem;
|
||||
use std::ops::*;
|
||||
|
||||
use num_traits::{cast, NumCast};
|
||||
|
@ -34,6 +33,7 @@ use num::BaseFloat;
|
|||
use point::Point3;
|
||||
use rotation::{Basis3, Rotation, Rotation3};
|
||||
use vector::Vector3;
|
||||
use quaternion;
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
use mint;
|
||||
|
@ -63,7 +63,7 @@ impl<S> Quaternion<S> {
|
|||
/// Construct a new quaternion from a scalar and a vector.
|
||||
#[inline]
|
||||
pub const fn from_sv(s: S, v: Vector3<S>) -> Quaternion<S> {
|
||||
Quaternion { s: s, v: v }
|
||||
Quaternion { v, s }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -541,23 +541,22 @@ impl<S: BaseFloat> Rotation3 for Quaternion<S> {
|
|||
impl<S: BaseFloat> From<Quaternion<S>> for [S; 4] {
|
||||
#[inline]
|
||||
fn from(v: Quaternion<S>) -> Self {
|
||||
match v.into() {
|
||||
(xi, yj, zk, w) => [xi, yj, zk, w],
|
||||
}
|
||||
let (xi, yj, zk, w) = v.into();
|
||||
[xi, yj, zk, w]
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> AsRef<[S; 4]> for Quaternion<S> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[S; 4] {
|
||||
unsafe { mem::transmute(self) }
|
||||
unsafe { &*(self as *const quaternion::Quaternion<S> as *const [S; 4]) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> AsMut<[S; 4]> for Quaternion<S> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [S; 4] {
|
||||
unsafe { mem::transmute(self) }
|
||||
unsafe { &mut *(self as *mut quaternion::Quaternion<S> as *mut [S; 4]) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,63 +570,61 @@ impl<S: BaseFloat> From<[S; 4]> for Quaternion<S> {
|
|||
impl<'a, S: BaseFloat> From<&'a [S; 4]> for &'a Quaternion<S> {
|
||||
#[inline]
|
||||
fn from(v: &'a [S; 4]) -> &'a Quaternion<S> {
|
||||
unsafe { mem::transmute(v) }
|
||||
unsafe { &*(v as *const [S; 4] as *const quaternion::Quaternion<S>) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, S: BaseFloat> From<&'a mut [S; 4]> for &'a mut Quaternion<S> {
|
||||
#[inline]
|
||||
fn from(v: &'a mut [S; 4]) -> &'a mut Quaternion<S> {
|
||||
unsafe { mem::transmute(v) }
|
||||
unsafe { &mut *(v as *mut [S; 4] as *mut quaternion::Quaternion<S>) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> From<Quaternion<S>> for (S, S, S, S) {
|
||||
#[inline]
|
||||
fn from(v: Quaternion<S>) -> Self {
|
||||
match v {
|
||||
Quaternion {
|
||||
let Quaternion {
|
||||
s,
|
||||
v: Vector3 { x, y, z },
|
||||
} => (x, y, z, s),
|
||||
}
|
||||
} = v;
|
||||
(x, y, z, s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> AsRef<(S, S, S, S)> for Quaternion<S> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &(S, S, S, S) {
|
||||
unsafe { mem::transmute(self) }
|
||||
unsafe { &*(self as *const quaternion::Quaternion<S> as *const (S, S, S, S)) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> AsMut<(S, S, S, S)> for Quaternion<S> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut (S, S, S, S) {
|
||||
unsafe { mem::transmute(self) }
|
||||
unsafe { &mut *(self as *mut quaternion::Quaternion<S> as *mut (S, S, S, S)) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> From<(S, S, S, S)> for Quaternion<S> {
|
||||
#[inline]
|
||||
fn from(v: (S, S, S, S)) -> Quaternion<S> {
|
||||
match v {
|
||||
(xi, yj, zk, w) => Quaternion::new(w, xi, yj, zk),
|
||||
}
|
||||
let (xi, yj, zk, w) = v;
|
||||
Quaternion::new(w, xi, yj, zk)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, S: BaseFloat> From<&'a (S, S, S, S)> for &'a Quaternion<S> {
|
||||
#[inline]
|
||||
fn from(v: &'a (S, S, S, S)) -> &'a Quaternion<S> {
|
||||
unsafe { mem::transmute(v) }
|
||||
unsafe { &*(v as *const (S, S, S, S) as *const quaternion::Quaternion<S>) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, S: BaseFloat> From<&'a mut (S, S, S, S)> for &'a mut Quaternion<S> {
|
||||
#[inline]
|
||||
fn from(v: &'a mut (S, S, S, S)) -> &'a mut Quaternion<S> {
|
||||
unsafe { mem::transmute(v) }
|
||||
unsafe { &mut *(v as *mut (S, S, S, S) as *mut quaternion::Quaternion<S>) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,7 @@ pub trait Transform<P: EuclideanSpace>: Sized + One {
|
|||
|
||||
/// Inverse transform a vector using this transform
|
||||
fn inverse_transform_vector(&self, vec: P::Diff) -> Option<P::Diff> {
|
||||
self.inverse_transform()
|
||||
.and_then(|inverse| Some(inverse.transform_vector(vec)))
|
||||
self.inverse_transform().map(|inverse| inverse.transform_vector(vec))
|
||||
}
|
||||
|
||||
/// Transform a point using this transform.
|
||||
|
@ -117,8 +116,8 @@ where
|
|||
let disp = rot.rotate_vector(P::origin() - eye);
|
||||
Decomposed {
|
||||
scale: P::Scalar::one(),
|
||||
rot: rot,
|
||||
disp: disp,
|
||||
rot,
|
||||
disp,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,8 +127,8 @@ where
|
|||
let disp = rot.rotate_vector(P::origin() - eye);
|
||||
Decomposed {
|
||||
scale: P::Scalar::one(),
|
||||
rot: rot,
|
||||
disp: disp,
|
||||
rot,
|
||||
disp,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,8 +138,8 @@ where
|
|||
let disp = rot.rotate_vector(P::origin() - eye);
|
||||
Decomposed {
|
||||
scale: P::Scalar::one(),
|
||||
rot: rot,
|
||||
disp: disp,
|
||||
rot,
|
||||
disp,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +200,7 @@ pub trait Transform3:
|
|||
impl<S: BaseFloat, R: Rotation2<Scalar = S>> From<Decomposed<Vector2<S>, R>> for Matrix3<S> {
|
||||
fn from(dec: Decomposed<Vector2<S>, R>) -> Matrix3<S> {
|
||||
let m: Matrix2<_> = dec.rot.into();
|
||||
let mut m: Matrix3<_> = (&m * dec.scale).into();
|
||||
let mut m: Matrix3<_> = (m * dec.scale).into();
|
||||
m.z = dec.disp.extend(S::one());
|
||||
m
|
||||
}
|
||||
|
@ -210,7 +209,7 @@ impl<S: BaseFloat, R: Rotation2<Scalar = S>> From<Decomposed<Vector2<S>, R>> for
|
|||
impl<S: BaseFloat, R: Rotation3<Scalar = S>> From<Decomposed<Vector3<S>, R>> for Matrix4<S> {
|
||||
fn from(dec: Decomposed<Vector3<S>, R>) -> Matrix4<S> {
|
||||
let m: Matrix3<_> = dec.rot.into();
|
||||
let mut m: Matrix4<_> = (&m * dec.scale).into();
|
||||
let mut m: Matrix4<_> = (m * dec.scale).into();
|
||||
m.w = dec.disp.extend(S::one());
|
||||
m
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue