diff --git a/examples/relativity.rs b/examples/relativity.rs index a0bb3c2da..65b795706 100644 --- a/examples/relativity.rs +++ b/examples/relativity.rs @@ -108,7 +108,7 @@ struct InertialCamera { } impl InertialCamera { - pub fn new(fov: f32, znear: f32, zfar: f32, eye: Vec3, at: Vec3) -> InertialCamera { + fn new(fov: f32, znear: f32, zfar: f32, eye: Vec3, at: Vec3) -> InertialCamera { let mut fp = FirstPerson::new_with_frustrum(fov, znear, zfar, eye, at); fp.set_move_step(0.0); @@ -185,7 +185,7 @@ struct Context { } impl Context { - pub fn new(speed_of_light: f32, speed_of_player: Vec3, position: Vec3) -> Context { + fn new(speed_of_light: f32, speed_of_player: Vec3, position: Vec3) -> Context { Context { speed_of_light: speed_of_light, speed_of_player: speed_of_player, @@ -195,28 +195,28 @@ impl Context { } /// The default material used to draw objects. -pub struct RelativisticMaterial { - priv context: RWArc, - priv shader: Shader, - priv pos: ShaderAttribute>, - priv normal: ShaderAttribute>, - priv tex_coord: ShaderAttribute>, - priv light: ShaderUniform>, - priv color: ShaderUniform>, - priv transform: ShaderUniform>, - priv scale: ShaderUniform>, - priv ntransform: ShaderUniform>, - priv view: ShaderUniform>, - priv tex: ShaderUniform, - priv light_vel: ShaderUniform, - priv rel_vel: ShaderUniform>, - priv rot: ShaderUniform>, - priv player_position: ShaderUniform> +struct RelativisticMaterial { + context: RWArc, + shader: Shader, + pos: ShaderAttribute>, + normal: ShaderAttribute>, + tex_coord: ShaderAttribute>, + light: ShaderUniform>, + color: ShaderUniform>, + transform: ShaderUniform>, + scale: ShaderUniform>, + ntransform: ShaderUniform>, + view: ShaderUniform>, + tex: ShaderUniform, + light_vel: ShaderUniform, + rel_vel: ShaderUniform>, + rot: ShaderUniform>, + player_position: ShaderUniform> } impl RelativisticMaterial { /// Creates a new `RelativisticMaterial`. - pub fn new(context: RWArc) -> RelativisticMaterial { + fn new(context: RWArc) -> RelativisticMaterial { // load the shader let mut shader = Shader::new_from_str(RELATIVISTIC_VERTEX_SRC, RELATIVISTIC_FRAGMENT_SRC); @@ -326,7 +326,7 @@ impl Material for RelativisticMaterial { } } -pub static RELATIVISTIC_VERTEX_SRC: &'static str = +static RELATIVISTIC_VERTEX_SRC: &'static str = "#version 120 attribute vec3 position; attribute vec3 normal; @@ -382,7 +382,7 @@ pub static RELATIVISTIC_VERTEX_SRC: &'static str = tex_coord = tex_coord_v; }"; -pub static RELATIVISTIC_FRAGMENT_SRC: &'static str = +static RELATIVISTIC_FRAGMENT_SRC: &'static str = "#version 120 uniform vec3 color; uniform vec3 light_position; diff --git a/src/lib.rs b/src/lib.rs index f4d6f4ee7..46bd66b8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,7 @@ I’d love to see people improving this library for their own needs. However, ke #[deny(missing_doc)]; #[deny(unused_result)]; #[deny(unnecessary_typecast)]; +#[deny(visible_private_types)]; #[feature(globs)]; #[feature(macro_rules)]; #[feature(managed_boxes)]; diff --git a/src/object.rs b/src/object.rs index 59d982fac..b76bcbfb7 100644 --- a/src/object.rs +++ b/src/object.rs @@ -12,13 +12,10 @@ use light::Light; #[path = "error.rs"] mod error; -type Transform3d = Iso3; -type Scale3d = Mat3; - /// Set of data identifying a scene node. pub struct ObjectData { - priv scale: Scale3d, - priv transform: Transform3d, + priv scale: Mat3, + priv transform: Iso3, priv texture: Rc, priv color: Vec3, priv visible: bool, @@ -27,12 +24,12 @@ pub struct ObjectData { impl ObjectData { /// The scale matrix of this object. - pub fn scale<'a>(&'a self) -> &'a Scale3d { + pub fn scale<'a>(&'a self) -> &'a Mat3 { &'a self.scale } /// The transformation matrix (scaling excluded) of this object. - pub fn transform<'a>(&'a self) -> &'a Transform3d { + pub fn transform<'a>(&'a self) -> &'a Iso3 { &'a self.transform } @@ -314,39 +311,39 @@ impl Object { } } -impl Transformation for Object { +impl Transformation> for Object { #[inline] - fn transformation(&self) -> Transform3d { + fn transformation(&self) -> Iso3 { self.data.borrow().borrow().get().transform.clone() } #[inline] - fn inv_transformation(&self) -> Transform3d { + fn inv_transformation(&self) -> Iso3 { self.data.borrow().borrow().get().transform.inv_transformation() } #[inline] - fn append_transformation(&mut self, t: &Transform3d) { + fn append_transformation(&mut self, t: &Iso3) { self.data.borrow().borrow_mut().get().transform.append_transformation(t) } #[inline] - fn append_transformation_cpy(_: &Object, _: &Transform3d) -> Object { + fn append_transformation_cpy(_: &Object, _: &Iso3) -> Object { fail!("Cannot clone an object.") } #[inline] - fn prepend_transformation(&mut self, t: &Transform3d) { + fn prepend_transformation(&mut self, t: &Iso3) { self.data.borrow().borrow_mut().get().transform.prepend_transformation(t) } #[inline] - fn prepend_transformation_cpy(_: &Object, _: &Transform3d) -> Object { + fn prepend_transformation_cpy(_: &Object, _: &Iso3) -> Object { fail!("Cannot clone an object.") } #[inline] - fn set_transformation(&mut self, t: Transform3d) { + fn set_transformation(&mut self, t: Iso3) { self.data.borrow().borrow_mut().get().transform.set_transformation(t) } } diff --git a/src/resource/mesh.rs b/src/resource/mesh.rs index 5ef9b4460..fc4ff3f24 100644 --- a/src/resource/mesh.rs +++ b/src/resource/mesh.rs @@ -9,12 +9,6 @@ use nalgebra::na; use resource::ShaderAttribute; use resource::gpu_vector::{GPUVector, DynamicDraw, StaticDraw, ArrayBuffer, ElementArrayBuffer}; -type Coord = Vec3; -type Normal = Vec3; -type UV = Vec2; -type Vertex = GLuint; -type Face = Vec3; - #[path = "../error.rs"] mod error; @@ -22,20 +16,20 @@ mod error; /// /// It also contains the GPU location of those buffers. pub struct Mesh { - priv coords: RWArc>, - priv faces: RWArc>, - priv normals: RWArc>, - priv uvs: RWArc> + priv coords: RWArc>>, + priv faces: RWArc>>, + priv normals: RWArc>>, + priv uvs: RWArc>> } impl Mesh { /// Creates a new mesh. /// /// If the normals and uvs are not given, they are automatically computed. - pub fn new(coords: ~[Coord], - faces: ~[Face], - normals: Option<~[Normal]>, - uvs: Option<~[UV]>, + pub fn new(coords: ~[Vec3], + faces: ~[Vec3], + normals: Option<~[Vec3]>, + uvs: Option<~[Vec2]>, dynamic_draw: bool) -> Mesh { let normals = match normals { @@ -58,10 +52,10 @@ impl Mesh { } /// Creates a new mesh. Arguments set to `None` are automatically computed. - pub fn new_with_gpu_vectors(coords: RWArc>, - faces: RWArc>, - normals: RWArc>, - uvs: RWArc>) + pub fn new_with_gpu_vectors(coords: RWArc>>, + faces: RWArc>>, + normals: RWArc>>, + uvs: RWArc>>) -> Mesh { Mesh { coords: coords, @@ -72,17 +66,17 @@ impl Mesh { } /// Binds this mesh vertex coordinates buffer to a vertex attribute. - pub fn bind_coords(&mut self, coords: &mut ShaderAttribute) { + pub fn bind_coords(&mut self, coords: &mut ShaderAttribute>) { self.coords.write(|c| coords.bind(c)); } /// Binds this mesh vertex normals buffer to a vertex attribute. - pub fn bind_normals(&mut self, normals: &mut ShaderAttribute) { + pub fn bind_normals(&mut self, normals: &mut ShaderAttribute>) { self.normals.write(|n| normals.bind(n)); } /// Binds this mesh vertex uvs buffer to a vertex attribute. - pub fn bind_uvs(&mut self, uvs: &mut ShaderAttribute) { + pub fn bind_uvs(&mut self, uvs: &mut ShaderAttribute>) { self.uvs.write(|u| uvs.bind(u)); } @@ -93,9 +87,9 @@ impl Mesh { /// Binds this mesh buffers to vertex attributes. pub fn bind(&mut self, - coords: &mut ShaderAttribute, - normals: &mut ShaderAttribute, - uvs: &mut ShaderAttribute) { + coords: &mut ShaderAttribute>, + normals: &mut ShaderAttribute>, + uvs: &mut ShaderAttribute>) { self.bind_coords(coords); self.bind_normals(normals); self.bind_uvs(uvs); @@ -128,27 +122,27 @@ impl Mesh { } /// This mesh faces. - pub fn faces<'a>(&'a self) -> &'a RWArc> { + pub fn faces<'a>(&'a self) -> &'a RWArc>> { &'a self.faces } /// This mesh normals. - pub fn normals<'a>(&'a self) -> &'a RWArc> { + pub fn normals<'a>(&'a self) -> &'a RWArc>> { &'a self.normals } /// This mesh vertex coordinates. - pub fn coords<'a>(&'a self) -> &'a RWArc> { + pub fn coords<'a>(&'a self) -> &'a RWArc>> { &'a self.coords } /// This mesh texture coordinates. - pub fn uvs<'a>(&'a self) -> &'a RWArc> { + pub fn uvs<'a>(&'a self) -> &'a RWArc>> { &'a self.uvs } /// Computes normals from a set of faces. - pub fn compute_normals_array(coordinates: &[Coord], faces: &[Face]) -> ~[Normal] { + pub fn compute_normals_array(coordinates: &[Vec3], faces: &[Vec3]) -> ~[Vec3] { let mut res = ~[]; Mesh::compute_normals(coordinates, faces, &mut res); @@ -157,9 +151,9 @@ impl Mesh { } /// Computes normals from a set of faces. - pub fn compute_normals(coordinates: &[Coord], - faces: &[Face], - normals: &mut ~[Normal]) { + pub fn compute_normals(coordinates: &[Vec3], + faces: &[Vec3], + normals: &mut ~[Vec3]) { let mut divisor = vec::from_elem(coordinates.len(), 0f32); // Shrink the output buffer if it is too big.