From 54953a8f01dafc17bce1c43caa6147ca5a5c9d3f Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 4 Dec 2012 14:41:21 +1000 Subject: [PATCH] Find more trouble spots where Number::from causes ICEs --- src/angle.rs | 4 +++- src/mat.rs | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/angle.rs b/src/angle.rs index 17756c4..4f6e93f 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -245,6 +245,8 @@ pub impl Rotation { let s: T = sin(&self.theta); let _0: T = cast(0); let _1: T = cast(1); + // let _0: T = Number::from(0); // FIXME: causes ICE + // let _1: T = Number::from(0); // FIXME: causes ICE let t: T = _1 - c; let x = self.axis.x; @@ -263,7 +265,7 @@ pub impl Rotation { #[inline(always)] pure fn to_quat() -> Quat { - let half = self.theta / cast(2); + let half = self.theta / Number::from(2); Quat::from_sv(cos(&half), self.axis.mul_t(sin(&half))) } } diff --git a/src/mat.rs b/src/mat.rs index c3c0f68..65e3cea 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -342,6 +342,7 @@ pub impl Mat2: Matrix> { #[inline(always)] pure fn inverse(&self) -> Option> { let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE let d = self.determinant(); if d.fuzzy_eq(&_0) { None @@ -366,6 +367,7 @@ pub impl Mat2: Matrix> { #[inline(always)] pure fn is_diagonal(&self) -> bool { let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE self[0][1].fuzzy_eq(&_0) && self[1][0].fuzzy_eq(&_0) } @@ -385,6 +387,7 @@ pub impl Mat2: Matrix> { #[inline(always)] pure fn is_invertible(&self) -> bool { let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE !self.determinant().fuzzy_eq(&_0) } } @@ -523,6 +526,7 @@ pub impl Mat3 { #[inline(always)] static pure fn from_value(value: T) -> Mat3 { let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE Mat3::new(value, _0, _0, _0, value, _0, _0, _0, value) @@ -532,6 +536,8 @@ pub impl Mat3 { static pure fn from_Mat2(m: &Mat2) -> Mat3 { let _0 = cast(0); let _1 = cast(1); + // let _0 = Number::from(0); // FIXME: causes ICE + // let _1 = Number::from(1); // FIXME: causes ICE Mat3::new(m[0][0], m[0][1], _0, m[1][0], m[1][1], _0, _0, _0, _1) @@ -583,8 +589,10 @@ pub impl Mat3: Matrix> { */ #[inline(always)] static pure fn identity() -> Mat3 { - let _0 = cast(0); - let _1 = cast(1); + // let _0 = cast(0); + // let _1 = cast(1); + let _0 = Number::from(0); + let _1 = Number::from(1); Mat3::new(_1, _0, _0, _0, _1, _0, _0, _0, _1) @@ -610,7 +618,7 @@ pub impl Mat3: Matrix> { */ #[inline(always)] static pure fn zero() -> Mat3 { - let _0 = cast(0); + let _0 = Number::from(0); Mat3::new(_0, _0, _0, _0, _0, _0, _0, _0, _0) @@ -672,6 +680,7 @@ pub impl Mat3: Matrix> { pure fn inverse(&self) -> Option> { let d = self.determinant(); let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE if d.fuzzy_eq(&_0) { None } else { @@ -698,6 +707,7 @@ pub impl Mat3: Matrix> { #[inline(always)] pure fn is_diagonal(&self) -> bool { let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE self[0][1].fuzzy_eq(&_0) && self[0][2].fuzzy_eq(&_0) && @@ -729,6 +739,7 @@ pub impl Mat3: Matrix> { #[inline(always)] pure fn is_invertible(&self) -> bool { let _0 = cast(0); + // let _0 = Number::from(0); // FIXME: causes ICE !self.determinant().fuzzy_eq(&_0) } } @@ -752,7 +763,7 @@ pub impl Mat3: ToQuat { let _1: T = Number::from(1.0); let half: T = Number::from(0.5); - if trace >= cast(0) { + if trace >= Number::from(0) { s = (_1 + trace).sqrt(); w = half * s; s = half / s; @@ -996,8 +1007,8 @@ pub impl Mat4: Matrix> { */ #[inline(always)] static pure fn identity() -> Mat4 { - let _0 = cast(0); - let _1 = cast(1); + let _0 = Number::from(0); + let _1 = Number::from(1); Mat4::new(_1, _0, _0, _0, _0, _1, _0, _0, _0, _0, _1, _0, @@ -1026,7 +1037,7 @@ pub impl Mat4: Matrix> { */ #[inline(always)] static pure fn zero() -> Mat4 { - let _0 = cast(0); + let _0 = Number::from(0); Mat4::new(_0, _0, _0, _0, _0, _0, _0, _0, _0, _0, _0, _0, @@ -1106,6 +1117,7 @@ pub impl Mat4: Matrix> { pure fn inverse(&self) -> Option> { let d = self.determinant(); + // let _0 = Number::from(0); // FIXME: Triggers ICE let _0 = cast(0); if d.fuzzy_eq(&_0) { None