diff --git a/src/gltypes.rs b/src/gltypes.rs index ee1f846..70080c9 100644 --- a/src/gltypes.rs +++ b/src/gltypes.rs @@ -23,14 +23,17 @@ use core::sys::size_of; use vec::{ + Vec2, + Vec3, + Vec4, Vector, + Vector2, + Vector3, + Vector4, NumericVector, NumericVector2, NumericVector3, NumericVector4, - Vec2, - Vec3, - Vec4, }; use mat::{Matrix, Mat2, Mat3, Mat4}; @@ -66,7 +69,7 @@ pub type uvec4 = Vec4; /// a four-component unsigned integer ve // Vector method wrappers pub impl vec2 { - #[inline(always)] static pure fn new(x: f32, y: f32) -> vec2 { Vec2::new(x, y) } + #[inline(always)] static pure fn new(x: f32, y: f32) -> vec2 { Vector2::new(x, y) } #[inline(always)] static pure fn from_value(v: f32) -> vec2 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> vec2 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> vec2 { NumericVector::zero() } @@ -79,7 +82,7 @@ pub impl vec2 { } pub impl vec3 { - #[inline(always)] static pure fn new(x: f32, y: f32, z: f32) -> vec3 { Vec3::new(x, y, z) } + #[inline(always)] static pure fn new(x: f32, y: f32, z: f32) -> vec3 { Vector3::new(x, y, z) } #[inline(always)] static pure fn from_value(v: f32) -> vec3 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> vec3 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> vec3 { NumericVector::zero() } @@ -93,7 +96,7 @@ pub impl vec3 { } pub impl vec4 { - #[inline(always)] static pure fn new(x: f32, y: f32, z: f32, w: f32) -> vec4 { Vec4::new(x, y, z, w) } + #[inline(always)] static pure fn new(x: f32, y: f32, z: f32, w: f32) -> vec4 { Vector4::new(x, y, z, w) } #[inline(always)] static pure fn from_value(v: f32) -> vec4 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> vec4 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> vec4 { NumericVector::zero() } @@ -109,7 +112,7 @@ pub impl vec4 { pub impl dvec2 { - #[inline(always)] static pure fn new(x: f64, y: f64) -> dvec2 { Vec2::new(x, y) } + #[inline(always)] static pure fn new(x: f64, y: f64) -> dvec2 { Vector2::new(x, y) } #[inline(always)] static pure fn from_value(v: f64) -> dvec2 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> dvec2 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> dvec2 { NumericVector::zero() } @@ -122,7 +125,7 @@ pub impl dvec2 { } pub impl dvec3 { - #[inline(always)] static pure fn new(x: f64, y: f64, z: f64) -> dvec3 { Vec3::new(x, y, z) } + #[inline(always)] static pure fn new(x: f64, y: f64, z: f64) -> dvec3 { Vector3::new(x, y, z) } #[inline(always)] static pure fn from_value(v: f64) -> dvec3 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> dvec3 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> dvec3 { NumericVector::zero() } @@ -136,7 +139,7 @@ pub impl dvec3 { } pub impl dvec4 { - #[inline(always)] static pure fn new(x: f64, y: f64, z: f64, w: f64) -> dvec4 { Vec4::new(x, y, z, w) } + #[inline(always)] static pure fn new(x: f64, y: f64, z: f64, w: f64) -> dvec4 { Vector4::new(x, y, z, w) } #[inline(always)] static pure fn from_value(v: f64) -> dvec4 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> dvec4 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> dvec4 { NumericVector::zero() } @@ -152,7 +155,7 @@ pub impl dvec4 { pub impl bvec2 { - #[inline(always)] static pure fn new(x: bool, y: bool) -> bvec2 { Vec2::new(x, y) } + #[inline(always)] static pure fn new(x: bool, y: bool) -> bvec2 { Vector2::new(x, y) } #[inline(always)] static pure fn from_value(v: bool) -> bvec2 { Vector::from_value(v) } #[inline(always)] static pure fn dim() -> uint { 2 } @@ -160,7 +163,7 @@ pub impl bvec2 { } pub impl bvec3 { - #[inline(always)] static pure fn new(x: bool, y: bool, z: bool) -> bvec3 { Vec3::new(x, y, z) } + #[inline(always)] static pure fn new(x: bool, y: bool, z: bool) -> bvec3 { Vector3::new(x, y, z) } #[inline(always)] static pure fn from_value(v: bool) -> bvec3 { Vector::from_value(v) } #[inline(always)] static pure fn dim() -> uint { 3 } @@ -168,7 +171,7 @@ pub impl bvec3 { } pub impl bvec4 { - #[inline(always)] static pure fn new(x: bool, y: bool, z: bool, w: bool) -> bvec4 { Vec4::new(x, y, z, w) } + #[inline(always)] static pure fn new(x: bool, y: bool, z: bool, w: bool) -> bvec4 { Vector4::new(x, y, z, w) } #[inline(always)] static pure fn from_value(v: bool) -> bvec4 { Vector::from_value(v) } #[inline(always)] static pure fn dim() -> uint { 4 } @@ -177,7 +180,7 @@ pub impl bvec4 { pub impl ivec2 { - #[inline(always)] static pure fn new(x: i32, y: i32) -> ivec2 { Vec2::new(x, y) } + #[inline(always)] static pure fn new(x: i32, y: i32) -> ivec2 { Vector2::new(x, y) } #[inline(always)] static pure fn from_value(v: i32) -> ivec2 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> ivec2 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> ivec2 { NumericVector::zero() } @@ -190,7 +193,7 @@ pub impl ivec2 { } pub impl ivec3 { - #[inline(always)] static pure fn new(x: i32, y: i32, z: i32) -> ivec3 { Vec3::new(x, y, z) } + #[inline(always)] static pure fn new(x: i32, y: i32, z: i32) -> ivec3 { Vector3::new(x, y, z) } #[inline(always)] static pure fn from_value(v: i32) -> ivec3 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> ivec3 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> ivec3 { NumericVector::zero() } @@ -204,7 +207,7 @@ pub impl ivec3 { } pub impl ivec4 { - #[inline(always)] static pure fn new(x: i32, y: i32, z: i32, w: i32) -> ivec4 { Vec4::new(x, y, z, w) } + #[inline(always)] static pure fn new(x: i32, y: i32, z: i32, w: i32) -> ivec4 { Vector4::new(x, y, z, w) } #[inline(always)] static pure fn from_value(v: i32) -> ivec4 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> ivec4 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> ivec4 { NumericVector::zero() } @@ -220,7 +223,7 @@ pub impl ivec4 { pub impl uvec2 { - #[inline(always)] static pure fn new(x: u32, y: u32) -> uvec2 { Vec2::new(x, y) } + #[inline(always)] static pure fn new(x: u32, y: u32) -> uvec2 { Vector2::new(x, y) } #[inline(always)] static pure fn from_value(v: u32) -> uvec2 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> uvec2 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> uvec2 { NumericVector::zero() } @@ -233,7 +236,7 @@ pub impl uvec2 { } pub impl uvec3 { - #[inline(always)] static pure fn new(x: u32, y: u32, z: u32) -> uvec3 { Vec3::new(x, y, z) } + #[inline(always)] static pure fn new(x: u32, y: u32, z: u32) -> uvec3 { Vector3::new(x, y, z) } #[inline(always)] static pure fn from_value(v: u32) -> uvec3 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> uvec3 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> uvec3 { NumericVector::zero() } @@ -247,7 +250,7 @@ pub impl uvec3 { } pub impl uvec4 { - #[inline(always)] static pure fn new(x: u32, y: u32, z: u32, w: u32) -> uvec4 { Vec4::new(x, y, z, w) } + #[inline(always)] static pure fn new(x: u32, y: u32, z: u32, w: u32) -> uvec4 { Vector4::new(x, y, z, w) } #[inline(always)] static pure fn from_value(v: u32) -> uvec4 { Vector::from_value(v) } #[inline(always)] static pure fn identity() -> uvec4 { NumericVector::identity() } #[inline(always)] static pure fn zero() -> uvec4 { NumericVector::zero() } diff --git a/src/vec.rs b/src/vec.rs index 809121f..fd3ea1a 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -47,21 +47,21 @@ pub trait MutableVector: Vector { * A generic 2-dimensional vector */ pub trait Vector2: Vector { - // static pure fn new(x: T, y: T) -> self; + static pure fn new(x: T, y: T) -> self; } /** * A generic 3-dimensional vector */ pub trait Vector3: Vector { - // static pure fn new(x: T, y: T, z: T) -> self; + static pure fn new(x: T, y: T, z: T) -> self; } /** * A generic 4-dimensional vector */ pub trait Vector4: Vector { - // static pure fn new(x: T, y: T, z: T, w: T) -> self; + static pure fn new(x: T, y: T, z: T, w: T) -> self; } /** diff --git a/src/vec2.rs b/src/vec2.rs index 2f07cea..6599196 100644 --- a/src/vec2.rs +++ b/src/vec2.rs @@ -11,6 +11,7 @@ use numeric::number::Number::{zero,one}; use vec::{ Vec3, Vector, + Vector2, MutableVector, NumericVector, NumericVector2, @@ -39,7 +40,7 @@ use vec::{ #[deriving_eq] pub struct Vec2 { x: T, y: T } -pub impl Vec2/*: Vector2*/ { +pub impl Vec2 { #[inline(always)] static pure fn new(x: T, y: T ) -> Vec2 { Vec2 { x: x, y: y } @@ -62,6 +63,13 @@ pub impl Vec2: Vector { } } +pub impl Vec2: Vector2 { + #[inline(always)] + static pure fn new(x: T, y: T ) -> Vec2 { + Vec2 { x: x, y: y } + } +} + pub impl Vec2: Index { #[inline(always)] pure fn index(&self, i: uint) -> T { diff --git a/src/vec3.rs b/src/vec3.rs index 6fb327a..c5d8dcc 100644 --- a/src/vec3.rs +++ b/src/vec3.rs @@ -11,6 +11,7 @@ use numeric::number::Number::{zero,one}; use vec::{ Vec4, Vector, + Vector3, MutableVector, NumericVector, NumericVector3, @@ -41,7 +42,7 @@ use vec::{ #[deriving_eq] pub struct Vec3 { x: T, y: T, z: T } -pub impl Vec3/*: Vector3*/ { +pub impl Vec3 { #[inline(always)] static pure fn new(x: T, y: T, z: T) -> Vec3 { Vec3 { x: x, y: y, z: z } @@ -64,6 +65,13 @@ pub impl Vec3: Vector { } } +pub impl Vec3: Vector3 { + #[inline(always)] + static pure fn new(x: T, y: T, z: T) -> Vec3 { + Vec3 { x: x, y: y, z: z } + } +} + pub impl Vec3: Index { #[inline(always)] pure fn index(&self, i: uint) -> T { diff --git a/src/vec4.rs b/src/vec4.rs index d600692..43acf60 100644 --- a/src/vec4.rs +++ b/src/vec4.rs @@ -10,6 +10,7 @@ use numeric::number::Number::{zero,one}; use vec::{ Vector, + Vector4, MutableVector, NumericVector, NumericVector4, @@ -40,7 +41,7 @@ use vec::{ #[deriving_eq] pub struct Vec4 { x: T, y: T, z: T, w: T } -pub impl Vec4/*: Vector4*/ { +pub impl Vec4 { #[inline(always)] static pure fn new(x: T, y: T, z: T, w: T) -> Vec4 { Vec4 { x: x, y: y, z: z, w: w } @@ -63,6 +64,13 @@ pub impl Vec4: Vector { } } +pub impl Vec4: Vector4 { + #[inline(always)] + static pure fn new(x: T, y: T, z: T, w: T) -> Vec4 { + Vec4 { x: x, y: y, z: z, w: w } + } +} + pub impl Vec4: Index { #[inline(always)] pure fn index(&self, i: uint) -> T {