Fix lifetime issues
This commit is contained in:
parent
c6816207e0
commit
9e8666c53f
8 changed files with 61 additions and 61 deletions
|
@ -238,7 +238,7 @@ pub trait Matrix4<T,V>: Matrix<T,V> {
|
|||
/**
|
||||
* A mutable matrix
|
||||
*/
|
||||
pub trait MutableMatrix<'self,T,V>: Matrix<T,V> {
|
||||
pub trait MutableMatrix<T,V>: Matrix<T,V> {
|
||||
/**
|
||||
* # Return value
|
||||
*
|
||||
|
|
|
@ -246,8 +246,8 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
|
|||
|
||||
#[inline(always)]
|
||||
fn mul_self_t(&mut self, value: T) {
|
||||
&mut self.x.mul_self_t(&value);
|
||||
&mut self.y.mul_self_t(&value);
|
||||
&mut self.x.mul_self_t(value);
|
||||
&mut self.y.mul_self_t(value);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -516,9 +516,9 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
|
|||
|
||||
#[inline(always)]
|
||||
fn mul_self_t(&mut self, value: T) {
|
||||
self.col_mut(0).mul_self_t(&value);
|
||||
self.col_mut(1).mul_self_t(&value);
|
||||
self.col_mut(2).mul_self_t(&value);
|
||||
self.col_mut(0).mul_self_t(value);
|
||||
self.col_mut(1).mul_self_t(value);
|
||||
self.col_mut(2).mul_self_t(value);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
12
src/mat4.rs
12
src/mat4.rs
|
@ -244,8 +244,8 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
|
|||
I.swap_cols(i1, j);
|
||||
|
||||
// Scale col j to have a unit diagonal
|
||||
I.col_mut(j).div_self_t(&A[j][j]);
|
||||
A.col_mut(j).div_self_t(&A[j][j]);
|
||||
I.col_mut(j).div_self_t(A[j][j]);
|
||||
A.col_mut(j).div_self_t(A[j][j]);
|
||||
|
||||
// Eliminate off-diagonal elems in col j of A,
|
||||
// doing identical ops to I
|
||||
|
@ -442,10 +442,10 @@ impl<T:Copy + Float + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + N
|
|||
|
||||
#[inline(always)]
|
||||
fn mul_self_t(&mut self, value: T) {
|
||||
self.col_mut(0).mul_self_t(&value);
|
||||
self.col_mut(1).mul_self_t(&value);
|
||||
self.col_mut(2).mul_self_t(&value);
|
||||
self.col_mut(3).mul_self_t(&value);
|
||||
self.col_mut(0).mul_self_t(value);
|
||||
self.col_mut(1).mul_self_t(value);
|
||||
self.col_mut(2).mul_self_t(value);
|
||||
self.col_mut(3).mul_self_t(value);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -175,7 +175,7 @@ pub trait NumericVector4<T>: NumericVector<T> {
|
|||
/**
|
||||
* A mutable vector with numeric components
|
||||
*/
|
||||
pub trait MutableNumericVector<'self, T>: MutableVector<&'self T> +
|
||||
pub trait MutableNumericVector<'self, T>: MutableVector<T> +
|
||||
NumericVector<T> {
|
||||
/**
|
||||
* Negate the vector
|
||||
|
@ -216,7 +216,7 @@ pub trait MutableNumericVector<'self, T>: MutableVector<&'self T> +
|
|||
/**
|
||||
* A mutable 3-dimensional vector with numeric components
|
||||
*/
|
||||
pub trait MutableNumericVector3<'self, T>: MutableNumericVector<&'self T> {
|
||||
pub trait MutableNumericVector3<'self, T>: MutableNumericVector<T> {
|
||||
/**
|
||||
* Set to the cross product of the vector and `other`
|
||||
*/
|
||||
|
@ -309,7 +309,7 @@ pub trait EuclideanVector<T>: NumericVector<T> {
|
|||
*
|
||||
* * `T` - The type of the components. This should be a floating point type.
|
||||
*/
|
||||
pub trait MutableEuclideanVector<'self, T>: MutableNumericVector<&'self T> +
|
||||
pub trait MutableEuclideanVector<'self, T>: MutableNumericVector<T> +
|
||||
EuclideanVector<T> {
|
||||
/**
|
||||
* Normalize the vector
|
||||
|
|
26
src/vec2.rs
26
src/vec2.rs
|
@ -174,7 +174,7 @@ impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Numer
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector<&'self T> for Vec2<T> {
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector<T> for Vec2<T> {
|
||||
#[inline(always)]
|
||||
fn neg_self(&mut self) {
|
||||
*self.index_mut(0) = -*self.index_mut(0);
|
||||
|
@ -182,15 +182,15 @@ impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Mutab
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_self_t(&mut self, value: &T) {
|
||||
*self.index_mut(0) *= (*value);
|
||||
*self.index_mut(1) *= (*value);
|
||||
fn mul_self_t(&mut self, value: T) {
|
||||
*self.index_mut(0) *= value;
|
||||
*self.index_mut(1) *= value;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn div_self_t(&mut self, value: &T) {
|
||||
*self.index_mut(0) /= (*value);
|
||||
*self.index_mut(1) /= (*value);
|
||||
fn div_self_t(&mut self, value: T) {
|
||||
*self.index_mut(0) /= value;
|
||||
*self.index_mut(1) /= value;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -267,21 +267,21 @@ impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Euclid
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableEuclideanVector<&'self T> for Vec2<T> {
|
||||
impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableEuclideanVector<T> for Vec2<T> {
|
||||
#[inline(always)]
|
||||
fn normalize_self(&mut self) {
|
||||
let n = one::<T>() / self.length();
|
||||
self.mul_self_t(&n);
|
||||
self.mul_self_t(n);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn normalize_self_to(&mut self, length: &T) {
|
||||
fn normalize_self_to(&mut self, length: T) {
|
||||
let n = length / self.length();
|
||||
self.mul_self_t(&n);
|
||||
self.mul_self_t(n);
|
||||
}
|
||||
|
||||
fn lerp_self(&mut self, other: &Vec2<T>, amount: &T) {
|
||||
self.add_self_v(&other.sub_v(&*self).mul_t(*amount));
|
||||
fn lerp_self(&mut self, other: &Vec2<T>, amount: T) {
|
||||
self.add_self_v(&other.sub_v(&*self).mul_t(amount));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
32
src/vec3.rs
32
src/vec3.rs
|
@ -192,7 +192,7 @@ impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Numer
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector<&'self T> for Vec3<T> {
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector<T> for Vec3<T> {
|
||||
#[inline(always)]
|
||||
fn neg_self(&mut self) {
|
||||
*self.index_mut(0) = -*self.index_mut(0);
|
||||
|
@ -201,17 +201,17 @@ impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Mutab
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_self_t(&mut self, value: &T) {
|
||||
*self.index_mut(0) *= (*value);
|
||||
*self.index_mut(1) *= (*value);
|
||||
*self.index_mut(2) *= (*value);
|
||||
fn mul_self_t(&mut self, value: T) {
|
||||
*self.index_mut(0) *= value;
|
||||
*self.index_mut(1) *= value;
|
||||
*self.index_mut(2) *= value;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn div_self_t(&mut self, value: &T) {
|
||||
*self.index_mut(0) /= (*value);
|
||||
*self.index_mut(1) /= (*value);
|
||||
*self.index_mut(2) /= (*value);
|
||||
fn div_self_t(&mut self, value: T) {
|
||||
*self.index_mut(0) /= value;
|
||||
*self.index_mut(1) /= value;
|
||||
*self.index_mut(2) /= value;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -243,7 +243,7 @@ impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Mutab
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector3<&'self T> for Vec3<T> {
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector3<T> for Vec3<T> {
|
||||
#[inline(always)]
|
||||
fn cross_self(&mut self, other: &Vec3<T>) {
|
||||
*self = self.cross(other);
|
||||
|
@ -299,21 +299,21 @@ impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Euclid
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableEuclideanVector<&'self T> for Vec3<T> {
|
||||
impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableEuclideanVector<T> for Vec3<T> {
|
||||
#[inline(always)]
|
||||
fn normalize_self(&mut self) {
|
||||
let n = one::<T>() / self.length();
|
||||
self.mul_self_t(&n);
|
||||
self.mul_self_t(n);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn normalize_self_to(&mut self, length: &T) {
|
||||
fn normalize_self_to(&mut self, length: T) {
|
||||
let n = length / self.length();
|
||||
self.mul_self_t(&n);
|
||||
self.mul_self_t(n);
|
||||
}
|
||||
|
||||
fn lerp_self(&mut self, other: &Vec3<T>, amount: &T) {
|
||||
self.add_self_v(&other.sub_v(&*self).mul_t(*amount));
|
||||
fn lerp_self(&mut self, other: &Vec3<T>, amount: T) {
|
||||
self.add_self_v(&other.sub_v(&*self).mul_t(amount));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
34
src/vec4.rs
34
src/vec4.rs
|
@ -197,7 +197,7 @@ impl<T:Copy + Number> NumericVector4<T> for Vec4<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector<&'self T> for Vec4<T> {
|
||||
impl<'self,T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableNumericVector<T> for Vec4<T> {
|
||||
#[inline(always)]
|
||||
fn neg_self(&mut self) {
|
||||
*self.index_mut(0) = -*self.index_mut(0);
|
||||
|
@ -207,19 +207,19 @@ impl<T:Copy + Number + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Mutab
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_self_t(&mut self, value: &T) {
|
||||
*self.index_mut(0) *= (*value);
|
||||
*self.index_mut(1) *= (*value);
|
||||
*self.index_mut(2) *= (*value);
|
||||
*self.index_mut(3) *= (*value);
|
||||
fn mul_self_t(&mut self, value: T) {
|
||||
*self.index_mut(0) *= value;
|
||||
*self.index_mut(1) *= value;
|
||||
*self.index_mut(2) *= value;
|
||||
*self.index_mut(3) *= value;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn div_self_t(&mut self, value: &T) {
|
||||
*self.index_mut(0) /= (*value);
|
||||
*self.index_mut(1) /= (*value);
|
||||
*self.index_mut(2) /= (*value);
|
||||
*self.index_mut(3) /= (*value);
|
||||
fn div_self_t(&mut self, value: T) {
|
||||
*self.index_mut(0) /= value;
|
||||
*self.index_mut(1) /= value;
|
||||
*self.index_mut(2) /= value;
|
||||
*self.index_mut(3) /= value;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -297,21 +297,21 @@ impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> Euclid
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableEuclideanVector<&'self T> for Vec4<T> {
|
||||
impl<T: Copy + Float + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>> MutableEuclideanVector<T> for Vec4<T> {
|
||||
#[inline(always)]
|
||||
fn normalize_self(&mut self) {
|
||||
let n = one::<T>() / self.length();
|
||||
self.mul_self_t(&n);
|
||||
self.mul_self_t(n);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn normalize_self_to(&mut self, length: &T) {
|
||||
fn normalize_self_to(&mut self, length: T) {
|
||||
let n = length / self.length();
|
||||
self.mul_self_t(&n);
|
||||
self.mul_self_t(n);
|
||||
}
|
||||
|
||||
fn lerp_self(&mut self, other: &Vec4<T>, amount: &T) {
|
||||
self.add_self_v(&other.sub_v(&*self).mul_t(*amount));
|
||||
fn lerp_self(&mut self, other: &Vec4<T>, amount: T) {
|
||||
self.add_self_v(&other.sub_v(&*self).mul_t(amount));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue