Skip to content

Commit

Permalink
Format Rust code using rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 31, 2022
1 parent c78da18 commit c2ba761
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ impl ToSimpleMeshWithMaterial for Mesh {
(material.diffuse[1] * 255.0) as u8,
(material.diffuse[2] * 255.0) as u8,
);

// Check if the model contains vertex colors.
if !self.vertex_color.is_empty() {
// Get the vertex_color from the first indice in the tri.
let color = (
(self.vertex_color[(self.indices[x * 3] * 3) as usize] * 255.0) as u8,
(self.vertex_color[(self.indices[x * 3] * 3 + 1) as usize] * 255.0) as u8,
(self.vertex_color[(self.indices[x * 3] * 3 + 2) as usize] * 255.0) as u8
(self.vertex_color[(self.indices[x * 3] * 3 + 1) as usize] * 255.0) as u8,
(self.vertex_color[(self.indices[x * 3] * 3 + 2) as usize] * 255.0) as u8,
);
tri.color = color;
}
Expand Down
8 changes: 5 additions & 3 deletions src/inputs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::context::Context;
use crate::geometry::{SimpleMesh, ToSimpleMesh, ToSimpleMeshWithMaterial};
use clap::{App, Arg, ArgMatches, SubCommand};
use tobj::LoadOptions;
use std::error::Error;
use std::fs::OpenOptions;
use std::path::Path;
use tobj::LoadOptions;

pub fn cli_matches<'a>() -> ArgMatches<'a> {
commands_for_subcommands(
Expand Down Expand Up @@ -105,10 +105,12 @@ pub fn match_meshes(matches: &ArgMatches) -> Result<Vec<SimpleMesh>, Box<dyn Err
Some(ext) => match ext.to_str() {
None => error("couldn't parse filename extension", ""),
Some(extstr) => match &*extstr.to_lowercase() {

"obj" => match tobj::load_obj(&path, &tobj::GPU_LOAD_OPTIONS) {
Err(e) => error("tobj couldnt load/parse OBJ", &e.to_string()),
Ok(present) => Ok(to_meshes(present.0, present.1.expect("Expected to have materials."))),
Ok(present) => Ok(to_meshes(
present.0,
present.1.expect("Expected to have materials."),
)),
},
"stl" => match OpenOptions::new().read(true).open(&path) {
Err(e) => error("STL load failed", &e.to_string()),
Expand Down

0 comments on commit c2ba761

Please sign in to comment.