From 21ae345adc0cd3b367bbbbfb3fd07a3f966be96e Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 12 Jun 2013 07:50:16 +1000 Subject: [PATCH] Be more selective about inlining, #[inline(always)] -> #[inline] for functions other than map --- src/mat.rs | 235 ++++++++++++++------------- src/projection.rs | 5 +- src/quat.rs | 69 ++++---- src/vec.rs | 394 +++++++++++++++++++++++----------------------- 4 files changed, 344 insertions(+), 359 deletions(-) diff --git a/src/mat.rs b/src/mat.rs index dc5be50..63adabc 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -25,32 +25,32 @@ use quat::Quat; pub struct Mat2 { x: Vec2, y: Vec2 } impl Mat2 { - #[inline(always)] + #[inline] pub fn col<'a>(&'a self, i: uint) -> &'a Vec2 { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn col_mut<'a>(&'a mut self, i: uint) -> &'a mut Vec2 { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [Vec2,..2] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [Vec2,..2] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn elem<'a>(&'a self, i: uint, j: uint) -> &'a T { self.col(i).index(j) } - #[inline(always)] + #[inline] pub fn elem_mut<'a>(&'a mut self, i: uint, j: uint) -> &'a mut T { self.col_mut(i).index_mut(j) } @@ -72,7 +72,7 @@ impl Mat2 { /// r1 | c0r1 | c1r1 | /// +------+------+ /// ~~~ - #[inline(always)] + #[inline] pub fn new(c0r0: T, c0r1: T, c1r0: T, c1r1: T) -> Mat2 { Mat2::from_cols(Vec2::new(c0r0, c0r1), @@ -94,38 +94,38 @@ impl Mat2 { /// r1 | c0.y | c1.y | /// +------+------+ /// ~~~ - #[inline(always)] + #[inline] pub fn from_cols(c0: Vec2, c1: Vec2) -> Mat2 { Mat2 { x: c0, y: c1 } } - #[inline(always)] + #[inline] pub fn row(&self, i: uint) -> Vec2 { Vec2::new(*self.elem(0, i), *self.elem(1, i)) } - #[inline(always)] + #[inline] pub fn swap_cols(&mut self, a: uint, b: uint) { let tmp = *self.col(a); *self.col_mut(a) = *self.col(b); *self.col_mut(b) = tmp; } - #[inline(always)] + #[inline] pub fn swap_rows(&mut self, a: uint, b: uint) { self.x.swap(a, b); self.y.swap(a, b); } - #[inline(always)] + #[inline] pub fn transpose(&self) -> Mat2 { Mat2::new(*self.elem(0, 0), *self.elem(1, 0), *self.elem(0, 1), *self.elem(1, 1)) } - #[inline(always)] + #[inline] pub fn transpose_self(&mut self) { let tmp01 = *self.elem(0, 1); let tmp10 = *self.elem(1, 0); @@ -148,7 +148,7 @@ impl Mat2 { /// r1 | 0 | val | /// +-----+-----+ /// ~~~ - #[inline(always)] + #[inline] pub fn from_value(value: T) -> Mat2 { Mat2::new(value, Zero::zero(), Zero::zero(), value) @@ -163,7 +163,7 @@ impl Mat2 { /// r1 | 0 | 1 | /// +----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn identity() -> Mat2 { Mat2::new(One::one::(), Zero::zero::(), Zero::zero::(), One::one::()) @@ -178,55 +178,55 @@ impl Mat2 { /// r1 | 0 | 0 | /// +----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn zero() -> Mat2 { Mat2::new(Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Mat2 { Mat2::from_cols(self.col(0).mul_t(value), self.col(1).mul_t(value)) } - #[inline(always)] + #[inline] pub fn mul_v(&self, vec: &Vec2) -> Vec2 { Vec2::new(self.row(0).dot(vec), self.row(1).dot(vec)) } - #[inline(always)] + #[inline] pub fn add_m(&self, other: &Mat2) -> Mat2 { Mat2::from_cols(self.col(0).add_v(other.col(0)), self.col(1).add_v(other.col(1))) } - #[inline(always)] + #[inline] pub fn sub_m(&self, other: &Mat2) -> Mat2 { Mat2::from_cols(self.col(0).sub_v(other.col(0)), self.col(1).sub_v(other.col(1))) } - #[inline(always)] + #[inline] pub fn mul_m(&self, other: &Mat2) -> Mat2 { Mat2::new(self.row(0).dot(other.col(0)), self.row(1).dot(other.col(0)), self.row(0).dot(other.col(1)), self.row(1).dot(other.col(1))) } - #[inline(always)] + #[inline] pub fn mul_self_t(&mut self, value: T) { self.x.mul_self_t(value); self.y.mul_self_t(value); } - #[inline(always)] + #[inline] pub fn add_self_m(&mut self, other: &Mat2) { self.x.add_self_v(other.col(0)); self.y.add_self_v(other.col(1)); } - #[inline(always)] + #[inline] pub fn sub_self_m(&mut self, other: &Mat2) { self.x.sub_self_v(other.col(0)); self.y.sub_self_v(other.col(1)); @@ -248,12 +248,12 @@ impl Mat2 { *self.col(1).index(1) } - #[inline(always)] + #[inline] pub fn to_identity(&mut self) { *self = Mat2::identity(); } - #[inline(always)] + #[inline] pub fn to_zero(&mut self) { *self = Mat2::zero(); } @@ -269,7 +269,7 @@ impl Mat2 { /// r2 | 0 | 0 | 1 | /// +----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn to_mat3(&self) -> Mat3 { Mat3::new(*self.elem(0, 0), *self.elem(0, 1), Zero::zero(), *self.elem(1, 0), *self.elem(1, 1), Zero::zero(), @@ -289,7 +289,7 @@ impl Mat2 { /// r3 | 0 | 0 | 0 | 1 | /// +----+----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn to_mat4(&self) -> Mat4 { Mat4::new(*self.elem(0, 0), *self.elem(0, 1), Zero::zero(), Zero::zero(), *self.elem(1, 0), *self.elem(1, 1), Zero::zero(), Zero::zero(), @@ -299,14 +299,14 @@ impl Mat2 { } impl Neg> for Mat2 { - #[inline(always)] + #[inline] pub fn neg(&self) -> Mat2 { Mat2::from_cols(-self.col(0), -self.col(1)) } } impl Mat2 { - #[inline(always)] + #[inline] pub fn from_angle(radians: T) -> Mat2 { let cos_theta = radians.cos(); let sin_theta = radians.sin(); @@ -317,7 +317,7 @@ impl Mat2 { } impl> Mat2 { - #[inline(always)] + #[inline] pub fn inverse(&self) -> Option> { let d = self.determinant(); if d.approx_eq(&Zero::zero()) { @@ -328,51 +328,51 @@ impl> Mat2 { } } - #[inline(always)] + #[inline] pub fn invert_self(&mut self) { *self = self.inverse().expect("Couldn't invert the matrix!"); } - #[inline(always)] + #[inline] pub fn is_identity(&self) -> bool { self.approx_eq(&Mat2::identity()) } - #[inline(always)] + #[inline] pub fn is_diagonal(&self) -> bool { self.elem(0, 1).approx_eq(&Zero::zero()) && self.elem(1, 0).approx_eq(&Zero::zero()) } - #[inline(always)] + #[inline] pub fn is_rotated(&self) -> bool { !self.approx_eq(&Mat2::identity()) } - #[inline(always)] + #[inline] pub fn is_symmetric(&self) -> bool { self.elem(0, 1).approx_eq(self.elem(1, 0)) && self.elem(1, 0).approx_eq(self.elem(0, 1)) } - #[inline(always)] + #[inline] pub fn is_invertible(&self) -> bool { !self.determinant().approx_eq(&Zero::zero()) } } impl> ApproxEq for Mat2 { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Mat2) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Mat2, epsilon: &T) -> bool { self.col(0).approx_eq_eps(other.col(0), epsilon) && self.col(1).approx_eq_eps(other.col(1), epsilon) @@ -392,32 +392,32 @@ pub type Mat2f64 = Mat2; pub struct Mat3 { x: Vec3, y: Vec3, z: Vec3 } impl Mat3 { - #[inline(always)] + #[inline] pub fn col<'a>(&'a self, i: uint) -> &'a Vec3 { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn col_mut<'a>(&'a mut self, i: uint) -> &'a mut Vec3 { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [Vec3,..3] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [Vec3,..3] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn elem<'a>(&'a self, i: uint, j: uint) -> &'a T { self.col(i).index(j) } - #[inline(always)] + #[inline] pub fn elem_mut<'a>(&'a mut self, i: uint, j: uint) -> &'a mut T { self.col_mut(i).index_mut(j) } @@ -442,7 +442,7 @@ impl Mat3 { /// r2 | c0r2 | c1r2 | c2r2 | /// +------+------+------+ /// ~~~ - #[inline(always)] + #[inline] pub fn new(c0r0:T, c0r1:T, c0r2:T, c1r0:T, c1r1:T, c1r2:T, c2r0:T, c2r1:T, c2r2:T) -> Mat3 { @@ -469,42 +469,42 @@ impl Mat3 { /// r2 | c0.z | c1.z | c2.z | /// +------+------+------+ /// ~~~ - #[inline(always)] + #[inline] pub fn from_cols(c0: Vec3, c1: Vec3, c2: Vec3) -> Mat3 { Mat3 { x: c0, y: c1, z: c2 } } - #[inline(always)] + #[inline] pub fn row(&self, i: uint) -> Vec3 { Vec3::new(*self.elem(0, i), *self.elem(1, i), *self.elem(2, i)) } - #[inline(always)] + #[inline] pub fn swap_cols(&mut self, a: uint, b: uint) { let tmp = *self.col(a); *self.col_mut(a) = *self.col(b); *self.col_mut(b) = tmp; } - #[inline(always)] + #[inline] pub fn swap_rows(&mut self, a: uint, b: uint) { self.x.swap(a, b); self.y.swap(a, b); self.z.swap(a, b); } - #[inline(always)] + #[inline] pub fn transpose(&self) -> Mat3 { Mat3::new(*self.elem(0, 0), *self.elem(1, 0), *self.elem(2, 0), *self.elem(0, 1), *self.elem(1, 1), *self.elem(2, 1), *self.elem(0, 2), *self.elem(1, 2), *self.elem(2, 2)) } - #[inline(always)] + #[inline] pub fn transpose_self(&mut self) { let tmp01 = *self.elem(0, 1); let tmp02 = *self.elem(0, 2); @@ -546,7 +546,7 @@ impl Mat3 { /// r2 | 0 | 0 | val | /// +-----+-----+-----+ /// ~~~ - #[inline(always)] + #[inline] pub fn from_value(value: T) -> Mat3 { Mat3::new(value, Zero::zero(), Zero::zero(), Zero::zero(), value, Zero::zero(), @@ -564,7 +564,7 @@ impl Mat3 { /// r2 | 0 | 0 | 1 | /// +----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn identity() -> Mat3 { Mat3::new(One::one::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), One::one::(), Zero::zero::(), @@ -582,42 +582,42 @@ impl Mat3 { /// r2 | 0 | 0 | 0 | /// +----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn zero() -> Mat3 { Mat3::new(Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Mat3 { Mat3::from_cols(self.col(0).mul_t(value), self.col(1).mul_t(value), self.col(2).mul_t(value)) } - #[inline(always)] + #[inline] pub fn mul_v(&self, vec: &Vec3) -> Vec3 { Vec3::new(self.row(0).dot(vec), self.row(1).dot(vec), self.row(2).dot(vec)) } - #[inline(always)] + #[inline] pub fn add_m(&self, other: &Mat3) -> Mat3 { Mat3::from_cols(self.col(0).add_v(other.col(0)), self.col(1).add_v(other.col(1)), self.col(2).add_v(other.col(2))) } - #[inline(always)] + #[inline] pub fn sub_m(&self, other: &Mat3) -> Mat3 { Mat3::from_cols(self.col(0).sub_v(other.col(0)), self.col(1).sub_v(other.col(1)), self.col(2).sub_v(other.col(2))) } - #[inline(always)] + #[inline] pub fn mul_m(&self, other: &Mat3) -> Mat3 { Mat3::new(self.row(0).dot(other.col(0)), self.row(1).dot(other.col(0)), @@ -632,21 +632,21 @@ impl Mat3 { self.row(2).dot(other.col(2))) } - #[inline(always)] + #[inline] pub fn mul_self_t(&mut self, value: T) { self.col_mut(0).mul_self_t(value); self.col_mut(1).mul_self_t(value); self.col_mut(2).mul_self_t(value); } - #[inline(always)] + #[inline] pub fn add_self_m(&mut self, other: &Mat3) { self.col_mut(0).add_self_v(other.col(0)); self.col_mut(1).add_self_v(other.col(1)); self.col_mut(2).add_self_v(other.col(2)); } - #[inline(always)] + #[inline] pub fn sub_self_m(&mut self, other: &Mat3) { self.col_mut(0).sub_self_v(other.col(0)); self.col_mut(1).sub_self_v(other.col(1)); @@ -667,12 +667,12 @@ impl Mat3 { *self.elem(2, 2) } - #[inline(always)] + #[inline] pub fn to_identity(&mut self) { *self = Mat3::identity(); } - #[inline(always)] + #[inline] pub fn to_zero(&mut self) { *self = Mat3::zero(); } @@ -690,7 +690,7 @@ impl Mat3 { /// r3 | 0 | 0 | 0 | 1 | /// +----+----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn to_mat4(&self) -> Mat4 { Mat4::new(*self.elem(0, 0), *self.elem(0, 1), *self.elem(0, 2), Zero::zero(), *self.elem(1, 0), *self.elem(1, 1), *self.elem(1, 2), Zero::zero(), @@ -700,7 +700,7 @@ impl Mat3 { } impl Neg> for Mat3 { - #[inline(always)] + #[inline] pub fn neg(&self) -> Mat3 { Mat3::from_cols(-self.col(0), -self.col(1), -self.col(2)) } @@ -708,7 +708,6 @@ impl Neg> for Mat3 { impl Mat3 { /// Construct a matrix from an angular rotation around the `x` axis - #[inline(always)] pub fn from_angle_x(radians: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations let cos_theta = radians.cos(); @@ -720,7 +719,6 @@ impl Mat3 { } /// Construct a matrix from an angular rotation around the `y` axis - #[inline(always)] pub fn from_angle_y(radians: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations let cos_theta = radians.cos(); @@ -732,7 +730,6 @@ impl Mat3 { } /// Construct a matrix from an angular rotation around the `z` axis - #[inline(always)] pub fn from_angle_z(radians: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations let cos_theta = radians.cos(); @@ -750,7 +747,6 @@ impl Mat3 { /// - `theta_x`: the angular rotation around the `x` axis (pitch) /// - `theta_y`: the angular rotation around the `y` axis (yaw) /// - `theta_z`: the angular rotation around the `z` axis (roll) - #[inline(always)] pub fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#General_rotations let cx = radians_x.cos(); @@ -766,7 +762,6 @@ impl Mat3 { } /// Construct a matrix from an axis and an angular rotation - #[inline(always)] pub fn from_angle_axis(radians: T, axis: &Vec3) -> Mat3 { let c = radians.cos(); let s = radians.sin(); @@ -781,12 +776,11 @@ impl Mat3 { _1_c*x*z + s*y, _1_c*y*z - s*x, _1_c*z*z + c) } - #[inline(always)] + #[inline] pub fn from_axes(x: Vec3, y: Vec3, z: Vec3) -> Mat3 { Mat3::from_cols(x, y, z) } - #[inline(always)] pub fn look_at(dir: &Vec3, up: &Vec3) -> Mat3 { let dir_ = dir.normalize(); let side = dir_.cross(&up.normalize()); @@ -796,7 +790,6 @@ impl Mat3 { } /// Convert the matrix to a quaternion - #[inline(always)] pub fn to_quat(&self) -> Quat { // Implemented using a mix of ideas from jMonkeyEngine and Ken Shoemake's // paper on Quaternions: http://www.cs.ucr.edu/~vbz/resources/Quatut.pdf @@ -859,17 +852,17 @@ impl> Mat3 { } } - #[inline(always)] + #[inline] pub fn invert_self(&mut self) { *self = self.inverse().expect("Couldn't invert the matrix!"); } - #[inline(always)] + #[inline] pub fn is_identity(&self) -> bool { self.approx_eq(&Mat3::identity()) } - #[inline(always)] + #[inline] pub fn is_diagonal(&self) -> bool { self.elem(0, 1).approx_eq(&Zero::zero()) && self.elem(0, 2).approx_eq(&Zero::zero()) && @@ -881,12 +874,12 @@ impl> Mat3 { self.elem(2, 1).approx_eq(&Zero::zero()) } - #[inline(always)] + #[inline] pub fn is_rotated(&self) -> bool { !self.approx_eq(&Mat3::identity()) } - #[inline(always)] + #[inline] pub fn is_symmetric(&self) -> bool { self.elem(0, 1).approx_eq(self.elem(1, 0)) && self.elem(0, 2).approx_eq(self.elem(2, 0)) && @@ -898,24 +891,24 @@ impl> Mat3 { self.elem(2, 1).approx_eq(self.elem(1, 2)) } - #[inline(always)] + #[inline] pub fn is_invertible(&self) -> bool { !self.determinant().approx_eq(&Zero::zero()) } } impl> ApproxEq for Mat3 { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Mat3) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Mat3, epsilon: &T) -> bool { self.col(0).approx_eq_eps(other.col(0), epsilon) && self.col(1).approx_eq_eps(other.col(1), epsilon) && @@ -948,32 +941,32 @@ pub type Mat3f64 = Mat3; pub struct Mat4 { x: Vec4, y: Vec4, z: Vec4, w: Vec4 } impl Mat4 { - #[inline(always)] + #[inline] pub fn col<'a>(&'a self, i: uint) -> &'a Vec4 { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn col_mut<'a>(&'a mut self, i: uint) -> &'a mut Vec4 { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [Vec4,..4] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [Vec4,..4] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn elem<'a>(&'a self, i: uint, j: uint) -> &'a T { self.col(i).index(j) } - #[inline(always)] + #[inline] pub fn elem_mut<'a>(&'a mut self, i: uint, j: uint) -> &'a mut T { self.col_mut(i).index_mut(j) } @@ -1001,7 +994,7 @@ impl Mat4 { /// r3 | c0r3 | c1r3 | c2r3 | c3r3 | /// +------+------+------+------+ /// ~~~ - #[inline(always)] + #[inline] pub fn new(c0r0: T, c0r1: T, c0r2: T, c0r3: T, c1r0: T, c1r1: T, c1r2: T, c1r3: T, c2r0: T, c2r1: T, c2r2: T, c2r3: T, @@ -1033,7 +1026,7 @@ impl Mat4 { /// r3 | c0.w | c1.w | c2.w | c3.w | /// +------+------+------+------+ /// ~~~ - #[inline(always)] + #[inline] pub fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, @@ -1041,7 +1034,7 @@ impl Mat4 { Mat4 { x: c0, y: c1, z: c2, w: c3 } } - #[inline(always)] + #[inline] pub fn row(&self, i: uint) -> Vec4 { Vec4::new(*self.elem(0, i), *self.elem(1, i), @@ -1049,14 +1042,14 @@ impl Mat4 { *self.elem(3, i)) } - #[inline(always)] + #[inline] pub fn swap_cols(&mut self, a: uint, b: uint) { let tmp = *self.col(a); *self.col_mut(a) = *self.col(b); *self.col_mut(b) = tmp; } - #[inline(always)] + #[inline] pub fn swap_rows(&mut self, a: uint, b: uint) { self.x.swap(a, b); self.y.swap(a, b); @@ -1064,7 +1057,7 @@ impl Mat4 { self.w.swap(a, b); } - #[inline(always)] + #[inline] pub fn transpose(&self) -> Mat4 { Mat4::new(*self.elem(0, 0), *self.elem(1, 0), *self.elem(2, 0), *self.elem(3, 0), *self.elem(0, 1), *self.elem(1, 1), *self.elem(2, 1), *self.elem(3, 1), @@ -1072,7 +1065,7 @@ impl Mat4 { *self.elem(0, 3), *self.elem(1, 3), *self.elem(2, 3), *self.elem(3, 3)) } - #[inline(always)] + #[inline] pub fn transpose_self(&mut self) { let tmp01 = *self.elem(0, 1); let tmp02 = *self.elem(0, 2); @@ -1134,7 +1127,7 @@ impl Mat4 { /// r3 | 0 | 0 | 0 | val | /// +-----+-----+-----+-----+ /// ~~~ - #[inline(always)] + #[inline] pub fn from_value(value: T) -> Mat4 { Mat4::new(value, Zero::zero(), Zero::zero(), Zero::zero(), Zero::zero(), value, Zero::zero(), Zero::zero(), @@ -1155,7 +1148,7 @@ impl Mat4 { /// r3 | 0 | 0 | 0 | 1 | /// +----+----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn identity() -> Mat4 { Mat4::new(One::one::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), One::one::(), Zero::zero::(), Zero::zero::(), @@ -1176,7 +1169,7 @@ impl Mat4 { /// r3 | 0 | 0 | 0 | 0 | /// +----+----+----+----+ /// ~~~ - #[inline(always)] + #[inline] pub fn zero() -> Mat4 { Mat4::new(Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::(), @@ -1184,7 +1177,7 @@ impl Mat4 { Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Mat4 { Mat4::from_cols(self.col(0).mul_t(value), self.col(1).mul_t(value), @@ -1192,7 +1185,7 @@ impl Mat4 { self.col(3).mul_t(value)) } - #[inline(always)] + #[inline] pub fn mul_v(&self, vec: &Vec4) -> Vec4 { Vec4::new(self.row(0).dot(vec), self.row(1).dot(vec), @@ -1200,7 +1193,7 @@ impl Mat4 { self.row(3).dot(vec)) } - #[inline(always)] + #[inline] pub fn add_m(&self, other: &Mat4) -> Mat4 { Mat4::from_cols(self.col(0).add_v(other.col(0)), self.col(1).add_v(other.col(1)), @@ -1208,7 +1201,7 @@ impl Mat4 { self.col(3).add_v(other.col(3))) } - #[inline(always)] + #[inline] pub fn sub_m(&self, other: &Mat4) -> Mat4 { Mat4::from_cols(self.col(0).sub_v(other.col(0)), self.col(1).sub_v(other.col(1)), @@ -1216,7 +1209,7 @@ impl Mat4 { self.col(3).sub_v(other.col(3))) } - #[inline(always)] + #[inline] pub fn mul_m(&self, other: &Mat4) -> Mat4 { Mat4::new(self.row(0).dot(other.col(0)), self.row(1).dot(other.col(0)), @@ -1239,7 +1232,7 @@ impl Mat4 { self.row(3).dot(other.col(3))) } - #[inline(always)] + #[inline] pub fn mul_self_t(&mut self, value: T) { self.col_mut(0).mul_self_t(value); self.col_mut(1).mul_self_t(value); @@ -1247,7 +1240,7 @@ impl Mat4 { self.col_mut(3).mul_self_t(value); } - #[inline(always)] + #[inline] pub fn add_self_m(&mut self, other: &Mat4) { self.col_mut(0).add_self_v(other.col(0)); self.col_mut(1).add_self_v(other.col(1)); @@ -1255,7 +1248,7 @@ impl Mat4 { self.col_mut(3).add_self_v(other.col(3)); } - #[inline(always)] + #[inline] pub fn sub_self_m(&mut self, other: &Mat4) { self.col_mut(0).sub_self_v(other.col(0)); self.col_mut(1).sub_self_v(other.col(1)); @@ -1294,19 +1287,19 @@ impl Mat4 { *self.elem(3, 3) } - #[inline(always)] + #[inline] pub fn to_identity(&mut self) { *self = Mat4::identity(); } - #[inline(always)] + #[inline] pub fn to_zero(&mut self) { *self = Mat4::zero(); } } impl Neg> for Mat4 { - #[inline(always)] + #[inline] pub fn neg(&self) -> Mat4 { Mat4::from_cols(-self.col(0), -self.col(1), -self.col(2), -self.col(3)) } @@ -1359,17 +1352,17 @@ impl> Mat4 { } } - #[inline(always)] + #[inline] pub fn invert_self(&mut self) { *self = self.inverse().expect("Couldn't invert the matrix!"); } - #[inline(always)] + #[inline] pub fn is_identity(&self) -> bool { self.approx_eq(&Mat4::identity()) } - #[inline(always)] + #[inline] pub fn is_diagonal(&self) -> bool { self.elem(0, 1).approx_eq(&Zero::zero()) && self.elem(0, 2).approx_eq(&Zero::zero()) && @@ -1388,12 +1381,12 @@ impl> Mat4 { self.elem(3, 2).approx_eq(&Zero::zero()) } - #[inline(always)] + #[inline] pub fn is_rotated(&self) -> bool { !self.approx_eq(&Mat4::identity()) } - #[inline(always)] + #[inline] pub fn is_symmetric(&self) -> bool { self.elem(0, 1).approx_eq(self.elem(1, 0)) && self.elem(0, 2).approx_eq(self.elem(2, 0)) && @@ -1412,24 +1405,24 @@ impl> Mat4 { self.elem(3, 2).approx_eq(self.elem(2, 3)) } - #[inline(always)] + #[inline] pub fn is_invertible(&self) -> bool { !self.determinant().approx_eq(&Zero::zero()) } } impl> ApproxEq for Mat4 { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Mat4) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Mat4, epsilon: &T) -> bool { self.col(0).approx_eq_eps(other.col(0), epsilon) && self.col(1).approx_eq_eps(other.col(1), epsilon) && diff --git a/src/projection.rs b/src/projection.rs index 7fd50ba..293f284 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -17,7 +17,7 @@ use std::num::{Zero, One}; use mat::Mat4; // FIXME: We can remove this once we have numeric conversions in std -#[inline(always)] +#[inline] priv fn two() -> T { One::one::() + One::one::() } @@ -30,7 +30,6 @@ priv fn two() -> T { /// This is the equivalent of the gluPerspective function, the algorithm of which /// can be found [here](http://www.opengl.org/wiki/GluPerspective_code). /// -#[inline(always)] pub fn perspective(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4 { let ymax = near * (fovy / two::()).to_radians().tan(); let xmax = ymax * aspectRatio; @@ -44,7 +43,6 @@ pub fn perspective(fovy: T, aspectRatio: T, near: T, far: T) -> M /// This is the equivalent of the now deprecated [glFrustrum] /// (http://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml) function. /// -#[inline(always)] pub fn frustum(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4 { let c0r0 = (two::() * near) / (right - left); let c0r1 = Zero::zero(); @@ -78,7 +76,6 @@ pub fn frustum(left: T, right: T, bottom: T, top: T, near: T, far /// This is the equivalent of the now deprecated [glOrtho] /// (http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml) function. /// -#[inline(always)] pub fn ortho(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4 { let c0r0 = two::() / (right - left); let c0r1 = Zero::zero(); diff --git a/src/quat.rs b/src/quat.rs index bac1886..7f4aeb5 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -21,7 +21,7 @@ use mat::Mat3; use vec::Vec3; // FIXME: We can remove this once we have numeric conversions in std -#[inline(always)] +#[inline] priv fn two() -> T { One::one::() + One::one::() } @@ -40,22 +40,22 @@ priv fn two() -> T { pub struct Quat { s: T, v: Vec3 } impl Quat { - #[inline(always)] + #[inline] pub fn index<'a>(&'a self, i: uint) -> &'a T { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut T { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [T,..4] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T,..4] { unsafe { transmute(self) } } @@ -71,7 +71,7 @@ impl Quat { /// - `xi`: the fist imaginary component /// - `yj`: the second imaginary component /// - `zk`: the third imaginary component - #[inline(always)] + #[inline] pub fn new(w: T, xi: T, yj: T, zk: T) -> Quat { Quat::from_sv(w, Vec3::new(xi, yj, zk)) } @@ -82,19 +82,19 @@ impl Quat { /// /// - `s`: the scalar component /// - `v`: a vector containing the three imaginary components - #[inline(always)] + #[inline] pub fn from_sv(s: T, v: Vec3) -> Quat { Quat { s: s, v: v } } - #[inline(always)] + #[inline] pub fn swap(&mut self, a: uint, b: uint) { let tmp = *self.index(a); *self.index_mut(a) = *self.index(b); *self.index_mut(b) = tmp; } - #[inline(always)] + #[inline] pub fn map(&self, f: &fn(&T) -> T) -> Quat { Quat::new(f(self.index(0)), f(self.index(1)), @@ -105,7 +105,7 @@ impl Quat { impl Quat { /// The multiplicative identity, ie: `q = 1 + 0i + 0j + 0i` - #[inline(always)] + #[inline] pub fn identity() -> Quat { Quat::new(One::one(), Zero::zero(), @@ -114,7 +114,7 @@ impl Quat { } /// The additive identity, ie: `q = 0 + 0i + 0j + 0i` - #[inline(always)] + #[inline] pub fn zero() -> Quat { Quat::new(Zero::zero(), Zero::zero(), @@ -122,7 +122,7 @@ impl Quat { Zero::zero()) } - #[inline(always)] + #[inline] pub fn from_angle_x(radians: T) -> Quat { Quat::new((radians / two()).cos(), radians.sin(), @@ -130,7 +130,7 @@ impl Quat { Zero::zero()) } - #[inline(always)] + #[inline] pub fn from_angle_y(radians: T) -> Quat { Quat::new((radians / two()).cos(), Zero::zero(), @@ -138,7 +138,7 @@ impl Quat { Zero::zero()) } - #[inline(always)] + #[inline] pub fn from_angle_z(radians: T) -> Quat { Quat::new((radians / two()).cos(), Zero::zero(), @@ -146,7 +146,6 @@ impl Quat { radians.sin()) } - #[inline(always)] pub fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Quat { // http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Conversion let xdiv2 = radians_x / two(); @@ -158,7 +157,7 @@ impl Quat { zdiv2.cos() * xdiv2.cos() * ydiv2.sin() - zdiv2.sin() * xdiv2.sin() * ydiv2.cos()) } - #[inline(always)] + #[inline] pub fn from_angle_axis(radians: T, axis: &Vec3) -> Quat { let half = radians / two(); Quat::from_sv(half.cos(), axis.mul_t(half.sin())) @@ -169,7 +168,7 @@ impl Quat { } /// The result of multiplying the quaternion a scalar - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Quat { Quat::new(*self.index(0) * value, *self.index(1) * value, @@ -178,7 +177,7 @@ impl Quat { } /// The result of dividing the quaternion a scalar - #[inline(always)] + #[inline] pub fn div_t(&self, value: T) -> Quat { Quat::new(*self.index(0) / value, *self.index(1) / value, @@ -187,14 +186,14 @@ impl Quat { } /// The result of multiplying the quaternion by a vector - #[inline(always)] + #[inline] pub fn mul_v(&self, vec: &Vec3) -> Vec3 { let tmp = self.v.cross(vec).add_v(&vec.mul_t(self.s)); self.v.cross(&tmp).mul_t(two()).add_v(vec) } /// The sum of this quaternion and `other` - #[inline(always)] + #[inline] pub fn add_q(&self, other: &Quat) -> Quat { Quat::new(*self.index(0) + *other.index(0), *self.index(1) + *other.index(1), @@ -203,7 +202,7 @@ impl Quat { } /// The sum of this quaternion and `other` - #[inline(always)] + #[inline] pub fn sub_q(&self, other: &Quat) -> Quat { Quat::new(*self.index(0) - *other.index(0), *self.index(1) - *other.index(1), @@ -212,7 +211,6 @@ impl Quat { } /// The the result of multipliplying the quaternion by `other` - #[inline(always)] pub fn mul_q(&self, other: &Quat) -> Quat { Quat::new(self.s * other.s - self.v.x * other.v.x - self.v.y * other.v.y - self.v.z * other.v.z, self.s * other.v.x + self.v.x * other.s + self.v.y * other.v.z - self.v.z * other.v.y, @@ -221,19 +219,19 @@ impl Quat { } /// The dot product of the quaternion and `other` - #[inline(always)] + #[inline] pub fn dot(&self, other: &Quat) -> T { self.s * other.s + self.v.dot(&other.v) } /// The conjugate of the quaternion - #[inline(always)] + #[inline] pub fn conjugate(&self) -> Quat { Quat::from_sv(self.s, -self.v) } /// The multiplicative inverse of the quaternion - #[inline(always)] + #[inline] pub fn inverse(&self) -> Quat { self.conjugate().div_t(self.magnitude2()) } @@ -241,7 +239,7 @@ impl Quat { /// The squared magnitude of the quaternion. This is useful for /// magnitude comparisons where the exact magnitude does not need to be /// calculated. - #[inline(always)] + #[inline] pub fn magnitude2(&self) -> T { self.s * self.s + self.v.length2() } @@ -253,19 +251,18 @@ impl Quat { /// For instances where the exact magnitude of the quaternion does not need /// to be known, for example for quaternion-quaternion magnitude comparisons, /// it is advisable to use the `magnitude2` method instead. - #[inline(always)] + #[inline] pub fn magnitude(&self) -> T { self.magnitude2().sqrt() } /// The normalized quaternion - #[inline(always)] + #[inline] pub fn normalize(&self) -> Quat { self.mul_t(One::one::() / self.magnitude()) } /// Convert the quaternion to a 3 x 3 rotation matrix - #[inline(always)] pub fn to_mat3(&self) -> Mat3 { let x2 = self.v.x + self.v.x; let y2 = self.v.y + self.v.y; @@ -295,14 +292,13 @@ impl Quat { /// # Return value /// /// The intoperlated quaternion - #[inline(always)] pub fn nlerp(&self, other: &Quat, amount: T) -> Quat { self.mul_t(One::one::() - amount).add_q(&other.mul_t(amount)).normalize() } } impl Neg> for Quat { - #[inline(always)] + #[inline] pub fn neg(&self) -> Quat { Quat::new(-*self.index(0), -*self.index(1), @@ -312,12 +308,12 @@ impl Neg> for Quat { } impl Quat { - #[inline(always)] + #[inline] pub fn look_at(dir: &Vec3, up: &Vec3) -> Quat { Mat3::look_at(dir, up).to_quat() } - #[inline(always)] + #[inline] pub fn from_axes(x: Vec3, y: Vec3, z: Vec3) -> Quat { Mat3::from_axes(x, y, z).to_quat() } @@ -341,7 +337,6 @@ impl Quat { /// (http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/) /// - [Arcsynthesis OpenGL tutorial] /// (http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Interpolation.html) - #[inline(always)] pub fn slerp(&self, other: &Quat, amount: T) -> Quat { let dot = self.dot(other); let dot_threshold = cast(0.9995); @@ -365,17 +360,17 @@ impl Quat { } impl> ApproxEq for Quat { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Quat) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Quat, epsilon: &T) -> bool { self.index(0).approx_eq_eps(other.index(0), epsilon) && self.index(1).approx_eq_eps(other.index(1), epsilon) && diff --git a/src/vec.rs b/src/vec.rs index 62d76c8..6de3389 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -21,39 +21,39 @@ use std::num::{Zero, One}; pub struct Vec2 { x: T, y: T } impl Vec2 { - #[inline(always)] + #[inline] pub fn index<'a>(&'a self, i: uint) -> &'a T { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut T { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [T,..2] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T,..2] { unsafe { transmute(self) } } } impl Vec2 { - #[inline(always)] + #[inline] pub fn new(x: T, y: T ) -> Vec2 { Vec2 { x: x, y: y } } - #[inline(always)] + #[inline] pub fn from_value(value: T) -> Vec2 { Vec2::new(value, value) } - #[inline(always)] + #[inline] pub fn swap(&mut self, a: uint, b: uint) { let tmp = *self.index(a); *self.index_mut(a) = *self.index(b); @@ -68,231 +68,231 @@ impl Vec2 { } impl Vec2 { - #[inline(always)] + #[inline] pub fn identity() -> Vec2 { Vec2::new(One::one::(), One::one::()) } - #[inline(always)] + #[inline] pub fn zero() -> Vec2 { Vec2::new(Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_x() -> Vec2 { Vec2::new(One::one::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_y() -> Vec2 { Vec2::new(Zero::zero::(), One::one::()) } - #[inline(always)] + #[inline] pub fn is_zero(&self) -> bool { *self.index(0) == Zero::zero() && *self.index(1) == Zero::zero() } - #[inline(always)] + #[inline] pub fn add_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) + value, *self.index(1) + value) } - #[inline(always)] + #[inline] pub fn sub_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) - value, *self.index(1) - value) } - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) * value, *self.index(1) * value) } - #[inline(always)] + #[inline] pub fn div_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) / value, *self.index(1) / value) } - #[inline(always)] + #[inline] pub fn rem_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) % value, *self.index(1) % value) } - #[inline(always)] + #[inline] pub fn add_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) + *other.index(0), *self.index(1) + *other.index(1)) } - #[inline(always)] + #[inline] pub fn sub_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) - *other.index(0), *self.index(1) - *other.index(1)) } - #[inline(always)] + #[inline] pub fn mul_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) * *other.index(0), *self.index(1) * *other.index(1)) } - #[inline(always)] + #[inline] pub fn div_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) / *other.index(0), *self.index(1) / *other.index(1)) } - #[inline(always)] + #[inline] pub fn rem_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) % *other.index(0), *self.index(1) % *other.index(1)) } - #[inline(always)] + #[inline] pub fn neg_self(&mut self) { *self.index_mut(0) = -*self.index(0); *self.index_mut(1) = -*self.index(1); } - #[inline(always)] + #[inline] pub fn add_self_t(&mut self, value: T) { *self.index_mut(0) += value; *self.index_mut(1) += value; } - #[inline(always)] + #[inline] pub fn sub_self_t(&mut self, value: T) { *self.index_mut(0) -= value; *self.index_mut(1) -= value; } - #[inline(always)] + #[inline] pub fn mul_self_t(&mut self, value: T) { *self.index_mut(0) *= value; *self.index_mut(1) *= value; } - #[inline(always)] + #[inline] pub fn div_self_t(&mut self, value: T) { *self.index_mut(0) /= value; *self.index_mut(1) /= value; } - #[inline(always)] + #[inline] pub fn rem_self_t(&mut self, value: T) { *self.index_mut(0) %= value; *self.index_mut(1) %= value; } - #[inline(always)] + #[inline] pub fn add_self_v(&mut self, other: &Vec2) { *self.index_mut(0) += *other.index(0); *self.index_mut(1) += *other.index(1); } - #[inline(always)] + #[inline] pub fn sub_self_v(&mut self, other: &Vec2) { *self.index_mut(0) -= *other.index(0); *self.index_mut(1) -= *other.index(1); } - #[inline(always)] + #[inline] pub fn mul_self_v(&mut self, other: &Vec2) { *self.index_mut(0) *= *other.index(0); *self.index_mut(1) *= *other.index(1); } - #[inline(always)] + #[inline] pub fn div_self_v(&mut self, other: &Vec2) { *self.index_mut(0) /= *other.index(0); *self.index_mut(1) /= *other.index(1); } - #[inline(always)] + #[inline] pub fn rem_self_v(&mut self, other: &Vec2) { *self.index_mut(0) /= *other.index(0); *self.index_mut(1) /= *other.index(1); } - #[inline(always)] + #[inline] pub fn dot(&self, other: &Vec2) -> T { *self.index(0) * *other.index(0) + *self.index(1) * *other.index(1) } - #[inline(always)] + #[inline] pub fn perp_dot(&self, other: &Vec2) -> T { (*self.index(0) * *other.index(1)) - (*self.index(1) * *other.index(0)) } - #[inline(always)] + #[inline] pub fn to_homogeneous(&self) -> Vec3 { Vec3::new(self.x, self.y, Zero::zero()) } } impl Neg> for Vec2 { - #[inline(always)] + #[inline] pub fn neg(&self) -> Vec2 { Vec2::new(-self.index(0), -self.index(1)) } } impl Vec2 { - #[inline(always)] + #[inline] pub fn length2(&self) -> T { self.dot(self) } - #[inline(always)] + #[inline] pub fn length(&self) -> T { self.length2().sqrt() } - #[inline(always)] + #[inline] pub fn distance2(&self, other: &Vec2) -> T { other.sub_v(self).length2() } - #[inline(always)] + #[inline] pub fn distance(&self, other: &Vec2) -> T { other.distance2(self).sqrt() } - #[inline(always)] + #[inline] pub fn angle(&self, other: &Vec2) -> T { self.perp_dot(other).atan2(self.dot(other)) } - #[inline(always)] + #[inline] pub fn normalize(&self) -> Vec2 { self.mul_t(One::one::()/self.length()) } - #[inline(always)] + #[inline] pub fn normalize_to(&self, length: T) -> Vec2 { self.mul_t(length / self.length()) } - #[inline(always)] + #[inline] pub fn lerp(&self, other: &Vec2, amount: T) -> Vec2 { self.add_v(&other.sub_v(self).mul_t(amount)) } - #[inline(always)] + #[inline] pub fn normalize_self(&mut self) { let n = One::one::() / self.length(); self.mul_self_t(n); } - #[inline(always)] + #[inline] pub fn normalize_self_to(&mut self, length: T) { let n = length / self.length(); self.mul_self_t(n); @@ -305,17 +305,17 @@ impl Vec2 { } impl> ApproxEq for Vec2 { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Vec2) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Vec2, epsilon: &T) -> bool { self.index(0).approx_eq_eps(other.index(0), epsilon) && self.index(1).approx_eq_eps(other.index(1), epsilon) @@ -323,49 +323,49 @@ impl> ApproxEq for Vec2 { } impl Vec2 { - #[inline(always)] + #[inline] pub fn lt_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) < value, *self.index(1) < value) } - #[inline(always)] + #[inline] pub fn le_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) <= value, *self.index(1) <= value) } - #[inline(always)] + #[inline] pub fn ge_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) >= value, *self.index(1) >= value) } - #[inline(always)] + #[inline] pub fn gt_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) > value, *self.index(1) > value) } - #[inline(always)] + #[inline] pub fn lt_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) < *other.index(0), *self.index(1) < *other.index(1)) } - #[inline(always)] + #[inline] pub fn le_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) <= *other.index(0), *self.index(1) <= *other.index(1)) } - #[inline(always)] + #[inline] pub fn ge_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) >= *other.index(0), *self.index(1) >= *other.index(1)) } - #[inline(always)] + #[inline] pub fn gt_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) > *other.index(0), *self.index(1) > *other.index(1)) @@ -373,25 +373,25 @@ impl Vec2 { } impl Vec2 { - #[inline(always)] + #[inline] pub fn eq_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) == value, *self.index(1) == value) } - #[inline(always)] + #[inline] pub fn ne_t(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) != value, *self.index(1) != value) } - #[inline(always)] + #[inline] pub fn eq_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) == *other.index(0), *self.index(1) == *other.index(1)) } - #[inline(always)] + #[inline] pub fn ne_v(&self, other: &Vec2) -> Vec2 { Vec2::new(*self.index(0) != *other.index(0), *self.index(1) != *other.index(1)) @@ -399,17 +399,17 @@ impl Vec2 { } impl Vec2 { - #[inline(always)] + #[inline] pub fn any(&self) -> bool { *self.index(0) || *self.index(1) } - #[inline(always)] + #[inline] pub fn all(&self) -> bool { *self.index(0) && *self.index(1) } - #[inline(always)] + #[inline] pub fn not(&self) -> Vec2 { Vec2::new(!*self.index(0), !*self.index(1)) } @@ -442,39 +442,39 @@ pub type Vec2b = Vec2; pub struct Vec3 { x: T, y: T, z: T } impl Vec3 { - #[inline(always)] + #[inline] pub fn index<'a>(&'a self, i: uint) -> &'a T { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut T { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [T,..3] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T,..3] { unsafe { transmute(self) } } } impl Vec3 { - #[inline(always)] + #[inline] pub fn new(x: T, y: T, z: T ) -> Vec3 { Vec3 { x: x, y: y, z: z } } - #[inline(always)] + #[inline] pub fn from_value(value: T) -> Vec3 { Vec3::new(value, value, value) } - #[inline(always)] + #[inline] pub fn swap(&mut self, a: uint, b: uint) { let tmp = *self.index(a); *self.index_mut(a) = *self.index(b); @@ -490,265 +490,265 @@ impl Vec3 { } impl Vec3 { - #[inline(always)] + #[inline] pub fn identity() -> Vec3 { Vec3::new(One::one::(), One::one::(), One::one::()) } - #[inline(always)] + #[inline] pub fn zero() -> Vec3 { Vec3::new(Zero::zero::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_x() -> Vec3 { Vec3::new(One::one::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_y() -> Vec3 { Vec3::new(Zero::zero::(), One::one::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_z() -> Vec3 { Vec3::new(Zero::zero::(), Zero::zero::(), One::one::()) } - #[inline(always)] + #[inline] pub fn is_zero(&self) -> bool { *self.index(0) == Zero::zero() && *self.index(1) == Zero::zero() && *self.index(2) == Zero::zero() } - #[inline(always)] + #[inline] pub fn add_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) + value, *self.index(1) + value, *self.index(2) + value) } - #[inline(always)] + #[inline] pub fn sub_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) - value, *self.index(1) - value, *self.index(2) - value) } - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) * value, *self.index(1) * value, *self.index(2) * value) } - #[inline(always)] + #[inline] pub fn div_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) / value, *self.index(1) / value, *self.index(2) / value) } - #[inline(always)] + #[inline] pub fn rem_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) % value, *self.index(1) % value, *self.index(2) % value) } - #[inline(always)] + #[inline] pub fn add_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) + *other.index(0), *self.index(1) + *other.index(1), *self.index(2) + *other.index(2)) } - #[inline(always)] + #[inline] pub fn sub_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) - *other.index(0), *self.index(1) - *other.index(1), *self.index(2) - *other.index(2)) } - #[inline(always)] + #[inline] pub fn mul_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) * *other.index(0), *self.index(1) * *other.index(1), *self.index(2) * *other.index(2)) } - #[inline(always)] + #[inline] pub fn div_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) / *other.index(0), *self.index(1) / *other.index(1), *self.index(2) / *other.index(2)) } - #[inline(always)] + #[inline] pub fn rem_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) % *other.index(0), *self.index(1) % *other.index(1), *self.index(2) % *other.index(2)) } - #[inline(always)] + #[inline] pub fn neg_self(&mut self) { *self.index_mut(0) = -*self.index(0); *self.index_mut(1) = -*self.index(1); *self.index_mut(2) = -*self.index(2); } - #[inline(always)] + #[inline] pub fn add_self_t(&mut self, value: T) { *self.index_mut(0) += value; *self.index_mut(1) += value; *self.index_mut(2) += value; } - #[inline(always)] + #[inline] pub fn sub_self_t(&mut self, value: T) { *self.index_mut(0) -= value; *self.index_mut(1) -= value; *self.index_mut(2) -= value; } - #[inline(always)] + #[inline] pub fn mul_self_t(&mut self, value: T) { *self.index_mut(0) *= value; *self.index_mut(1) *= value; *self.index_mut(2) *= value; } - #[inline(always)] + #[inline] pub fn div_self_t(&mut self, value: T) { *self.index_mut(0) /= value; *self.index_mut(1) /= value; *self.index_mut(2) /= value; } - #[inline(always)] + #[inline] pub fn rem_self_t(&mut self, value: T) { *self.index_mut(0) %= value; *self.index_mut(1) %= value; *self.index_mut(2) %= value; } - #[inline(always)] + #[inline] pub fn add_self_v(&mut self, other: &Vec3) { *self.index_mut(0) += *other.index(0); *self.index_mut(1) += *other.index(1); *self.index_mut(2) += *other.index(2); } - #[inline(always)] + #[inline] pub fn sub_self_v(&mut self, other: &Vec3) { *self.index_mut(0) -= *other.index(0); *self.index_mut(1) -= *other.index(1); *self.index_mut(2) -= *other.index(2); } - #[inline(always)] + #[inline] pub fn mul_self_v(&mut self, other: &Vec3) { *self.index_mut(0) *= *other.index(0); *self.index_mut(1) *= *other.index(1); *self.index_mut(2) *= *other.index(2); } - #[inline(always)] + #[inline] pub fn div_self_v(&mut self, other: &Vec3) { *self.index_mut(0) /= *other.index(0); *self.index_mut(1) /= *other.index(1); *self.index_mut(2) /= *other.index(2); } - #[inline(always)] + #[inline] pub fn rem_self_v(&mut self, other: &Vec3) { *self.index_mut(0) /= *other.index(0); *self.index_mut(1) /= *other.index(1); *self.index_mut(2) /= *other.index(2); } - #[inline(always)] + #[inline] pub fn dot(&self, other: &Vec3) -> T { *self.index(0) * *other.index(0) + *self.index(1) * *other.index(1) + *self.index(2) * *other.index(2) } - #[inline(always)] + #[inline] pub fn cross(&self, other: &Vec3) -> Vec3 { Vec3::new((*self.index(1) * *other.index(2)) - (*self.index(2) * *other.index(1)), (*self.index(2) * *other.index(0)) - (*self.index(0) * *other.index(2)), (*self.index(0) * *other.index(1)) - (*self.index(1) * *other.index(0))) } - #[inline(always)] + #[inline] pub fn cross_self(&mut self, other: &Vec3) { *self = self.cross(other) } - #[inline(always)] + #[inline] pub fn to_homogeneous(&self) -> Vec4 { Vec4::new(self.x, self.y, self.z, Zero::zero()) } } impl Neg> for Vec3 { - #[inline(always)] + #[inline] pub fn neg(&self) -> Vec3 { Vec3::new(-self.index(0), -self.index(1), -self.index(2)) } } impl Vec3 { - #[inline(always)] + #[inline] pub fn length2(&self) -> T { self.dot(self) } - #[inline(always)] + #[inline] pub fn length(&self) -> T { self.length2().sqrt() } - #[inline(always)] + #[inline] pub fn distance2(&self, other: &Vec3) -> T { other.sub_v(self).length2() } - #[inline(always)] + #[inline] pub fn distance(&self, other: &Vec3) -> T { other.distance2(self).sqrt() } - #[inline(always)] + #[inline] pub fn angle(&self, other: &Vec3) -> T { self.cross(other).length().atan2(self.dot(other)) } - #[inline(always)] + #[inline] pub fn normalize(&self) -> Vec3 { self.mul_t(One::one::()/self.length()) } - #[inline(always)] + #[inline] pub fn normalize_to(&self, length: T) -> Vec3 { self.mul_t(length / self.length()) } - #[inline(always)] + #[inline] pub fn lerp(&self, other: &Vec3, amount: T) -> Vec3 { self.add_v(&other.sub_v(self).mul_t(amount)) } - #[inline(always)] + #[inline] pub fn normalize_self(&mut self) { let n = One::one::() / self.length(); self.mul_self_t(n); } - #[inline(always)] + #[inline] pub fn normalize_self_to(&mut self, length: T) { let n = length / self.length(); self.mul_self_t(n); @@ -761,17 +761,17 @@ impl Vec3 { } impl> ApproxEq for Vec3 { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Vec3) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Vec3, epsilon: &T) -> bool { self.index(0).approx_eq_eps(other.index(0), epsilon) && self.index(1).approx_eq_eps(other.index(1), epsilon) && @@ -780,56 +780,56 @@ impl> ApproxEq for Vec3 { } impl Vec3 { - #[inline(always)] + #[inline] pub fn lt_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) < value, *self.index(1) < value, *self.index(2) < value) } - #[inline(always)] + #[inline] pub fn le_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) <= value, *self.index(1) <= value, *self.index(2) <= value) } - #[inline(always)] + #[inline] pub fn ge_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) >= value, *self.index(1) >= value, *self.index(2) >= value) } - #[inline(always)] + #[inline] pub fn gt_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) > value, *self.index(1) > value, *self.index(2) > value) } - #[inline(always)] + #[inline] pub fn lt_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) < *other.index(0), *self.index(1) < *other.index(1), *self.index(2) < *other.index(2)) } - #[inline(always)] + #[inline] pub fn le_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) <= *other.index(0), *self.index(1) <= *other.index(1), *self.index(2) <= *other.index(2)) } - #[inline(always)] + #[inline] pub fn ge_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) >= *other.index(0), *self.index(1) >= *other.index(1), *self.index(2) >= *other.index(2)) } - #[inline(always)] + #[inline] pub fn gt_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) > *other.index(0), *self.index(1) > *other.index(1), @@ -838,28 +838,28 @@ impl Vec3 { } impl Vec3 { - #[inline(always)] + #[inline] pub fn eq_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) == value, *self.index(1) == value, *self.index(2) == value) } - #[inline(always)] + #[inline] pub fn ne_t(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) != value, *self.index(1) != value, *self.index(2) != value) } - #[inline(always)] + #[inline] pub fn eq_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) == *other.index(0), *self.index(1) == *other.index(1), *self.index(2) == *other.index(2)) } - #[inline(always)] + #[inline] pub fn ne_v(&self, other: &Vec3) -> Vec3 { Vec3::new(*self.index(0) != *other.index(0), *self.index(1) != *other.index(1), @@ -868,17 +868,17 @@ impl Vec3 { } impl Vec3 { - #[inline(always)] + #[inline] pub fn any(&self) -> bool { *self.index(0) || *self.index(1) || *self.index(2) } - #[inline(always)] + #[inline] pub fn all(&self) -> bool { *self.index(0) && *self.index(1) && *self.index(2) } - #[inline(always)] + #[inline] pub fn not(&self) -> Vec3 { Vec3::new(!*self.index(0), !*self.index(1), !*self.index(2)) } @@ -911,39 +911,39 @@ pub type Vec3b = Vec3; pub struct Vec4 { x: T, y: T, z: T, w: T } impl Vec4 { - #[inline(always)] + #[inline] pub fn index<'a>(&'a self, i: uint) -> &'a T { &'a self.as_slice()[i] } - #[inline(always)] + #[inline] pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut T { &'a mut self.as_mut_slice()[i] } - #[inline(always)] + #[inline] pub fn as_slice<'a>(&'a self) -> &'a [T,..4] { unsafe { transmute(self) } } - #[inline(always)] + #[inline] pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T,..4] { unsafe { transmute(self) } } } impl Vec4 { - #[inline(always)] + #[inline] pub fn new(x: T, y: T, z: T, w: T ) -> Vec4 { Vec4 { x: x, y: y, z: z, w: w } } - #[inline(always)] + #[inline] pub fn from_value(value: T) -> Vec4 { Vec4::new(value, value, value, value) } - #[inline(always)] + #[inline] pub fn swap(&mut self, a: uint, b: uint) { let tmp = *self.index(a); *self.index_mut(a) = *self.index(b); @@ -960,37 +960,37 @@ impl Vec4 { } impl Vec4 { - #[inline(always)] + #[inline] pub fn identity() -> Vec4 { Vec4::new(One::one::(), One::one::(), One::one::(), One::one::()) } - #[inline(always)] + #[inline] pub fn zero() -> Vec4 { Vec4::new(Zero::zero::(), Zero::zero::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_x() -> Vec4 { Vec4::new(One::one::(), Zero::zero::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_y() -> Vec4 { Vec4::new(Zero::zero::(), One::one::(), Zero::zero::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_z() -> Vec4 { Vec4::new(Zero::zero::(), Zero::zero::(), One::one::(), Zero::zero::()) } - #[inline(always)] + #[inline] pub fn unit_w() -> Vec4 { Vec4::new(Zero::zero::(), Zero::zero::(), Zero::zero::(), One::one::()) } - #[inline(always)] + #[inline] pub fn is_zero(&self) -> bool { *self.index(0) == Zero::zero() && *self.index(1) == Zero::zero() && @@ -998,7 +998,7 @@ impl Vec4 { *self.index(3) == Zero::zero() } - #[inline(always)] + #[inline] pub fn add_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) + value, *self.index(1) + value, @@ -1006,7 +1006,7 @@ impl Vec4 { *self.index(3) + value) } - #[inline(always)] + #[inline] pub fn sub_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) - value, *self.index(1) - value, @@ -1014,7 +1014,7 @@ impl Vec4 { *self.index(3) - value) } - #[inline(always)] + #[inline] pub fn mul_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) * value, *self.index(1) * value, @@ -1022,7 +1022,7 @@ impl Vec4 { *self.index(3) * value) } - #[inline(always)] + #[inline] pub fn div_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) / value, *self.index(1) / value, @@ -1030,7 +1030,7 @@ impl Vec4 { *self.index(3) / value) } - #[inline(always)] + #[inline] pub fn rem_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) % value, *self.index(1) % value, @@ -1038,7 +1038,7 @@ impl Vec4 { *self.index(3) % value) } - #[inline(always)] + #[inline] pub fn add_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) + *other.index(0), *self.index(1) + *other.index(1), @@ -1046,7 +1046,7 @@ impl Vec4 { *self.index(3) + *other.index(3)) } - #[inline(always)] + #[inline] pub fn sub_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) - *other.index(0), *self.index(1) - *other.index(1), @@ -1054,7 +1054,7 @@ impl Vec4 { *self.index(3) - *other.index(3)) } - #[inline(always)] + #[inline] pub fn mul_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) * *other.index(0), *self.index(1) * *other.index(1), @@ -1062,7 +1062,7 @@ impl Vec4 { *self.index(3) * *other.index(3)) } - #[inline(always)] + #[inline] pub fn div_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) / *other.index(0), *self.index(1) / *other.index(1), @@ -1070,7 +1070,7 @@ impl Vec4 { *self.index(3) / *other.index(3)) } - #[inline(always)] + #[inline] pub fn rem_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) % *other.index(0), *self.index(1) % *other.index(1), @@ -1078,7 +1078,7 @@ impl Vec4 { *self.index(3) % *other.index(3)) } - #[inline(always)] + #[inline] pub fn neg_self(&mut self) { *self.index_mut(0) = -*self.index(0); *self.index_mut(1) = -*self.index(1); @@ -1086,7 +1086,7 @@ impl Vec4 { *self.index_mut(3) = -*self.index(3); } - #[inline(always)] + #[inline] pub fn add_self_t(&mut self, value: T) { *self.index_mut(0) += value; *self.index_mut(1) += value; @@ -1094,7 +1094,7 @@ impl Vec4 { *self.index_mut(3) += value; } - #[inline(always)] + #[inline] pub fn sub_self_t(&mut self, value: T) { *self.index_mut(0) -= value; *self.index_mut(1) -= value; @@ -1102,7 +1102,7 @@ impl Vec4 { *self.index_mut(3) -= value; } - #[inline(always)] + #[inline] pub fn mul_self_t(&mut self, value: T) { *self.index_mut(0) *= value; *self.index_mut(1) *= value; @@ -1110,7 +1110,7 @@ impl Vec4 { *self.index_mut(3) *= value; } - #[inline(always)] + #[inline] pub fn div_self_t(&mut self, value: T) { *self.index_mut(0) /= value; *self.index_mut(1) /= value; @@ -1118,7 +1118,7 @@ impl Vec4 { *self.index_mut(3) /= value; } - #[inline(always)] + #[inline] pub fn rem_self_t(&mut self, value: T) { *self.index_mut(0) %= value; *self.index_mut(1) %= value; @@ -1126,7 +1126,7 @@ impl Vec4 { *self.index_mut(3) %= value; } - #[inline(always)] + #[inline] pub fn add_self_v(&mut self, other: &Vec4) { *self.index_mut(0) += *other.index(0); *self.index_mut(1) += *other.index(1); @@ -1134,7 +1134,7 @@ impl Vec4 { *self.index_mut(3) += *other.index(3); } - #[inline(always)] + #[inline] pub fn sub_self_v(&mut self, other: &Vec4) { *self.index_mut(0) -= *other.index(0); *self.index_mut(1) -= *other.index(1); @@ -1142,7 +1142,7 @@ impl Vec4 { *self.index_mut(3) -= *other.index(3); } - #[inline(always)] + #[inline] pub fn mul_self_v(&mut self, other: &Vec4) { *self.index_mut(0) *= *other.index(0); *self.index_mut(1) *= *other.index(1); @@ -1150,7 +1150,7 @@ impl Vec4 { *self.index_mut(3) *= *other.index(3); } - #[inline(always)] + #[inline] pub fn div_self_v(&mut self, other: &Vec4) { *self.index_mut(0) /= *other.index(0); *self.index_mut(1) /= *other.index(1); @@ -1158,7 +1158,7 @@ impl Vec4 { *self.index_mut(3) /= *other.index(3); } - #[inline(always)] + #[inline] pub fn rem_self_v(&mut self, other: &Vec4) { *self.index_mut(0) /= *other.index(0); *self.index_mut(1) /= *other.index(1); @@ -1166,7 +1166,7 @@ impl Vec4 { *self.index_mut(3) /= *other.index(3); } - #[inline(always)] + #[inline] pub fn dot(&self, other: &Vec4) -> T { *self.index(0) * *other.index(0) + *self.index(1) * *other.index(1) + @@ -1176,60 +1176,60 @@ impl Vec4 { } impl Neg> for Vec4 { - #[inline(always)] + #[inline] pub fn neg(&self) -> Vec4 { Vec4::new(-self.index(0), -self.index(1), -self.index(2), -self.index(3)) } } impl Vec4 { - #[inline(always)] + #[inline] pub fn length2(&self) -> T { self.dot(self) } - #[inline(always)] + #[inline] pub fn length(&self) -> T { self.length2().sqrt() } - #[inline(always)] + #[inline] pub fn distance2(&self, other: &Vec4) -> T { other.sub_v(self).length2() } - #[inline(always)] + #[inline] pub fn distance(&self, other: &Vec4) -> T { other.distance2(self).sqrt() } - #[inline(always)] + #[inline] pub fn angle(&self, other: &Vec4) -> T { (self.dot(other) / (self.length() * other.length())).acos() } - #[inline(always)] + #[inline] pub fn normalize(&self) -> Vec4 { self.mul_t(One::one::()/self.length()) } - #[inline(always)] + #[inline] pub fn normalize_to(&self, length: T) -> Vec4 { self.mul_t(length / self.length()) } - #[inline(always)] + #[inline] pub fn lerp(&self, other: &Vec4, amount: T) -> Vec4 { self.add_v(&other.sub_v(self).mul_t(amount)) } - #[inline(always)] + #[inline] pub fn normalize_self(&mut self) { let n = One::one::() / self.length(); self.mul_self_t(n); } - #[inline(always)] + #[inline] pub fn normalize_self_to(&mut self, length: T) { let n = length / self.length(); self.mul_self_t(n); @@ -1242,17 +1242,17 @@ impl Vec4 { } impl> ApproxEq for Vec4 { - #[inline(always)] + #[inline] pub fn approx_epsilon() -> T { ApproxEq::approx_epsilon::() } - #[inline(always)] + #[inline] pub fn approx_eq(&self, other: &Vec4) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) } - #[inline(always)] + #[inline] pub fn approx_eq_eps(&self, other: &Vec4, epsilon: &T) -> bool { self.index(0).approx_eq_eps(other.index(0), epsilon) && self.index(1).approx_eq_eps(other.index(1), epsilon) && @@ -1262,7 +1262,7 @@ impl> ApproxEq for Vec4 { } impl Vec4 { - #[inline(always)] + #[inline] pub fn lt_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) < value, *self.index(1) < value, @@ -1270,7 +1270,7 @@ impl Vec4 { *self.index(3) < value) } - #[inline(always)] + #[inline] pub fn le_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) <= value, *self.index(1) <= value, @@ -1278,7 +1278,7 @@ impl Vec4 { *self.index(3) <= value) } - #[inline(always)] + #[inline] pub fn ge_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) >= value, *self.index(1) >= value, @@ -1286,7 +1286,7 @@ impl Vec4 { *self.index(3) >= value) } - #[inline(always)] + #[inline] pub fn gt_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) > value, *self.index(1) > value, @@ -1294,7 +1294,7 @@ impl Vec4 { *self.index(3) > value) } - #[inline(always)] + #[inline] pub fn lt_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) < *other.index(0), *self.index(1) < *other.index(1), @@ -1302,7 +1302,7 @@ impl Vec4 { *self.index(3) < *other.index(3)) } - #[inline(always)] + #[inline] pub fn le_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) <= *other.index(0), *self.index(1) <= *other.index(1), @@ -1310,7 +1310,7 @@ impl Vec4 { *self.index(3) <= *other.index(3)) } - #[inline(always)] + #[inline] pub fn ge_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) >= *other.index(0), *self.index(1) >= *other.index(1), @@ -1318,7 +1318,7 @@ impl Vec4 { *self.index(3) >= *other.index(3)) } - #[inline(always)] + #[inline] pub fn gt_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) > *other.index(0), *self.index(1) > *other.index(1), @@ -1328,7 +1328,7 @@ impl Vec4 { } impl Vec4 { - #[inline(always)] + #[inline] pub fn eq_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) == value, *self.index(1) == value, @@ -1336,7 +1336,7 @@ impl Vec4 { *self.index(3) == value) } - #[inline(always)] + #[inline] pub fn ne_t(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) != value, *self.index(1) != value, @@ -1344,7 +1344,7 @@ impl Vec4 { *self.index(3) != value) } - #[inline(always)] + #[inline] pub fn eq_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) == *other.index(0), *self.index(1) == *other.index(1), @@ -1352,7 +1352,7 @@ impl Vec4 { *self.index(3) == *other.index(3)) } - #[inline(always)] + #[inline] pub fn ne_v(&self, other: &Vec4) -> Vec4 { Vec4::new(*self.index(0) != *other.index(0), *self.index(1) != *other.index(1), @@ -1362,17 +1362,17 @@ impl Vec4 { } impl Vec4 { - #[inline(always)] + #[inline] pub fn any(&self) -> bool { *self.index(0) || *self.index(1) || *self.index(2) || *self.index(3) } - #[inline(always)] + #[inline] pub fn all(&self) -> bool { *self.index(0) && *self.index(1) && *self.index(2) && *self.index(3) } - #[inline(always)] + #[inline] pub fn not(&self) -> Vec4 { Vec4::new(!*self.index(0), !*self.index(1), !*self.index(2), !*self.index(3)) }