Merge pull request #11 from luqmana/rescue-mission

Rescue mission
This commit is contained in:
Brendan Zabarauskas 2013-03-28 18:44:40 -07:00
commit 0285bf5098
9 changed files with 40 additions and 51 deletions

View file

@ -220,8 +220,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
swap(self.col_mut(a), *self.col_mut(a) <-> *self.col_mut(b);
self.col_mut(b));
} }
#[inline(always)] #[inline(always)]
@ -381,10 +380,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec2<T>> for Mat2<T> { impl<T:Copy> Index<uint, Vec2<T>> for Mat2<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> Vec2<T> { fn index(&self, i: uint) -> Vec2<T> {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Mat2<T>, *Vec2<T>>( transmute::<*Mat2<T>, *Vec2<T>>(
to_unsafe_ptr(self)), 2) |slice| { slice[*i] } to_unsafe_ptr(self)), 2) |slice| { slice[i] }
} }
} }
} }

View file

@ -1,7 +1,6 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::Eq; use core::cmp::Eq;
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::sys::size_of; use core::sys::size_of;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
@ -488,8 +487,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
swap(self.col_mut(a), *self.col_mut(a) <-> *self.col_mut(b);
self.col_mut(b));
} }
#[inline(always)] #[inline(always)]
@ -545,23 +543,23 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); *self.col_mut(0).index_mut(1) <-> *self.col_mut(1).index_mut(0);
swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0)); *self.col_mut(0).index_mut(2) <-> *self.col_mut(2).index_mut(0);
swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); *self.col_mut(1).index_mut(0) <-> *self.col_mut(0).index_mut(1);
swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); *self.col_mut(1).index_mut(2) <-> *self.col_mut(2).index_mut(1);
swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); *self.col_mut(2).index_mut(0) <-> *self.col_mut(0).index_mut(2);
swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); *self.col_mut(2).index_mut(1) <-> *self.col_mut(1).index_mut(2);
} }
} }
impl<T:Copy> Index<uint, Vec3<T>> for Mat3<T> { impl<T:Copy> Index<uint, Vec3<T>> for Mat3<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> Vec3<T> { fn index(&self, i: uint) -> Vec3<T> {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Mat3<T>, *Vec3<T>>( transmute::<*Mat3<T>, *Vec3<T>>(
to_unsafe_ptr(self)), 3) |slice| { slice[*i] } to_unsafe_ptr(self)), 3) |slice| { slice[i] }
} }
} }
} }

View file

@ -1,7 +1,6 @@
use core::cast::transmute; use core::cast::transmute;
use core::cmp::Eq; use core::cmp::Eq;
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::util::swap;
use core::sys::size_of; use core::sys::size_of;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
@ -413,8 +412,7 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn swap_cols(&mut self, a: uint, b: uint) { fn swap_cols(&mut self, a: uint, b: uint) {
swap(self.col_mut(a), *self.col_mut(a) <-> *self.col_mut(b);
self.col_mut(b));
} }
#[inline(always)] #[inline(always)]
@ -474,21 +472,21 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
#[inline(always)] #[inline(always)]
fn transpose_self(&mut self) { fn transpose_self(&mut self) {
swap(self.col_mut(0).index_mut(1), self.col_mut(1).index_mut(0)); *self.col_mut(0).index_mut(1) <-> *self.col_mut(1).index_mut(0);
swap(self.col_mut(0).index_mut(2), self.col_mut(2).index_mut(0)); *self.col_mut(0).index_mut(2) <-> *self.col_mut(2).index_mut(0);
swap(self.col_mut(0).index_mut(3), self.col_mut(3).index_mut(0)); *self.col_mut(0).index_mut(3) <-> *self.col_mut(3).index_mut(0);
swap(self.col_mut(1).index_mut(0), self.col_mut(0).index_mut(1)); *self.col_mut(1).index_mut(0) <-> *self.col_mut(0).index_mut(1);
swap(self.col_mut(1).index_mut(2), self.col_mut(2).index_mut(1)); *self.col_mut(1).index_mut(2) <-> *self.col_mut(2).index_mut(1);
swap(self.col_mut(1).index_mut(3), self.col_mut(3).index_mut(1)); *self.col_mut(1).index_mut(3) <-> *self.col_mut(3).index_mut(1);
swap(self.col_mut(2).index_mut(0), self.col_mut(0).index_mut(2)); *self.col_mut(2).index_mut(0) <-> *self.col_mut(0).index_mut(2);
swap(self.col_mut(2).index_mut(1), self.col_mut(1).index_mut(2)); *self.col_mut(2).index_mut(1) <-> *self.col_mut(1).index_mut(2);
swap(self.col_mut(2).index_mut(3), self.col_mut(3).index_mut(2)); *self.col_mut(2).index_mut(3) <-> *self.col_mut(3).index_mut(2);
swap(self.col_mut(3).index_mut(0), self.col_mut(0).index_mut(3)); *self.col_mut(3).index_mut(0) <-> *self.col_mut(0).index_mut(3);
swap(self.col_mut(3).index_mut(1), self.col_mut(1).index_mut(3)); *self.col_mut(3).index_mut(1) <-> *self.col_mut(1).index_mut(3);
swap(self.col_mut(3).index_mut(2), self.col_mut(2).index_mut(3)); *self.col_mut(3).index_mut(2) <-> *self.col_mut(2).index_mut(3);
} }
} }
@ -501,10 +499,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
impl<T:Copy> Index<uint, Vec4<T>> for Mat4<T> { impl<T:Copy> Index<uint, Vec4<T>> for Mat4<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> Vec4<T> { fn index(&self, i: uint) -> Vec4<T> {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Mat4<T>, *Vec4<T>>( transmute::<*Mat4<T>, *Vec4<T>>(
to_unsafe_ptr(self)), 4) |slice| { slice[*i] } to_unsafe_ptr(self)), 4) |slice| { slice[i] }
} }
} }
} }

View file

@ -391,10 +391,10 @@ pub impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T>
impl<T:Copy> Index<uint, T> for Quat<T> { impl<T:Copy> Index<uint, T> for Quat<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> T { fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice( unsafe { do buf_as_slice(
transmute::<*Quat<T>, *T>( transmute::<*Quat<T>, *T>(
to_unsafe_ptr(self)), 4) |slice| { slice[*i] } to_unsafe_ptr(self)), 4) |slice| { slice[i] }
} }
} }
} }

View file

@ -2,7 +2,6 @@ use core::cast::transmute;
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::sys::size_of; use core::sys::size_of;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::{FuzzyEq, FUZZY_EPSILON}; use std::cmp::{FuzzyEq, FUZZY_EPSILON};
@ -68,8 +67,8 @@ impl<T> Vector2<T> for Vec2<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec2<T> { impl<T:Copy + Eq> Index<uint, T> for Vec2<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> T { fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[*i] } } unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[i] } }
} }
} }
@ -85,8 +84,7 @@ impl<T:Copy> MutableVector<T> for Vec2<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
swap(self.index_mut(a), *self.index_mut(a) <-> *self.index_mut(b);
self.index_mut(b));
} }
} }

View file

@ -2,7 +2,6 @@ use core::cast::transmute;
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::sys::size_of; use core::sys::size_of;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::{FuzzyEq, FUZZY_EPSILON}; use std::cmp::{FuzzyEq, FUZZY_EPSILON};
@ -70,8 +69,8 @@ impl<T> Vector3<T> for Vec3<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec3<T> { impl<T:Copy + Eq> Index<uint, T> for Vec3<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> T { fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[*i] } } unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } }
} }
} }
@ -88,8 +87,7 @@ impl<T:Copy> MutableVector<T> for Vec3<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
swap(self.index_mut(a), *self.index_mut(a) <-> *self.index_mut(b);
self.index_mut(b));
} }
} }

View file

@ -2,7 +2,6 @@ use core::cast::transmute;
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::ptr::to_unsafe_ptr; use core::ptr::to_unsafe_ptr;
use core::sys::size_of; use core::sys::size_of;
use core::util::swap;
use core::vec::raw::buf_as_slice; use core::vec::raw::buf_as_slice;
use std::cmp::{FuzzyEq, FUZZY_EPSILON}; use std::cmp::{FuzzyEq, FUZZY_EPSILON};
@ -68,8 +67,8 @@ impl<T> Vector4<T> for Vec4<T> {
impl<T:Copy + Eq> Index<uint, T> for Vec4<T> { impl<T:Copy + Eq> Index<uint, T> for Vec4<T> {
#[inline(always)] #[inline(always)]
fn index(&self, i: &uint) -> T { fn index(&self, i: uint) -> T {
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[*i] } } unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } }
} }
} }
@ -87,8 +86,7 @@ impl<T:Copy> MutableVector<T> for Vec4<T> {
#[inline(always)] #[inline(always)]
fn swap(&mut self, a: uint, b: uint) { fn swap(&mut self, a: uint, b: uint) {
swap(self.index_mut(a), *self.index_mut(a) <-> *self.index_mut(b);
self.index_mut(b));
} }
} }