From 939d34275f63d43bebe686f6a10522177a071a28 Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Sat, 21 Oct 2023 02:57:06 +0200 Subject: [PATCH] importer: clean up commented code --- Cargo.lock | 689 ++------------------------------------------ Cargo.toml | 4 - TODO.md | 1 + src/importer/stl.rs | 2 +- src/mesh.rs | 86 ++---- src/model.rs | 237 +-------------- 6 files changed, 49 insertions(+), 970 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a70ffd..6fcd940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,24 +17,6 @@ dependencies = [ "memchr 0.1.11", ] -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr 2.6.4", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "anyhow" version = "1.0.75" @@ -55,7 +37,7 @@ dependencies = [ "log 0.4.20", "parking", "polling", - "rustix 0.37.25", + "rustix", "slab", "socket2", "waker-fn", @@ -82,52 +64,12 @@ dependencies = [ "system-deps", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", -] - [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base64" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" - -[[package]] -name = "bindgen" -version = "0.59.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "clap", - "env_logger 0.9.3", - "lazy_static", - "lazycell", - "log 0.4.20", - "peeking_take_while", - "proc-macro2", - "quote", - "regex 1.10.2", - "rustc-hash", - "shlex", - "which", -] - [[package]] name = "bit_field" version = "0.10.2" @@ -140,12 +82,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - [[package]] name = "block" version = "0.1.6" @@ -189,15 +125,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-expr" version = "0.15.5" @@ -220,32 +147,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75476fe966a8af7c0ceae2a3e514afa87d4451741fcdfab8bfaa07ad301842ec" -[[package]] -name = "clang-sys" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" -dependencies = [ - "glob", - "libc", - "libloading", -] - -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "cmake" version = "0.1.50" @@ -318,17 +219,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "dispatch" version = "0.2.0" @@ -348,20 +238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" dependencies = [ "log 0.3.9", - "regex 0.1.80", -] - -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log 0.4.20", - "regex 1.10.2", - "termcolor", + "regex", ] [[package]] @@ -420,18 +297,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "filetime" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "windows-sys", -] - [[package]] name = "flate2" version = "1.0.28" @@ -448,16 +313,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ - "spin 0.9.8", -] - -[[package]] -name = "form_urlencoded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" -dependencies = [ - "percent-encoding", + "spin", ] [[package]] @@ -577,7 +433,7 @@ version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "919ebc7bdbf60a529689a5e58f80d9dcde27e3d2ab4f2f7ce711ec439fe789c5" dependencies = [ - "bitflags 1.3.2", + "bitflags", "glfw-sys", "objc", "raw-window-handle", @@ -614,12 +470,6 @@ dependencies = [ "rand 0.3.23", ] -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "gobject-sys" version = "0.16.3" @@ -670,46 +520,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "image" version = "0.24.7" @@ -735,7 +551,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "122d677d0efcd64ca15f12907beaf46b26bbd2cdc855ee5b227f29cf50f75bb5" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "imgui-sys", "mint", @@ -779,17 +595,11 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "libc", "windows-sys", ] -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - [[package]] name = "jpeg-decoder" version = "0.3.0" @@ -818,18 +628,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "lebe" version = "0.5.2" @@ -842,28 +640,12 @@ version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi 0.3.9", -] - [[package]] name = "linux-raw-sys" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" - [[package]] name = "lock_api" version = "0.4.10" @@ -922,12 +704,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -944,16 +720,6 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr 2.6.4", - "minimal-lexical", -] - [[package]] name = "num" version = "0.1.42" @@ -990,17 +756,6 @@ dependencies = [ "rustc-serialize", ] -[[package]] -name = "num-derive" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "num-integer" version = "0.1.45" @@ -1054,37 +809,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.3", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "objc" version = "0.2.7" @@ -1161,18 +885,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1197,7 +909,7 @@ version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ - "bitflags 1.3.2", + "bitflags", "crc32fast", "fdeflate", "flate2", @@ -1211,7 +923,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags 1.3.2", + "bitflags", "cfg-if", "concurrent-queue", "libc", @@ -1220,16 +932,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - [[package]] name = "proc-macro2" version = "1.0.69" @@ -1254,7 +956,7 @@ version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d086a75fc7bdfbadd649f7c1fa524f39be4979b15506f621b3742b752f5364ed" dependencies = [ - "env_logger 0.3.5", + "env_logger", "log 0.3.9", "rand 0.3.23", ] @@ -1347,7 +1049,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -1356,48 +1058,19 @@ version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" dependencies = [ - "aho-corasick 0.5.3", + "aho-corasick", "memchr 0.1.11", - "regex-syntax 0.3.9", + "regex-syntax", "thread_local", "utf8-ranges", ] -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick 1.1.2", - "memchr 2.6.4", - "regex-automata", - "regex-syntax 0.8.2", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick 1.1.2", - "memchr 2.6.4", - "regex-syntax 0.8.2", -] - [[package]] name = "regex-syntax" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rfd" version = "0.11.4" @@ -1423,58 +1096,6 @@ dependencies = [ "windows", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted", - "web-sys", - "winapi 0.3.9", -] - -[[package]] -name = "russimp" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "092eac409a1374888bb0b57089126beaa6a5ce4e620d1727074477d581a0d874" -dependencies = [ - "derivative", - "num-derive", - "num-traits", - "num_enum", - "russimp-sys", - "strum", - "strum_macros", -] - -[[package]] -name = "russimp-sys" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6cad9e6bdff17e7008cceac2d3f428c624d0aad5ef27a9ea23bdbe6455d591" -dependencies = [ - "bindgen", - "flate2", - "num_cpus", - "serde", - "serde_json", - "tar", - "ureq", - "vcpkg", -] - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-serialize" version = "0.3.24" @@ -1487,77 +1108,20 @@ version = "0.37.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.3.8", + "linux-raw-sys", "windows-sys", ] -[[package]] -name = "rustix" -version = "0.38.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys 0.4.10", - "windows-sys", -] - -[[package]] -name = "rustls" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" -dependencies = [ - "log 0.4.20", - "ring", - "rustls-webpki", - "sct", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "serde" version = "1.0.189" @@ -1575,18 +1139,7 @@ checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", -] - -[[package]] -name = "serde_json" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" -dependencies = [ - "itoa", - "ryu", - "serde", + "syn", ] [[package]] @@ -1598,12 +1151,6 @@ dependencies = [ "serde", ] -[[package]] -name = "shlex" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" - [[package]] name = "simd-adler32" version = "0.3.7" @@ -1635,12 +1182,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -1650,42 +1191,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.38", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.38" @@ -1710,41 +1215,12 @@ dependencies = [ "version-compare", ] -[[package]] -name = "tar" -version = "0.4.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" -dependencies = [ - "filetime", - "libc", - "xattr", -] - [[package]] name = "target-lexicon" version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" -[[package]] -name = "termcolor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thread-id" version = "2.0.0" @@ -1776,7 +1252,6 @@ dependencies = [ "imgui", "mint", "rfd", - "russimp", ] [[package]] @@ -1790,21 +1265,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "toml" version = "0.8.2" @@ -1814,7 +1274,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.2", + "toml_edit", ] [[package]] @@ -1826,17 +1286,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.20.2" @@ -1850,84 +1299,18 @@ dependencies = [ "winnow", ] -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "ureq" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3" -dependencies = [ - "base64", - "flate2", - "log 0.4.20", - "once_cell", - "rustls", - "rustls-webpki", - "url", - "webpki-roots", -] - -[[package]] -name = "url" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - [[package]] name = "utf8-ranges" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version-compare" version = "0.1.1" @@ -1961,7 +1344,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn", "wasm-bindgen-shared", ] @@ -1995,7 +1378,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2016,30 +1399,12 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" - [[package]] name = "weezl" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.19", -] - [[package]] name = "winapi" version = "0.2.8" @@ -2068,15 +1433,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2224,15 +1580,6 @@ dependencies = [ "memchr 2.6.4", ] -[[package]] -name = "xattr" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4686009f71ff3e5c4dbcf1a282d0a44db3f021ba69350cd42086b3e5f1c6985" -dependencies = [ - "libc", -] - [[package]] name = "zune-inflate" version = "0.2.54" diff --git a/Cargo.toml b/Cargo.toml index 4b0d6c2..17b613a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,3 @@ rfd = "0.11.3" [dependencies.imgui] version = "0.11.0" features = ["docking", "tables-api"] - -[dependencies.russimp] -version = "2.0.6" -features = ["prebuilt"] diff --git a/TODO.md b/TODO.md index c8fdf03..e909697 100644 --- a/TODO.md +++ b/TODO.md @@ -30,5 +30,6 @@ - [ ] Have the program accept model files as CLI args - [ ] Have it so that when an instance of 3dobs is open, any other file associated with 3dobs is opened in the same instance - [ ] Show how many memory each loaded model is using + - [ ] Move the invisible point lights to be around selected object from all sides so it's nicely illuminated - [ ] Bring back the regular camera movement (can maybe be a switch between them) (for later) diff --git a/src/importer/stl.rs b/src/importer/stl.rs index 6bce362..6a848ea 100644 --- a/src/importer/stl.rs +++ b/src/importer/stl.rs @@ -229,7 +229,7 @@ pub fn load_stl(mut file: std::fs::File) -> Result (glm::Vec3, glm::Vec3, glm::Vec3) { - let pos = glm::vec3(matrix.c0.w, matrix.c1.w, matrix.c2.w); - matrix.c3.x = 0.0; - matrix.c3.y = 0.0; - matrix.c3.z = 0.0; - - let scale_x = glm::length(glm::vec3(matrix.c0.x, matrix.c1.x, matrix.c2.x)); - let scale_y = glm::length(glm::vec3(matrix.c0.y, matrix.c1.y, matrix.c2.y)); - let scale_z = glm::length(glm::vec3(matrix.c0.z, matrix.c1.z, matrix.c2.z)); - let scale = glm::vec3(scale_x, scale_y, scale_z); - - let matrix = glm::mat3( - matrix[0][0] / scale_x, matrix[0][1] / scale_y, matrix[0][2] / scale_z, - matrix[1][0] / scale_x, matrix[1][1] / scale_y, matrix[1][2] / scale_z, - matrix[2][0] / scale_x, matrix[2][1] / scale_y, matrix[2][2] / scale_z, - ); - - let mut pitch = 0.0; - let mut yaw = 0.0; - let mut roll = 0.0; - - // source: https://www.geometrictools.com/Documentation/EulerAngles.pdf - if matrix[0][2] < 1.0 { - if matrix[0][2] > -1.0 { - pitch = (-matrix[1][2]).atan2(matrix[2][2]).to_degrees(); - yaw = matrix[0][2].asin().to_degrees(); - roll = (-matrix[0][1]).atan2(matrix[0][0]).to_degrees(); - } else { - pitch = -(matrix[1][0].atan2(matrix[1][1])).to_degrees(); - yaw = -(std::f32::consts::FRAC_PI_2).to_degrees(); - roll = 0.0; - } - } else { - pitch = matrix[1][0].atan2(matrix[1][1]).to_degrees(); - yaw = std::f32::consts::FRAC_PI_2.to_degrees(); - roll = 0.0; - } - - let rotation = glm::vec3(pitch, yaw, roll); - - (pos, rotation, scale) -} - fn create_rotation_matrix(pitch: f32, yaw: f32, roll: f32, pivot: glm::Vec3) -> glm::Mat4 { let pitch = pitch.to_radians(); let yaw = yaw.to_radians(); @@ -122,8 +78,6 @@ impl Mesh { gl::BindVertexArray(0); } - // let (position, rotation, scale) = decompose_mat(transformation); - Mesh { name: name.to_string(), vertices, @@ -225,26 +179,26 @@ impl Vertex { } } -#[derive(Clone, Debug)] -pub struct Texture { - pub id: u32, - pub typ: russimp::material::TextureType, - pub path: std::path::PathBuf, -} +// #[derive(Clone, Debug)] +// pub struct Texture { +// pub id: u32, +// pub typ: russimp::material::TextureType, +// pub path: std::path::PathBuf, +// } -impl Texture { - pub fn new(path: std::path::PathBuf, typ: russimp::material::TextureType) -> Result> { - let path_str = match path.to_str() { - Some(path) => path, - None => return Err("Failed to convert texture path to string".into()), - }; - let id = utils::load_texture(path_str)?; +// impl Texture { +// pub fn new(path: std::path::PathBuf, typ: russimp::material::TextureType) -> Result> { +// let path_str = match path.to_str() { +// Some(path) => path, +// None => return Err("Failed to convert texture path to string".into()), +// }; +// let id = utils::load_texture(path_str)?; - Ok(Texture { - id, - typ, - path, - }) - } -} +// Ok(Texture { +// id, +// typ, +// path, +// }) +// } +// } diff --git a/src/model.rs b/src/model.rs index a537b0b..3d5c0d9 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1,12 +1,4 @@ -use russimp; -use anyhow::{Result, anyhow}; - -use crate::{mesh::{Mesh, Vertex, Texture, apply_rotation}, shader::Shader, utils, ui::ui, log, aabb, importer}; - -const SUPPORTED_TEXTURE_TYPES: [russimp::material::TextureType; 2] = [ - russimp::material::TextureType::Diffuse, - russimp::material::TextureType::Specular, -]; +use crate::{mesh::{Mesh, apply_rotation}, shader::Shader, utils, ui::ui, aabb, importer}; const SCALING_FACTOR: f32 = 8.0; @@ -19,180 +11,7 @@ pub struct Model { pub scaling_factor: f32, } -// fn process_node<'a>( -// node: &russimp::node::Node, -// scene: &'a russimp::scene::Scene, -// meshes: &mut Vec, -// dir: &std::path::PathBuf, -// loaded_textures: &mut Vec, -// init_trans: &glm::Mat4, -// aabb: &mut aabb::AABB, -// scale: &mut f32, -// ) -> Vec> { -// let mut errors = vec![]; - -// let node_trans = glm::mat4( -// node.transformation.a1, node.transformation.a2, node.transformation.a3, node.transformation.a4, -// node.transformation.b1, node.transformation.b2, node.transformation.b3, node.transformation.b4, -// node.transformation.c1, node.transformation.c2, node.transformation.c3, node.transformation.c4, -// node.transformation.d1, node.transformation.d2, node.transformation.d3, node.transformation.d4, -// ); -// let mut new_trans = *init_trans * node_trans; - -// for i in 0..node.meshes.len() { -// let mesh = &scene.meshes[node.meshes[i] as usize]; -// let (processed_mesh, mut errs) = process_mesh(mesh, scene, dir, loaded_textures, &mut new_trans, aabb); -// errors.append(&mut errs); -// meshes.push(processed_mesh); -// } - -// for child in node.children.borrow().clone().into_iter() { -// let mut errs = process_node(&child, scene, meshes, dir, loaded_textures, &new_trans, aabb, scale); -// errors.append(&mut errs); -// } - -// let scale_factor_x = SCALING_FACTOR / (aabb.max.x - aabb.min.x); -// let scale_factor_y = SCALING_FACTOR / (aabb.max.y - aabb.min.y); -// let scale_factor_z = SCALING_FACTOR / (aabb.max.z - aabb.min.z); - -// // Use the minimum scaling factor to maintain proportions -// *scale = scale_factor_x.min(scale_factor_y).min(scale_factor_z); - -// return errors; -// } - -// fn process_mesh( -// mesh: &russimp::mesh::Mesh, -// scene: &russimp::scene::Scene, -// dir: &std::path::PathBuf, -// loaded_textures: &mut Vec, -// transformation: &mut glm::Mat4, -// aabb: &mut aabb::AABB -// ) -> (Mesh, Vec>) { -// let mut vertices = vec![]; -// let mut indices = vec![]; -// let mut textures = vec![]; - -// for i in 0..mesh.vertices.len() { -// let pos = glm::vec4(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z, 1.0); - -// let norm = match mesh.normals.len() { -// 0 => glm::vec3(0.0, 0.0, 0.0), -// _ => glm::vec3(mesh.normals[i].x, mesh.normals[i].y, mesh.normals[i].z), -// }; - -// let t = &mesh.texture_coords[0]; -// let tex_coords = match t { -// Some(tex) => { -// glm::vec2(tex[i].x, tex[i].y) -// }, -// None => glm::vec2(0.0, 0.0) -// }; - -// let vertex = Vertex::new(pos.truncate(3), norm, tex_coords); - -// if vertex.position.x < aabb.min.x { -// aabb.min.x = vertex.position.x; -// } - -// if vertex.position.y < aabb.min.y { -// aabb.min.y = vertex.position.y; -// } - -// if vertex.position.z < aabb.min.z { -// aabb.min.z = vertex.position.z; -// } - -// if vertex.position.x > aabb.max.x { -// aabb.max.x = vertex.position.x; -// } - -// if vertex.position.y > aabb.max.y { -// aabb.max.y = vertex.position.y; -// } - -// if vertex.position.z > aabb.max.z { -// aabb.max.z = vertex.position.z; -// } - -// vertices.push(vertex); -// } - -// for i in 0..mesh.faces.len() { -// for j in 0..mesh.faces[i].0.len() { -// indices.push(mesh.faces[i].0[j]); -// } -// } - -// let mat = &scene.materials[mesh.material_index as usize]; - -// let material = process_material(mat); - -// let (mut found_textures, errs) = load_material_textures(mat, dir, loaded_textures); -// textures.append(&mut found_textures); - -// let mesh = Mesh::new(mesh.name.as_str(), vertices, indices, textures, material, transformation); -// return (mesh, errs); -// } - -// fn process_material(mat: &russimp::material::Material) -> Material { -// let mat_name = String::from("Default_Mat"); -// let ambient = glm::vec3(0.2, 0.2, 0.2); -// let diffuse = glm::vec3(0.7, 0.7, 0.7); -// let specular = glm::vec3(0.1, 0.1, 0.1); -// let shininess = 32.0; - -// // TODO: better way of mapping properties -// // for property in mat.properties.iter() { -// // match property.key.as_str() { -// // "$clr.ambient" => { -// // ambient = match &property.data { -// // russimp::material::PropertyTypeInfo::FloatArray(a) => { -// // glm::vec3(a[0], a[1], a[2]) -// // }, -// // _ => panic!("Property should not be this type: {}", property.key) -// // }; -// // }, -// // "$clr.diffuse" => { -// // diffuse = match &property.data { -// // russimp::material::PropertyTypeInfo::FloatArray(a) => { -// // glm::vec3(a[0], a[1], a[2]) -// // }, -// // _ => panic!("Property should not be this type: {}", property.key) -// // }; -// // }, -// // "$clr.specular" => { -// // specular = match &property.data { -// // russimp::material::PropertyTypeInfo::FloatArray(a) => { -// // glm::vec3(a[0], a[1], a[2]) -// // }, -// // _ => panic!("Property should not be this type: {}", property.key) -// // } -// // } -// // "?mat.name" => { -// // mat_name = match &property.data { -// // russimp::material::PropertyTypeInfo::String(s) => { -// // s.to_string() -// // }, -// // _ => panic!("Property should not be this type: {}", property.key) -// // }; -// // } -// // "$mat.shininess" => { -// // shininess = match &property.data { -// // russimp::material::PropertyTypeInfo::FloatArray(a) => { -// // a[0] -// // }, -// // _ => panic!("Property should not be this type: {}", property.key) -// // }; -// // } -// // _ => {}, -// // } -// // } - -// Material::new(mat_name, ambient, diffuse, specular, shininess) -// } - -// // TODO: might nuke this cuz we don't need textures I think +// TODO: texture support, kept for reference // fn load_material_textures( // mat: &russimp::material::Material, // dir: &std::path::PathBuf, @@ -243,45 +62,15 @@ pub struct Model { impl Model { pub fn new(obj: importer::Object, state: &mut ui::State) -> Model { - // let scene = russimp::scene::Scene::from_file(path, - // vec![ - // russimp::scene::PostProcess::Triangulate, - // russimp::scene::PostProcess::GenerateNormals, - // russimp::scene::PostProcess::FlipUVs, - // ]) - // .map_err(|e| { - // let e = match e { - // russimp::RussimpError::TextureNotFound => anyhow!("Texture not found"), - // _ => anyhow!("{}", e) - // }; - // return e; - // })?; - - // let root_node = match &scene.root { - // Some(root) => root, - // None => return Err("Scene has no root node".into()), - // }; - - // if scene.flags & russimp::sys::AI_SCENE_FLAGS_INCOMPLETE == 1 { - // return Err("Scene is incomplete")?; - // } - - // let directory = match std::path::Path::new(path).parent() { - // Some(dir) => dir, - // None => return Err("Model path has no parent directory".into()), - // }.to_path_buf(); - - // let mut loaded_textures = vec![]; - // let mut meshes = vec![]; - // let init_trans_mat = utils::mat_ident(); - let mut scale: f32 = 1.0; - // let errors = process_node(&root_node, &scene, &mut meshes, &directory, &mut loaded_textures, &init_trans_mat, &mut aabb, &mut scale); - - // for err in errors { - // state.logger.history.push(log::LogMessage::new(log::LogLevel::Warning, &err.to_string())); - // } let mut meshes = Vec::new(); + let scale_factor_x = SCALING_FACTOR / (obj.aabb.max.x - obj.aabb.min.x); + let scale_factor_y = SCALING_FACTOR / (obj.aabb.max.y - obj.aabb.min.y); + let scale_factor_z = SCALING_FACTOR / (obj.aabb.max.z - obj.aabb.min.z); + + // Use the minimum scaling factor to maintain proportions + let scale = scale_factor_x.min(scale_factor_y).min(scale_factor_z); + for mesh in obj.meshes.into_iter() { meshes.push(Mesh::new(&mesh.name, mesh.vertices, mesh.indices, mesh.material)); } @@ -293,14 +82,6 @@ impl Model { scaling_factor: scale, meshes, } - // Ok(Model { - // id: state.get_next_id(), - // name: root_node.name.to_owned(), - // aabb_mesh: aabb::AABBMesh::new(&aabb), - // aabb, - // scaling_factor: scale, - // meshes, - // }) } pub fn draw(&self, shader: &Shader, draw_aabb: bool) {