From febd970f030925c44ad1005d6b8c441fd9bb96f1 Mon Sep 17 00:00:00 2001 From: Cedric Hutchings Date: Fri, 25 Oct 2019 07:59:53 -0400 Subject: [PATCH 1/3] cargo update --- Cargo.lock | 295 ++++++++++++++++++++++++----------------------------- 1 file changed, 136 insertions(+), 159 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a59295..4b0c055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,10 +5,10 @@ name = "alga" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "approx 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libm 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libm 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -16,53 +16,52 @@ name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "approx" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "atty" -version = "0.2.11" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitflags" -version = "1.0.4" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.32.0" +version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -71,91 +70,91 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm" -version = "0.9.3" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_cursor 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_input 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_screen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_style 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_terminal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_input 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_style 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_terminal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_cursor" -version = "0.2.1" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_input" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_screen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_screen" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_style" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_terminal" -version = "0.2.2" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_cursor 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_utils" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossterm_winapi" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -165,74 +164,78 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "generic-array" -version = "0.12.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.2.53" +version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libm" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "matrixmultiply" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rawpointer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rawpointer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "nalgebra" -version = "0.17.2" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "alga 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "approx 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matrixmultiply 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "matrixmultiply 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-complex" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -240,7 +243,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -249,12 +252,12 @@ name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -275,12 +278,12 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -290,10 +293,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -301,8 +304,8 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -315,7 +318,7 @@ dependencies = [ [[package]] name = "rawpointer" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -326,28 +329,15 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_syscall" -version = "0.1.51" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "sloth" version = "0.1.0" dependencies = [ - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossterm 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "nalgebra 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "nalgebra 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "stl_io 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tobj 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tobj 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -355,45 +345,35 @@ name = "stl_io" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "strsim" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "termion" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "textwrap" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tobj" -version = "0.1.6" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "typenum" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -403,7 +383,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -423,51 +403,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum alga 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc836ad7a40dc9d8049574e2a29979f5dc77deeea4d7ebcd29773452f0e9694" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum approx 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3c57ff1a5b00753647aebbbcf4ea67fa1e711a65ea7a30eb90dbf07de2485aee" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum crossterm 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "927454c82a994b7c90928f1fd43f9a4203f61490c87901d265db4fd7b46c34d4" -"checksum crossterm_cursor 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e5f322497503049f595591096a3b683189a6a99ea2fe949c9225f86424ca092" -"checksum crossterm_input 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "efb6f1a1831fa737172bae7dad530c869c40d39d1b9800819e818ea068cf29cf" -"checksum crossterm_screen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "95a4430df9097688954bc8735001f81a0d7c7f42497c60936e6a94c1f2c53947" -"checksum crossterm_style 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13f47876deeda8ae6313756e1910f79314088f39b33b345b7a6c252eefda1b53" -"checksum crossterm_terminal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00c9e7fd9c19394c0da7f4279f7017035defe5396f91ca1b0e8b03a0299ebb60" -"checksum crossterm_utils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c3b65f38e665bb045b3abe2ee6c0c902e14eb889c08c8dbdf0adab5993c802f6" -"checksum crossterm_winapi 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71dc52848cd3c5e06d5d0e193c0d64ce93b71502e124723a33bf615ef7089610" +"checksum crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "21ac79357981b3c35917a377e6138729b66316db7649f9f96fbb517bb02361e5" +"checksum crossterm_cursor 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fb4bfd085f17d83e6cd2943f0150d3b4331e465de8dba1750d1966192faf63dc" +"checksum crossterm_input 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c6dd255ca05a596bae31ec392fdb67a829509bb767213f00f37c6b62814db663" +"checksum crossterm_screen 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf294484fc34c22d514c41afc0b97ce74e10ea54d6eb5fe4806d1e1ac0f7b76" +"checksum crossterm_style 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "983596405fe738aac9645656b666073fe6e0a8bf088679b7e256916ee41b61f7" +"checksum crossterm_terminal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "db8546b519e0c26aa1f43a4a4ea45ccb41eaca74b9a753ea1788f9ad90212636" +"checksum crossterm_utils 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f874a71b2040c730669ddff805c9bc2a1a2f6de9d7f6aab2ae8d29ccbf8a0617" +"checksum crossterm_winapi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b055e7cc627c452e6a9b977022f48a2db6f0ff73df446ca970f95eef9c381d45" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" -"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee" -"checksum libm 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "03c0bb6d5ce1b5cc6fd0578ec1cbc18c9d88b5b591a5c7c1d6c6175e266a0819" -"checksum matrixmultiply 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfed72d871629daa12b25af198f110e8095d7650f5f4c61c5bac28364604f9b" -"checksum nalgebra 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f76a29833cbba252d6799bcfd8e603610a2165a18b62c7f4307495d851c3d337" -"checksum num-complex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "107b9be86cd2481930688277b675b0114578227f034674726605b8a482d8baf8" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum libm 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" +"checksum matrixmultiply 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f7ec66360130972f34830bfad9ef05c6610a43938a467bcc9ab9369ab3478f" +"checksum nalgebra 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "be539bb5e751c248d25c21c850b69105809306f367c35bf1daa8724f0cb786df" +"checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rawpointer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebac11a9d2e11f2af219b8b8d833b76b1ea0e054aa0e8d8e9e4cbde353bdf019" +"checksum rawpointer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum stl_io 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dc89130962899464d00274e09685e0b0728c0ba18c82feaff6ae9a912b3cd06c" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" -"checksum tobj 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c5eb0cdeabef6fcefb92c6dcb8571ba1880d36eb608da4f9cf62673765eadc31" -"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" -"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum tobj 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "1ed6f4ec3b7c466b7a72471179e55e2b6a7452b53691b6115185132fc2e06b1c" +"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" From 2eda3252494228cd9c87bced3d36cdbbd6bff5f5 Mon Sep 17 00:00:00 2001 From: Cedric Hutchings Date: Fri, 25 Oct 2019 08:00:20 -0400 Subject: [PATCH 2/3] cargo fmt --- src/context.rs | 297 +++++++++++++++++++-------------------- src/geometry.rs | 345 +++++++++++++++++++++++----------------------- src/inputs.rs | 326 +++++++++++++++++++++---------------------- src/main.rs | 9 +- src/rasterizer.rs | 2 +- 5 files changed, 495 insertions(+), 484 deletions(-) diff --git a/src/context.rs b/src/context.rs index bc49add..a234782 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,146 +1,151 @@ -use crate::geometry::SimpleMesh; -use crossterm::{cursor, terminal, Attribute, Color, Colored}; -use nalgebra::Matrix4; -use std::error::Error; -use std::f32; - -pub struct Context { - pub utransform: Matrix4, - pub width: usize, - pub height: usize, - pub frame_buffer: Vec<(char, (u8, u8, u8))>, - pub z_buffer: Vec, - pub image: bool -} - -impl Context { - pub fn blank(image: bool) -> Context { - //TODO: Make this a constant struct - Context { - utransform: Matrix4::new( - 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, - ), - width: 0, - height: 0, - frame_buffer: vec![], - z_buffer: vec![], - image - } - } - pub fn clear(&mut self) { - self.frame_buffer = vec![(' ', (0, 0, 0)); - if self.image { - self.width * self.height + self.height - } else { - self.width * self.height - } as usize]; - self.z_buffer = vec![f32::MAX; self.width * self.height as usize]; //f32::MAX is written to the z-buffer as an infinite back-wall to render with - } - pub fn camera(&mut self, proj: Matrix4, view: Matrix4) -> &Matrix4 { - self.utransform = proj * view; - &self.utransform - } - pub fn flush(&self, color: bool, webify: bool) -> Result<(), Box> { - let mut prev_color = None; - - if !self.image { - cursor().goto(0, 0)?; - } - - if color { - for pixel in &self.frame_buffer { - match prev_color { - Some(c) if c == pixel.1 => { - print!("{}", pixel.0); - } - _ => { - prev_color = Some(pixel.1); - if webify { - print!( - "{}", - (pixel.1).0, (pixel.1).1, (pixel.1).2, pixel.0 - ) - } else { - print!( - "{}{}{}", - Colored::Fg(Color::Rgb { - r: (pixel.1).0, - g: (pixel.1).1, - b: (pixel.1).2 - }), - Colored::Bg(Color::Rgb { - r: 25, - g: 25, - b: 25 - }), - pixel.0 - ) - } - } - } - } - if !self.image { - println!("{}", Attribute::Reset); - } - } else { - let mut frame = String::from(""); - for pixel in &self.frame_buffer { - frame.push(pixel.0); - } - println!("{}", frame) - } - - Ok(()) - } - pub fn update( - &mut self, - mut old_size: (u16, u16), - meshes: &[SimpleMesh], - ) -> Result<(), Box> { - let terminal = terminal(); - let terminal_size = if self.image { - (self.width as u16, self.height as u16) - } else { - terminal.terminal_size() - }; - - if old_size != terminal_size { - old_size = terminal_size; // It changed! Set new size - old_size.0 += 1; - let mut scale: f32 = 0.0; // The scene's scale - for mesh in meshes { - // This calculates the maximum axis value (x y or z) in all meshes - scale = scale - .max(mesh.bounding_box.max.x) - .max(mesh.bounding_box.max.y) - .max(mesh.bounding_box.max.z); - } - scale = f32::from(old_size.1).min(f32::from(old_size.0) / 2.0) / scale / 2.0; // Constrain to width and height, whichever is smaller - let t = Matrix4::new( - scale, - 0.0, - 0.0, - f32::from(old_size.0) / 4.0, // X translation is divided by 4 because there's a 1 char space between charxels - 0.0, - -scale, - 0.0, - f32::from(old_size.1) / 2.0, // Y translation is divided by 2 to center - 0.0, - 0.0, - scale, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - ); - self.utransform = t; - if !self.image { - self.width = old_size.0 as usize; - self.height = (old_size.1) as usize; - } - } - - Ok(()) - } -} +use crate::geometry::SimpleMesh; +use crossterm::{cursor, terminal, Attribute, Color, Colored}; +use nalgebra::Matrix4; +use std::error::Error; +use std::f32; + +pub struct Context { + pub utransform: Matrix4, + pub width: usize, + pub height: usize, + pub frame_buffer: Vec<(char, (u8, u8, u8))>, + pub z_buffer: Vec, + pub image: bool, +} + +impl Context { + pub fn blank(image: bool) -> Context { + //TODO: Make this a constant struct + Context { + utransform: Matrix4::new( + 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, + ), + width: 0, + height: 0, + frame_buffer: vec![], + z_buffer: vec![], + image, + } + } + pub fn clear(&mut self) { + self.frame_buffer = vec![ + (' ', (0, 0, 0)); + if self.image { + self.width * self.height + self.height + } else { + self.width * self.height + } as usize + ]; + self.z_buffer = vec![f32::MAX; self.width * self.height as usize]; //f32::MAX is written to the z-buffer as an infinite back-wall to render with + } + pub fn camera(&mut self, proj: Matrix4, view: Matrix4) -> &Matrix4 { + self.utransform = proj * view; + &self.utransform + } + pub fn flush(&self, color: bool, webify: bool) -> Result<(), Box> { + let mut prev_color = None; + + if !self.image { + cursor().goto(0, 0)?; + } + + if color { + for pixel in &self.frame_buffer { + match prev_color { + Some(c) if c == pixel.1 => { + print!("{}", pixel.0); + } + _ => { + prev_color = Some(pixel.1); + if webify { + print!( + "{}", + (pixel.1).0, + (pixel.1).1, + (pixel.1).2, + pixel.0 + ) + } else { + print!( + "{}{}{}", + Colored::Fg(Color::Rgb { + r: (pixel.1).0, + g: (pixel.1).1, + b: (pixel.1).2 + }), + Colored::Bg(Color::Rgb { + r: 25, + g: 25, + b: 25 + }), + pixel.0 + ) + } + } + } + } + if !self.image { + println!("{}", Attribute::Reset); + } + } else { + let mut frame = String::from(""); + for pixel in &self.frame_buffer { + frame.push(pixel.0); + } + println!("{}", frame) + } + + Ok(()) + } + pub fn update( + &mut self, + mut old_size: (u16, u16), + meshes: &[SimpleMesh], + ) -> Result<(), Box> { + let terminal = terminal(); + let terminal_size = if self.image { + (self.width as u16, self.height as u16) + } else { + terminal.terminal_size() + }; + + if old_size != terminal_size { + old_size = terminal_size; // It changed! Set new size + old_size.0 += 1; + let mut scale: f32 = 0.0; // The scene's scale + for mesh in meshes { + // This calculates the maximum axis value (x y or z) in all meshes + scale = scale + .max(mesh.bounding_box.max.x) + .max(mesh.bounding_box.max.y) + .max(mesh.bounding_box.max.z); + } + scale = f32::from(old_size.1).min(f32::from(old_size.0) / 2.0) / scale / 2.0; // Constrain to width and height, whichever is smaller + let t = Matrix4::new( + scale, + 0.0, + 0.0, + f32::from(old_size.0) / 4.0, // X translation is divided by 4 because there's a 1 char space between charxels + 0.0, + -scale, + 0.0, + f32::from(old_size.1) / 2.0, // Y translation is divided by 2 to center + 0.0, + 0.0, + scale, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + ); + self.utransform = t; + if !self.image { + self.width = old_size.0 as usize; + self.height = (old_size.1) as usize; + } + } + + Ok(()) + } +} diff --git a/src/geometry.rs b/src/geometry.rs index 22de96c..6a9f546 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -1,172 +1,173 @@ -use nalgebra::{Matrix4, Unit, Vector4}; -use std::clone::Clone; -use tobj::{Material, Mesh}; - -// 2 3D points = Axis aligned bounding box -pub struct AABB { - pub min: Vector4, - pub max: Vector4, -} - -// Functions for the AABB -impl AABB { - pub fn new(min: Vector4, max: Vector4) -> AABB { - AABB { min, max } - } -} - -// Three Points in 3D = Triangle -pub struct Triangle { - pub color: (u8, u8, u8), - pub v1: Vector4, - pub v2: Vector4, - pub v3: Vector4, -} - -// Functions for Triangle Struct -impl Triangle { - pub fn to_aabb(&self) -> AABB { - // Forgive me for this brag, but this is the best thing I've written in rust - AABB::new( - Vector4::from_fn(|x, _size| self.v1[x].min(self.v2[x].min(self.v3[x]))), - Vector4::from_fn(|x, _size| self.v1[x].max(self.v2[x].max(self.v3[x]))), - ) - } - // This mutates the triangle's points into a given Matrix space - pub fn mul(&mut self, transform: Matrix4) -> &mut Triangle { - self.v1 = transform * self.v1; - self.v2 = transform * self.v2; - self.v3 = transform * self.v3; - self - } - pub fn normal(&self) -> Unit> { - let v1 = self.v2 - self.v1; - let v2 = self.v3 - self.v1; - let x = (v1[1] * v2[2]) - (v1[2] * v2[1]); - let y = (v1[2] * v2[0]) - (v1[0] * v2[2]); - let z = (v1[0] * v2[1]) - (v1[1] * v2[0]); - Unit::new_normalize(Vector4::new(x, y, z, 0.0)) - } -} - -impl Clone for Triangle { - fn clone(&self) -> Triangle { - Triangle { - color: self.color, - v1: self.v1, - v2: self.v2, - v3: self.v3, - } - } -} - -pub trait ToSimpleMesh { - fn to_simple_mesh(&self) -> SimpleMesh; -} - -pub trait ToSimpleMeshWithMaterial { - fn to_simple_mesh_with_materials(&self, materials: &[Material]) -> SimpleMesh; -} - -pub struct SimpleMesh { - pub bounding_box: AABB, - pub triangles: Vec, -} - -impl ToSimpleMeshWithMaterial for Mesh { - fn to_simple_mesh_with_materials(&self, materials: &[Material]) -> SimpleMesh { - let mut bounding_box = AABB { - // This is the general bounding box for the mesh - min: Vector4::new(0.0, 0.0, 0.0, 1.0), - max: Vector4::new(0.0, 0.0, 0.0, 1.0), - }; - let mut triangles = vec![ - Triangle { - // Repeat this triangle for all faces in polygon - color: (1, 1, 1), - v1: Vector4::new(0.0, 0.0, 0.0, 1.0), - v2: Vector4::new(0.0, 0.0, 0.0, 1.0), - v3: Vector4::new(0.0, 0.0, 0.0, 1.0) - }; - self.indices.len() / 3 - ]; - for (x, tri) in triangles.iter_mut().enumerate() { - tri.v1.x = self.positions[(self.indices[x * 3] * 3) as usize]; - tri.v1.y = self.positions[(self.indices[x * 3] * 3 + 1) as usize]; - tri.v1.z = self.positions[(self.indices[x * 3] * 3 + 2) as usize]; - tri.v2.x = self.positions[(self.indices[x * 3 + 1] * 3) as usize]; - tri.v2.y = self.positions[(self.indices[x * 3 + 1] * 3 + 1) as usize]; - tri.v2.z = self.positions[(self.indices[x * 3 + 1] * 3 + 2) as usize]; - tri.v3.x = self.positions[(self.indices[x * 3 + 2] * 3) as usize]; - tri.v3.y = self.positions[(self.indices[x * 3 + 2] * 3 + 1) as usize]; - tri.v3.z = self.positions[(self.indices[x * 3 + 2] * 3 + 2) as usize]; - - if !materials.is_empty() { - let material = &materials[self.material_id.unwrap()]; - tri.color = ( - (material.diffuse[0] * 255.0) as u8, - (material.diffuse[1] * 255.0) as u8, - (material.diffuse[2] * 255.0) as u8, - ); - } - - let aabb = tri.to_aabb(); // Compare this triangles aabb to the mesh's aabb - bounding_box.min.x = aabb.min.x.min(bounding_box.min.x); - bounding_box.min.y = aabb.min.y.min(bounding_box.min.y); - bounding_box.min.z = aabb.min.z.min(bounding_box.min.z); - bounding_box.max.x = aabb.max.x.max(bounding_box.max.x); - bounding_box.max.y = aabb.max.y.max(bounding_box.max.y); - bounding_box.max.z = aabb.max.z.max(bounding_box.max.z); - } - SimpleMesh { - triangles, - bounding_box, - } - } -} - -impl ToSimpleMesh for Mesh { - fn to_simple_mesh(&self) -> SimpleMesh { - self.to_simple_mesh_with_materials(&[]) - } -} - -/// Convert stl_io IndexedMesh into Sloth style triangles. -impl ToSimpleMesh for stl_io::IndexedMesh { - fn to_simple_mesh(&self) -> SimpleMesh { - let mut bounding_box = AABB { - min: Vector4::new(std::f32::MAX, std::f32::MAX, std::f32::MAX, 1.0), - max: Vector4::new(std::f32::MIN, std::f32::MIN, std::f32::MIN, 1.0), - }; - fn stlv2v4(stlio_vec: [f32; 3]) -> Vector4 { - Vector4::new(stlio_vec[0], stlio_vec[1], stlio_vec[2], 1.0) - }; - let mut triangles = vec![ - Triangle { - // at time of writing, stl_io lacked color - color: (0xFF, 0xFF, 0x00), - v1: Vector4::new(0.0, 0.0, 0.0, 1.0), - v2: Vector4::new(0.0, 0.0, 0.0, 1.0), - v3: Vector4::new(0.0, 0.0, 0.0, 1.0) - }; - self.faces.len() - ]; - #[allow(clippy::needless_range_loop)] // We need an index number, to get the triangle's index too - for t_index in 0..self.faces.len() { - triangles[t_index].v1 = stlv2v4(self.vertices[self.faces[t_index].vertices[0]]); - triangles[t_index].v2 = stlv2v4(self.vertices[self.faces[t_index].vertices[1]]); - triangles[t_index].v3 = stlv2v4(self.vertices[self.faces[t_index].vertices[2]]); - let aabb = triangles[t_index].to_aabb(); - bounding_box.min.x = aabb.min.x.min(bounding_box.min.x); - bounding_box.min.y = aabb.min.y.min(bounding_box.min.y); - bounding_box.min.z = aabb.min.z.min(bounding_box.min.z); - bounding_box.max.x = aabb.max.x.max(bounding_box.max.x); - bounding_box.max.y = aabb.max.y.max(bounding_box.max.y); - bounding_box.max.z = aabb.max.z.max(bounding_box.max.z); - } - SimpleMesh { - triangles, - bounding_box, - } - } -} +use nalgebra::{Matrix4, Unit, Vector4}; +use std::clone::Clone; +use tobj::{Material, Mesh}; + +// 2 3D points = Axis aligned bounding box +pub struct AABB { + pub min: Vector4, + pub max: Vector4, +} + +// Functions for the AABB +impl AABB { + pub fn new(min: Vector4, max: Vector4) -> AABB { + AABB { min, max } + } +} + +// Three Points in 3D = Triangle +pub struct Triangle { + pub color: (u8, u8, u8), + pub v1: Vector4, + pub v2: Vector4, + pub v3: Vector4, +} + +// Functions for Triangle Struct +impl Triangle { + pub fn to_aabb(&self) -> AABB { + // Forgive me for this brag, but this is the best thing I've written in rust + AABB::new( + Vector4::from_fn(|x, _size| self.v1[x].min(self.v2[x].min(self.v3[x]))), + Vector4::from_fn(|x, _size| self.v1[x].max(self.v2[x].max(self.v3[x]))), + ) + } + // This mutates the triangle's points into a given Matrix space + pub fn mul(&mut self, transform: Matrix4) -> &mut Triangle { + self.v1 = transform * self.v1; + self.v2 = transform * self.v2; + self.v3 = transform * self.v3; + self + } + pub fn normal(&self) -> Unit> { + let v1 = self.v2 - self.v1; + let v2 = self.v3 - self.v1; + let x = (v1[1] * v2[2]) - (v1[2] * v2[1]); + let y = (v1[2] * v2[0]) - (v1[0] * v2[2]); + let z = (v1[0] * v2[1]) - (v1[1] * v2[0]); + Unit::new_normalize(Vector4::new(x, y, z, 0.0)) + } +} + +impl Clone for Triangle { + fn clone(&self) -> Triangle { + Triangle { + color: self.color, + v1: self.v1, + v2: self.v2, + v3: self.v3, + } + } +} + +pub trait ToSimpleMesh { + fn to_simple_mesh(&self) -> SimpleMesh; +} + +pub trait ToSimpleMeshWithMaterial { + fn to_simple_mesh_with_materials(&self, materials: &[Material]) -> SimpleMesh; +} + +pub struct SimpleMesh { + pub bounding_box: AABB, + pub triangles: Vec, +} + +impl ToSimpleMeshWithMaterial for Mesh { + fn to_simple_mesh_with_materials(&self, materials: &[Material]) -> SimpleMesh { + let mut bounding_box = AABB { + // This is the general bounding box for the mesh + min: Vector4::new(0.0, 0.0, 0.0, 1.0), + max: Vector4::new(0.0, 0.0, 0.0, 1.0), + }; + let mut triangles = vec![ + Triangle { + // Repeat this triangle for all faces in polygon + color: (1, 1, 1), + v1: Vector4::new(0.0, 0.0, 0.0, 1.0), + v2: Vector4::new(0.0, 0.0, 0.0, 1.0), + v3: Vector4::new(0.0, 0.0, 0.0, 1.0) + }; + self.indices.len() / 3 + ]; + for (x, tri) in triangles.iter_mut().enumerate() { + tri.v1.x = self.positions[(self.indices[x * 3] * 3) as usize]; + tri.v1.y = self.positions[(self.indices[x * 3] * 3 + 1) as usize]; + tri.v1.z = self.positions[(self.indices[x * 3] * 3 + 2) as usize]; + tri.v2.x = self.positions[(self.indices[x * 3 + 1] * 3) as usize]; + tri.v2.y = self.positions[(self.indices[x * 3 + 1] * 3 + 1) as usize]; + tri.v2.z = self.positions[(self.indices[x * 3 + 1] * 3 + 2) as usize]; + tri.v3.x = self.positions[(self.indices[x * 3 + 2] * 3) as usize]; + tri.v3.y = self.positions[(self.indices[x * 3 + 2] * 3 + 1) as usize]; + tri.v3.z = self.positions[(self.indices[x * 3 + 2] * 3 + 2) as usize]; + + if !materials.is_empty() { + let material = &materials[self.material_id.unwrap()]; + tri.color = ( + (material.diffuse[0] * 255.0) as u8, + (material.diffuse[1] * 255.0) as u8, + (material.diffuse[2] * 255.0) as u8, + ); + } + + let aabb = tri.to_aabb(); // Compare this triangles aabb to the mesh's aabb + bounding_box.min.x = aabb.min.x.min(bounding_box.min.x); + bounding_box.min.y = aabb.min.y.min(bounding_box.min.y); + bounding_box.min.z = aabb.min.z.min(bounding_box.min.z); + bounding_box.max.x = aabb.max.x.max(bounding_box.max.x); + bounding_box.max.y = aabb.max.y.max(bounding_box.max.y); + bounding_box.max.z = aabb.max.z.max(bounding_box.max.z); + } + SimpleMesh { + triangles, + bounding_box, + } + } +} + +impl ToSimpleMesh for Mesh { + fn to_simple_mesh(&self) -> SimpleMesh { + self.to_simple_mesh_with_materials(&[]) + } +} + +/// Convert stl_io IndexedMesh into Sloth style triangles. +impl ToSimpleMesh for stl_io::IndexedMesh { + fn to_simple_mesh(&self) -> SimpleMesh { + let mut bounding_box = AABB { + min: Vector4::new(std::f32::MAX, std::f32::MAX, std::f32::MAX, 1.0), + max: Vector4::new(std::f32::MIN, std::f32::MIN, std::f32::MIN, 1.0), + }; + fn stlv2v4(stlio_vec: [f32; 3]) -> Vector4 { + Vector4::new(stlio_vec[0], stlio_vec[1], stlio_vec[2], 1.0) + }; + let mut triangles = vec![ + Triangle { + // at time of writing, stl_io lacked color + color: (0xFF, 0xFF, 0x00), + v1: Vector4::new(0.0, 0.0, 0.0, 1.0), + v2: Vector4::new(0.0, 0.0, 0.0, 1.0), + v3: Vector4::new(0.0, 0.0, 0.0, 1.0) + }; + self.faces.len() + ]; + #[allow(clippy::needless_range_loop)] + // We need an index number, to get the triangle's index too + for t_index in 0..self.faces.len() { + triangles[t_index].v1 = stlv2v4(self.vertices[self.faces[t_index].vertices[0]]); + triangles[t_index].v2 = stlv2v4(self.vertices[self.faces[t_index].vertices[1]]); + triangles[t_index].v3 = stlv2v4(self.vertices[self.faces[t_index].vertices[2]]); + let aabb = triangles[t_index].to_aabb(); + bounding_box.min.x = aabb.min.x.min(bounding_box.min.x); + bounding_box.min.y = aabb.min.y.min(bounding_box.min.y); + bounding_box.min.z = aabb.min.z.min(bounding_box.min.z); + bounding_box.max.x = aabb.max.x.max(bounding_box.max.x); + bounding_box.max.y = aabb.max.y.max(bounding_box.max.y); + bounding_box.max.z = aabb.max.z.max(bounding_box.max.z); + } + SimpleMesh { + triangles, + bounding_box, + } + } +} diff --git a/src/inputs.rs b/src/inputs.rs index f71ddf2..1442c96 100644 --- a/src/inputs.rs +++ b/src/inputs.rs @@ -1,161 +1,165 @@ -use clap::{App, Arg, ArgMatches, SubCommand}; -use crate::geometry::{SimpleMesh, ToSimpleMeshWithMaterial, ToSimpleMesh}; -use crate::context::{Context}; -use std::fs::OpenOptions; -use std::path::Path; -use std::error::Error; - -pub fn cli_matches<'a>() -> ArgMatches<'a> { - commands_for_subcommands(App::new("Sloth") - .version("0.1") - .author("Mitchell Hynes. ") - .about("A toy for rendering 3D objects in the command line") - .subcommand(commands_for_subcommands(SubCommand::with_name("image") - .about("Generates a colorless terminal output as lines of text") - .author("Mitchell Hynes ") - .arg( - Arg::with_name("frame count") - .short("j") - .long("webify") - .help("Generates a portable JS based render of your object for the web") - .takes_value(true) - ) - .arg( - Arg::with_name("width") - .short("w") - .help("Sets the width of the image to generate") - .takes_value(true) - .required(true) - ) - .arg( - Arg::with_name("height") - .short("h") - .help("Sets the height of the image to generate") - .takes_value(true) - ))) - .arg( - Arg::with_name("input filename(s)") - .help("Sets the input file to render") - .required(true) - .multiple(true) - .index(1) - )) - .get_matches() -} - -fn commands_for_subcommands<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { - command_flag_color(command_rotates(app)) -} - -fn command_flag_color<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { - app.arg( - Arg::with_name("no color") - .short("b") - .help("Flags the rasterizer to render without color") - ) -} - -fn command_rotates<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { - app.arg( - Arg::with_name("x") - .short("x") - .long("yaw") - .help("Sets the object's static X rotation (in radians)") - .takes_value(true) - ) - .arg( - Arg::with_name("y") - .short("y") - .long("pitch") - .help("Sets the object's static Y rotation (in radians)") - .takes_value(true) - ) - .arg( - Arg::with_name("z") - .short("z") - .long("roll") - .help("Sets the object's static Z rotation (in radians)") - .takes_value(true) - ) -} - -pub fn to_meshes(models: Vec, materials: Vec) -> Vec { - let mut meshes: Vec = vec![]; - for model in models { - meshes.push(model.mesh.to_simple_mesh_with_materials(&materials)); - } - meshes -} - -pub fn match_meshes(matches: &ArgMatches) -> Result, Box> { - let mut mesh_queue: Vec = vec![]; - for slice in matches.value_of("input filename(s)").unwrap().split(' ') { - let error = |s: &str, e: &str| -> Result, Box> { - Err(format!("filename: [{}] couldn't load, {}. {}", slice, s, e).into()) - }; - // Fill list with file inputs (Splits for spaces -> multiple files) - let path = Path::new(slice); - let meshes = match path.extension() { - None => error("couldn't determine filename extension", ""), - 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) { - Err(e) => error("tobj couldnt load/parse OBJ", &e.to_string()), - Ok(present) => Ok(to_meshes(present.0, present.1)), - }, - "stl" => match OpenOptions::new().read(true).open(&path) { - Err(e) => error("STL load failed", &e.to_string()), - Ok(mut file) => match stl_io::read_stl(&mut file) { - Err(e) => error("stl_io couldnt parse STL", &e.to_string()), - Ok(stlio_mesh) => Ok(vec![stlio_mesh.to_simple_mesh()]), - }, - }, - _ => error("unknown filename extension", ""), - }, - }, - }; - mesh_queue.append(&mut meshes.unwrap()); - } - Ok(mesh_queue) -} - -pub fn match_turntable(matches: &ArgMatches) -> Result<(f32, f32, f32, f32), Box> { - let mut turntable = (0.0, 0.0, 0.0, 0.0); - if let Some(x) = matches.value_of("x") { - turntable.0 = x.parse()?; - } - if let Some(y) = matches.value_of("y") { - turntable.1 = y.parse()?; - } - if let Some(z) = matches.value_of("z") { - turntable.2 = z.parse()?; - } - if let Some(s) = matches.value_of("speed") { - turntable.3 = s.parse()?; - } else { - turntable.3 = 1.0; // No speed defined -> 1.0 rad/s - } - turntable.1 += std::f32::consts::PI; // All models for some reason are backwards, this fixes that - Ok(turntable) -} - -pub fn match_image_mode(matches: &ArgMatches) -> bool { - matches.is_present("image") -} - -pub fn match_no_color_mode(matches: &ArgMatches) -> bool { - matches.is_present("no color") -} - -pub fn match_dimensions(context: &mut Context, matches: &ArgMatches) -> Result<(), Box> { - if let Some(x) = matches.value_of("width") { - context.width = x.parse()?; - if let Some(y) = matches.value_of("height") { - context.height = y.parse()?; - } else { - context.height = context.width; - } - } - Ok(()) -} +use crate::context::Context; +use crate::geometry::{SimpleMesh, ToSimpleMesh, ToSimpleMeshWithMaterial}; +use clap::{App, Arg, ArgMatches, SubCommand}; +use std::error::Error; +use std::fs::OpenOptions; +use std::path::Path; + +pub fn cli_matches<'a>() -> ArgMatches<'a> { + commands_for_subcommands( + App::new("Sloth") + .version("0.1") + .author("Mitchell Hynes. ") + .about("A toy for rendering 3D objects in the command line") + .subcommand(commands_for_subcommands( + SubCommand::with_name("image") + .about("Generates a colorless terminal output as lines of text") + .author("Mitchell Hynes ") + .arg( + Arg::with_name("frame count") + .short("j") + .long("webify") + .help("Generates a portable JS based render of your object for the web") + .takes_value(true), + ) + .arg( + Arg::with_name("width") + .short("w") + .help("Sets the width of the image to generate") + .takes_value(true) + .required(true), + ) + .arg( + Arg::with_name("height") + .short("h") + .help("Sets the height of the image to generate") + .takes_value(true), + ), + )) + .arg( + Arg::with_name("input filename(s)") + .help("Sets the input file to render") + .required(true) + .multiple(true) + .index(1), + ), + ) + .get_matches() +} + +fn commands_for_subcommands<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + command_flag_color(command_rotates(app)) +} + +fn command_flag_color<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + app.arg( + Arg::with_name("no color") + .short("b") + .help("Flags the rasterizer to render without color"), + ) +} + +fn command_rotates<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + app.arg( + Arg::with_name("x") + .short("x") + .long("yaw") + .help("Sets the object's static X rotation (in radians)") + .takes_value(true), + ) + .arg( + Arg::with_name("y") + .short("y") + .long("pitch") + .help("Sets the object's static Y rotation (in radians)") + .takes_value(true), + ) + .arg( + Arg::with_name("z") + .short("z") + .long("roll") + .help("Sets the object's static Z rotation (in radians)") + .takes_value(true), + ) +} + +pub fn to_meshes(models: Vec, materials: Vec) -> Vec { + let mut meshes: Vec = vec![]; + for model in models { + meshes.push(model.mesh.to_simple_mesh_with_materials(&materials)); + } + meshes +} + +pub fn match_meshes(matches: &ArgMatches) -> Result, Box> { + let mut mesh_queue: Vec = vec![]; + for slice in matches.value_of("input filename(s)").unwrap().split(' ') { + let error = |s: &str, e: &str| -> Result, Box> { + Err(format!("filename: [{}] couldn't load, {}. {}", slice, s, e).into()) + }; + // Fill list with file inputs (Splits for spaces -> multiple files) + let path = Path::new(slice); + let meshes = match path.extension() { + None => error("couldn't determine filename extension", ""), + 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) { + Err(e) => error("tobj couldnt load/parse OBJ", &e.to_string()), + Ok(present) => Ok(to_meshes(present.0, present.1)), + }, + "stl" => match OpenOptions::new().read(true).open(&path) { + Err(e) => error("STL load failed", &e.to_string()), + Ok(mut file) => match stl_io::read_stl(&mut file) { + Err(e) => error("stl_io couldnt parse STL", &e.to_string()), + Ok(stlio_mesh) => Ok(vec![stlio_mesh.to_simple_mesh()]), + }, + }, + _ => error("unknown filename extension", ""), + }, + }, + }; + mesh_queue.append(&mut meshes.unwrap()); + } + Ok(mesh_queue) +} + +pub fn match_turntable(matches: &ArgMatches) -> Result<(f32, f32, f32, f32), Box> { + let mut turntable = (0.0, 0.0, 0.0, 0.0); + if let Some(x) = matches.value_of("x") { + turntable.0 = x.parse()?; + } + if let Some(y) = matches.value_of("y") { + turntable.1 = y.parse()?; + } + if let Some(z) = matches.value_of("z") { + turntable.2 = z.parse()?; + } + if let Some(s) = matches.value_of("speed") { + turntable.3 = s.parse()?; + } else { + turntable.3 = 1.0; // No speed defined -> 1.0 rad/s + } + turntable.1 += std::f32::consts::PI; // All models for some reason are backwards, this fixes that + Ok(turntable) +} + +pub fn match_image_mode(matches: &ArgMatches) -> bool { + matches.is_present("image") +} + +pub fn match_no_color_mode(matches: &ArgMatches) -> bool { + matches.is_present("no color") +} + +pub fn match_dimensions(context: &mut Context, matches: &ArgMatches) -> Result<(), Box> { + if let Some(x) = matches.value_of("width") { + context.width = x.parse()?; + if let Some(y) = matches.value_of("height") { + context.height = y.parse()?; + } else { + context.height = context.width; + } + } + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 267ec3a..51d9f2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ pub use inputs::*; fn main() -> Result<(), Box> { let matches = cli_matches(); // Read command line arguments - + let mesh_queue: Vec = match_meshes(&matches)?; // A list of meshes to render let mut turntable = match_turntable(&matches)?; let crossterm = Crossterm::new(); @@ -66,7 +66,8 @@ fn main() -> Result<(), Box> { } } } - let rot = Rotation3::from_euler_angles(turntable.0, turntable.1, turntable.2).to_homogeneous(); + let rot = + Rotation3::from_euler_angles(turntable.0, turntable.1, turntable.2).to_homogeneous(); context.update(size, &mesh_queue)?; // This checks for if there needs to be a context update context.clear(); // This clears the z and frame buffer for mesh in &mesh_queue { @@ -77,7 +78,7 @@ fn main() -> Result<(), Box> { if webify { println!("`"); } - + context.flush(!no_color, webify)?; // This prints all framebuffer info stdout().flush()?; let dt = Instant::now().duration_since(last_time).as_nanos() as f32 / 1_000_000_000.0; @@ -94,7 +95,7 @@ fn main() -> Result<(), Box> { } else { println!("`,"); } - webify_frame_count+=1; + webify_frame_count += 1; } if context.image && !webify { diff --git a/src/rasterizer.rs b/src/rasterizer.rs index d171e7a..8f74dc6 100644 --- a/src/rasterizer.rs +++ b/src/rasterizer.rs @@ -1,5 +1,5 @@ +use crate::context::Context; use crate::geometry::{SimpleMesh, Triangle}; -use crate::context::{Context}; use nalgebra::{Matrix4, Vector4}; pub fn default_shader(shade: f32) -> char { From e3715c5846c9e12790f56b5f5a2fdebaade2f618 Mon Sep 17 00:00:00 2001 From: Cedric Hutchings Date: Fri, 25 Oct 2019 08:03:00 -0400 Subject: [PATCH 3/3] fix dyn Error warnings --- src/context.rs | 4 ++-- src/inputs.rs | 8 ++++---- src/main.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/context.rs b/src/context.rs index a234782..d096186 100644 --- a/src/context.rs +++ b/src/context.rs @@ -42,7 +42,7 @@ impl Context { self.utransform = proj * view; &self.utransform } - pub fn flush(&self, color: bool, webify: bool) -> Result<(), Box> { + pub fn flush(&self, color: bool, webify: bool) -> Result<(), Box> { let mut prev_color = None; if !self.image { @@ -101,7 +101,7 @@ impl Context { &mut self, mut old_size: (u16, u16), meshes: &[SimpleMesh], - ) -> Result<(), Box> { + ) -> Result<(), Box> { let terminal = terminal(); let terminal_size = if self.image { (self.width as u16, self.height as u16) diff --git a/src/inputs.rs b/src/inputs.rs index 1442c96..28d7cb0 100644 --- a/src/inputs.rs +++ b/src/inputs.rs @@ -91,10 +91,10 @@ pub fn to_meshes(models: Vec, materials: Vec) -> Ve meshes } -pub fn match_meshes(matches: &ArgMatches) -> Result, Box> { +pub fn match_meshes(matches: &ArgMatches) -> Result, Box> { let mut mesh_queue: Vec = vec![]; for slice in matches.value_of("input filename(s)").unwrap().split(' ') { - let error = |s: &str, e: &str| -> Result, Box> { + let error = |s: &str, e: &str| -> Result, Box> { Err(format!("filename: [{}] couldn't load, {}. {}", slice, s, e).into()) }; // Fill list with file inputs (Splits for spaces -> multiple files) @@ -124,7 +124,7 @@ pub fn match_meshes(matches: &ArgMatches) -> Result, Box> Ok(mesh_queue) } -pub fn match_turntable(matches: &ArgMatches) -> Result<(f32, f32, f32, f32), Box> { +pub fn match_turntable(matches: &ArgMatches) -> Result<(f32, f32, f32, f32), Box> { let mut turntable = (0.0, 0.0, 0.0, 0.0); if let Some(x) = matches.value_of("x") { turntable.0 = x.parse()?; @@ -152,7 +152,7 @@ pub fn match_no_color_mode(matches: &ArgMatches) -> bool { matches.is_present("no color") } -pub fn match_dimensions(context: &mut Context, matches: &ArgMatches) -> Result<(), Box> { +pub fn match_dimensions(context: &mut Context, matches: &ArgMatches) -> Result<(), Box> { if let Some(x) = matches.value_of("width") { context.width = x.parse()?; if let Some(y) = matches.value_of("height") { diff --git a/src/main.rs b/src/main.rs index 51d9f2e..59e539c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ pub use rasterizer::*; pub mod inputs; pub use inputs::*; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let matches = cli_matches(); // Read command line arguments let mesh_queue: Vec = match_meshes(&matches)?; // A list of meshes to render