Fix std imports
This commit is contained in:
parent
288c49b474
commit
3721167cdc
4 changed files with 24 additions and 23 deletions
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
use std::cast::transmute;
|
use std::cast::transmute;
|
||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
use std::num::{Zero, One};
|
use std::num::{Zero, One, cast};
|
||||||
|
use std::uint;
|
||||||
|
|
||||||
use vec::*;
|
use vec::*;
|
||||||
use quat::Quat;
|
use quat::Quat;
|
||||||
|
@ -1073,8 +1074,8 @@ impl<T:Copy + Float + NumAssign> BaseMat3<T, Vec3<T>> for Mat3<T> {
|
||||||
let w, x, y, z;
|
let w, x, y, z;
|
||||||
let trace = self.trace();
|
let trace = self.trace();
|
||||||
|
|
||||||
let _1: T = num::cast(1.0);
|
let _1: T = cast(1.0);
|
||||||
let half: T = num::cast(0.5);
|
let half: T = cast(0.5);
|
||||||
|
|
||||||
cond! (
|
cond! (
|
||||||
(trace >= Zero::zero()) {
|
(trace >= Zero::zero()) {
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
use std::num::cast;
|
||||||
use mat::{Mat4, BaseMat4};
|
use mat::{Mat4, BaseMat4};
|
||||||
|
|
||||||
use num::NumAssign;
|
use num::NumAssign;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ use num::NumAssign;
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn perspective<T:Copy + Float + NumAssign>(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4<T> {
|
pub fn perspective<T:Copy + Float + NumAssign>(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4<T> {
|
||||||
let _2: T = num::cast(2);
|
let _2: T = cast(2);
|
||||||
|
|
||||||
let ymax = near * (fovy / _2).to_radians().tan();
|
let ymax = near * (fovy / _2).to_radians().tan();
|
||||||
let xmax = ymax * aspectRatio;
|
let xmax = ymax * aspectRatio;
|
||||||
|
@ -43,9 +43,9 @@ pub fn perspective<T:Copy + Float + NumAssign>(fovy: T, aspectRatio: T, near: T,
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn frustum<T:Copy + Float + NumAssign>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4<T> {
|
pub fn frustum<T:Copy + Float + NumAssign>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4<T> {
|
||||||
let _0: T = num::cast(0);
|
let _0: T = cast(0);
|
||||||
let _1: T = num::cast(1);
|
let _1: T = cast(1);
|
||||||
let _2: T = num::cast(2);
|
let _2: T = cast(2);
|
||||||
|
|
||||||
let c0r0 = (_2 * near) / (right - left);
|
let c0r0 = (_2 * near) / (right - left);
|
||||||
let c0r1 = _0;
|
let c0r1 = _0;
|
||||||
|
@ -81,9 +81,9 @@ pub fn frustum<T:Copy + Float + NumAssign>(left: T, right: T, bottom: T, top: T,
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn ortho<T:Copy + Float + NumAssign>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4<T> {
|
pub fn ortho<T:Copy + Float + NumAssign>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4<T> {
|
||||||
let _0: T = num::cast(0);
|
let _0: T = cast(0);
|
||||||
let _1: T = num::cast(1);
|
let _1: T = cast(1);
|
||||||
let _2: T = num::cast(2);
|
let _2: T = cast(2);
|
||||||
|
|
||||||
let c0r0 = _2 / (right - left);
|
let c0r0 = _2 / (right - left);
|
||||||
let c0r1 = _0;
|
let c0r1 = _0;
|
||||||
|
|
18
src/quat.rs
18
src/quat.rs
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
use std::cast::transmute;
|
use std::cast::transmute;
|
||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
use std::num::{Zero, One};
|
use std::num::{Zero, One, cast};
|
||||||
|
|
||||||
use mat::{Mat3, BaseMat3};
|
use mat::{Mat3, BaseMat3};
|
||||||
use vec::{Vec3, BaseVec3, AffineVec, NumVec, NumVec3};
|
use vec::{Vec3, BaseVec3, AffineVec, NumVec, NumVec3};
|
||||||
|
@ -81,7 +81,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from_angle_x(radians: T) -> Quat<T> {
|
fn from_angle_x(radians: T) -> Quat<T> {
|
||||||
let _2 = num::cast(2);
|
let _2 = cast(2);
|
||||||
Quat::new((radians / _2).cos(),
|
Quat::new((radians / _2).cos(),
|
||||||
radians.sin(),
|
radians.sin(),
|
||||||
Zero::zero(),
|
Zero::zero(),
|
||||||
|
@ -90,7 +90,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from_angle_y(radians: T) -> Quat<T> {
|
fn from_angle_y(radians: T) -> Quat<T> {
|
||||||
let _2 = num::cast(2);
|
let _2 = cast(2);
|
||||||
Quat::new((radians / _2).cos(),
|
Quat::new((radians / _2).cos(),
|
||||||
Zero::zero(),
|
Zero::zero(),
|
||||||
radians.sin(),
|
radians.sin(),
|
||||||
|
@ -99,7 +99,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from_angle_z(radians: T) -> Quat<T> {
|
fn from_angle_z(radians: T) -> Quat<T> {
|
||||||
let _2 = num::cast(2);
|
let _2 = cast(2);
|
||||||
Quat::new((radians / _2).cos(),
|
Quat::new((radians / _2).cos(),
|
||||||
Zero::zero(),
|
Zero::zero(),
|
||||||
Zero::zero(),
|
Zero::zero(),
|
||||||
|
@ -109,7 +109,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Quat<T> {
|
fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Quat<T> {
|
||||||
// http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Conversion
|
// 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 xdiv2 = radians_x / _2;
|
||||||
let ydiv2 = radians_y / _2;
|
let ydiv2 = radians_y / _2;
|
||||||
let zdiv2 = radians_z / _2;
|
let zdiv2 = radians_z / _2;
|
||||||
|
@ -121,7 +121,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn from_angle_axis(radians: T, axis: &Vec3<T>) -> Quat<T> {
|
fn from_angle_axis(radians: T, axis: &Vec3<T>) -> Quat<T> {
|
||||||
let half = radians / num::cast(2);
|
let half = radians / cast(2);
|
||||||
Quat::from_sv(half.cos(), axis.mul_t(half.sin()))
|
Quat::from_sv(half.cos(), axis.mul_t(half.sin()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mul_v(&self, vec: &Vec3<T>) -> Vec3<T> {
|
fn mul_v(&self, vec: &Vec3<T>) -> Vec3<T> {
|
||||||
let tmp = self.v.cross(vec).add_v(&vec.mul_t(self.s));
|
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`
|
/// The sum of this quaternion and `other`
|
||||||
|
@ -278,7 +278,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
fn slerp(&self, other: &Quat<T>, amount: T) -> Quat<T> {
|
fn slerp(&self, other: &Quat<T>, amount: T) -> Quat<T> {
|
||||||
let dot = self.dot(other);
|
let dot = self.dot(other);
|
||||||
|
|
||||||
let dot_threshold = num::cast(0.9995);
|
let dot_threshold = cast(0.9995);
|
||||||
|
|
||||||
if dot > dot_threshold {
|
if dot > dot_threshold {
|
||||||
return self.nlerp(other, amount); // if quaternions are close together use `nlerp`
|
return self.nlerp(other, amount); // if quaternions are close together use `nlerp`
|
||||||
|
@ -300,7 +300,7 @@ pub impl<T:Copy + Float + NumAssign> Quat<T> {
|
||||||
/// A pointer to the first component of the quaternion
|
/// A pointer to the first component of the quaternion
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_ptr(&self) -> *T {
|
fn to_ptr(&self) -> *T {
|
||||||
unsafe { cast::transmute(self) }
|
unsafe { transmute(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert the quaternion to a 3 x 3 rotation matrix
|
/// Convert the quaternion to a 3 x 3 rotation matrix
|
||||||
|
|
|
@ -405,7 +405,7 @@ impl<T:Copy + Eq> BaseVec<T> for Vec2<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_ptr(&self) -> *T {
|
fn to_ptr(&self) -> *T {
|
||||||
unsafe { cast::transmute(self) }
|
unsafe { transmute(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -739,7 +739,7 @@ impl<T:Copy + Eq> BaseVec<T> for Vec3<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_ptr(&self) -> *T {
|
fn to_ptr(&self) -> *T {
|
||||||
unsafe { cast::transmute(self) }
|
unsafe { transmute(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -1096,7 +1096,7 @@ impl<T:Copy + Eq> BaseVec<T> for Vec4<T> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_ptr(&self) -> *T {
|
fn to_ptr(&self) -> *T {
|
||||||
unsafe { cast::transmute(self) }
|
unsafe { transmute(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
Loading…
Reference in a new issue