From f93963919a02aa229824aa45f34f34f87e5b3510 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Mon, 11 Aug 2014 18:55:14 +1000 Subject: [PATCH] Transition codebase to the new method names --- src/frustum.rs | 12 ++++----- src/matrix.rs | 68 +++++++++++++++++++++++++------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/frustum.rs b/src/frustum.rs index 707989e..6adbd1f 100644 --- a/src/frustum.rs +++ b/src/frustum.rs @@ -50,12 +50,12 @@ Frustum { /// Extracts frustum planes from a projection matrix pub fn from_matrix4(mat: Matrix4) -> Frustum { - Frustum::new(Plane::from_vector4(mat.r(3).add_v(&mat.r(0)).normalize()), - Plane::from_vector4(mat.r(3).sub_v(&mat.r(0)).normalize()), - Plane::from_vector4(mat.r(3).add_v(&mat.r(1)).normalize()), - Plane::from_vector4(mat.r(3).sub_v(&mat.r(1)).normalize()), - Plane::from_vector4(mat.r(3).add_v(&mat.r(2)).normalize()), - Plane::from_vector4(mat.r(3).sub_v(&mat.r(2)).normalize())) + Frustum::new(Plane::from_vector4(mat.row(3).add_v(&mat.row(0)).normalize()), + Plane::from_vector4(mat.row(3).sub_v(&mat.row(0)).normalize()), + Plane::from_vector4(mat.row(3).add_v(&mat.row(1)).normalize()), + Plane::from_vector4(mat.row(3).sub_v(&mat.row(1)).normalize()), + Plane::from_vector4(mat.row(3).add_v(&mat.row(2)).normalize()), + Plane::from_vector4(mat.row(3).sub_v(&mat.row(2)).normalize())) } } diff --git a/src/matrix.rs b/src/matrix.rs index 90a5e2f..0e42821 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -402,8 +402,8 @@ impl Array2, Vector2, S> for Matrix2 { #[inline] fn swap_rows(&mut self, a: uint, b: uint) { - (&mut self[0]).swap_i(a, b); - (&mut self[1]).swap_i(a, b); + (&mut self[0]).swap_elems(a, b); + (&mut self[1]).swap_elems(a, b); } #[inline] @@ -440,9 +440,9 @@ impl Array2, Vector3, S> for Matrix3 { #[inline] fn swap_rows(&mut self, a: uint, b: uint) { - (&mut self[0]).swap_i(a, b); - (&mut self[1]).swap_i(a, b); - (&mut self[2]).swap_i(a, b); + (&mut self[0]).swap_elems(a, b); + (&mut self[1]).swap_elems(a, b); + (&mut self[2]).swap_elems(a, b); } #[inline] @@ -481,10 +481,10 @@ impl Array2, Vector4, S> for Matrix4 { #[inline] fn swap_rows(&mut self, a: uint, b: uint) { - (&mut self[0]).swap_i(a, b); - (&mut self[1]).swap_i(a, b); - (&mut self[2]).swap_i(a, b); - (&mut self[3]).swap_i(a, b); + (&mut self[0]).swap_elems(a, b); + (&mut self[1]).swap_elems(a, b); + (&mut self[2]).swap_elems(a, b); + (&mut self[3]).swap_elems(a, b); } #[inline] @@ -546,13 +546,13 @@ impl Matrix> for Matrix2 { #[inline] fn mul_v(&self, v: &Vector2) -> Vector2 { - Vector2::new(self.r(0).dot(v), - self.r(1).dot(v)) + Vector2::new(self.row(0).dot(v), + self.row(1).dot(v)) } fn mul_m(&self, other: &Matrix2) -> Matrix2 { - Matrix2::new(self.r(0).dot(&other[0]), self.r(1).dot(&other[0]), - self.r(0).dot(&other[1]), self.r(1).dot(&other[1])) + Matrix2::new(self.row(0).dot(&other[0]), self.row(1).dot(&other[0]), + self.row(0).dot(&other[1]), self.row(1).dot(&other[1])) } #[inline] @@ -598,7 +598,7 @@ impl Matrix> for Matrix2 { #[inline] fn transpose_self(&mut self) { - self.swap_cr((0, 1), (1, 0)); + self.swap_elems((0, 1), (1, 0)); } #[inline] @@ -675,15 +675,15 @@ impl Matrix> for Matrix3 { #[inline] fn mul_v(&self, v: &Vector3) -> Vector3 { - Vector3::new(self.r(0).dot(v), - self.r(1).dot(v), - self.r(2).dot(v)) + Vector3::new(self.row(0).dot(v), + self.row(1).dot(v), + self.row(2).dot(v)) } fn mul_m(&self, other: &Matrix3) -> Matrix3 { - Matrix3::new(self.r(0).dot(&other[0]),self.r(1).dot(&other[0]),self.r(2).dot(&other[0]), - self.r(0).dot(&other[1]),self.r(1).dot(&other[1]),self.r(2).dot(&other[1]), - self.r(0).dot(&other[2]),self.r(1).dot(&other[2]),self.r(2).dot(&other[2])) + Matrix3::new(self.row(0).dot(&other[0]),self.row(1).dot(&other[0]),self.row(2).dot(&other[0]), + self.row(0).dot(&other[1]),self.row(1).dot(&other[1]),self.row(2).dot(&other[1]), + self.row(0).dot(&other[2]),self.row(1).dot(&other[2]),self.row(2).dot(&other[2])) } #[inline] @@ -736,9 +736,9 @@ impl Matrix> for Matrix3 { #[inline] fn transpose_self(&mut self) { - self.swap_cr((0, 1), (1, 0)); - self.swap_cr((0, 2), (2, 0)); - self.swap_cr((1, 2), (2, 1)); + self.swap_elems((0, 1), (1, 0)); + self.swap_elems((0, 2), (2, 0)); + self.swap_elems((1, 2), (2, 1)); } fn determinant(&self) -> S { @@ -786,7 +786,7 @@ impl Matrix> for Matrix3 { } } -// Using self.r(0).dot(other.c(0)) like the other matrix multiplies +// Using self.row(0).dot(other[0]) like the other matrix multiplies // causes the LLVM to miss identical loads and multiplies. This optimization // causes the code to be auto vectorized properly increasing the performance // around ~4 times. @@ -841,10 +841,10 @@ impl Matrix> for Matrix4 { #[inline] fn mul_v(&self, v: &Vector4) -> Vector4 { - Vector4::new(self.r(0).dot(v), - self.r(1).dot(v), - self.r(2).dot(v), - self.r(3).dot(v)) + Vector4::new(self.row(0).dot(v), + self.row(1).dot(v), + self.row(2).dot(v), + self.row(3).dot(v)) } fn mul_m(&self, other: &Matrix4) -> Matrix4 { @@ -910,12 +910,12 @@ impl Matrix> for Matrix4 { } fn transpose_self(&mut self) { - self.swap_cr((0, 1), (1, 0)); - self.swap_cr((0, 2), (2, 0)); - self.swap_cr((0, 3), (3, 0)); - self.swap_cr((1, 2), (2, 1)); - self.swap_cr((1, 3), (3, 1)); - self.swap_cr((2, 3), (3, 2)); + self.swap_elems((0, 1), (1, 0)); + self.swap_elems((0, 2), (2, 0)); + self.swap_elems((0, 3), (3, 0)); + self.swap_elems((1, 2), (2, 1)); + self.swap_elems((1, 3), (3, 1)); + self.swap_elems((2, 3), (3, 2)); } fn determinant(&self) -> S {