From 3721167cdc2aeac15e8e6c205fd516db6d962c89 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Thu, 6 Jun 2013 12:38:23 +1000 Subject: [PATCH] Fix std imports --- src/mat.rs | 7 ++++--- src/projection.rs | 16 ++++++++-------- src/quat.rs | 18 +++++++++--------- src/vec.rs | 6 +++--- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/mat.rs b/src/mat.rs index faf50dc..49e84b4 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -15,7 +15,8 @@ use std::cast::transmute; use std::cmp::ApproxEq; -use std::num::{Zero, One}; +use std::num::{Zero, One, cast}; +use std::uint; use vec::*; use quat::Quat; @@ -1073,8 +1074,8 @@ impl BaseMat3> for Mat3 { let w, x, y, z; let trace = self.trace(); - let _1: T = num::cast(1.0); - let half: T = num::cast(0.5); + let _1: T = cast(1.0); + let half: T = cast(0.5); cond! ( (trace >= Zero::zero()) { diff --git a/src/projection.rs b/src/projection.rs index 3698d9c..fa5c222 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::num::cast; use mat::{Mat4, BaseMat4}; - use num::NumAssign; /** @@ -27,7 +27,7 @@ use num::NumAssign; */ #[inline(always)] pub fn perspective(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4 { - let _2: T = num::cast(2); + let _2: T = cast(2); let ymax = near * (fovy / _2).to_radians().tan(); let xmax = ymax * aspectRatio; @@ -43,9 +43,9 @@ pub fn perspective(fovy: T, aspectRatio: T, near: T, */ #[inline(always)] pub fn frustum(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4 { - let _0: T = num::cast(0); - let _1: T = num::cast(1); - let _2: T = num::cast(2); + let _0: T = cast(0); + let _1: T = cast(1); + let _2: T = cast(2); let c0r0 = (_2 * near) / (right - left); let c0r1 = _0; @@ -81,9 +81,9 @@ pub fn frustum(left: T, right: T, bottom: T, top: T, */ #[inline(always)] pub fn ortho(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4 { - let _0: T = num::cast(0); - let _1: T = num::cast(1); - let _2: T = num::cast(2); + let _0: T = cast(0); + let _1: T = cast(1); + let _2: T = cast(2); let c0r0 = _2 / (right - left); let c0r1 = _0; diff --git a/src/quat.rs b/src/quat.rs index 087bb23..034b587 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -15,7 +15,7 @@ use std::cast::transmute; use std::cmp::ApproxEq; -use std::num::{Zero, One}; +use std::num::{Zero, One, cast}; use mat::{Mat3, BaseMat3}; use vec::{Vec3, BaseVec3, AffineVec, NumVec, NumVec3}; @@ -81,7 +81,7 @@ pub impl Quat { #[inline(always)] fn from_angle_x(radians: T) -> Quat { - let _2 = num::cast(2); + let _2 = cast(2); Quat::new((radians / _2).cos(), radians.sin(), Zero::zero(), @@ -90,7 +90,7 @@ pub impl Quat { #[inline(always)] fn from_angle_y(radians: T) -> Quat { - let _2 = num::cast(2); + let _2 = cast(2); Quat::new((radians / _2).cos(), Zero::zero(), radians.sin(), @@ -99,7 +99,7 @@ pub impl Quat { #[inline(always)] fn from_angle_z(radians: T) -> Quat { - let _2 = num::cast(2); + let _2 = cast(2); Quat::new((radians / _2).cos(), Zero::zero(), Zero::zero(), @@ -109,7 +109,7 @@ pub impl Quat { #[inline(always)] 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 _2 = num::cast(2); + let _2 = cast(2); let xdiv2 = radians_x / _2; let ydiv2 = radians_y / _2; let zdiv2 = radians_z / _2; @@ -121,7 +121,7 @@ pub impl Quat { #[inline(always)] fn from_angle_axis(radians: T, axis: &Vec3) -> Quat { - let half = radians / num::cast(2); + let half = radians / cast(2); Quat::from_sv(half.cos(), axis.mul_t(half.sin())) } @@ -171,7 +171,7 @@ pub impl Quat { #[inline(always)] 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(num::cast(2)).add_v(vec) + self.v.cross(&tmp).mul_t(cast(2)).add_v(vec) } /// The sum of this quaternion and `other` @@ -278,7 +278,7 @@ pub impl Quat { fn slerp(&self, other: &Quat, amount: T) -> Quat { let dot = self.dot(other); - let dot_threshold = num::cast(0.9995); + let dot_threshold = cast(0.9995); if dot > dot_threshold { return self.nlerp(other, amount); // if quaternions are close together use `nlerp` @@ -300,7 +300,7 @@ pub impl Quat { /// A pointer to the first component of the quaternion #[inline(always)] fn to_ptr(&self) -> *T { - unsafe { cast::transmute(self) } + unsafe { transmute(self) } } /// Convert the quaternion to a 3 x 3 rotation matrix diff --git a/src/vec.rs b/src/vec.rs index ab8aec0..fe69e88 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -405,7 +405,7 @@ impl BaseVec for Vec2 { #[inline(always)] fn to_ptr(&self) -> *T { - unsafe { cast::transmute(self) } + unsafe { transmute(self) } } #[inline(always)] @@ -739,7 +739,7 @@ impl BaseVec for Vec3 { #[inline(always)] fn to_ptr(&self) -> *T { - unsafe { cast::transmute(self) } + unsafe { transmute(self) } } #[inline(always)] @@ -1096,7 +1096,7 @@ impl BaseVec for Vec4 { #[inline(always)] fn to_ptr(&self) -> *T { - unsafe { cast::transmute(self) } + unsafe { transmute(self) } } #[inline(always)]