From 4f56b9b6bdb4f85a58311061da9acbd5a55271ad Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jan 2024 17:42:41 -0800 Subject: [PATCH 01/24] Initial commit --- .gitignore | 1 + Cargo.lock | 559 +++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 12 ++ LICENSE-APACHE | 176 ++++++++++++++++ LICENSE-MIT | 23 ++ README.md | 19 ++ src/bsp.rs | 237 +++++++++++++++++++++ src/lib.rs | 1 + 8 files changed, 1028 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 src/bsp.rs create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..6116b27 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,559 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "approx" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278" +dependencies = [ + "num-traits", +] + +[[package]] +name = "array-init" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "binrw" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173901312e9850391d4d7c1318c4e099fdc037d61870fca427429830efdb4e5f" +dependencies = [ + "array-init", + "binrw_derive", + "bytemuck", +] + +[[package]] +name = "binrw_derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb515fdd6f8d3a357c8e19b8ec59ef53880807864329b1cb1cba5c53bf76557e" +dependencies = [ + "either", + "owo-colors", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "bsp_loader" +version = "0.1.0" +dependencies = [ + "glam", + "strafesnet_common", + "vbsp", + "vmdl", +] + +[[package]] +name = "bv" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340" +dependencies = [ + "feature-probe", +] + +[[package]] +name = "bytemuck" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "byteorder" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cgmath" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a98d30140e3296250832bbaaff83b27dcd6fa3cc70fb6f1f3e5c9c0023b5317" +dependencies = [ + "approx", + "num-traits", +] + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "feature-probe" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glam" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "indexmap" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "lzma" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "782ba3f542e8bc1349386c15e9dc3119ae6da96479f96b3863cc7a88bbdfd4e4" +dependencies = [ + "byteorder 0.5.3", +] + +[[package]] +name = "lzma-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" +dependencies = [ + "byteorder 1.5.0", + "crc", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strafesnet_common" +version = "0.1.0" +source = "git+https://git.itzana.me/StrafesNET/common?rev=434ca29aef7e3015c9ca1ed45de8fef42e33fdfb#434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" +dependencies = [ + "glam", +] + +[[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.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn_util" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6754c4559b79657554e9d8a0d56e65e490c76d382b9c23108364ec4125dea23c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "vbsp" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9267540dab0c93bb5201c40ba3b2d027e2717bf355a8f9bf25377b06a5b32f6" +dependencies = [ + "ahash", + "arrayvec", + "binrw", + "bitflags", + "bv", + "cgmath", + "itertools", + "lzma-rs", + "num_enum", + "static_assertions", + "thiserror", + "vbsp-derive", + "zip-lzma", +] + +[[package]] +name = "vbsp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ade687fadf34b1b7502387fc9eb7b4032ddc9b93022d31356e9984c957abaad" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "syn_util", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "vmdl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "892922743c4c107372331efd8f67c57282590f8c18c26b4465c4b0e1e6678664" +dependencies = [ + "arrayvec", + "bitflags", + "bytemuck", + "cgmath", + "itertools", + "static_assertions", + "thiserror", + "tracing", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winnow" +version = "0.5.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +dependencies = [ + "memchr", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "zip-lzma" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b480cb31fccfb2786565c0e0712865fd6f1ea0ea850c50316f643c3948196e63" +dependencies = [ + "byteorder 1.5.0", + "crc32fast", + "crossbeam-utils", + "lzma", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8078120 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "bsp_loader" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +glam = "0.25.0" +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" } +vbsp = "0.5.0" +vmdl = "0.1.1" diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..a7e77cb --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..468cd79 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9800e2 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +StrafesNET BSP Loader +===================== + +## Convert Valve BSP files into StrafesNET data structures + +#### License + + +Licensed under either of Apache License, Version +2.0 or MIT license at your option. + + +
+ + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. + \ No newline at end of file diff --git a/src/bsp.rs b/src/bsp.rs new file mode 100644 index 0000000..1781c48 --- /dev/null +++ b/src/bsp.rs @@ -0,0 +1,237 @@ +use strafesnet_common::{model,integer}; + +const VALVE_SCALE:f32=1.0/16.0; +fn valve_transform(v:[f32;3])->integer::Planar64Vec3{ + integer::Planar64Vec3::try_from([v[0]*VALVE_SCALE,v[2]*VALVE_SCALE,-v[1]*VALVE_SCALE]).unwrap() +} +pub fn generate_indexed_models(input:&mut R)->Result{ + let mut s=Vec::new(); + + match input.read_to_end(&mut s){ + Ok(_)=>(), + Err(e)=>println!("load_bsp::generate_indexed_models read_to_end failed: {:?}",e), + } + + match vbsp::Bsp::read(s.as_slice()){ + Ok(bsp)=>{ + let mut spawn_point=integer::Planar64Vec3::ZERO; + + let vertices: Vec<_> = bsp + .vertices + .iter() + .map(|vertex|<[f32;3]>::from(vertex.position)) + .collect(); + + let mut name_from_texture_id=Vec::new(); + let mut texture_id_from_name=std::collections::HashMap::new(); + + let mut models=bsp.models().map(|world_model|{ + //non-deduplicated + let mut spam_pos=Vec::new(); + let mut spam_tex=Vec::new(); + let mut spam_normal=Vec::new(); + let mut spam_vertices=Vec::new(); + let groups=world_model.faces() + .filter(|face| face.is_visible())//TODO: look at this + .map(|face|{ + let face_texture=face.texture(); + let face_texture_data=face_texture.texture_data(); + let (texture_u,texture_v)=(glam::Vec3A::from_slice(&face_texture.texture_transforms_u[0..3]),glam::Vec3A::from_slice(&face_texture.texture_transforms_v[0..3])); + let texture_offset=glam::vec2(face_texture.texture_transforms_u[3],face_texture.texture_transforms_v[3]); + let texture_size=glam::vec2(face_texture_data.width as f32,face_texture_data.height as f32); + + //texture + let texture_id=if let Some(&texture_id)=texture_id_from_name.get(face_texture_data.name()){ + texture_id + }else{ + let texture_id=name_from_texture_id.len() as u32; + texture_id_from_name.insert(face_texture_data.name().to_string(),texture_id); + name_from_texture_id.push(face_texture_data.name().to_string()); + texture_id + }; + + //normal + let normal=face.normal(); + let normal_idx=spam_normal.len() as u32; + spam_normal.push(valve_transform(<[f32;3]>::from(normal))); + let mut vertices:Vec=face.vertex_indexes().map(|vertex_index|{ + let pos=glam::Vec3A::from_array(vertices[vertex_index as usize]); + let pos_idx=spam_pos.len(); + spam_pos.push(valve_transform(vertices[vertex_index as usize])); + + //calculate texture coordinates + let tex=(glam::vec2(pos.dot(texture_u),pos.dot(texture_v))+texture_offset)/texture_size; + let tex_idx=spam_tex.len() as u32; + spam_tex.push(tex); + + let i=spam_vertices.len() as u32; + spam_vertices.push(model::IndexedVertex{ + pos: pos_idx as u32, + tex: tex_idx as u32, + normal: normal_idx, + color: 0, + }); + i + }).collect(); + vertices.reverse(); + model::IndexedGroup{ + texture:Some(texture_id), + polys:vec![model::IndexedPolygon{vertices}], + } + }).collect(); + model::IndexedModel{ + unique_pos:spam_pos, + unique_tex:spam_tex, + unique_normal:spam_normal, + unique_color:vec![glam::Vec4::ONE], + unique_vertices:spam_vertices, + groups, + instances:vec![model::ModelInstance{ + attributes:model::CollisionAttributes::Decoration, + transform:integer::Planar64Affine3::new( + integer::Planar64Mat3::default(), + valve_transform(<[f32;3]>::from(world_model.origin)) + ), + ..Default::default() + }], + } + }).collect(); + + //dedupe prop models + let mut model_dedupe=std::collections::HashSet::new(); + for prop in bsp.static_props(){ + model_dedupe.insert(prop.model()); + } + + //generate unique meshes + let mut model_map=std::collections::HashMap::with_capacity(model_dedupe.len()); + let mut prop_models=Vec::new(); + for model_name in model_dedupe{ + let model_name_lower=model_name.to_lowercase(); + //.mdl, .vvd, .dx90.vtx + let mut path=std::path::PathBuf::from(model_name_lower.as_str()); + let file_name=std::path::PathBuf::from(path.file_stem().unwrap()); + path.pop(); + path.push(file_name); + let mut vvd_path=path.clone(); + let mut vtx_path=path.clone(); + vvd_path.set_extension("vvd"); + vtx_path.set_extension("dx90.vtx"); + match (bsp.pack.get(model_name_lower.as_str()),bsp.pack.get(vvd_path.as_os_str().to_str().unwrap()),bsp.pack.get(vtx_path.as_os_str().to_str().unwrap())){ + (Ok(Some(mdl_file)),Ok(Some(vvd_file)),Ok(Some(vtx_file)))=>{ + match (vmdl::mdl::Mdl::read(mdl_file.as_ref()),vmdl::vvd::Vvd::read(vvd_file.as_ref()),vmdl::vtx::Vtx::read(vtx_file.as_ref())){ + (Ok(mdl),Ok(vvd),Ok(vtx))=>{ + let model=vmdl::Model::from_parts(mdl,vtx,vvd); + let texture_paths=model.texture_directories(); + if texture_paths.len()!=1{ + println!("WARNING: multiple texture paths"); + } + let skin=model.skin_tables().nth(0).unwrap(); + + let mut spam_pos=Vec::with_capacity(model.vertices().len()); + let mut spam_normal=Vec::with_capacity(model.vertices().len()); + let mut spam_tex=Vec::with_capacity(model.vertices().len()); + let mut spam_vertices=Vec::with_capacity(model.vertices().len()); + for (i,vertex) in model.vertices().iter().enumerate(){ + spam_pos.push(valve_transform(<[f32;3]>::from(vertex.position))); + spam_normal.push(valve_transform(<[f32;3]>::from(vertex.normal))); + spam_tex.push(glam::Vec2::from_array(vertex.texture_coordinates)); + spam_vertices.push(model::IndexedVertex{ + pos:i as u32, + tex:i as u32, + normal:i as u32, + color:0, + }); + } + + let model_id=prop_models.len(); + model_map.insert(model_name,model_id); + prop_models.push(model::IndexedModel{ + unique_pos:spam_pos, + unique_normal:spam_normal, + unique_tex:spam_tex, + unique_color:vec![glam::Vec4::ONE], + unique_vertices:spam_vertices, + groups:model.meshes().map(|mesh|{ + let texture=if let (Some(texture_path),Some(texture_name))=(texture_paths.get(0),skin.texture(mesh.material_index())){ + let mut path=std::path::PathBuf::from(texture_path.as_str()); + path.push(texture_name); + let texture_location=path.as_os_str().to_str().unwrap(); + let texture_id=if let Some(&texture_id)=texture_id_from_name.get(texture_location){ + texture_id + }else{ + println!("texture! {}",texture_location); + let texture_id=name_from_texture_id.len() as u32; + texture_id_from_name.insert(texture_location.to_string(),texture_id); + name_from_texture_id.push(texture_location.to_string()); + texture_id + }; + Some(texture_id) + }else{ + None + }; + + model::IndexedGroup{ + texture, + polys:{ + //looking at the code, it would seem that the strips are pre-deindexed into triangle lists when calling this function + mesh.vertex_strip_indices().map(|strip|{ + strip.collect::>().chunks(3).map(|tri|{ + model::IndexedPolygon{vertices:vec![tri[0] as u32,tri[1] as u32,tri[2] as u32]} + }).collect::>() + }).flatten().collect() + }, + } + }).collect(), + instances:Vec::new(), + }); + }, + _=>println!("model_name={} error",model_name), + } + }, + _=>println!("no model name={}",model_name), + } + } + + //generate model instances + for prop in bsp.static_props(){ + let placement=prop.as_prop_placement(); + if let Some(&model_index)=model_map.get(placement.model){ + prop_models[model_index].instances.push(model::ModelInstance{ + transform:integer::Planar64Affine3::new( + integer::Planar64Mat3::try_from( + glam::Mat3A::from_diagonal(glam::Vec3::splat(placement.scale)) + //TODO: figure this out + *glam::Mat3A::from_quat(glam::Quat::from_xyzw( + placement.rotation.v.x,//b + placement.rotation.v.y,//c + placement.rotation.v.z,//d + placement.rotation.s,//a + )) + ).unwrap(), + valve_transform(<[f32;3]>::from(placement.origin)), + ), + attributes:model::CollisionAttributes::Decoration, + ..Default::default() + }); + }else{ + //println!("model not found {}",placement.model); + } + } + + //actually add the prop models + prop_models.append(&mut models); + + Ok(model::IndexedModelInstances{ + textures:name_from_texture_id, + models:prop_models, + spawn_point, + modes:Vec::new(), + }) + }, + Err(e)=>{ + println!("rotten {:?}",e); + Err(e) + }, + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e06ee2d --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod bsp; \ No newline at end of file From 79b8120106e63de237b8ed59c3d3e30db51e7146 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jan 2024 17:46:34 -0800 Subject: [PATCH 02/24] rename package --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6116b27..2f400f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,16 +72,6 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" -[[package]] -name = "bsp_loader" -version = "0.1.0" -dependencies = [ - "glam", - "strafesnet_common", - "vbsp", - "vmdl", -] - [[package]] name = "bv" version = "0.11.1" @@ -341,6 +331,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strafesnet_bsp_loader" +version = "0.1.0" +dependencies = [ + "glam", + "strafesnet_common", + "vbsp", + "vmdl", +] + [[package]] name = "strafesnet_common" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 8078120..0346953 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bsp_loader" +name = "strafesnet_bsp_loader" version = "0.1.0" edition = "2021" From 38efed0d040bce0a19e320287060594952a7214e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 18:02:32 -0800 Subject: [PATCH 03/24] data structure rewrite + refactor loaders --- Cargo.lock | 13 +++- Cargo.toml | 2 +- src/bsp.rs | 221 +++++++++++++++++++++++++++-------------------------- src/lib.rs | 37 ++++++++- 4 files changed, 162 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f400f7..26020d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,6 +200,16 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +[[package]] +name = "id" +version = "0.1.0" +source = "git+https://git.itzana.me/Quaternions/id?rev=1f710976cc786c8853dab73d6e1cee53158deeb0#1f710976cc786c8853dab73d6e1cee53158deeb0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "indexmap" version = "2.2.1" @@ -344,9 +354,10 @@ dependencies = [ [[package]] name = "strafesnet_common" version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=434ca29aef7e3015c9ca1ed45de8fef42e33fdfb#434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" +source = "git+https://git.itzana.me/StrafesNET/common?rev=47cdea0c8a5d10a2440ca6270a975d560aa3642d#47cdea0c8a5d10a2440ca6270a975d560aa3642d" dependencies = [ "glam", + "id", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0346953..127ff5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] glam = "0.25.0" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "47cdea0c8a5d10a2440ca6270a975d560aa3642d" } vbsp = "0.5.0" vmdl = "0.1.1" diff --git a/src/bsp.rs b/src/bsp.rs index 1781c48..5a6006c 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -1,108 +1,126 @@ -use strafesnet_common::{model,integer}; +use strafesnet_common::{map,model,integer,gameplay_attributes}; const VALVE_SCALE:f32=1.0/16.0; fn valve_transform(v:[f32;3])->integer::Planar64Vec3{ integer::Planar64Vec3::try_from([v[0]*VALVE_SCALE,v[2]*VALVE_SCALE,-v[1]*VALVE_SCALE]).unwrap() } -pub fn generate_indexed_models(input:&mut R)->Result{ - let mut s=Vec::new(); +pub fn convert( + bsp:&vbsp::Bsp, + mut acquire_texture_id:AcquireTextureId, + mut acquire_mesh_id:AcquireMeshId +)->strafesnet_common::map::CompleteMap +where + AcquireTextureId:FnMut(&str)->model::TextureId, + AcquireMeshId:FnMut(&str)->model::MeshId, +{ + let mut unique_render_configs=Vec::new(); - match input.read_to_end(&mut s){ - Ok(_)=>(), - Err(e)=>println!("load_bsp::generate_indexed_models read_to_end failed: {:?}",e), + let mut unique_attributes=Vec::new(); + unique_attributes.push(gameplay_attributes::CollisionAttributes::contact_default()); + const TEMP_TOUCH_ME_ATTRIBUTE:gameplay_attributes::CollisionAttributesId=gameplay_attributes::CollisionAttributesId::new(0); + + //declare all prop models to Loader + for prop in bsp.static_props(){ + acquire_mesh_id(prop.model()); } - match vbsp::Bsp::read(s.as_slice()){ - Ok(bsp)=>{ - let mut spawn_point=integer::Planar64Vec3::ZERO; + //TODO: make the main map one single mesh with a bunch of different physics groups and graphics groups - let vertices: Vec<_> = bsp - .vertices - .iter() - .map(|vertex|<[f32;3]>::from(vertex.position)) - .collect(); + //the generated MeshIds in here will collide with the Loader Mesh Ids + //but I can't think of a good workaround other than just remapping one later. + let (meshes,models):(Vec,Vec)=bsp.models().enumerate().map(|(mesh_id,world_model)|{ + let mesh_id=model::MeshId::new(mesh_id as u32); + //non-deduplicated + let mut spam_pos=Vec::new(); + let mut spam_tex=Vec::new(); + let mut spam_normal=Vec::new(); + let mut spam_vertices=Vec::new(); + let mut graphics_groups=Vec::new(); + let mut physics_group=model::IndexedPhysicsGroup::default(); + let polygon_groups=world_model.faces().enumerate().map(|(polygon_group_id,face)|{ + let polygon_group_id=model::PolygonGroupId::new(polygon_group_id as u32); + let face_texture=face.texture(); + let face_texture_data=face_texture.texture_data(); + let (texture_u,texture_v)=(glam::Vec3A::from_slice(&face_texture.texture_transforms_u[0..3]),glam::Vec3A::from_slice(&face_texture.texture_transforms_v[0..3])); + let texture_offset=glam::vec2(face_texture.texture_transforms_u[3],face_texture.texture_transforms_v[3]); + let texture_size=glam::vec2(face_texture_data.width as f32,face_texture_data.height as f32); - let mut name_from_texture_id=Vec::new(); - let mut texture_id_from_name=std::collections::HashMap::new(); + //texture + let texture_id=acquire_texture_id(face_texture_data.name()); //this is equivalent to a get_or_create pattern because there is a singular no-texture RenderId + //so RenderId==TextureId + //not the most failsafe code but this is just for the map tool lmao + if unique_render_configs.len()==texture_id.get() as usize{ + unique_render_configs.push(model::RenderConfig::texture(texture_id)); + }; + let render_id=model::RenderConfigId::new(texture_id.get()); - let mut models=bsp.models().map(|world_model|{ - //non-deduplicated - let mut spam_pos=Vec::new(); - let mut spam_tex=Vec::new(); - let mut spam_normal=Vec::new(); - let mut spam_vertices=Vec::new(); - let groups=world_model.faces() - .filter(|face| face.is_visible())//TODO: look at this - .map(|face|{ - let face_texture=face.texture(); - let face_texture_data=face_texture.texture_data(); - let (texture_u,texture_v)=(glam::Vec3A::from_slice(&face_texture.texture_transforms_u[0..3]),glam::Vec3A::from_slice(&face_texture.texture_transforms_v[0..3])); - let texture_offset=glam::vec2(face_texture.texture_transforms_u[3],face_texture.texture_transforms_v[3]); - let texture_size=glam::vec2(face_texture_data.width as f32,face_texture_data.height as f32); + //normal + let normal=face.normal(); + let normal_idx=spam_normal.len() as u32; + spam_normal.push(valve_transform(<[f32;3]>::from(normal))); + let mut indices:Vec=face.vertex_positions().map(|vertex_position|{ + let vertex_xyz=<[f32;3]>::from(vertex_position); + let pos=glam::Vec3A::from_array(vertex_xyz); + let pos_idx=spam_pos.len(); + spam_pos.push(valve_transform(vertex_xyz)); - //texture - let texture_id=if let Some(&texture_id)=texture_id_from_name.get(face_texture_data.name()){ - texture_id - }else{ - let texture_id=name_from_texture_id.len() as u32; - texture_id_from_name.insert(face_texture_data.name().to_string(),texture_id); - name_from_texture_id.push(face_texture_data.name().to_string()); - texture_id - }; + //calculate texture coordinates + let tex=(glam::vec2(pos.dot(texture_u),pos.dot(texture_v))+texture_offset)/texture_size; + let tex_idx=spam_tex.len() as u32; + spam_tex.push(tex); - //normal - let normal=face.normal(); - let normal_idx=spam_normal.len() as u32; - spam_normal.push(valve_transform(<[f32;3]>::from(normal))); - let mut vertices:Vec=face.vertex_indexes().map(|vertex_index|{ - let pos=glam::Vec3A::from_array(vertices[vertex_index as usize]); - let pos_idx=spam_pos.len(); - spam_pos.push(valve_transform(vertices[vertex_index as usize])); - - //calculate texture coordinates - let tex=(glam::vec2(pos.dot(texture_u),pos.dot(texture_v))+texture_offset)/texture_size; - let tex_idx=spam_tex.len() as u32; - spam_tex.push(tex); - - let i=spam_vertices.len() as u32; - spam_vertices.push(model::IndexedVertex{ - pos: pos_idx as u32, - tex: tex_idx as u32, - normal: normal_idx, - color: 0, - }); - i - }).collect(); - vertices.reverse(); - model::IndexedGroup{ - texture:Some(texture_id), - polys:vec![model::IndexedPolygon{vertices}], - } - }).collect(); - model::IndexedModel{ - unique_pos:spam_pos, - unique_tex:spam_tex, - unique_normal:spam_normal, - unique_color:vec![glam::Vec4::ONE], - unique_vertices:spam_vertices, - groups, - instances:vec![model::ModelInstance{ - attributes:model::CollisionAttributes::Decoration, - transform:integer::Planar64Affine3::new( - integer::Planar64Mat3::default(), - valve_transform(<[f32;3]>::from(world_model.origin)) - ), - ..Default::default() - }], - } + let vertex_id=model::VertexId::new(spam_vertices.len() as u32); + spam_vertices.push(model::IndexedVertex{ + pos:model::PositionId::new(pos_idx as u32), + tex:model::TextureCoordinateId::new(tex_idx as u32), + normal:model::NormalId::new(normal_idx), + color:model::ColorId::new(0), + }); + vertex_id }).collect(); - - //dedupe prop models - let mut model_dedupe=std::collections::HashSet::new(); - for prop in bsp.static_props(){ - model_dedupe.insert(prop.model()); + if face.is_visible(){ + graphics_groups.push(model::IndexedGraphicsGroup{ + render:render_id, + groups:vec![polygon_group_id], + }) } + physics_group.groups.push(polygon_group_id); + model::PolygonGroup::PolygonList(model::PolygonList::new(vec![indices])) + }).collect(); + ( + model::Mesh{ + unique_pos:spam_pos, + unique_tex:spam_tex, + unique_normal:spam_normal, + unique_color:vec![glam::Vec4::ONE], + unique_vertices:spam_vertices, + polygon_groups, + graphics_groups, + physics_groups:vec![physics_group], + }, + model::Model{ + mesh:mesh_id, + attributes:TEMP_TOUCH_ME_ATTRIBUTE, + transform:integer::Planar64Affine3::new( + integer::Planar64Mat3::default(), + valve_transform(<[f32;3]>::from(world_model.origin)) + ), + color:glam::Vec4::ONE, + }, + ) + }).unzip(); + map::CompleteMap{ + attributes:unique_attributes, + meshes, + render_configs:unique_render_configs, + models, + modes:strafesnet_common::gameplay_modes::Modes::new(Vec::new()), + } +} + +/* + //call self.acquire_texture_id for each texture in the mesh //generate unique meshes let mut model_map=std::collections::HashMap::with_capacity(model_dedupe.len()); let mut prop_models=Vec::new(); @@ -137,16 +155,16 @@ pub fn generate_indexed_models(input:&mut R)->Res spam_normal.push(valve_transform(<[f32;3]>::from(vertex.normal))); spam_tex.push(glam::Vec2::from_array(vertex.texture_coordinates)); spam_vertices.push(model::IndexedVertex{ - pos:i as u32, - tex:i as u32, - normal:i as u32, - color:0, + pos:model::PositionId::new(i as u32), + tex:model::TextureCoordinateId::new(i as u32), + normal:model::NormalId::new(i as u32), + color:model::ColorId::new(0), }); } let model_id=prop_models.len(); model_map.insert(model_name,model_id); - prop_models.push(model::IndexedModel{ + prop_models.push(model::Mesh{ unique_pos:spam_pos, unique_normal:spam_normal, unique_tex:spam_tex, @@ -221,17 +239,4 @@ pub fn generate_indexed_models(input:&mut R)->Res //actually add the prop models prop_models.append(&mut models); - - Ok(model::IndexedModelInstances{ - textures:name_from_texture_id, - models:prop_models, - spawn_point, - modes:Vec::new(), - }) - }, - Err(e)=>{ - println!("rotten {:?}",e); - Err(e) - }, - } -} +*/ diff --git a/src/lib.rs b/src/lib.rs index e06ee2d..f683f49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,36 @@ -pub mod bsp; \ No newline at end of file +mod bsp; + +pub struct Bsp(vbsp::Bsp); + +#[derive(Debug)] +pub enum ReadError{ + Bsp(vbsp::BspError), + Io(std::io::Error), +} +impl std::fmt::Display for ReadError{ + fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ + write!(f,"{self:?}") + } +} +impl std::error::Error for ReadError{} + +pub fn read(mut input:R)->Result{ + let mut s=Vec::new(); + + //TODO: mmap + input.read_to_end(&mut s).map_err(ReadError::Io)?; + + vbsp::Bsp::read(s.as_slice()).map(Bsp).map_err(ReadError::Bsp) +} + +pub fn convert( + bsp:&Bsp, + acquire_texture_id:AcquireTextureId, + acquire_mesh_id:AcquireMeshId +)->strafesnet_common::map::CompleteMap +where + AcquireTextureId:FnMut(&str)->strafesnet_common::model::TextureId, + AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId, +{ + bsp::convert(&bsp.0,acquire_texture_id,acquire_mesh_id) +} \ No newline at end of file From 32a28880db373024c93ae7a4c57a5f9ea2f32749 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 14 Feb 2024 00:42:20 -0800 Subject: [PATCH 04/24] does not need to be mutable --- src/bsp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bsp.rs b/src/bsp.rs index 5a6006c..d829743 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -58,7 +58,7 @@ where let normal=face.normal(); let normal_idx=spam_normal.len() as u32; spam_normal.push(valve_transform(<[f32;3]>::from(normal))); - let mut indices:Vec=face.vertex_positions().map(|vertex_position|{ + let indices:Vec=face.vertex_positions().map(|vertex_position|{ let vertex_xyz=<[f32;3]>::from(vertex_position); let pos=glam::Vec3A::from_array(vertex_xyz); let pos_idx=spam_pos.len(); From b8283d921f077151a7c5463551bf673681d9d262 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 14 Feb 2024 00:42:30 -0800 Subject: [PATCH 05/24] todo --- src/bsp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bsp.rs b/src/bsp.rs index d829743..7111c74 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -79,6 +79,7 @@ where vertex_id }).collect(); if face.is_visible(){ + //TODO: deduplicate graphics groups by render id graphics_groups.push(model::IndexedGraphicsGroup{ render:render_id, groups:vec![polygon_group_id], From 45b2af405bd171f4c7227668eac7eb1a1a0d4ea9 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 14 Feb 2024 17:11:41 -0800 Subject: [PATCH 06/24] new loading api --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/bsp.rs | 342 +++++++++++++++++++++++++++++++--------------------- src/data.rs | 60 +++++++++ src/lib.rs | 15 +-- 5 files changed, 272 insertions(+), 149 deletions(-) create mode 100644 src/data.rs diff --git a/Cargo.lock b/Cargo.lock index 26020d0..279d009 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,7 +354,7 @@ dependencies = [ [[package]] name = "strafesnet_common" version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=47cdea0c8a5d10a2440ca6270a975d560aa3642d#47cdea0c8a5d10a2440ca6270a975d560aa3642d" +source = "git+https://git.itzana.me/StrafesNET/common?rev=093a54c527134ef7020a22a0f5778df8cba60228#093a54c527134ef7020a22a0f5778df8cba60228" dependencies = [ "glam", "id", diff --git a/Cargo.toml b/Cargo.toml index 127ff5e..f25a566 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] glam = "0.25.0" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "47cdea0c8a5d10a2440ca6270a975d560aa3642d" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "093a54c527134ef7020a22a0f5778df8cba60228" } vbsp = "0.5.0" vmdl = "0.1.1" diff --git a/src/bsp.rs b/src/bsp.rs index 7111c74..b657217 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -4,31 +4,55 @@ const VALVE_SCALE:f32=1.0/16.0; fn valve_transform(v:[f32;3])->integer::Planar64Vec3{ integer::Planar64Vec3::try_from([v[0]*VALVE_SCALE,v[2]*VALVE_SCALE,-v[1]*VALVE_SCALE]).unwrap() } -pub fn convert( +pub fn convert_bsp( bsp:&vbsp::Bsp, - mut acquire_texture_id:AcquireTextureId, + acquire_render_config_id:&mut AcquireRenderConfigId, mut acquire_mesh_id:AcquireMeshId -)->strafesnet_common::map::CompleteMap +)->PartialMap1 where - AcquireTextureId:FnMut(&str)->model::TextureId, + AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId, AcquireMeshId:FnMut(&str)->model::MeshId, { - let mut unique_render_configs=Vec::new(); - + //figure out real attributes later let mut unique_attributes=Vec::new(); unique_attributes.push(gameplay_attributes::CollisionAttributes::contact_default()); const TEMP_TOUCH_ME_ATTRIBUTE:gameplay_attributes::CollisionAttributesId=gameplay_attributes::CollisionAttributesId::new(0); + let mut prop_mesh_count=0; //declare all prop models to Loader - for prop in bsp.static_props(){ - acquire_mesh_id(prop.model()); - } + let prop_models=bsp.static_props().map(|prop|{ + //get or create mesh_id + let mesh_id=acquire_mesh_id(prop.model()); + //not the most failsafe code but this is just for the map tool lmao + if prop_mesh_count==mesh_id.get(){ + prop_mesh_count+=1; + }; + let placement=prop.as_prop_placement(); + model::Model{ + mesh:mesh_id, + attributes:TEMP_TOUCH_ME_ATTRIBUTE, + transform:integer::Planar64Affine3::new( + integer::Planar64Mat3::try_from( + glam::Mat3A::from_diagonal(glam::Vec3::splat(placement.scale)) + //TODO: figure this out + *glam::Mat3A::from_quat(glam::Quat::from_xyzw( + placement.rotation.v.x,//b + placement.rotation.v.y,//c + placement.rotation.v.z,//d + placement.rotation.s,//a + )) + ).unwrap(), + valve_transform(<[f32;3]>::from(placement.origin)), + ), + color:glam::Vec4::ONE, + } + }).collect(); //TODO: make the main map one single mesh with a bunch of different physics groups and graphics groups //the generated MeshIds in here will collide with the Loader Mesh Ids //but I can't think of a good workaround other than just remapping one later. - let (meshes,models):(Vec,Vec)=bsp.models().enumerate().map(|(mesh_id,world_model)|{ + let (world_meshes,world_models):(Vec,Vec)=bsp.models().enumerate().map(|(mesh_id,world_model)|{ let mesh_id=model::MeshId::new(mesh_id as u32); //non-deduplicated let mut spam_pos=Vec::new(); @@ -45,14 +69,9 @@ where let texture_offset=glam::vec2(face_texture.texture_transforms_u[3],face_texture.texture_transforms_v[3]); let texture_size=glam::vec2(face_texture_data.width as f32,face_texture_data.height as f32); - //texture - let texture_id=acquire_texture_id(face_texture_data.name()); //this is equivalent to a get_or_create pattern because there is a singular no-texture RenderId - //so RenderId==TextureId - //not the most failsafe code but this is just for the map tool lmao - if unique_render_configs.len()==texture_id.get() as usize{ - unique_render_configs.push(model::RenderConfig::texture(texture_id)); - }; - let render_id=model::RenderConfigId::new(texture_id.get()); + //this automatically figures out what the texture is trying to do and creates + //a render config for it, and then returns the id to that render config + let render_id=acquire_render_config_id(Some(face_texture_data.name())); //normal let normal=face.normal(); @@ -111,133 +130,176 @@ where ) }).unzip(); - map::CompleteMap{ + PartialMap1{ attributes:unique_attributes, - meshes, - render_configs:unique_render_configs, - models, + world_meshes, + prop_models, + world_models, modes:strafesnet_common::gameplay_modes::Modes::new(Vec::new()), } } -/* - //call self.acquire_texture_id for each texture in the mesh - //generate unique meshes - let mut model_map=std::collections::HashMap::with_capacity(model_dedupe.len()); - let mut prop_models=Vec::new(); - for model_name in model_dedupe{ - let model_name_lower=model_name.to_lowercase(); - //.mdl, .vvd, .dx90.vtx - let mut path=std::path::PathBuf::from(model_name_lower.as_str()); - let file_name=std::path::PathBuf::from(path.file_stem().unwrap()); - path.pop(); - path.push(file_name); - let mut vvd_path=path.clone(); - let mut vtx_path=path.clone(); - vvd_path.set_extension("vvd"); - vtx_path.set_extension("dx90.vtx"); - match (bsp.pack.get(model_name_lower.as_str()),bsp.pack.get(vvd_path.as_os_str().to_str().unwrap()),bsp.pack.get(vtx_path.as_os_str().to_str().unwrap())){ - (Ok(Some(mdl_file)),Ok(Some(vvd_file)),Ok(Some(vtx_file)))=>{ - match (vmdl::mdl::Mdl::read(mdl_file.as_ref()),vmdl::vvd::Vvd::read(vvd_file.as_ref()),vmdl::vtx::Vtx::read(vtx_file.as_ref())){ - (Ok(mdl),Ok(vvd),Ok(vtx))=>{ - let model=vmdl::Model::from_parts(mdl,vtx,vvd); - let texture_paths=model.texture_directories(); - if texture_paths.len()!=1{ - println!("WARNING: multiple texture paths"); - } - let skin=model.skin_tables().nth(0).unwrap(); - - let mut spam_pos=Vec::with_capacity(model.vertices().len()); - let mut spam_normal=Vec::with_capacity(model.vertices().len()); - let mut spam_tex=Vec::with_capacity(model.vertices().len()); - let mut spam_vertices=Vec::with_capacity(model.vertices().len()); - for (i,vertex) in model.vertices().iter().enumerate(){ - spam_pos.push(valve_transform(<[f32;3]>::from(vertex.position))); - spam_normal.push(valve_transform(<[f32;3]>::from(vertex.normal))); - spam_tex.push(glam::Vec2::from_array(vertex.texture_coordinates)); - spam_vertices.push(model::IndexedVertex{ - pos:model::PositionId::new(i as u32), - tex:model::TextureCoordinateId::new(i as u32), - normal:model::NormalId::new(i as u32), - color:model::ColorId::new(0), - }); - } - - let model_id=prop_models.len(); - model_map.insert(model_name,model_id); - prop_models.push(model::Mesh{ - unique_pos:spam_pos, - unique_normal:spam_normal, - unique_tex:spam_tex, - unique_color:vec![glam::Vec4::ONE], - unique_vertices:spam_vertices, - groups:model.meshes().map(|mesh|{ - let texture=if let (Some(texture_path),Some(texture_name))=(texture_paths.get(0),skin.texture(mesh.material_index())){ - let mut path=std::path::PathBuf::from(texture_path.as_str()); - path.push(texture_name); - let texture_location=path.as_os_str().to_str().unwrap(); - let texture_id=if let Some(&texture_id)=texture_id_from_name.get(texture_location){ - texture_id - }else{ - println!("texture! {}",texture_location); - let texture_id=name_from_texture_id.len() as u32; - texture_id_from_name.insert(texture_location.to_string(),texture_id); - name_from_texture_id.push(texture_location.to_string()); - texture_id - }; - Some(texture_id) - }else{ - None - }; - - model::IndexedGroup{ - texture, - polys:{ - //looking at the code, it would seem that the strips are pre-deindexed into triangle lists when calling this function - mesh.vertex_strip_indices().map(|strip|{ - strip.collect::>().chunks(3).map(|tri|{ - model::IndexedPolygon{vertices:vec![tri[0] as u32,tri[1] as u32,tri[2] as u32]} - }).collect::>() - }).flatten().collect() - }, - } - }).collect(), - instances:Vec::new(), - }); - }, - _=>println!("model_name={} error",model_name), - } - }, - _=>println!("no model name={}",model_name), +//partially constructed map types +pub struct PartialMap1{ + attributes:Vec, + prop_models:Vec, + world_meshes:Vec, + world_models:Vec, + modes:strafesnet_common::gameplay_modes::Modes, +} +impl PartialMap1{ + pub fn add_prop_meshes( + self, + prop_meshes:impl IntoIterator, + acquire_render_config_id:&mut AcquireRenderConfigId, + )->PartialMap2 + where + AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId, + { + PartialMap2{ + attributes:self.attributes, + prop_meshes:prop_meshes.into_iter().filter_map(|(mesh_id,model_data)| + //this will generate new render ids and texture ids + match convert_mesh(model_data,acquire_render_config_id){ + Ok(mesh)=>Some((mesh_id,mesh)), + Err(e)=>{ + println!("error converting mesh: {e}"); + None + } } - } + ).collect(), + prop_models:self.prop_models, + world_meshes:self.world_meshes, + world_models:self.world_models, + modes:self.modes, + } + } +} +pub struct PartialMap2{ + attributes:Vec, + prop_meshes:Vec<(model::MeshId,model::Mesh)>, + prop_models:Vec, + world_meshes:Vec, + world_models:Vec, + modes:strafesnet_common::gameplay_modes::Modes, +} +impl PartialMap2{ + pub fn add_render_configs_and_textures( + mut self, + render_configs:impl IntoIterator, + textures:impl IntoIterator)>, + )->map::CompleteMap{ + //merge mesh and model lists, flatten and remap all ids + let mesh_id_offset=self.world_meshes.len(); + println!("prop_meshes.len()={}",self.prop_meshes.len()); + let (mut prop_meshes,prop_mesh_id_map):(Vec,std::collections::HashMap) + =self.prop_meshes.into_iter().enumerate().map(|(new_mesh_id,(old_mesh_id,mesh))|{ + (mesh,(old_mesh_id,model::MeshId::new((mesh_id_offset+new_mesh_id) as u32))) + }).unzip(); + self.world_meshes.append(&mut prop_meshes); + //there is no modes or runtime behaviour with references to the model ids currently + //so just relentlessly cull them if the mesh is missing + self.world_models.extend(self.prop_models.into_iter().filter_map(|mut model| + prop_mesh_id_map.get(&model.mesh).map(|&new_mesh_id|{ + model.mesh=new_mesh_id; + model + }) + )); + //let mut models=Vec::new(); + let (textures,texture_id_map):(Vec>,std::collections::HashMap) + =textures.into_iter() + //.filter_map(f) cull unused textures + .enumerate().map(|(new_texture_id,(old_texture_id,texture))|{ + (texture,(old_texture_id,model::TextureId::new(new_texture_id as u32))) + }).unzip(); + let render_configs=render_configs.into_iter().map(|(render_config_id,mut render_config)|{ + //this may generate duplicate no-texture render configs but idc + render_config.texture=render_config.texture.and_then(|texture_id| + texture_id_map.get(&texture_id).copied() + ); + render_config + }).collect(); + map::CompleteMap{ + modes:self.modes, + attributes:self.attributes, + meshes:self.world_meshes, + models:self.world_models, + textures, + render_configs, + } + } +} - //generate model instances - for prop in bsp.static_props(){ - let placement=prop.as_prop_placement(); - if let Some(&model_index)=model_map.get(placement.model){ - prop_models[model_index].instances.push(model::ModelInstance{ - transform:integer::Planar64Affine3::new( - integer::Planar64Mat3::try_from( - glam::Mat3A::from_diagonal(glam::Vec3::splat(placement.scale)) - //TODO: figure this out - *glam::Mat3A::from_quat(glam::Quat::from_xyzw( - placement.rotation.v.x,//b - placement.rotation.v.y,//c - placement.rotation.v.z,//d - placement.rotation.s,//a - )) - ).unwrap(), - valve_transform(<[f32;3]>::from(placement.origin)), - ), - attributes:model::CollisionAttributes::Decoration, - ..Default::default() - }); - }else{ - //println!("model not found {}",placement.model); - } - } +fn convert_mesh( + model_data:crate::data::ModelData, + acquire_render_config_id:&mut AcquireRenderConfigId, +)->Result +where + AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId, +{ + let model=model_data.read_model()?; + let texture_paths=model.texture_directories(); + if texture_paths.len()!=1{ + println!("WARNING: multiple texture paths"); + } + let skin=model.skin_tables().nth(0).unwrap(); - //actually add the prop models - prop_models.append(&mut models); -*/ + let mut spam_pos=Vec::with_capacity(model.vertices().len()); + let mut spam_normal=Vec::with_capacity(model.vertices().len()); + let mut spam_tex=Vec::with_capacity(model.vertices().len()); + let mut spam_vertices=Vec::with_capacity(model.vertices().len()); + for (i,vertex) in model.vertices().iter().enumerate(){ + spam_pos.push(valve_transform(<[f32;3]>::from(vertex.position))); + spam_normal.push(valve_transform(<[f32;3]>::from(vertex.normal))); + spam_tex.push(glam::Vec2::from_array(vertex.texture_coordinates)); + spam_vertices.push(model::IndexedVertex{ + pos:model::PositionId::new(i as u32), + tex:model::TextureCoordinateId::new(i as u32), + normal:model::NormalId::new(i as u32), + color:model::ColorId::new(0), + }); + } + let mut graphics_groups=Vec::new(); + let mut physics_groups=Vec::new(); + let polygon_groups=model.meshes().enumerate().map(|(polygon_group_id,mesh)|{ + let polygon_group_id=model::PolygonGroupId::new(polygon_group_id as u32); + + let render_id=if let (Some(texture_path),Some(texture_name))=(texture_paths.get(0),skin.texture(mesh.material_index())){ + let mut path=std::path::PathBuf::from(texture_path.as_str()); + path.push(texture_name); + acquire_render_config_id(path.as_os_str().to_str()) + }else{ + acquire_render_config_id(None) + }; + + graphics_groups.push(model::IndexedGraphicsGroup{ + render:render_id, + groups:vec![polygon_group_id], + }); + physics_groups.push(model::IndexedPhysicsGroup{ + groups:vec![polygon_group_id], + }); + model::PolygonGroup::PolygonList(model::PolygonList::new( + //looking at the code, it would seem that the strips are pre-deindexed into triangle lists when calling this function + mesh.vertex_strip_indices().flat_map(|mut strip| + std::iter::from_fn(move||{ + match (strip.next(),strip.next(),strip.next()){ + (Some(v1),Some(v2),Some(v3))=>Some([v1,v2,v3].map(|vertex_id|model::VertexId::new(vertex_id as u32)).to_vec()), + //ignore extra vertices, not sure what to do in this case, failing the whole conversion could be appropriate + _=>None, + } + }) + ).collect() + )) + }).collect(); + Ok(model::Mesh{ + unique_pos:spam_pos, + unique_normal:spam_normal, + unique_tex:spam_tex, + unique_color:vec![glam::Vec4::ONE], + unique_vertices:spam_vertices, + polygon_groups, + graphics_groups, + physics_groups, + }) +} diff --git a/src/data.rs b/src/data.rs new file mode 100644 index 0000000..83ca678 --- /dev/null +++ b/src/data.rs @@ -0,0 +1,60 @@ +pub struct Bsp(vbsp::Bsp); +impl Bsp{ + pub const fn new(value:vbsp::Bsp)->Self{ + Self(value) + } +} +impl AsRef for Bsp{ + fn as_ref(&self)->&vbsp::Bsp{ + &self.0 + } +} + +pub struct MdlData(Vec); +impl MdlData{ + pub const fn new(value:Vec)->Self{ + Self(value) + } +} +impl AsRef<[u8]> for MdlData{ + fn as_ref(&self)->&[u8]{ + self.0.as_ref() + } +} +pub struct VtxData(Vec); +impl VtxData{ + pub const fn new(value:Vec)->Self{ + Self(value) + } +} +impl AsRef<[u8]> for VtxData{ + fn as_ref(&self)->&[u8]{ + self.0.as_ref() + } +} +pub struct VvdData(Vec); +impl VvdData{ + pub const fn new(value:Vec)->Self{ + Self(value) + } +} +impl AsRef<[u8]> for VvdData{ + fn as_ref(&self)->&[u8]{ + self.0.as_ref() + } +} + +pub struct ModelData{ + pub mdl:MdlData, + pub vtx:VtxData, + pub vvd:VvdData, +} +impl ModelData{ + pub fn read_model(&self)->Result{ + Ok(vmdl::Model::from_parts( + vmdl::mdl::Mdl::read(self.mdl.as_ref())?, + vmdl::vtx::Vtx::read(self.vtx.as_ref())?, + vmdl::vvd::Vvd::read(self.vvd.as_ref())?, + )) + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index f683f49..81978ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ mod bsp; +pub mod data; -pub struct Bsp(vbsp::Bsp); +pub use data::Bsp; #[derive(Debug)] pub enum ReadError{ @@ -20,17 +21,17 @@ pub fn read(mut input:R)->Result{ //TODO: mmap input.read_to_end(&mut s).map_err(ReadError::Io)?; - vbsp::Bsp::read(s.as_slice()).map(Bsp).map_err(ReadError::Bsp) + vbsp::Bsp::read(s.as_slice()).map(Bsp::new).map_err(ReadError::Bsp) } -pub fn convert( +pub fn convert( bsp:&Bsp, - acquire_texture_id:AcquireTextureId, + acquire_render_config_id:&mut AcquireRenderConfigId, acquire_mesh_id:AcquireMeshId -)->strafesnet_common::map::CompleteMap +)->bsp::PartialMap1 where - AcquireTextureId:FnMut(&str)->strafesnet_common::model::TextureId, + AcquireRenderConfigId:FnMut(Option<&str>)->strafesnet_common::model::RenderConfigId, AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId, { - bsp::convert(&bsp.0,acquire_texture_id,acquire_mesh_id) + bsp::convert_bsp(bsp.as_ref(),acquire_render_config_id,acquire_mesh_id) } \ No newline at end of file From f91de2d66972713d3c78a264fd688f6f4c117651 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 15 Feb 2024 01:41:26 -0800 Subject: [PATCH 07/24] mutable reference external api is unnecessary --- src/bsp.rs | 6 +++--- src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bsp.rs b/src/bsp.rs index b657217..deb51ef 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -6,7 +6,7 @@ fn valve_transform(v:[f32;3])->integer::Planar64Vec3{ } pub fn convert_bsp( bsp:&vbsp::Bsp, - acquire_render_config_id:&mut AcquireRenderConfigId, + mut acquire_render_config_id:AcquireRenderConfigId, mut acquire_mesh_id:AcquireMeshId )->PartialMap1 where @@ -151,7 +151,7 @@ impl PartialMap1{ pub fn add_prop_meshes( self, prop_meshes:impl IntoIterator, - acquire_render_config_id:&mut AcquireRenderConfigId, + mut acquire_render_config_id:AcquireRenderConfigId, )->PartialMap2 where AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId, @@ -160,7 +160,7 @@ impl PartialMap1{ attributes:self.attributes, prop_meshes:prop_meshes.into_iter().filter_map(|(mesh_id,model_data)| //this will generate new render ids and texture ids - match convert_mesh(model_data,acquire_render_config_id){ + match convert_mesh(model_data,&mut acquire_render_config_id){ Ok(mesh)=>Some((mesh_id,mesh)), Err(e)=>{ println!("error converting mesh: {e}"); diff --git a/src/lib.rs b/src/lib.rs index 81978ee..e8d4d91 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ pub fn read(mut input:R)->Result{ pub fn convert( bsp:&Bsp, - acquire_render_config_id:&mut AcquireRenderConfigId, + acquire_render_config_id:AcquireRenderConfigId, acquire_mesh_id:AcquireMeshId )->bsp::PartialMap1 where From 3cab9afa32da59ff196de0ae78de3d35ff1f0021 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 17 Feb 2024 19:33:00 -0800 Subject: [PATCH 08/24] indices is already a polygon list --- src/bsp.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bsp.rs b/src/bsp.rs index deb51ef..5df6131 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -77,7 +77,7 @@ where let normal=face.normal(); let normal_idx=spam_normal.len() as u32; spam_normal.push(valve_transform(<[f32;3]>::from(normal))); - let indices:Vec=face.vertex_positions().map(|vertex_position|{ + let mut polygon_iter=face.vertex_positions().map(|vertex_position|{ let vertex_xyz=<[f32;3]>::from(vertex_position); let pos=glam::Vec3A::from_array(vertex_xyz); let pos_idx=spam_pos.len(); @@ -96,6 +96,13 @@ where color:model::ColorId::new(0), }); vertex_id + }); + let polygon_list=std::iter::from_fn(move||{ + match (polygon_iter.next(),polygon_iter.next(),polygon_iter.next()){ + (Some(v1),Some(v2),Some(v3))=>Some(vec![v1,v2,v3]), + //ignore extra vertices, not sure what to do in this case, failing the whole conversion could be appropriate + _=>None, + } }).collect(); if face.is_visible(){ //TODO: deduplicate graphics groups by render id @@ -105,7 +112,7 @@ where }) } physics_group.groups.push(polygon_group_id); - model::PolygonGroup::PolygonList(model::PolygonList::new(vec![indices])) + model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list)) }).collect(); ( model::Mesh{ From c0a85cd71919ea3a6d7570d2f80ed155cc4872ee Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 17 Feb 2024 20:31:02 -0800 Subject: [PATCH 09/24] improve texture transform math --- src/bsp.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bsp.rs b/src/bsp.rs index 5df6131..4987acf 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -65,9 +65,9 @@ where let polygon_group_id=model::PolygonGroupId::new(polygon_group_id as u32); let face_texture=face.texture(); let face_texture_data=face_texture.texture_data(); - let (texture_u,texture_v)=(glam::Vec3A::from_slice(&face_texture.texture_transforms_u[0..3]),glam::Vec3A::from_slice(&face_texture.texture_transforms_v[0..3])); - let texture_offset=glam::vec2(face_texture.texture_transforms_u[3],face_texture.texture_transforms_v[3]); - let texture_size=glam::vec2(face_texture_data.width as f32,face_texture_data.height as f32); + //this would be better as a 4x2 matrix + let texture_transform_u=glam::Vec4::from_array(face_texture.texture_transforms_u)/(face_texture_data.width as f32); + let texture_transform_v=glam::Vec4::from_array(face_texture.texture_transforms_v)/(face_texture_data.height as f32); //this automatically figures out what the texture is trying to do and creates //a render config for it, and then returns the id to that render config @@ -79,12 +79,12 @@ where spam_normal.push(valve_transform(<[f32;3]>::from(normal))); let mut polygon_iter=face.vertex_positions().map(|vertex_position|{ let vertex_xyz=<[f32;3]>::from(vertex_position); - let pos=glam::Vec3A::from_array(vertex_xyz); let pos_idx=spam_pos.len(); spam_pos.push(valve_transform(vertex_xyz)); //calculate texture coordinates - let tex=(glam::vec2(pos.dot(texture_u),pos.dot(texture_v))+texture_offset)/texture_size; + let pos=glam::Vec3::from_array(vertex_xyz).extend(1.0); + let tex=glam::vec2(texture_transform_u.dot(pos),texture_transform_v.dot(pos)); let tex_idx=spam_tex.len() as u32; spam_tex.push(tex); From b73da3e552dea9f88ed1a6a06a30bf08bab682fe Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 21 Feb 2024 09:15:05 -0800 Subject: [PATCH 10/24] make use of into --- src/bsp.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/bsp.rs b/src/bsp.rs index 4987acf..93b63d5 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -35,14 +35,9 @@ where integer::Planar64Mat3::try_from( glam::Mat3A::from_diagonal(glam::Vec3::splat(placement.scale)) //TODO: figure this out - *glam::Mat3A::from_quat(glam::Quat::from_xyzw( - placement.rotation.v.x,//b - placement.rotation.v.y,//c - placement.rotation.v.z,//d - placement.rotation.s,//a - )) + *glam::Mat3A::from_quat(glam::Quat::from_array(placement.rotation.into())) ).unwrap(), - valve_transform(<[f32;3]>::from(placement.origin)), + valve_transform(placement.origin.into()), ), color:glam::Vec4::ONE, } @@ -76,9 +71,9 @@ where //normal let normal=face.normal(); let normal_idx=spam_normal.len() as u32; - spam_normal.push(valve_transform(<[f32;3]>::from(normal))); + spam_normal.push(valve_transform(normal.into())); let mut polygon_iter=face.vertex_positions().map(|vertex_position|{ - let vertex_xyz=<[f32;3]>::from(vertex_position); + let vertex_xyz=vertex_position.into(); let pos_idx=spam_pos.len(); spam_pos.push(valve_transform(vertex_xyz)); @@ -130,7 +125,7 @@ where attributes:TEMP_TOUCH_ME_ATTRIBUTE, transform:integer::Planar64Affine3::new( integer::Planar64Mat3::default(), - valve_transform(<[f32;3]>::from(world_model.origin)) + valve_transform(world_model.origin.into()) ), color:glam::Vec4::ONE, }, @@ -256,8 +251,8 @@ where let mut spam_tex=Vec::with_capacity(model.vertices().len()); let mut spam_vertices=Vec::with_capacity(model.vertices().len()); for (i,vertex) in model.vertices().iter().enumerate(){ - spam_pos.push(valve_transform(<[f32;3]>::from(vertex.position))); - spam_normal.push(valve_transform(<[f32;3]>::from(vertex.normal))); + spam_pos.push(valve_transform(vertex.position.into())); + spam_normal.push(valve_transform(vertex.normal.into())); spam_tex.push(glam::Vec2::from_array(vertex.texture_coordinates)); spam_vertices.push(model::IndexedVertex{ pos:model::PositionId::new(i as u32), From 0a50ee3cbd3c66df6376832f4fa90ad437bef5f5 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 15 Feb 2024 01:03:10 -0800 Subject: [PATCH 11/24] disable physics --- src/bsp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bsp.rs b/src/bsp.rs index 93b63d5..9c83d51 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -15,7 +15,7 @@ where { //figure out real attributes later let mut unique_attributes=Vec::new(); - unique_attributes.push(gameplay_attributes::CollisionAttributes::contact_default()); + unique_attributes.push(gameplay_attributes::CollisionAttributes::Decoration); const TEMP_TOUCH_ME_ATTRIBUTE:gameplay_attributes::CollisionAttributesId=gameplay_attributes::CollisionAttributesId::new(0); let mut prop_mesh_count=0; From 4f166e0d5cac1f29a2120a593510c72984f553a2 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 2 Mar 2024 05:00:43 -0800 Subject: [PATCH 12/24] update common --- Cargo.lock | 63 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 279d009..e50faaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" dependencies = [ "cfg-if", "getrandom", @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" dependencies = [ "bytemuck_derive", ] @@ -98,7 +98,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -146,9 +146,9 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -161,9 +161,9 @@ checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "equivalent" @@ -207,14 +207,14 @@ source = "git+https://git.itzana.me/Quaternions/id?rev=1f710976cc786c8853dab73d6 dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "indexmap" -version = "2.2.1" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "lzma" @@ -262,9 +262,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -287,7 +287,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -354,8 +354,9 @@ dependencies = [ [[package]] name = "strafesnet_common" version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=093a54c527134ef7020a22a0f5778df8cba60228#093a54c527134ef7020a22a0f5778df8cba60228" +source = "git+https://git.itzana.me/StrafesNET/common?rev=9aec0e1b5247e0e9c5c99d34e4fefba94f8af11a#9aec0e1b5247e0e9c5c99d34e4fefba94f8af11a" dependencies = [ + "bitflags", "glam", "id", ] @@ -373,9 +374,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -395,22 +396,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -421,9 +422,9 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", @@ -449,7 +450,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] @@ -530,9 +531,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winnow" -version = "0.5.35" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -554,7 +555,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f25a566..efd01c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] glam = "0.25.0" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "093a54c527134ef7020a22a0f5778df8cba60228" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "ef922135e6d19f296d8e4d90df0d0d71fa3412e2" } vbsp = "0.5.0" vmdl = "0.1.1" From a051f442df2479a3677640e01845bb690a0c6f43 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 2 Mar 2024 05:11:01 -0800 Subject: [PATCH 13/24] use entities & brushes instead of models --- src/bsp.rs | 74 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/src/bsp.rs b/src/bsp.rs index 9c83d51..0d215fe 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -47,8 +47,7 @@ where //the generated MeshIds in here will collide with the Loader Mesh Ids //but I can't think of a good workaround other than just remapping one later. - let (world_meshes,world_models):(Vec,Vec)=bsp.models().enumerate().map(|(mesh_id,world_model)|{ - let mesh_id=model::MeshId::new(mesh_id as u32); + let world_meshes:Vec=bsp.models().map(|world_model|{ //non-deduplicated let mut spam_pos=Vec::new(); let mut spam_tex=Vec::new(); @@ -73,7 +72,8 @@ where let normal_idx=spam_normal.len() as u32; spam_normal.push(valve_transform(normal.into())); let mut polygon_iter=face.vertex_positions().map(|vertex_position|{ - let vertex_xyz=vertex_position.into(); + //world_model.origin seems to always be 0,0,0 + let vertex_xyz=(world_model.origin+vertex_position).into(); let pos_idx=spam_pos.len(); spam_pos.push(valve_transform(vertex_xyz)); @@ -109,28 +109,54 @@ where physics_group.groups.push(polygon_group_id); model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list)) }).collect(); - ( - model::Mesh{ - unique_pos:spam_pos, - unique_tex:spam_tex, - unique_normal:spam_normal, - unique_color:vec![glam::Vec4::ONE], - unique_vertices:spam_vertices, - polygon_groups, - graphics_groups, - physics_groups:vec![physics_group], - }, - model::Model{ - mesh:mesh_id, - attributes:TEMP_TOUCH_ME_ATTRIBUTE, - transform:integer::Planar64Affine3::new( - integer::Planar64Mat3::default(), - valve_transform(world_model.origin.into()) - ), - color:glam::Vec4::ONE, - }, + model::Mesh{ + unique_pos:spam_pos, + unique_tex:spam_tex, + unique_normal:spam_normal, + unique_color:vec![glam::Vec4::ONE], + unique_vertices:spam_vertices, + polygon_groups, + graphics_groups, + physics_groups:vec![physics_group], + } + }).collect(); + + let world_models:Vec= + //one instance of the main world mesh + std::iter::once(( + //world_model + model::MeshId::new(0), + //model_origin + vbsp::Vector::from([0.0,0.0,0.0]), + //model_color + [255.0,255.0,255.0] + )).chain( + //entities sprinkle instances of the other meshes around + bsp.entities.iter() + .flat_map(|ent|ent.parse())//ignore entity parsing errors + .filter_map(|ent|match ent{ + vbsp::Entity::Brush(brush)=>Some(brush), + vbsp::Entity::BrushIllusionary(brush)=>Some(brush), + vbsp::Entity::BrushWall(brush)=>Some(brush), + vbsp::Entity::BrushWallToggle(brush)=>Some(brush), + _=>None, + }).flat_map(|brush| + //The first character of brush.model is '*' + brush.model[1..].parse().map(|mesh_id|//ignore parse int errors + (model::MeshId::new(mesh_id),brush.origin,brush.color) + ) ) - }).unzip(); + ).map(|(mesh_id,model_origin,model_color)|{ + model::Model{ + mesh:mesh_id, + attributes:TEMP_TOUCH_ME_ATTRIBUTE, + transform:integer::Planar64Affine3::new( + integer::Planar64Mat3::default(), + valve_transform(model_origin.into()) + ), + color:(glam::Vec3::from_array(model_color)/255.0).extend(1.0), + } + }).collect(); PartialMap1{ attributes:unique_attributes, From e2473f0537d32d1ac20cef908e8a47bee931944b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 12 Mar 2024 22:00:40 -0700 Subject: [PATCH 14/24] update common --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e50faaf..3950a20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,7 +354,7 @@ dependencies = [ [[package]] name = "strafesnet_common" version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=9aec0e1b5247e0e9c5c99d34e4fefba94f8af11a#9aec0e1b5247e0e9c5c99d34e4fefba94f8af11a" +source = "git+https://git.itzana.me/StrafesNET/common?rev=a9f3e61f2bb1074025b6cb466a5e3f2abc988c34#a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" dependencies = [ "bitflags", "glam", diff --git a/Cargo.toml b/Cargo.toml index efd01c7..d573a1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] glam = "0.25.0" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "ef922135e6d19f296d8e4d90df0d0d71fa3412e2" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" } vbsp = "0.5.0" vmdl = "0.1.1" From e391e9bc27d4b53e763b8a7d11bcae6d9e79e057 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 29 Mar 2024 01:26:09 -0700 Subject: [PATCH 15/24] use strafesnet registry --- .cargo/config.toml | 2 ++ Cargo.lock | 10 ++++++---- Cargo.toml | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..8b662bc --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[registries.strafesnet] +index = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 3950a20..6ffc777 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,7 +203,8 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "id" version = "0.1.0" -source = "git+https://git.itzana.me/Quaternions/id?rev=1f710976cc786c8853dab73d6e1cee53158deeb0#1f710976cc786c8853dab73d6e1cee53158deeb0" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a" dependencies = [ "proc-macro2", "quote", @@ -343,7 +344,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_bsp_loader" -version = "0.1.0" +version = "0.1.1" dependencies = [ "glam", "strafesnet_common", @@ -353,8 +354,9 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=a9f3e61f2bb1074025b6cb466a5e3f2abc988c34#a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" +version = "0.1.2" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "0704e795010e6ca97f3d3dd6c24e76bf2d23f91186e1807ad4c7cb84ba6b8239" dependencies = [ "bitflags", "glam", diff --git a/Cargo.toml b/Cargo.toml index d573a1f..2d21cfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,16 @@ [package] name = "strafesnet_bsp_loader" -version = "0.1.0" +version = "0.1.1" edition = "2021" +repository = "https://git.itzana.me/StrafesNET/bsp_loader" +license = "MIT OR Apache-2.0" +description = "Convert Valve BSP files to StrafesNET data structures." +authors = ["Rhys Lloyd "] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] glam = "0.25.0" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" } +strafesnet_common = { version = "0.1.2", registry = "strafesnet" } vbsp = "0.5.0" vmdl = "0.1.1" From db992afec5244d56c01ad93f74363517fca46a9d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 22 Jul 2024 13:44:15 -0700 Subject: [PATCH 16/24] update deps --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 6 +-- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ffc777..b9ee357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -38,9 +38,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "binrw" @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bv" @@ -83,22 +83,22 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.0.1" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" dependencies = [ "crc-catalog", ] @@ -146,24 +146,24 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "either" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "equivalent" @@ -179,9 +179,9 @@ checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -190,15 +190,15 @@ dependencies = [ [[package]] name = "glam" -version = "0.25.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" +checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "id" @@ -208,14 +208,14 @@ checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -232,9 +232,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lzma" @@ -257,15 +257,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -288,7 +288,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -305,9 +305,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "proc-macro-crate" @@ -320,18 +320,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -344,7 +344,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_bsp_loader" -version = "0.1.1" +version = "0.1.2" dependencies = [ "glam", "strafesnet_common", @@ -354,9 +354,9 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.1.2" +version = "0.1.3" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "0704e795010e6ca97f3d3dd6c24e76bf2d23f91186e1807ad4c7cb84ba6b8239" +checksum = "10a7e3b69506893bbdde90ce8a9d75cd56d280c0424d2dfdf98f8520179d0c1b" dependencies = [ "bitflags", "glam", @@ -376,9 +376,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -398,29 +398,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" @@ -452,7 +452,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -542,22 +542,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2d21cfb..9d3c6b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_bsp_loader" -version = "0.1.1" +version = "0.1.2" edition = "2021" repository = "https://git.itzana.me/StrafesNET/bsp_loader" license = "MIT OR Apache-2.0" @@ -10,7 +10,7 @@ authors = ["Rhys Lloyd "] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -glam = "0.25.0" -strafesnet_common = { version = "0.1.2", registry = "strafesnet" } +glam = "0.28.0" +strafesnet_common = { version = "0.1.3", registry = "strafesnet" } vbsp = "0.5.0" vmdl = "0.1.1" From 31725dae0c8be63e6a12c5cc864295626e774b27 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 29 Jul 2024 16:29:28 -0700 Subject: [PATCH 17/24] update deps --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b9ee357..de2d85b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,18 +272,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -344,7 +344,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_bsp_loader" -version = "0.1.2" +version = "0.1.3" dependencies = [ "glam", "strafesnet_common", @@ -354,9 +354,9 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.1.3" +version = "0.2.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "10a7e3b69506893bbdde90ce8a9d75cd56d280c0424d2dfdf98f8520179d0c1b" +checksum = "74580c59a09194ce39db49cd814a5c2fc2d61513c88c6b811b5b40c0da6de057" dependencies = [ "bitflags", "glam", @@ -418,9 +418,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" [[package]] name = "toml_edit" @@ -505,9 +505,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vmdl" diff --git a/Cargo.toml b/Cargo.toml index 9d3c6b5..8e396d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_bsp_loader" -version = "0.1.2" +version = "0.1.3" edition = "2021" repository = "https://git.itzana.me/StrafesNET/bsp_loader" license = "MIT OR Apache-2.0" @@ -11,6 +11,6 @@ authors = ["Rhys Lloyd "] [dependencies] glam = "0.28.0" -strafesnet_common = { version = "0.1.3", registry = "strafesnet" } +strafesnet_common = { version = "0.2.0", registry = "strafesnet" } vbsp = "0.5.0" vmdl = "0.1.1" From e1897acca3bc796381b609a70aa2c0e653c190a7 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 7 Aug 2024 18:41:42 -0700 Subject: [PATCH 18/24] update deps --- Cargo.lock | 19 ++++++++++--------- Cargo.toml | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de2d85b..5d32940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.16.1" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" dependencies = [ "bytemuck_derive", ] @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", @@ -344,7 +344,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_bsp_loader" -version = "0.1.3" +version = "0.1.4" dependencies = [ "glam", "strafesnet_common", @@ -354,10 +354,11 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.2.0" +version = "0.3.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "74580c59a09194ce39db49cd814a5c2fc2d61513c88c6b811b5b40c0da6de057" +checksum = "1077d45a0b064964906a57de765a5a2bfe47b41f2f807d13b18c70765e76d3dd" dependencies = [ + "arrayvec", "bitflags", "glam", "id", @@ -418,9 +419,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" diff --git a/Cargo.toml b/Cargo.toml index 8e396d3..eef365c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_bsp_loader" -version = "0.1.3" +version = "0.1.4" edition = "2021" repository = "https://git.itzana.me/StrafesNET/bsp_loader" license = "MIT OR Apache-2.0" @@ -11,6 +11,6 @@ authors = ["Rhys Lloyd "] [dependencies] glam = "0.28.0" -strafesnet_common = { version = "0.2.0", registry = "strafesnet" } +strafesnet_common = { version = "0.3.0", registry = "strafesnet" } vbsp = "0.5.0" vmdl = "0.1.1" From cddf8b6f84d6fe481852825f259fe60e3e4659a3 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 9 Aug 2024 14:37:13 -0700 Subject: [PATCH 19/24] update common --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d32940..db36c8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,9 +354,9 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.3.0" +version = "0.4.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "1077d45a0b064964906a57de765a5a2bfe47b41f2f807d13b18c70765e76d3dd" +checksum = "ea4126f6fbf9aecf89c9e319290f0221d177dcaa8659b4b9e3d82acc37829f12" dependencies = [ "arrayvec", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index eef365c..1d7c266 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,6 @@ authors = ["Rhys Lloyd "] [dependencies] glam = "0.28.0" -strafesnet_common = { version = "0.3.0", registry = "strafesnet" } +strafesnet_common = { version = "0.4.0", registry = "strafesnet" } vbsp = "0.5.0" vmdl = "0.1.1" From 2a0afdcc6012b7b399d3121370603b44e372512e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 9 Aug 2024 14:37:31 -0700 Subject: [PATCH 20/24] v0.1.5 update common --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db36c8e..65bb804 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -344,7 +344,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_bsp_loader" -version = "0.1.4" +version = "0.1.5" dependencies = [ "glam", "strafesnet_common", diff --git a/Cargo.toml b/Cargo.toml index 1d7c266..67149ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_bsp_loader" -version = "0.1.4" +version = "0.1.5" edition = "2021" repository = "https://git.itzana.me/StrafesNET/bsp_loader" license = "MIT OR Apache-2.0" From 4f13a1e69d71f3ade2901d35a46523cb939b482d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 17 Sep 2024 18:02:37 -0700 Subject: [PATCH 21/24] update deps --- Cargo.lock | 265 ++++++++++++++++++++++++++++++++++++++++++++++------- Cargo.toml | 4 +- 2 files changed, 232 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65bb804..104a471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,6 +15,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + [[package]] name = "approx" version = "0.4.0" @@ -32,9 +41,9 @@ checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" @@ -43,10 +52,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] -name = "binrw" -version = "0.13.3" +name = "beef" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173901312e9850391d4d7c1318c4e099fdc037d61870fca427429830efdb4e5f" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + +[[package]] +name = "binrw" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f36b7cb3ab9ff6a2858650d8dc360e783a5d14dc29594db48c56a3c233cc265" dependencies = [ "array-init", "binrw_derive", @@ -55,9 +70,9 @@ dependencies = [ [[package]] name = "binrw_derive" -version = "0.13.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb515fdd6f8d3a357c8e19b8ec59ef53880807864329b1cb1cba5c53bf76557e" +checksum = "20ea7a8c5c8eeffffac6d54d172444e15beffac6f817fac714460a9a9aa88da3" dependencies = [ "either", "owo-colors", @@ -83,9 +98,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.16.3" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" dependencies = [ "bytemuck_derive", ] @@ -159,6 +174,12 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "either" version = "1.13.0" @@ -177,6 +198,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "getrandom" version = "0.2.15" @@ -194,6 +221,16 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -223,19 +260,58 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "logos" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1ceb190eb9bdeecdd8f1ad6a71d6d632a50905948771718741b5461fb01e13" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-codegen" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90be66cb7bd40cb5cc2e9cfaf2d1133b04a3d93b72344267715010a466e0915a" +dependencies = [ + "beef", + "fnv", + "lazy_static", + "proc-macro2", + "quote", + "regex-syntax", + "syn 2.0.72", +] + +[[package]] +name = "logos-derive" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45154231e8e96586b39494029e58f12f8ffcb5ecf80333a603a13aa205ea8cbd" +dependencies = [ + "logos-codegen", +] + [[package]] name = "lzma" version = "0.2.2" @@ -261,6 +337,29 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "miette" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +dependencies = [ + "cfg-if", + "miette-derive", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -303,6 +402,31 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "parse-display" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914a1c2265c98e2446911282c6ac86d8524f495792c38c5bd884f80499c7538a" +dependencies = [ + "parse-display-derive", + "regex", + "regex-syntax", +] + +[[package]] +name = "parse-display-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ae7800a4c974efd12df917266338e79a7a74415173caf7e70aa0a0707345281" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "regex-syntax", + "structmeta", + "syn 2.0.72", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -336,6 +460,55 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -364,6 +537,29 @@ dependencies = [ "id", ] +[[package]] +name = "structmeta" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e1575d8d40908d70f6fd05537266b90ae71b15dbbe7a8b7dffa2b759306d329" +dependencies = [ + "proc-macro2", + "quote", + "structmeta-derive", + "syn 2.0.72", +] + +[[package]] +name = "structmeta-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "syn" version = "1.0.109" @@ -386,17 +582,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "syn_util" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6754c4559b79657554e9d8a0d56e65e490c76d382b9c23108364ec4125dea23c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "thiserror" version = "1.0.63" @@ -472,10 +657,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "vbsp" -version = "0.5.0" +name = "unicode-width" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9267540dab0c93bb5201c40ba3b2d027e2717bf355a8f9bf25377b06a5b32f6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "vbsp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14a5685e0bb386aac9b9c6046a05152a46a0bc58d53afb3fbe577f1a1c2bb05" dependencies = [ "ahash", "arrayvec", @@ -486,22 +677,24 @@ dependencies = [ "itertools", "lzma-rs", "num_enum", + "serde", "static_assertions", "thiserror", - "vbsp-derive", + "vdf-reader", "zip-lzma", ] [[package]] -name = "vbsp-derive" -version = "0.1.0" +name = "vdf-reader" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ade687fadf34b1b7502387fc9eb7b4032ddc9b93022d31356e9984c957abaad" +checksum = "543945fdc3d51b20e3e0f5fd845ddeca4a270e56522035cf152105bc144ffd65" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "syn_util", + "logos", + "miette", + "parse-display", + "serde", + "thiserror", ] [[package]] @@ -512,15 +705,17 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vmdl" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "892922743c4c107372331efd8f67c57282590f8c18c26b4465c4b0e1e6678664" +checksum = "da2f6b8c22da8937403a5da864e7ea390f30cd40b7a077079e40279aa6a4f553" dependencies = [ "arrayvec", "bitflags", "bytemuck", "cgmath", + "half", "itertools", + "num_enum", "static_assertions", "thiserror", "tracing", diff --git a/Cargo.toml b/Cargo.toml index 67149ad..22c074a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ authors = ["Rhys Lloyd "] [dependencies] glam = "0.28.0" strafesnet_common = { version = "0.4.0", registry = "strafesnet" } -vbsp = "0.5.0" -vmdl = "0.1.1" +vbsp = "0.6.0" +vmdl = "0.2.0" From fe5caa7ad38294c1bccd42a998effc1cd9d29241 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 16:25:22 -0700 Subject: [PATCH 22/24] update deps --- Cargo.lock | 171 +++++++++++++++++++++++++++++++++++------------------ Cargo.toml | 4 +- src/bsp.rs | 18 +++--- 3 files changed, 123 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 104a471..f872d74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,9 +47,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "beef" @@ -87,6 +87,12 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "bnum" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50202def95bf36cb7d1d7a7962cea1c36a3f8ad42425e5d2b71d7acb8041b5b8" + [[package]] name = "bv" version = "0.11.1" @@ -107,13 +113,13 @@ dependencies = [ [[package]] name = "bytemuck_derive" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" +checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -198,6 +204,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" +[[package]] +name = "fixed_wide" +version = "0.1.1" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "d9c2cf115b3785ede870fada07e8b1aeba3378345b4ca86fe3c772ecabc05c0f" +dependencies = [ + "arrayvec", + "bnum", + "paste", + "ratio_ops", +] + [[package]] name = "fnv" version = "1.0.7" @@ -217,9 +235,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" +checksum = "c28091a37a5d09b555cb6628fd954da299b536433834f5b8e59eba78e0cbbf8a" [[package]] name = "half" @@ -233,9 +251,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "id" @@ -245,14 +263,14 @@ checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "indexmap" -version = "2.3.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown", @@ -275,24 +293,35 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + +[[package]] +name = "linear_ops" +version = "0.1.0" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "b2e6977ac24f47086d8a7a2d4ae1c720e86dfdc8407cf5e34c18bfa01053c456" +dependencies = [ + "fixed_wide", + "paste", + "ratio_ops", +] [[package]] name = "logos" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1ceb190eb9bdeecdd8f1ad6a71d6d632a50905948771718741b5461fb01e13" +checksum = "1c6b6e02facda28ca5fb8dbe4b152496ba3b1bd5a4b40bb2b1b2d8ad74e0f39b" dependencies = [ "logos-derive", ] [[package]] name = "logos-codegen" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90be66cb7bd40cb5cc2e9cfaf2d1133b04a3d93b72344267715010a466e0915a" +checksum = "b32eb6b5f26efacd015b000bfc562186472cd9b34bdba3f6b264e2a052676d10" dependencies = [ "beef", "fnv", @@ -300,14 +329,14 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "logos-derive" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45154231e8e96586b39494029e58f12f8ffcb5ecf80333a603a13aa205ea8cbd" +checksum = "3e5d0c5463c911ef55624739fc353238b4e310f0144be1f875dc42fec6bfd5ec" dependencies = [ "logos-codegen", ] @@ -357,7 +386,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -387,14 +416,17 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "owo-colors" @@ -424,9 +456,15 @@ dependencies = [ "regex", "regex-syntax", "structmeta", - "syn 2.0.72", + "syn 2.0.79", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -434,10 +472,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] -name = "proc-macro-crate" -version = "3.1.0" +name = "portable-atomic" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] @@ -453,18 +497,24 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] +[[package]] +name = "ratio_ops" +version = "0.1.0" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "01239195d6afe0509e7e3511b716c0540251dfe7ece0a9a5a27116afb766c42c" + [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -474,9 +524,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -485,9 +535,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "serde" @@ -506,7 +556,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -527,14 +577,17 @@ dependencies = [ [[package]] name = "strafesnet_common" -version = "0.4.0" +version = "0.5.2" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "ea4126f6fbf9aecf89c9e319290f0221d177dcaa8659b4b9e3d82acc37829f12" +checksum = "91cc1f3699bd8248da18bf5d11273264396a257b5d47b8558acb2cb4e1761219" dependencies = [ "arrayvec", "bitflags", + "fixed_wide", "glam", "id", + "linear_ops", + "ratio_ops", ] [[package]] @@ -546,7 +599,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -557,7 +610,7 @@ checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -573,9 +626,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -584,22 +637,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -610,9 +663,9 @@ checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", @@ -638,7 +691,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -652,15 +705,15 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "vbsp" @@ -729,9 +782,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winnow" -version = "0.5.40" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -753,7 +806,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 22c074a..76374bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Rhys Lloyd "] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -glam = "0.28.0" -strafesnet_common = { version = "0.4.0", registry = "strafesnet" } +glam = "0.29.0" +strafesnet_common = { version = "0.5.2", registry = "strafesnet" } vbsp = "0.6.0" vmdl = "0.2.0" diff --git a/src/bsp.rs b/src/bsp.rs index 0d215fe..def11ee 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -1,8 +1,8 @@ use strafesnet_common::{map,model,integer,gameplay_attributes}; const VALVE_SCALE:f32=1.0/16.0; -fn valve_transform(v:[f32;3])->integer::Planar64Vec3{ - integer::Planar64Vec3::try_from([v[0]*VALVE_SCALE,v[2]*VALVE_SCALE,-v[1]*VALVE_SCALE]).unwrap() +fn valve_transform([x,y,z]:[f32;3])->integer::Planar64Vec3{ + integer::vec3::try_from_f32_array([x*VALVE_SCALE,z*VALVE_SCALE,-y*VALVE_SCALE]).unwrap() } pub fn convert_bsp( bsp:&vbsp::Bsp, @@ -32,11 +32,11 @@ where mesh:mesh_id, attributes:TEMP_TOUCH_ME_ATTRIBUTE, transform:integer::Planar64Affine3::new( - integer::Planar64Mat3::try_from( + integer::mat3::try_from_f32_array_2d(( glam::Mat3A::from_diagonal(glam::Vec3::splat(placement.scale)) //TODO: figure this out *glam::Mat3A::from_quat(glam::Quat::from_array(placement.rotation.into())) - ).unwrap(), + ).to_cols_array_2d()).unwrap(), valve_transform(placement.origin.into()), ), color:glam::Vec4::ONE, @@ -120,7 +120,7 @@ where physics_groups:vec![physics_group], } }).collect(); - + let world_models:Vec= //one instance of the main world mesh std::iter::once(( @@ -129,7 +129,7 @@ where //model_origin vbsp::Vector::from([0.0,0.0,0.0]), //model_color - [255.0,255.0,255.0] + vbsp::Color{r:255,g:255,b:255}, )).chain( //entities sprinkle instances of the other meshes around bsp.entities.iter() @@ -146,15 +146,15 @@ where (model::MeshId::new(mesh_id),brush.origin,brush.color) ) ) - ).map(|(mesh_id,model_origin,model_color)|{ + ).map(|(mesh_id,model_origin,vbsp::Color{r,g,b})|{ model::Model{ mesh:mesh_id, attributes:TEMP_TOUCH_ME_ATTRIBUTE, transform:integer::Planar64Affine3::new( - integer::Planar64Mat3::default(), + integer::mat3::identity(), valve_transform(model_origin.into()) ), - color:(glam::Vec3::from_array(model_color)/255.0).extend(1.0), + color:(glam::Vec3::from_array([r as f32,g as f32,b as f32])/255.0).extend(1.0), } }).collect(); From c2b04a046c133a038e2bf786c919e5668998c555 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 17:09:30 -0700 Subject: [PATCH 23/24] v0.2.2 update deps --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f872d74..403d681 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,7 +567,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_bsp_loader" -version = "0.1.5" +version = "0.2.2" dependencies = [ "glam", "strafesnet_common", diff --git a/Cargo.toml b/Cargo.toml index 76374bd..62aaaf7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_bsp_loader" -version = "0.1.5" +version = "0.2.2" edition = "2021" repository = "https://git.itzana.me/StrafesNET/bsp_loader" license = "MIT OR Apache-2.0" From 031ffb3e5015d845d8592da9637e501b42c888fd Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 2 Jan 2025 19:46:45 -0800 Subject: [PATCH 24/24] bsp_loader: move into folder --- .gitignore => lib/bsp_loader/.gitignore | 0 Cargo.lock => lib/bsp_loader/Cargo.lock | 0 Cargo.toml => lib/bsp_loader/Cargo.toml | 0 LICENSE-APACHE => lib/bsp_loader/LICENSE-APACHE | 0 LICENSE-MIT => lib/bsp_loader/LICENSE-MIT | 0 README.md => lib/bsp_loader/README.md | 0 {src => lib/bsp_loader/src}/bsp.rs | 0 {src => lib/bsp_loader/src}/data.rs | 0 {src => lib/bsp_loader/src}/lib.rs | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => lib/bsp_loader/.gitignore (100%) rename Cargo.lock => lib/bsp_loader/Cargo.lock (100%) rename Cargo.toml => lib/bsp_loader/Cargo.toml (100%) rename LICENSE-APACHE => lib/bsp_loader/LICENSE-APACHE (100%) rename LICENSE-MIT => lib/bsp_loader/LICENSE-MIT (100%) rename README.md => lib/bsp_loader/README.md (100%) rename {src => lib/bsp_loader/src}/bsp.rs (100%) rename {src => lib/bsp_loader/src}/data.rs (100%) rename {src => lib/bsp_loader/src}/lib.rs (100%) diff --git a/.gitignore b/lib/bsp_loader/.gitignore similarity index 100% rename from .gitignore rename to lib/bsp_loader/.gitignore diff --git a/Cargo.lock b/lib/bsp_loader/Cargo.lock similarity index 100% rename from Cargo.lock rename to lib/bsp_loader/Cargo.lock diff --git a/Cargo.toml b/lib/bsp_loader/Cargo.toml similarity index 100% rename from Cargo.toml rename to lib/bsp_loader/Cargo.toml diff --git a/LICENSE-APACHE b/lib/bsp_loader/LICENSE-APACHE similarity index 100% rename from LICENSE-APACHE rename to lib/bsp_loader/LICENSE-APACHE diff --git a/LICENSE-MIT b/lib/bsp_loader/LICENSE-MIT similarity index 100% rename from LICENSE-MIT rename to lib/bsp_loader/LICENSE-MIT diff --git a/README.md b/lib/bsp_loader/README.md similarity index 100% rename from README.md rename to lib/bsp_loader/README.md diff --git a/src/bsp.rs b/lib/bsp_loader/src/bsp.rs similarity index 100% rename from src/bsp.rs rename to lib/bsp_loader/src/bsp.rs diff --git a/src/data.rs b/lib/bsp_loader/src/data.rs similarity index 100% rename from src/data.rs rename to lib/bsp_loader/src/data.rs diff --git a/src/lib.rs b/lib/bsp_loader/src/lib.rs similarity index 100% rename from src/lib.rs rename to lib/bsp_loader/src/lib.rs