Browse Source

Clippy

master
Thomas Forgione 11 months ago
parent
commit
51274f86fc
Signed by: tforgione <thomas@forgione.fr> GPG Key ID: 63D3E1A00D54FD76
2 changed files with 13 additions and 9 deletions
  1. +12
    -8
      src/exporter/obj.rs
  2. +1
    -1
      src/parser/obj.rs

+ 12
- 8
src/exporter/obj.rs View File

@@ -5,9 +5,7 @@ use crate::exporter::{Exporter, Error};
use crate::model::{Face, FaceVertex, Model};

/// The OBJ exporter.
pub struct ObjExporter {

}
pub struct ObjExporter;

impl ObjExporter {
/// Creates a new obj exporter.
@@ -48,13 +46,19 @@ impl ObjExporter {
/// assert_eq!(ObjExporter::convert_face(face), "f 1/1/1 2/2/2 3/3/3");
/// ```
pub fn convert_face(face: Face) -> String {
format!("f {}", [face.0, face.1, face.2].into_iter()
format!("f {}", [face.0, face.1, face.2].iter()
.map(|&x| ObjExporter::convert_face_vertex(x))
.collect::<Vec<String>>()
.join(" "))
}
}

impl Default for ObjExporter {
fn default() -> Self {
Self::new()
}
}

impl Exporter for ObjExporter {
fn export<W: Write>(&mut self, model: &Model, writer: &mut W) -> Result<(), Error> {

@@ -63,21 +67,21 @@ impl Exporter for ObjExporter {
writeln!(writer, "v {} {} {}", vertex[0], vertex[1], vertex[2])?;
}

writeln!(writer, "")?;
writeln!(writer)?;

// Write the texture coordinates
for tc in model.texture_coordinates() {
writeln!(writer, "vt {} {}", tc[0], tc[1])?;
}

writeln!(writer, "")?;
writeln!(writer)?;

// Write the vertices
for normal in model.normals() {
writeln!(writer, "vn {} {} {}", normal[0], normal[1], normal[2])?;
}

writeln!(writer, "")?;
writeln!(writer)?;

// Write the real content of the model
for part in model.parts() {
@@ -92,7 +96,7 @@ impl Exporter for ObjExporter {
writeln!(writer, "{}", ObjExporter::convert_face(*face))?;
}

writeln!(writer, "")?;
writeln!(writer)?;
}

Ok(())


+ 1
- 1
src/parser/obj.rs View File

@@ -40,7 +40,7 @@ impl ObjParser {
Ok(())
}
/// Parses a face vertex.
pub fn parse_face_vertex(&self, line: &Line, face_vertex: &str) -> Result<FaceVertex, Error> {
pub fn parse_face_vertex(&self, _line: &Line, face_vertex: &str) -> Result<FaceVertex, Error> {
let mut subsplit = face_vertex
.split('/')
.map(|x| if x.is_empty() {


Loading…
Cancel
Save