From 2496f181e300b3db4cd2bb3d9d915ede3cef7ffe Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jan 2024 17:41:16 -0800 Subject: [PATCH 01/49] Initial commit --- .gitignore | 1 + Cargo.lock | 478 ++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 15 ++ LICENSE-APACHE | 176 ++++++++++++++++ LICENSE-MIT | 23 ++ README.md | 19 ++ src/lib.rs | 2 + src/primitives.rs | 493 +++++++++++++++++++++++++++++++++++++++++++ src/rbx.rs | 524 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 1731 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/lib.rs create mode 100644 src/primitives.rs create mode 100644 src/rbx.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..e7f31ab --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,478 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[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 = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "blake3" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[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 = "lazy-regex" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] + +[[package]] +name = "lazy-regex-proc_macros" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "lz4" +version = "1.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" +dependencies = [ + "libc", + "lz4-sys", +] + +[[package]] +name = "lz4-sys" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +dependencies = [ + "cc", + "libc", +] + +[[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 = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[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 = "profiling" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0f7f43585c34e4fdd7497d746bc32e14458cf11c69341cc0587b1d825dde42" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce97fecd27bc49296e5e20518b5a1bb54a14f7d5fe6228bc9686ee2a74915cc8" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rbx_binary" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6314dd6bf5c21d0598cdb53cf5d241aa643ba41da8b8abf7402b4a35096f03f6" +dependencies = [ + "log", + "lz4", + "profiling", + "rbx_dom_weak", + "rbx_reflection", + "rbx_reflection_database", + "thiserror", +] + +[[package]] +name = "rbx_dom_weak" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b67b56bac99849c2e3c57547b036927f71c57cf7f4d900d04e3e4ee774ec316" +dependencies = [ + "rbx_types", + "serde", +] + +[[package]] +name = "rbx_loader" +version = "0.1.0" +dependencies = [ + "glam", + "lazy-regex", + "rbx_binary", + "rbx_dom_weak", + "rbx_reflection_database", + "rbx_xml", + "strafesnet_common", +] + +[[package]] +name = "rbx_reflection" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d41509c991b53a7276a746a795eae2b9204f398164920f61976995b47fe1722" +dependencies = [ + "rbx_types", + "serde", + "thiserror", +] + +[[package]] +name = "rbx_reflection_database" +version = "0.2.10+roblox-607" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e20c06fa41f7aadc79005c8354f592b2c2f4d0c61e1080ed5718dafc30aea0" +dependencies = [ + "lazy_static", + "rbx_reflection", + "rmp-serde", + "serde", +] + +[[package]] +name = "rbx_types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ca23bfd469d067d81ef14f65fe09aeddc25abcf576a889d1a7664fe021cf18c" +dependencies = [ + "base64", + "bitflags", + "blake3", + "lazy_static", + "rand", + "serde", + "thiserror", +] + +[[package]] +name = "rbx_xml" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c03f95500961c32340791d1fabd4587f6873bdbff077ecca6ae32db7960dea" +dependencies = [ + "base64", + "log", + "rbx_dom_weak", + "rbx_reflection", + "rbx_reflection_database", + "xml-rs", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rmp" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "serde" +version = "1.0.196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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 = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[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", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "xml-rs" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c419ba1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "rbx_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" +lazy-regex = "3.1.0" +rbx_binary = "0.7.4" +rbx_dom_weak = "2.7.0" +rbx_reflection_database = "0.2.10" +rbx_xml = "0.13.3" +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" } 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..ad62509 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +StrafesNET Roblox Loader +======================== + +## Convert Roblox 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/lib.rs b/src/lib.rs new file mode 100644 index 0000000..57a6919 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,2 @@ +mod primitives; +pub mod rbx; \ No newline at end of file diff --git a/src/primitives.rs b/src/primitives.rs new file mode 100644 index 0000000..3c98259 --- /dev/null +++ b/src/primitives.rs @@ -0,0 +1,493 @@ +use strafesnet_common::model::{Color4,TextureCoordinate,IndexedModel,IndexedPolygon,IndexedGroup,IndexedVertex}; +use strafesnet_common::integer::Planar64Vec3; + +#[derive(Debug)] +pub enum Primitives{ + Sphere, + Cube, + Cylinder, + Wedge, + CornerWedge, +} +#[derive(Hash,PartialEq,Eq)] +pub enum CubeFace{ + Right, + Top, + Back, + Left, + Bottom, + Front, +} +const CUBE_DEFAULT_TEXTURE_COORDS:[TextureCoordinate;4]=[ + TextureCoordinate::new(0.0,0.0), + TextureCoordinate::new(1.0,0.0), + TextureCoordinate::new(1.0,1.0), + TextureCoordinate::new(0.0,1.0), +]; +const CUBE_DEFAULT_VERTICES:[Planar64Vec3;8]=[ + Planar64Vec3::int(-1,-1, 1),//0 left bottom back + Planar64Vec3::int( 1,-1, 1),//1 right bottom back + Planar64Vec3::int( 1, 1, 1),//2 right top back + Planar64Vec3::int(-1, 1, 1),//3 left top back + Planar64Vec3::int(-1, 1,-1),//4 left top front + Planar64Vec3::int( 1, 1,-1),//5 right top front + Planar64Vec3::int( 1,-1,-1),//6 right bottom front + Planar64Vec3::int(-1,-1,-1),//7 left bottom front +]; +const CUBE_DEFAULT_NORMALS:[Planar64Vec3;6]=[ + Planar64Vec3::int( 1, 0, 0),//CubeFace::Right + Planar64Vec3::int( 0, 1, 0),//CubeFace::Top + Planar64Vec3::int( 0, 0, 1),//CubeFace::Back + Planar64Vec3::int(-1, 0, 0),//CubeFace::Left + Planar64Vec3::int( 0,-1, 0),//CubeFace::Bottom + Planar64Vec3::int( 0, 0,-1),//CubeFace::Front +]; +const CUBE_DEFAULT_POLYS:[[[u32;3];4];6]=[ + // right (1, 0, 0) + [ + [6,2,0],//[vertex,tex,norm] + [5,1,0], + [2,0,0], + [1,3,0], + ], + // top (0, 1, 0) + [ + [5,3,1], + [4,2,1], + [3,1,1], + [2,0,1], + ], + // back (0, 0, 1) + [ + [0,3,2], + [1,2,2], + [2,1,2], + [3,0,2], + ], + // left (-1, 0, 0) + [ + [0,2,3], + [3,1,3], + [4,0,3], + [7,3,3], + ], + // bottom (0,-1, 0) + [ + [1,1,4], + [0,0,4], + [7,3,4], + [6,2,4], + ], + // front (0, 0,-1) + [ + [4,1,5], + [5,0,5], + [6,3,5], + [7,2,5], + ], +]; + +#[derive(Hash,PartialEq,Eq)] +pub enum WedgeFace{ + Right, + TopFront, + Back, + Left, + Bottom, +} +const WEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[ + Planar64Vec3::int( 1, 0, 0),//Wedge::Right + Planar64Vec3::int( 0, 1,-1),//Wedge::TopFront + Planar64Vec3::int( 0, 0, 1),//Wedge::Back + Planar64Vec3::int(-1, 0, 0),//Wedge::Left + Planar64Vec3::int( 0,-1, 0),//Wedge::Bottom +]; +/* +local cornerWedgeVerticies = { + Vector3.new(-1/2,-1/2,-1/2),7 + Vector3.new(-1/2,-1/2, 1/2),0 + Vector3.new( 1/2,-1/2,-1/2),6 + Vector3.new( 1/2,-1/2, 1/2),1 + Vector3.new( 1/2, 1/2,-1/2),5 +} +*/ +#[derive(Hash,PartialEq,Eq)] +pub enum CornerWedgeFace{ + Right, + TopBack, + TopLeft, + Bottom, + Front, +} +const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[ + Planar64Vec3::int( 1, 0, 0),//CornerWedge::Right + Planar64Vec3::int( 0, 1, 1),//CornerWedge::BackTop + Planar64Vec3::int(-1, 1, 0),//CornerWedge::LeftTop + Planar64Vec3::int( 0,-1, 0),//CornerWedge::Bottom + Planar64Vec3::int( 0, 0,-1),//CornerWedge::Front +]; +pub fn unit_sphere()->crate::model::IndexedModel{ + unit_cube() +} +#[derive(Default)] +pub struct CubeFaceDescription([Option;6]); +impl CubeFaceDescription{ + pub fn insert(&mut self,index:CubeFace,value:FaceDescription){ + self.0[index as usize]=Some(value); + } + pub fn pairs(self)->std::iter::FilterMap,6>>,impl FnMut((usize,Option))->Option<(usize,FaceDescription)>>{ + self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u))) + } +} +pub fn unit_cube()->crate::model::IndexedModel{ + let mut t=CubeFaceDescription::default(); + t.insert(CubeFace::Right,FaceDescription::default()); + t.insert(CubeFace::Top,FaceDescription::default()); + t.insert(CubeFace::Back,FaceDescription::default()); + t.insert(CubeFace::Left,FaceDescription::default()); + t.insert(CubeFace::Bottom,FaceDescription::default()); + t.insert(CubeFace::Front,FaceDescription::default()); + generate_partial_unit_cube(t) +} +pub fn unit_cylinder()->crate::model::IndexedModel{ + unit_cube() +} +#[derive(Default)] +pub struct WedgeFaceDescription([Option;5]); +impl WedgeFaceDescription{ + pub fn insert(&mut self,index:WedgeFace,value:FaceDescription){ + self.0[index as usize]=Some(value); + } + pub fn pairs(self)->std::iter::FilterMap,5>>,impl FnMut((usize,Option))->Option<(usize,FaceDescription)>>{ + self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u))) + } +} +pub fn unit_wedge()->crate::model::IndexedModel{ + let mut t=WedgeFaceDescription::default(); + t.insert(WedgeFace::Right,FaceDescription::default()); + t.insert(WedgeFace::TopFront,FaceDescription::default()); + t.insert(WedgeFace::Back,FaceDescription::default()); + t.insert(WedgeFace::Left,FaceDescription::default()); + t.insert(WedgeFace::Bottom,FaceDescription::default()); + generate_partial_unit_wedge(t) +} +#[derive(Default)] +pub struct CornerWedgeFaceDescription([Option;5]); +impl CornerWedgeFaceDescription{ + pub fn insert(&mut self,index:CornerWedgeFace,value:FaceDescription){ + self.0[index as usize]=Some(value); + } + pub fn pairs(self)->std::iter::FilterMap,5>>,impl FnMut((usize,Option))->Option<(usize,FaceDescription)>>{ + self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u))) + } +} +pub fn unit_cornerwedge()->crate::model::IndexedModel{ + let mut t=CornerWedgeFaceDescription::default(); + t.insert(CornerWedgeFace::Right,FaceDescription::default()); + t.insert(CornerWedgeFace::TopBack,FaceDescription::default()); + t.insert(CornerWedgeFace::TopLeft,FaceDescription::default()); + t.insert(CornerWedgeFace::Bottom,FaceDescription::default()); + t.insert(CornerWedgeFace::Front,FaceDescription::default()); + generate_partial_unit_cornerwedge(t) +} + +#[derive(Clone)] +pub struct FaceDescription{ + pub texture:Option, + pub transform:glam::Affine2, + pub color:Color4, +} +impl std::default::Default for FaceDescription{ + fn default()->Self { + Self{ + texture:None, + transform:glam::Affine2::IDENTITY, + color:Color4::new(1.0,1.0,1.0,0.0),//zero alpha to hide the default texture + } + } +} +//TODO: it's probably better to use a shared vertex buffer between all primitives and use indexed rendering instead of generating a unique vertex buffer for each primitive. +//implementation: put all roblox primitives into one model.groups <- this won't work but I forget why +pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->crate::model::IndexedModel{ + let mut generated_pos=Vec::new(); + let mut generated_tex=Vec::new(); + let mut generated_normal=Vec::new(); + let mut generated_color=Vec::new(); + let mut generated_vertices=Vec::new(); + let mut groups=Vec::new(); + let mut transforms=Vec::new(); + //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. + for (face_id,face_description) in face_descriptions.pairs(){ + //assume that scanning short lists is faster than hashing. + let transform_index=if let Some(transform_index)=transforms.iter().position(|&transform|transform==face_description.transform){ + transform_index + }else{ + //create new transform_index + let transform_index=transforms.len(); + transforms.push(face_description.transform); + for tex in CUBE_DEFAULT_TEXTURE_COORDS{ + generated_tex.push(face_description.transform.transform_point2(tex)); + } + transform_index + } as u32; + let color_index=if let Some(color_index)=generated_color.iter().position(|&color|color==face_description.color){ + color_index + }else{ + //create new color_index + let color_index=generated_color.len(); + generated_color.push(face_description.color); + color_index + } as u32; + //always push normal + let normal_index=generated_normal.len() as u32; + generated_normal.push(CUBE_DEFAULT_NORMALS[face_id]); + //push vertices as they are needed + groups.push(IndexedGroup{ + texture:face_description.texture, + polys:vec![IndexedPolygon{ + vertices:CUBE_DEFAULT_POLYS[face_id].map(|tup|{ + let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; + let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ + pos_index + }else{ + //create new pos_index + let pos_index=generated_pos.len(); + generated_pos.push(pos); + pos_index + } as u32; + //always push vertex + let vertex=IndexedVertex{ + pos:pos_index, + tex:tup[1]+4*transform_index, + normal:normal_index, + color:color_index, + }; + let vert_index=generated_vertices.len(); + generated_vertices.push(vertex); + vert_index as u32 + }).to_vec(), + }], + }); + } + IndexedModel{ + unique_pos:generated_pos, + unique_tex:generated_tex, + unique_normal:generated_normal, + unique_color:generated_color, + unique_vertices:generated_vertices, + groups, + instances:Vec::new(), + } +} +//don't think too hard about the copy paste because this is all going into the map tool eventually... +pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->crate::model::IndexedModel{ + let wedge_default_polys=vec![ + // right (1, 0, 0) + vec![ + [6,2,0],//[vertex,tex,norm] + [2,0,0], + [1,3,0], + ], + // FrontTop (0, 1, -1) + vec![ + [3,1,1], + [2,0,1], + [6,3,1], + [7,2,1], + ], + // back (0, 0, 1) + vec![ + [0,3,2], + [1,2,2], + [2,1,2], + [3,0,2], + ], + // left (-1, 0, 0) + vec![ + [0,2,3], + [3,1,3], + [7,3,3], + ], + // bottom (0,-1, 0) + vec![ + [1,1,4], + [0,0,4], + [7,3,4], + [6,2,4], + ], + ]; + let mut generated_pos=Vec::new(); + let mut generated_tex=Vec::new(); + let mut generated_normal=Vec::new(); + let mut generated_color=Vec::new(); + let mut generated_vertices=Vec::new(); + let mut groups=Vec::new(); + let mut transforms=Vec::new(); + //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. + for (face_id,face_description) in face_descriptions.pairs(){ + //assume that scanning short lists is faster than hashing. + let transform_index=if let Some(transform_index)=transforms.iter().position(|&transform|transform==face_description.transform){ + transform_index + }else{ + //create new transform_index + let transform_index=transforms.len(); + transforms.push(face_description.transform); + for tex in CUBE_DEFAULT_TEXTURE_COORDS{ + generated_tex.push(face_description.transform.transform_point2(tex)); + } + transform_index + } as u32; + let color_index=if let Some(color_index)=generated_color.iter().position(|&color|color==face_description.color){ + color_index + }else{ + //create new color_index + let color_index=generated_color.len(); + generated_color.push(face_description.color); + color_index + } as u32; + //always push normal + let normal_index=generated_normal.len() as u32; + generated_normal.push(WEDGE_DEFAULT_NORMALS[face_id]); + //push vertices as they are needed + groups.push(IndexedGroup{ + texture:face_description.texture, + polys:vec![IndexedPolygon{ + vertices:wedge_default_polys[face_id].iter().map(|tup|{ + let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; + let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ + pos_index + }else{ + //create new pos_index + let pos_index=generated_pos.len(); + generated_pos.push(pos); + pos_index + } as u32; + //always push vertex + let vertex=IndexedVertex{ + pos:pos_index, + tex:tup[1]+4*transform_index, + normal:normal_index, + color:color_index, + }; + let vert_index=generated_vertices.len(); + generated_vertices.push(vertex); + vert_index as u32 + }).collect(), + }], + }); + } + IndexedModel{ + unique_pos:generated_pos, + unique_tex:generated_tex, + unique_normal:generated_normal, + unique_color:generated_color, + unique_vertices:generated_vertices, + groups, + instances:Vec::new(), + } +} + +pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->crate::model::IndexedModel{ + let cornerwedge_default_polys=vec![ + // right (1, 0, 0) + vec![ + [6,2,0],//[vertex,tex,norm] + [5,1,0], + [1,3,0], + ], + // BackTop (0, 1, 1) + vec![ + [5,3,1], + [0,1,1], + [1,0,1], + ], + // LeftTop (-1, 1, 0) + vec![ + [5,3,2], + [7,2,2], + [0,1,2], + ], + // bottom (0,-1, 0) + vec![ + [1,1,3], + [0,0,3], + [7,3,3], + [6,2,3], + ], + // front (0, 0,-1) + vec![ + [5,0,4], + [6,3,4], + [7,2,4], + ], + ]; + let mut generated_pos=Vec::new(); + let mut generated_tex=Vec::new(); + let mut generated_normal=Vec::new(); + let mut generated_color=Vec::new(); + let mut generated_vertices=Vec::new(); + let mut groups=Vec::new(); + let mut transforms=Vec::new(); + //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. + for (face_id,face_description) in face_descriptions.pairs(){ + //assume that scanning short lists is faster than hashing. + let transform_index=if let Some(transform_index)=transforms.iter().position(|&transform|transform==face_description.transform){ + transform_index + }else{ + //create new transform_index + let transform_index=transforms.len(); + transforms.push(face_description.transform); + for tex in CUBE_DEFAULT_TEXTURE_COORDS{ + generated_tex.push(face_description.transform.transform_point2(tex)); + } + transform_index + } as u32; + let color_index=if let Some(color_index)=generated_color.iter().position(|&color|color==face_description.color){ + color_index + }else{ + //create new color_index + let color_index=generated_color.len(); + generated_color.push(face_description.color); + color_index + } as u32; + //always push normal + let normal_index=generated_normal.len() as u32; + generated_normal.push(CORNERWEDGE_DEFAULT_NORMALS[face_id]); + //push vertices as they are needed + groups.push(IndexedGroup{ + texture:face_description.texture, + polys:vec![IndexedPolygon{ + vertices:cornerwedge_default_polys[face_id].iter().map(|tup|{ + let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; + let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ + pos_index + }else{ + //create new pos_index + let pos_index=generated_pos.len(); + generated_pos.push(pos); + pos_index + } as u32; + //always push vertex + let vertex=IndexedVertex{ + pos:pos_index, + tex:tup[1]+4*transform_index, + normal:normal_index, + color:color_index, + }; + let vert_index=generated_vertices.len(); + generated_vertices.push(vertex); + vert_index as u32 + }).collect(), + }], + }); + } + IndexedModel{ + unique_pos:generated_pos, + unique_tex:generated_tex, + unique_normal:generated_normal, + unique_color:generated_color, + unique_vertices:generated_vertices, + groups, + instances:Vec::new(), + } +} diff --git a/src/rbx.rs b/src/rbx.rs new file mode 100644 index 0000000..8a76a87 --- /dev/null +++ b/src/rbx.rs @@ -0,0 +1,524 @@ +use crate::primitives; +use strafesnet_common::gameplay_attributes; +use strafesnet_common::integer::{Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3}; + +fn class_is_a(class: &str, superclass: &str) -> bool { + if class==superclass { + return true + } + let class_descriptor=rbx_reflection_database::get().classes.get(class); + if let Some(descriptor) = &class_descriptor { + if let Some(class_super) = &descriptor.superclass { + return class_is_a(&class_super, superclass) + } + } + return false +} +fn recursive_collect_superclass(objects: &mut std::vec::Vec,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance, superclass: &str){ + let mut stack=vec![instance]; + while let Some(item)=stack.pop(){ + for &referent in item.children(){ + if let Some(c)=dom.get_by_ref(referent){ + if class_is_a(c.class.as_str(),superclass){ + objects.push(c.referent());//copy ref + } + stack.push(c); + } + } + } +} +fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_weak::types::Vector3)->Planar64Affine3{ + Planar64Affine3::new( + Planar64Mat3::from_cols( + Planar64Vec3::try_from([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x]).unwrap() + *Planar64::try_from(size.x/2.0).unwrap(), + Planar64Vec3::try_from([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y]).unwrap() + *Planar64::try_from(size.y/2.0).unwrap(), + Planar64Vec3::try_from([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z]).unwrap() + *Planar64::try_from(size.z/2.0).unwrap(), + ), + Planar64Vec3::try_from([cf.position.x,cf.position.y,cf.position.z]).unwrap() + ) +} +fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,force_intersecting:bool)->model::CollisionAttributes{ + let mut general=model::GameMechanicAttributes::default(); + let mut intersecting=model::IntersectingAttributes::default(); + let mut contacting=model::ContactingAttributes::default(); + let mut force_can_collide=can_collide; + match name{ + "Water"=>{ + force_can_collide=false; + //TODO: read stupid CustomPhysicalProperties + intersecting.water=Some(model::IntersectingWater{density:Planar64::ONE,viscosity:Planar64::ONE/10,velocity}); + }, + "Accelerator"=>{ + //although the new game supports collidable accelerators, this is a roblox compatability map loader + force_can_collide=false; + general.accelerator=Some(model::GameMechanicAccelerator{acceleration:velocity}); + }, + // "UnorderedCheckpoint"=>general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ + // mode_id:0, + // stage_id:0, + // force:false, + // behaviour:model::StageElementBehaviour::Unordered + // })), + "SetVelocity"=>general.trajectory=Some(model::GameMechanicSetTrajectory::Velocity(velocity)), + "MapFinish"=>{force_can_collide=false;general.zone=Some(model::GameMechanicZone{mode_id:0,behaviour:model::ZoneBehaviour::Finish})}, + "MapAnticheat"=>{force_can_collide=false;general.zone=Some(model::GameMechanicZone{mode_id:0,behaviour:model::ZoneBehaviour::Anitcheat})}, + "Platform"=>general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ + mode_id:0, + stage_id:0, + force:false, + behaviour:model::StageElementBehaviour::Platform, + })), + other=>{ + if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$") + .captures(other){ + general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ + mode_id:0, + stage_id:captures[3].parse::().unwrap(), + force:match captures.get(1){ + Some(m)=>m.as_str()=="Force", + None=>false, + }, + behaviour:match &captures[2]{ + "Spawn"|"SpawnAt"=>model::StageElementBehaviour::SpawnAt, + //cancollide false so you don't hit the side + //NOT a decoration + "Trigger"=>{force_can_collide=false;model::StageElementBehaviour::Trigger}, + "Teleport"=>{force_can_collide=false;model::StageElementBehaviour::Teleport}, + "Platform"=>model::StageElementBehaviour::Platform, + _=>panic!("regex1[2] messed up bad"), + } + })); + }else if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Jump)(\d+)$") + .captures(other){ + general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ + mode_id:0, + stage_id:0, + force:match captures.get(1){ + Some(m)=>m.as_str()=="Force", + None=>false, + }, + behaviour:match &captures[2]{ + "Jump"=>model::StageElementBehaviour::JumpLimit(captures[3].parse::().unwrap()), + _=>panic!("regex4[1] messed up bad"), + } + })); + }else if let Some(captures)=lazy_regex::regex!(r"^Bonus(Finish|Anticheat)(\d+)$") + .captures(other){ + force_can_collide=false; + match &captures[1]{ + "Finish"=>general.zone=Some(model::GameMechanicZone{mode_id:captures[2].parse::().unwrap(),behaviour:model::ZoneBehaviour::Finish}), + "Anticheat"=>general.zone=Some(model::GameMechanicZone{mode_id:captures[2].parse::().unwrap(),behaviour:model::ZoneBehaviour::Anitcheat}), + _=>panic!("regex2[1] messed up bad"), + } + }else if let Some(captures)=lazy_regex::regex!(r"^(WormholeIn)(\d+)$") + .captures(other){ + force_can_collide=false; + match &captures[1]{ + "WormholeIn"=>general.teleport_behaviour=Some(model::TeleportBehaviour::Wormhole(model::GameMechanicWormhole{destination_model_id:captures[2].parse::().unwrap()})), + _=>panic!("regex3[1] messed up bad"), + } + } + // else if let Some(captures)=lazy_regex::regex!(r"^(OrderedCheckpoint)(\d+)$") + // .captures(other){ + // match &captures[1]{ + // "OrderedCheckpoint"=>general.checkpoint=Some(model::GameMechanicCheckpoint::Ordered{mode_id:0,checkpoint_id:captures[2].parse::().unwrap()}), + // _=>panic!("regex3[1] messed up bad"), + // } + // } + } + } + //need some way to skip this + if velocity!=Planar64Vec3::ZERO{ + general.booster=Some(model::GameMechanicBooster::Velocity(velocity)); + } + match force_can_collide{ + true=>{ + match name{ + "Bounce"=>contacting.contact_behaviour=Some(model::ContactingBehaviour::Elastic(u32::MAX)), + "Surf"=>contacting.contact_behaviour=Some(model::ContactingBehaviour::Surf), + "Ladder"=>contacting.contact_behaviour=Some(model::ContactingBehaviour::Ladder(model::ContactingLadder{sticky:true})), + _=>(), + } + model::CollisionAttributes::Contact{contacting,general} + }, + false=>if force_intersecting + ||general.any() + ||intersecting.any() + { + model::CollisionAttributes::Intersect{intersecting,general} + }else{ + model::CollisionAttributes::Decoration + }, + } +} + +struct RobloxAssetId(u64); +struct RobloxAssetIdParseErr; +impl std::str::FromStr for RobloxAssetId { + type Err=RobloxAssetIdParseErr; + fn from_str(s: &str) -> Result{ + let regman=lazy_regex::regex!(r"(\d+)$"); + if let Some(captures) = regman.captures(s) { + if captures.len()==2{//captures[0] is all captures concatenated, and then each individual capture + if let Ok(id) = captures[0].parse::() { + return Ok(Self(id)); + } + } + } + Err(RobloxAssetIdParseErr) + } +} +#[derive(Clone,Copy,PartialEq)] +struct RobloxTextureTransform{ + offset_u:f32, + offset_v:f32, + scale_u:f32, + scale_v:f32, +} +impl std::cmp::Eq for RobloxTextureTransform{}//???? +impl std::default::Default for RobloxTextureTransform{ + fn default() -> Self { + Self{offset_u:0.0,offset_v:0.0,scale_u:1.0,scale_v:1.0} + } +} +impl std::hash::Hash for RobloxTextureTransform { + fn hash(&self, state: &mut H) { + self.offset_u.to_ne_bytes().hash(state); + self.offset_v.to_ne_bytes().hash(state); + self.scale_u.to_ne_bytes().hash(state); + self.scale_v.to_ne_bytes().hash(state); + } +} +#[derive(Clone,PartialEq)] +struct RobloxFaceTextureDescription{ + texture:u32, + color:glam::Vec4, + transform:RobloxTextureTransform, +} +impl std::cmp::Eq for RobloxFaceTextureDescription{}//???? +impl std::hash::Hash for RobloxFaceTextureDescription { + fn hash(&self, state: &mut H) { + self.texture.hash(state); + self.transform.hash(state); + for &el in self.color.as_ref().iter() { + el.to_ne_bytes().hash(state); + } + } +} +impl RobloxFaceTextureDescription{ + fn to_face_description(&self)->primitives::FaceDescription{ + primitives::FaceDescription{ + texture:Some(self.texture), + transform:glam::Affine2::from_translation( + glam::vec2(self.transform.offset_u,self.transform.offset_v) + ) + *glam::Affine2::from_scale( + glam::vec2(self.transform.scale_u,self.transform.scale_v) + ), + color:self.color, + } + } +} +type RobloxPartDescription=[Option;6]; +type RobloxWedgeDescription=[Option;5]; +type RobloxCornerWedgeDescription=[Option;5]; +#[derive(Clone,Eq,Hash,PartialEq)] +enum RobloxBasePartDescription{ + Sphere(RobloxPartDescription), + Part(RobloxPartDescription), + Cylinder(RobloxPartDescription), + Wedge(RobloxWedgeDescription), + CornerWedge(RobloxCornerWedgeDescription), +} +pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModelInstances{ + //IndexedModelInstances includes textures + let mut spawn_point=Planar64Vec3::ZERO; + + let mut indexed_models=Vec::new(); + let mut model_id_from_description=std::collections::HashMap::::new(); + + let mut texture_id_from_asset_id=std::collections::HashMap::::new(); + let mut asset_id_from_texture_id=Vec::new(); + + let mut object_refs=Vec::new(); + let mut temp_objects=Vec::new(); + recursive_collect_superclass(&mut object_refs, &dom, dom.root(),"BasePart"); + for object_ref in object_refs { + if let Some(object)=dom.get_by_ref(object_ref){ + if let ( + Some(rbx_dom_weak::types::Variant::CFrame(cf)), + Some(rbx_dom_weak::types::Variant::Vector3(size)), + Some(rbx_dom_weak::types::Variant::Vector3(velocity)), + Some(rbx_dom_weak::types::Variant::Float32(transparency)), + Some(rbx_dom_weak::types::Variant::Color3uint8(color3)), + Some(rbx_dom_weak::types::Variant::Bool(can_collide)), + ) = ( + object.properties.get("CFrame"), + object.properties.get("Size"), + object.properties.get("Velocity"), + object.properties.get("Transparency"), + object.properties.get("Color"), + object.properties.get("CanCollide"), + ) + { + let model_transform=planar64_affine3_from_roblox(cf,size); + + if model_transform.matrix3.determinant()==Planar64::ZERO{ + let mut parent_ref=object.parent(); + let mut full_path=object.name.clone(); + while let Some(parent)=dom.get_by_ref(parent_ref){ + full_path=format!("{}.{}",parent.name,full_path); + parent_ref=parent.parent(); + } + println!("Zero determinant CFrame at location {}",full_path); + println!("matrix3:{}",model_transform.matrix3); + continue; + } + + //push TempIndexedAttributes + let mut force_intersecting=false; + let mut temp_indexing_attributes=Vec::new(); + if let Some(attr)=match &object.name[..]{ + "MapStart"=>{ + spawn_point=model_transform.transform_point3(Planar64Vec3::ZERO)+Planar64Vec3::Y*5/2; + Some(model::TempIndexedAttributes::Start(model::TempAttrStart{mode_id:0})) + }, + other=>{ + let regman=lazy_regex::regex!(r"^(BonusStart|Spawn|ForceSpawn|WormholeOut)(\d+)$"); + if let Some(captures) = regman.captures(other) { + match &captures[1]{ + "BonusStart"=>Some(model::TempIndexedAttributes::Start(model::TempAttrStart{mode_id:captures[2].parse::().unwrap()})), + "Spawn"|"ForceSpawn"=>Some(model::TempIndexedAttributes::Spawn(model::TempAttrSpawn{mode_id:0,stage_id:captures[2].parse::().unwrap()})), + "WormholeOut"=>Some(model::TempIndexedAttributes::Wormhole(model::TempAttrWormhole{wormhole_id:captures[2].parse::().unwrap()})), + _=>None, + } + }else{ + None + } + } + }{ + force_intersecting=true; + temp_indexing_attributes.push(attr); + } + + //TODO: also detect "CylinderMesh" etc here + let shape=match &object.class[..]{ + "Part"=>{ + if let Some(rbx_dom_weak::types::Variant::Enum(shape))=object.properties.get("Shape"){ + match shape.to_u32(){ + 0=>primitives::Primitives::Sphere, + 1=>primitives::Primitives::Cube, + 2=>primitives::Primitives::Cylinder, + 3=>primitives::Primitives::Wedge, + 4=>primitives::Primitives::CornerWedge, + _=>panic!("Funky roblox PartType={};",shape.to_u32()), + } + }else{ + panic!("Part has no Shape!"); + } + }, + "TrussPart"=>primitives::Primitives::Cube, + "WedgePart"=>primitives::Primitives::Wedge, + "CornerWedgePart"=>primitives::Primitives::CornerWedge, + _=>{ + println!("Unsupported BasePart ClassName={}; defaulting to cube",object.class); + primitives::Primitives::Cube + } + }; + + //use the biggest one and cut it down later... + let mut part_texture_description:RobloxPartDescription=[None,None,None,None,None,None]; + temp_objects.clear(); + recursive_collect_superclass(&mut temp_objects, &dom, object,"Decal"); + for &decal_ref in &temp_objects{ + if let Some(decal)=dom.get_by_ref(decal_ref){ + if let ( + Some(rbx_dom_weak::types::Variant::Content(content)), + Some(rbx_dom_weak::types::Variant::Enum(normalid)), + Some(rbx_dom_weak::types::Variant::Color3(decal_color3)), + Some(rbx_dom_weak::types::Variant::Float32(decal_transparency)), + ) = ( + decal.properties.get("Texture"), + decal.properties.get("Face"), + decal.properties.get("Color3"), + decal.properties.get("Transparency"), + ) { + if let Ok(asset_id)=content.clone().into_string().parse::(){ + let texture_id=if let Some(&texture_id)=texture_id_from_asset_id.get(&asset_id.0){ + texture_id + }else{ + let texture_id=asset_id_from_texture_id.len() as u32; + texture_id_from_asset_id.insert(asset_id.0,texture_id); + asset_id_from_texture_id.push(asset_id.0); + texture_id + }; + let normal_id=normalid.to_u32(); + if normal_id<6{ + let (roblox_texture_color,roblox_texture_transform)=if decal.class=="Texture"{ + //generate tranform + if let ( + Some(rbx_dom_weak::types::Variant::Float32(ox)), + Some(rbx_dom_weak::types::Variant::Float32(oy)), + Some(rbx_dom_weak::types::Variant::Float32(sx)), + Some(rbx_dom_weak::types::Variant::Float32(sy)), + ) = ( + decal.properties.get("OffsetStudsU"), + decal.properties.get("OffsetStudsV"), + decal.properties.get("StudsPerTileU"), + decal.properties.get("StudsPerTileV"), + ) + { + let (size_u,size_v)=match normal_id{ + 0=>(size.z,size.y),//right + 1=>(size.x,size.z),//top + 2=>(size.x,size.y),//back + 3=>(size.z,size.y),//left + 4=>(size.x,size.z),//bottom + 5=>(size.x,size.y),//front + _=>panic!("unreachable"), + }; + ( + glam::vec4(decal_color3.r,decal_color3.g,decal_color3.b,1.0-*decal_transparency), + RobloxTextureTransform{ + offset_u:*ox/(*sx),offset_v:*oy/(*sy), + scale_u:size_u/(*sx),scale_v:size_v/(*sy), + } + ) + }else{ + (glam::Vec4::ONE,RobloxTextureTransform::default()) + } + }else{ + (glam::Vec4::ONE,RobloxTextureTransform::default()) + }; + part_texture_description[normal_id as usize]=Some(RobloxFaceTextureDescription{ + texture:texture_id, + color:roblox_texture_color, + transform:roblox_texture_transform, + }); + }else{ + println!("NormalId={} unsupported for shape={:?}",normal_id,shape); + } + } + } + } + } + //obscure rust syntax "slice pattern" + let [ + f0,//Cube::Right + f1,//Cube::Top + f2,//Cube::Back + f3,//Cube::Left + f4,//Cube::Bottom + f5,//Cube::Front + ]=part_texture_description; + let basepart_texture_description=match shape{ + primitives::Primitives::Sphere=>RobloxBasePartDescription::Sphere([f0,f1,f2,f3,f4,f5]), + primitives::Primitives::Cube=>RobloxBasePartDescription::Part([f0,f1,f2,f3,f4,f5]), + primitives::Primitives::Cylinder=>RobloxBasePartDescription::Cylinder([f0,f1,f2,f3,f4,f5]), + //use front face texture first and use top face texture as a fallback + primitives::Primitives::Wedge=>RobloxBasePartDescription::Wedge([ + f0,//Cube::Right->Wedge::Right + if f5.is_some(){f5}else{f1},//Cube::Front|Cube::Top->Wedge::TopFront + f2,//Cube::Back->Wedge::Back + f3,//Cube::Left->Wedge::Left + f4,//Cube::Bottom->Wedge::Bottom + ]), + //TODO: fix Left+Back texture coordinates to match roblox when not overwridden by Top + primitives::Primitives::CornerWedge=>RobloxBasePartDescription::CornerWedge([ + f0,//Cube::Right->CornerWedge::Right + if f2.is_some(){f2}else{f1.clone()},//Cube::Back|Cube::Top->CornerWedge::TopBack + if f3.is_some(){f3}else{f1},//Cube::Left|Cube::Top->CornerWedge::TopLeft + f4,//Cube::Bottom->CornerWedge::Bottom + f5,//Cube::Front->CornerWedge::Front + ]), + }; + //make new model if unit cube has not been created before + let model_id=if let Some(&model_id)=model_id_from_description.get(&basepart_texture_description){ + //push to existing texture model + model_id + }else{ + let model_id=indexed_models.len(); + model_id_from_description.insert(basepart_texture_description.clone(),model_id);//borrow checker going crazy + indexed_models.push(match basepart_texture_description{ + RobloxBasePartDescription::Sphere(part_texture_description) + |RobloxBasePartDescription::Cylinder(part_texture_description) + |RobloxBasePartDescription::Part(part_texture_description)=>{ + let mut cube_face_description=primitives::CubeFaceDescription::default(); + for (face_id,roblox_face_description) in part_texture_description.iter().enumerate(){ + cube_face_description.insert( + match face_id{ + 0=>primitives::CubeFace::Right, + 1=>primitives::CubeFace::Top, + 2=>primitives::CubeFace::Back, + 3=>primitives::CubeFace::Left, + 4=>primitives::CubeFace::Bottom, + 5=>primitives::CubeFace::Front, + _=>panic!("unreachable"), + }, + match roblox_face_description{ + Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), + None=>primitives::FaceDescription::default(), + }); + } + primitives::generate_partial_unit_cube(cube_face_description) + }, + RobloxBasePartDescription::Wedge(wedge_texture_description)=>{ + let mut wedge_face_description=primitives::WedgeFaceDescription::default(); + for (face_id,roblox_face_description) in wedge_texture_description.iter().enumerate(){ + wedge_face_description.insert( + match face_id{ + 0=>primitives::WedgeFace::Right, + 1=>primitives::WedgeFace::TopFront, + 2=>primitives::WedgeFace::Back, + 3=>primitives::WedgeFace::Left, + 4=>primitives::WedgeFace::Bottom, + _=>panic!("unreachable"), + }, + match roblox_face_description{ + Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), + None=>primitives::FaceDescription::default(), + }); + } + primitives::generate_partial_unit_wedge(wedge_face_description) + }, + RobloxBasePartDescription::CornerWedge(cornerwedge_texture_description)=>{ + let mut cornerwedge_face_description=primitives::CornerWedgeFaceDescription::default(); + for (face_id,roblox_face_description) in cornerwedge_texture_description.iter().enumerate(){ + cornerwedge_face_description.insert( + match face_id{ + 0=>primitives::CornerWedgeFace::Right, + 1=>primitives::CornerWedgeFace::TopBack, + 2=>primitives::CornerWedgeFace::TopLeft, + 3=>primitives::CornerWedgeFace::Bottom, + 4=>primitives::CornerWedgeFace::Front, + _=>panic!("unreachable"), + }, + match roblox_face_description{ + Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), + None=>primitives::FaceDescription::default(), + }); + } + primitives::generate_partial_unit_cornerwedge(cornerwedge_face_description) + }, + }); + model_id + }; + indexed_models[model_id].instances.push(model::ModelInstance { + transform:model_transform, + color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency), + attributes:get_attributes(&object.name,*can_collide,Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(),force_intersecting), + temp_indexing:temp_indexing_attributes, + }); + } + } + } + model::IndexedModelInstances{ + textures:asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(), + models:indexed_models, + spawn_point, + modes:Vec::new(), + } +} From 0d2c27f60f4a448063edc57d9a23766775fb2cc5 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jan 2024 17:46:23 -0800 Subject: [PATCH 02/49] rename package --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7f31ab..82a6acc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,19 +284,6 @@ dependencies = [ "serde", ] -[[package]] -name = "rbx_loader" -version = "0.1.0" -dependencies = [ - "glam", - "lazy-regex", - "rbx_binary", - "rbx_dom_weak", - "rbx_reflection_database", - "rbx_xml", - "strafesnet_common", -] - [[package]] name = "rbx_reflection" version = "4.5.0" @@ -428,6 +415,19 @@ dependencies = [ "glam", ] +[[package]] +name = "strafesnet_rbx_loader" +version = "0.1.0" +dependencies = [ + "glam", + "lazy-regex", + "rbx_binary", + "rbx_dom_weak", + "rbx_reflection_database", + "rbx_xml", + "strafesnet_common", +] + [[package]] name = "syn" version = "2.0.48" diff --git a/Cargo.toml b/Cargo.toml index c419ba1..b49f4c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rbx_loader" +name = "strafesnet_rbx_loader" version = "0.1.0" edition = "2021" From 20bbb6924e94b67fe86195a43eaac6472ff084c8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jan 2024 20:24:52 -0800 Subject: [PATCH 03/49] update common --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82a6acc..92e910b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -410,7 +410,7 @@ 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=5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72#5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72" dependencies = [ "glam", ] diff --git a/Cargo.toml b/Cargo.toml index b49f4c6..3972497 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ rbx_binary = "0.7.4" rbx_dom_weak = "2.7.0" rbx_reflection_database = "0.2.10" rbx_xml = "0.13.3" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72" } From 93bc4dc0fb2175af8ded235c7a4b47af7235790a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jan 2024 20:25:07 -0800 Subject: [PATCH 04/49] data structure rewrite, implement texture_loader --- Cargo.lock | 13 +- Cargo.toml | 2 +- src/lib.rs | 26 ++- src/primitives.rs | 259 ++++++++++++------------ src/rbx.rs | 489 ++++++++++++++++++++++++++++++++-------------- 5 files changed, 520 insertions(+), 269 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92e910b..180a3bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,6 +98,16 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" +[[package]] +name = "id" +version = "0.1.0" +source = "git+https://git.itzana.me/Quaternions/id?rev=1f710976cc786c8853dab73d6e1cee53158deeb0#1f710976cc786c8853dab73d6e1cee53158deeb0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "lazy-regex" version = "3.1.0" @@ -410,9 +420,10 @@ dependencies = [ [[package]] name = "strafesnet_common" version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72#5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72" +source = "git+https://git.itzana.me/StrafesNET/common?rev=47cdea0c8a5d10a2440ca6270a975d560aa3642d#47cdea0c8a5d10a2440ca6270a975d560aa3642d" dependencies = [ "glam", + "id", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3972497..0897aab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ rbx_binary = "0.7.4" rbx_dom_weak = "2.7.0" rbx_reflection_database = "0.2.10" rbx_xml = "0.13.3" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "47cdea0c8a5d10a2440ca6270a975d560aa3642d" } diff --git a/src/lib.rs b/src/lib.rs index 57a6919..3b35ed8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,26 @@ +use std::io::Read; + +mod rbx; mod primitives; -pub mod rbx; \ No newline at end of file + +#[derive(Debug)] +pub enum Error{ + RbxBinary(rbx_binary::DecodeError), + RbxXml(rbx_xml::DecodeError), + Io(std::io::Error), + UnknownFileFormat, +} + +fn load_dom(input:R)->Result{ + let mut buf=std::io::BufReader::new(input); + let peek=std::io::BufRead::fill_buf(&mut buf).map_err(Error::Io)?; + match &peek[0..8]{ + b"return rbx_binary::from_reader(buf).map_err(Error::RbxBinary), + b"return rbx_xml::from_reader_default(buf).map_err(Error::RbxXml), + _=>Err(Error::UnknownFileFormat), + } +} + +pub fn readOption>(input:R,acquire_id:F)->Result{ + Ok(rbx::convert(load_dom(input)?,acquire_id)) +} \ No newline at end of file diff --git a/src/primitives.rs b/src/primitives.rs index 3c98259..518841c 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -1,4 +1,4 @@ -use strafesnet_common::model::{Color4,TextureCoordinate,IndexedModel,IndexedPolygon,IndexedGroup,IndexedVertex}; +use strafesnet_common::model::{Color4,TextureCoordinate,Mesh,IndexedGraphicsGroup,IndexedPhysicsGroup,IndexedVertex,PolygonGroupId,PolygonGroup,PolygonList,IndexedVertexList,PositionId,TextureCoordinateId,NormalId,ColorId,VertexId,RenderConfigId}; use strafesnet_common::integer::Planar64Vec3; #[derive(Debug)] @@ -126,8 +126,8 @@ const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[ Planar64Vec3::int( 0,-1, 0),//CornerWedge::Bottom Planar64Vec3::int( 0, 0,-1),//CornerWedge::Front ]; -pub fn unit_sphere()->crate::model::IndexedModel{ - unit_cube() +pub fn unit_sphere(render:RenderConfigId)->Mesh{ + unit_cube(render) } #[derive(Default)] pub struct CubeFaceDescription([Option;6]); @@ -139,18 +139,19 @@ impl CubeFaceDescription{ self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u))) } } -pub fn unit_cube()->crate::model::IndexedModel{ +pub fn unit_cube(render:RenderConfigId)->Mesh{ let mut t=CubeFaceDescription::default(); - t.insert(CubeFace::Right,FaceDescription::default()); - t.insert(CubeFace::Top,FaceDescription::default()); - t.insert(CubeFace::Back,FaceDescription::default()); - t.insert(CubeFace::Left,FaceDescription::default()); - t.insert(CubeFace::Bottom,FaceDescription::default()); - t.insert(CubeFace::Front,FaceDescription::default()); + t.insert(CubeFace::Right,FaceDescription::new_with_render_id(render)); + t.insert(CubeFace::Top,FaceDescription::new_with_render_id(render)); + t.insert(CubeFace::Back,FaceDescription::new_with_render_id(render)); + t.insert(CubeFace::Left,FaceDescription::new_with_render_id(render)); + t.insert(CubeFace::Bottom,FaceDescription::new_with_render_id(render)); + t.insert(CubeFace::Front,FaceDescription::new_with_render_id(render)); generate_partial_unit_cube(t) } -pub fn unit_cylinder()->crate::model::IndexedModel{ - unit_cube() +pub fn unit_cylinder(render:RenderConfigId)->Mesh{ + //lmao + unit_cube(render) } #[derive(Default)] pub struct WedgeFaceDescription([Option;5]); @@ -162,13 +163,13 @@ impl WedgeFaceDescription{ self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u))) } } -pub fn unit_wedge()->crate::model::IndexedModel{ +pub fn unit_wedge(render:RenderConfigId)->Mesh{ let mut t=WedgeFaceDescription::default(); - t.insert(WedgeFace::Right,FaceDescription::default()); - t.insert(WedgeFace::TopFront,FaceDescription::default()); - t.insert(WedgeFace::Back,FaceDescription::default()); - t.insert(WedgeFace::Left,FaceDescription::default()); - t.insert(WedgeFace::Bottom,FaceDescription::default()); + t.insert(WedgeFace::Right,FaceDescription::new_with_render_id(render)); + t.insert(WedgeFace::TopFront,FaceDescription::new_with_render_id(render)); + t.insert(WedgeFace::Back,FaceDescription::new_with_render_id(render)); + t.insert(WedgeFace::Left,FaceDescription::new_with_render_id(render)); + t.insert(WedgeFace::Bottom,FaceDescription::new_with_render_id(render)); generate_partial_unit_wedge(t) } #[derive(Default)] @@ -181,26 +182,26 @@ impl CornerWedgeFaceDescription{ self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u))) } } -pub fn unit_cornerwedge()->crate::model::IndexedModel{ +pub fn unit_cornerwedge(render:RenderConfigId)->Mesh{ let mut t=CornerWedgeFaceDescription::default(); - t.insert(CornerWedgeFace::Right,FaceDescription::default()); - t.insert(CornerWedgeFace::TopBack,FaceDescription::default()); - t.insert(CornerWedgeFace::TopLeft,FaceDescription::default()); - t.insert(CornerWedgeFace::Bottom,FaceDescription::default()); - t.insert(CornerWedgeFace::Front,FaceDescription::default()); + t.insert(CornerWedgeFace::Right,FaceDescription::new_with_render_id(render)); + t.insert(CornerWedgeFace::TopBack,FaceDescription::new_with_render_id(render)); + t.insert(CornerWedgeFace::TopLeft,FaceDescription::new_with_render_id(render)); + t.insert(CornerWedgeFace::Bottom,FaceDescription::new_with_render_id(render)); + t.insert(CornerWedgeFace::Front,FaceDescription::new_with_render_id(render)); generate_partial_unit_cornerwedge(t) } #[derive(Clone)] pub struct FaceDescription{ - pub texture:Option, + pub render:RenderConfigId, pub transform:glam::Affine2, pub color:Color4, } -impl std::default::Default for FaceDescription{ - fn default()->Self { +impl FaceDescription{ + pub fn new_with_render_id(render:RenderConfigId)->Self { Self{ - texture:None, + render, transform:glam::Affine2::IDENTITY, color:Color4::new(1.0,1.0,1.0,0.0),//zero alpha to hide the default texture } @@ -208,13 +209,15 @@ impl std::default::Default for FaceDescription{ } //TODO: it's probably better to use a shared vertex buffer between all primitives and use indexed rendering instead of generating a unique vertex buffer for each primitive. //implementation: put all roblox primitives into one model.groups <- this won't work but I forget why -pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->crate::model::IndexedModel{ +pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{ let mut generated_pos=Vec::new(); let mut generated_tex=Vec::new(); let mut generated_normal=Vec::new(); let mut generated_color=Vec::new(); let mut generated_vertices=Vec::new(); - let mut groups=Vec::new(); + let mut polygon_groups=Vec::new(); + let mut graphics_groups=Vec::new(); + let mut physics_groups=vec![IndexedPhysicsGroup::default()]; let mut transforms=Vec::new(); //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. for (face_id,face_description) in face_descriptions.pairs(){ @@ -242,46 +245,50 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->crate: let normal_index=generated_normal.len() as u32; generated_normal.push(CUBE_DEFAULT_NORMALS[face_id]); //push vertices as they are needed - groups.push(IndexedGroup{ - texture:face_description.texture, - polys:vec![IndexedPolygon{ - vertices:CUBE_DEFAULT_POLYS[face_id].map(|tup|{ - let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; - let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ - pos_index - }else{ - //create new pos_index - let pos_index=generated_pos.len(); - generated_pos.push(pos); - pos_index - } as u32; - //always push vertex - let vertex=IndexedVertex{ - pos:pos_index, - tex:tup[1]+4*transform_index, - normal:normal_index, - color:color_index, - }; - let vert_index=generated_vertices.len(); - generated_vertices.push(vertex); - vert_index as u32 - }).to_vec(), - }], + let group_id=PolygonGroupId::new(polygon_groups.len() as u32); + polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![ + CUBE_DEFAULT_POLYS[face_id].map(|tup|{ + let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; + let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ + pos_index + }else{ + //create new pos_index + let pos_index=generated_pos.len(); + generated_pos.push(pos); + pos_index + } as u32; + //always push vertex + let vertex=IndexedVertex{ + pos:PositionId::new(pos_index), + tex:TextureCoordinateId::new(tup[1]+4*transform_index), + normal:NormalId::new(normal_index), + color:ColorId::new(color_index), + }; + let vert_index=generated_vertices.len(); + generated_vertices.push(vertex); + VertexId::new(vert_index as u32) + }).to_vec(), + ]))); + graphics_groups.push(IndexedGraphicsGroup{ + render:face_description.render, + groups:vec![group_id], }); + physics_groups[0].groups.push(group_id); } - IndexedModel{ + Mesh{ unique_pos:generated_pos, unique_tex:generated_tex, unique_normal:generated_normal, unique_color:generated_color, unique_vertices:generated_vertices, - groups, - instances:Vec::new(), + polygon_groups, + graphics_groups, + physics_groups, } } //don't think too hard about the copy paste because this is all going into the map tool eventually... -pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->crate::model::IndexedModel{ - let wedge_default_polys=vec![ +pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh{ + let wedge_default_polys=[ // right (1, 0, 0) vec![ [6,2,0],//[vertex,tex,norm] @@ -321,7 +328,9 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->crat let mut generated_normal=Vec::new(); let mut generated_color=Vec::new(); let mut generated_vertices=Vec::new(); - let mut groups=Vec::new(); + let mut polygon_groups=Vec::new(); + let mut graphics_groups=Vec::new(); + let mut physics_groups=vec![IndexedPhysicsGroup::default()]; let mut transforms=Vec::new(); //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. for (face_id,face_description) in face_descriptions.pairs(){ @@ -349,46 +358,50 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->crat let normal_index=generated_normal.len() as u32; generated_normal.push(WEDGE_DEFAULT_NORMALS[face_id]); //push vertices as they are needed - groups.push(IndexedGroup{ - texture:face_description.texture, - polys:vec![IndexedPolygon{ - vertices:wedge_default_polys[face_id].iter().map(|tup|{ - let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; - let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ - pos_index - }else{ - //create new pos_index - let pos_index=generated_pos.len(); - generated_pos.push(pos); - pos_index - } as u32; - //always push vertex - let vertex=IndexedVertex{ - pos:pos_index, - tex:tup[1]+4*transform_index, - normal:normal_index, - color:color_index, - }; - let vert_index=generated_vertices.len(); - generated_vertices.push(vertex); - vert_index as u32 - }).collect(), - }], + let group_id=PolygonGroupId::new(polygon_groups.len() as u32); + polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![ + wedge_default_polys[face_id].iter().map(|tup|{ + let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; + let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ + pos_index + }else{ + //create new pos_index + let pos_index=generated_pos.len(); + generated_pos.push(pos); + pos_index + } as u32; + //always push vertex + let vertex=IndexedVertex{ + pos:PositionId::new(pos_index), + tex:TextureCoordinateId::new(tup[1]+4*transform_index), + normal:NormalId::new(normal_index), + color:ColorId::new(color_index), + }; + let vert_index=generated_vertices.len(); + generated_vertices.push(vertex); + VertexId::new(vert_index as u32) + }).collect() + ]))); + graphics_groups.push(IndexedGraphicsGroup{ + render:face_description.render, + groups:vec![group_id], }); + physics_groups[0].groups.push(group_id); } - IndexedModel{ + Mesh{ unique_pos:generated_pos, unique_tex:generated_tex, unique_normal:generated_normal, unique_color:generated_color, unique_vertices:generated_vertices, - groups, - instances:Vec::new(), + polygon_groups, + graphics_groups, + physics_groups, } } -pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->crate::model::IndexedModel{ - let cornerwedge_default_polys=vec![ +pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->Mesh{ + let cornerwedge_default_polys=[ // right (1, 0, 0) vec![ [6,2,0],//[vertex,tex,norm] @@ -426,7 +439,9 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri let mut generated_normal=Vec::new(); let mut generated_color=Vec::new(); let mut generated_vertices=Vec::new(); - let mut groups=Vec::new(); + let mut polygon_groups=Vec::new(); + let mut graphics_groups=Vec::new(); + let mut physics_groups=vec![IndexedPhysicsGroup::default()]; let mut transforms=Vec::new(); //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. for (face_id,face_description) in face_descriptions.pairs(){ @@ -454,40 +469,44 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri let normal_index=generated_normal.len() as u32; generated_normal.push(CORNERWEDGE_DEFAULT_NORMALS[face_id]); //push vertices as they are needed - groups.push(IndexedGroup{ - texture:face_description.texture, - polys:vec![IndexedPolygon{ - vertices:cornerwedge_default_polys[face_id].iter().map(|tup|{ - let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; - let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ - pos_index - }else{ - //create new pos_index - let pos_index=generated_pos.len(); - generated_pos.push(pos); - pos_index - } as u32; - //always push vertex - let vertex=IndexedVertex{ - pos:pos_index, - tex:tup[1]+4*transform_index, - normal:normal_index, - color:color_index, - }; - let vert_index=generated_vertices.len(); - generated_vertices.push(vertex); - vert_index as u32 - }).collect(), - }], + let group_id=PolygonGroupId::new(polygon_groups.len() as u32); + polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![ + cornerwedge_default_polys[face_id].iter().map(|tup|{ + let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize]; + let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){ + pos_index + }else{ + //create new pos_index + let pos_index=generated_pos.len(); + generated_pos.push(pos); + pos_index + } as u32; + //always push vertex + let vertex=IndexedVertex{ + pos:PositionId::new(pos_index), + tex:TextureCoordinateId::new(tup[1]+4*transform_index), + normal:NormalId::new(normal_index), + color:ColorId::new(color_index), + }; + let vert_index=generated_vertices.len(); + generated_vertices.push(vertex); + VertexId::new(vert_index as u32) + }).collect(), + ]))); + graphics_groups.push(IndexedGraphicsGroup{ + render:face_description.render, + groups:vec![group_id], }); + physics_groups[0].groups.push(group_id); } - IndexedModel{ + Mesh{ unique_pos:generated_pos, unique_tex:generated_tex, unique_normal:generated_normal, unique_color:generated_color, unique_vertices:generated_vertices, - groups, - instances:Vec::new(), + polygon_groups, + graphics_groups, + physics_groups, } } diff --git a/src/rbx.rs b/src/rbx.rs index 8a76a87..ec8c051 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -1,6 +1,14 @@ +use std::collections::HashMap; use crate::primitives; -use strafesnet_common::gameplay_attributes; +use strafesnet_common::map; +use strafesnet_common::model; +use strafesnet_common::gameplay_modes; +use strafesnet_common::gameplay_style; +use strafesnet_common::gameplay_attributes as attr; use strafesnet_common::integer::{Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3}; +use strafesnet_common::model::RenderConfig; +use strafesnet_common::model::RenderConfigId; +use strafesnet_common::updatable::Updatable; fn class_is_a(class: &str, superclass: &str) -> bool { if class==superclass { @@ -40,91 +48,265 @@ fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_we Planar64Vec3::try_from([cf.position.x,cf.position.y,cf.position.z]).unwrap() ) } -fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,force_intersecting:bool)->model::CollisionAttributes{ - let mut general=model::GameMechanicAttributes::default(); - let mut intersecting=model::IntersectingAttributes::default(); - let mut contacting=model::ContactingAttributes::default(); +struct ModeBuilder{ + mode:gameplay_modes::Mode, + final_stage_id_from_builder_stage_id:HashMap, +} +#[derive(Default)] +struct ModesBuilder{ + modes:HashMap, + stages:HashMap>, + mode_updates:Vec<(gameplay_modes::ModeId,gameplay_modes::ModeUpdate)>, + stage_updates:Vec<(gameplay_modes::ModeId,gameplay_modes::StageId,gameplay_modes::StageUpdate)>, +} +impl ModesBuilder{ + fn build(mut self)->gameplay_modes::Modes{ + //collect modes and stages into contiguous arrays + let mut unique_modes:Vec<(gameplay_modes::ModeId,gameplay_modes::Mode)> + =self.modes.into_iter().collect(); + unique_modes.sort_by(|a,b|a.0.cmp(&b.0)); + let (mut modes,final_mode_id_from_builder_mode_id):(Vec,HashMap) + =unique_modes.into_iter().enumerate() + .map(|(final_mode_id,(builder_mode_id,mut mode))|{ + ( + ModeBuilder{ + final_stage_id_from_builder_stage_id:self.stages.remove(&builder_mode_id).map_or_else(||HashMap::new(),|stages|{ + let mut unique_stages:Vec<(gameplay_modes::StageId,gameplay_modes::Stage)> + =stages.into_iter().collect(); + unique_stages.sort_by(|a,b|a.0.cmp(&b.0)); + unique_stages.into_iter().enumerate() + .map(|(final_stage_id,(builder_stage_id,stage))|{ + mode.push_stage(stage); + (builder_stage_id,gameplay_modes::StageId::new(final_stage_id as u32)) + }).collect() + }), + mode, + }, + ( + builder_mode_id, + gameplay_modes::ModeId::new(final_mode_id as u32) + ) + ) + }).unzip(); + //TODO: failure messages or errors or something + //push stage updates + for (builder_mode_id,builder_stage_id,stage_update) in self.stage_updates{ + if let Some(final_mode_id)=final_mode_id_from_builder_mode_id.get(&builder_mode_id){ + if let Some(mode)=modes.get_mut(final_mode_id.get() as usize){ + if let Some(&final_stage_id)=mode.final_stage_id_from_builder_stage_id.get(&builder_stage_id){ + if let Some(stage)=mode.mode.get_stage_mut(final_stage_id){ + stage.update(stage_update); + } + } + } + } + } + //push mode updates + for (builder_mode_id,mut mode_update) in self.mode_updates{ + if let Some(final_mode_id)=final_mode_id_from_builder_mode_id.get(&builder_mode_id){ + if let Some(mode)=modes.get_mut(final_mode_id.get() as usize){ + //map stage id on stage elements + mode_update.map_stage_element_ids(|stage_id| + //walk down one stage id at a time until a stage is found + //TODO use better logic like BTreeMap::upper_bound instead of walking + // final_stage_id_from_builder_stage_id.upper_bound(Bound::Included(&stage_id)) + // .value().copied().unwrap_or(gameplay_modes::StageId::FIRST) + (0..=stage_id.get()).rev().find_map(|builder_stage_id| + //map the stage element to that stage + mode.final_stage_id_from_builder_stage_id.get(&gameplay_modes::StageId::new(builder_stage_id)).copied() + ).unwrap_or(gameplay_modes::StageId::FIRST) + ); + mode.mode.update(mode_update); + } + } + } + gameplay_modes::Modes::new(modes.into_iter().map(|mode_builder|mode_builder.mode).collect()) + } + fn insert_mode(&mut self,mode_id:gameplay_modes::ModeId,mode:gameplay_modes::Mode){ + assert!(self.modes.insert(mode_id,mode).is_none(),"Cannot replace existing mode"); + } + fn insert_stage(&mut self,mode_id:gameplay_modes::ModeId,stage_id:gameplay_modes::StageId,stage:gameplay_modes::Stage){ + assert!(self.stages.entry(mode_id).or_insert(HashMap::new()).insert(stage_id,stage).is_none(),"Cannot replace existing stage"); + } + fn push_mode_update(&mut self,mode_id:gameplay_modes::ModeId,mode_update:gameplay_modes::ModeUpdate){ + self.mode_updates.push((mode_id,mode_update)); + } + fn push_stage_update(&mut self,mode_id:gameplay_modes::ModeId,stage_id:gameplay_modes::StageId,stage_update:gameplay_modes::StageUpdate){ + self.stage_updates.push((mode_id,stage_id,stage_update)); + } +} +fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Planar64Vec3,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap,wormhole_id_to_out_model:&mut HashMap)->attr::CollisionAttributes{ + let name=object.name.as_str(); + let mut general=attr::GeneralAttributes::default(); + let mut intersecting=attr::IntersectingAttributes::default(); + let mut contacting=attr::ContactingAttributes::default(); let mut force_can_collide=can_collide; + let mut force_intersecting=false; match name{ "Water"=>{ force_can_collide=false; //TODO: read stupid CustomPhysicalProperties - intersecting.water=Some(model::IntersectingWater{density:Planar64::ONE,viscosity:Planar64::ONE/10,velocity}); + intersecting.water=Some(attr::IntersectingWater{density:Planar64::ONE,viscosity:Planar64::ONE/10,velocity}); }, "Accelerator"=>{ //although the new game supports collidable accelerators, this is a roblox compatability map loader force_can_collide=false; - general.accelerator=Some(model::GameMechanicAccelerator{acceleration:velocity}); + general.accelerator=Some(attr::Accelerator{acceleration:velocity}); }, - // "UnorderedCheckpoint"=>general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ + // "UnorderedCheckpoint"=>general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(attr::StageElement{ // mode_id:0, // stage_id:0, // force:false, // behaviour:model::StageElementBehaviour::Unordered // })), - "SetVelocity"=>general.trajectory=Some(model::GameMechanicSetTrajectory::Velocity(velocity)), - "MapFinish"=>{force_can_collide=false;general.zone=Some(model::GameMechanicZone{mode_id:0,behaviour:model::ZoneBehaviour::Finish})}, - "MapAnticheat"=>{force_can_collide=false;general.zone=Some(model::GameMechanicZone{mode_id:0,behaviour:model::ZoneBehaviour::Anitcheat})}, - "Platform"=>general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ - mode_id:0, - stage_id:0, - force:false, - behaviour:model::StageElementBehaviour::Platform, - })), + "SetVelocity"=>general.trajectory=Some(attr::SetTrajectory::Velocity(velocity)), + "MapStart"=>{ + force_can_collide=false; + force_intersecting=true; + modes_builder.insert_mode( + gameplay_modes::ModeId::MAIN, + gameplay_modes::Mode::new( + gameplay_style::StyleModifiers::roblox_bhop(), + model_id + ) + ); + }, + "MapFinish"=>{ + force_can_collide=false; + force_intersecting=true; + modes_builder.push_mode_update( + gameplay_modes::ModeId::MAIN, + gameplay_modes::ModeUpdate::zone( + model_id, + gameplay_modes::Zone::Finish, + ), + ); + }, + "MapAnticheat"=>{ + force_can_collide=false; + force_intersecting=true; + modes_builder.push_mode_update( + gameplay_modes::ModeId::MAIN, + gameplay_modes::ModeUpdate::zone( + model_id, + gameplay_modes::Zone::Anticheat, + ), + ); + }, + "Platform"=>{ + modes_builder.push_mode_update( + gameplay_modes::ModeId::MAIN, + gameplay_modes::ModeUpdate::element( + model_id, + gameplay_modes::StageElement::new(gameplay_modes::StageId::FIRST,false,gameplay_modes::StageElementBehaviour::Platform),//roblox does not know which stage the platform belongs to + ), + ); + }, other=>{ - if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$") + let regman=lazy_regex::regex!(r"^(BonusStart|WormholeOut)(\d+)$"); + if let Some(captures)=regman.captures(other){ + match &captures[1]{ + "BonusStart"=>{ + force_can_collide=false; + force_intersecting=true; + modes_builder.insert_mode( + gameplay_modes::ModeId::new(captures[2].parse::().unwrap()), + gameplay_modes::Mode::new( + gameplay_style::StyleModifiers::roblox_bhop(), + model_id + ) + ); + }, + "WormholeOut"=>{ + //the PhysicsModelId has to exist for it to be teleported to! + force_intersecting=true; + //this object is not special in strafe client, but the roblox mapping needs to be converted to model id + assert!(wormhole_id_to_out_model.insert(captures[2].parse::().unwrap(),model_id).is_none(),"Cannot have multiple WormholeOut with same id"); + }, + _=>(), + } + }else if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$") .captures(other){ - general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ - mode_id:0, - stage_id:captures[3].parse::().unwrap(), - force:match captures.get(1){ + force_intersecting=true; + let stage_id=gameplay_modes::StageId::new(captures[3].parse::().unwrap()); + let stage_element=gameplay_modes::StageElement::new( + //stage_id: + stage_id, + //force: + match captures.get(1){ Some(m)=>m.as_str()=="Force", None=>false, }, - behaviour:match &captures[2]{ - "Spawn"|"SpawnAt"=>model::StageElementBehaviour::SpawnAt, + //behaviour: + match &captures[2]{ + "Spawn"=>{ + modes_builder.insert_stage( + gameplay_modes::ModeId::MAIN, + stage_id, + gameplay_modes::Stage::new(model_id), + ); + //TODO: let denormalize handle this + gameplay_modes::StageElementBehaviour::SpawnAt + }, + "SpawnAt"=>gameplay_modes::StageElementBehaviour::SpawnAt, //cancollide false so you don't hit the side //NOT a decoration - "Trigger"=>{force_can_collide=false;model::StageElementBehaviour::Trigger}, - "Teleport"=>{force_can_collide=false;model::StageElementBehaviour::Teleport}, - "Platform"=>model::StageElementBehaviour::Platform, + "Trigger"=>{force_can_collide=false;gameplay_modes::StageElementBehaviour::Trigger}, + "Teleport"=>{force_can_collide=false;gameplay_modes::StageElementBehaviour::Teleport}, + "Platform"=>gameplay_modes::StageElementBehaviour::Platform, _=>panic!("regex1[2] messed up bad"), - } - })); - }else if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Jump)(\d+)$") - .captures(other){ - general.teleport_behaviour=Some(model::TeleportBehaviour::StageElement(model::GameMechanicStageElement{ - mode_id:0, - stage_id:0, - force:match captures.get(1){ - Some(m)=>m.as_str()=="Force", - None=>false, }, - behaviour:match &captures[2]{ - "Jump"=>model::StageElementBehaviour::JumpLimit(captures[3].parse::().unwrap()), - _=>panic!("regex4[1] messed up bad"), - } - })); + ); + modes_builder.push_mode_update( + gameplay_modes::ModeId::MAIN, + gameplay_modes::ModeUpdate::element( + model_id, + stage_element, + ), + ); + }else if let Some(captures)=lazy_regex::regex!(r"^(Jump|WormholeIn)(\d+)$") + .captures(other){ + match &captures[1]{ + "Jump"=>modes_builder.push_mode_update( + gameplay_modes::ModeId::MAIN, + gameplay_modes::ModeUpdate::jump_limit( + model_id, + //jump_limit: + captures[2].parse::().unwrap() + ), + ), + "WormholeIn"=>{ + force_can_collide=false; + force_intersecting=true; + assert!(wormhole_in_model_to_id.insert(model_id,captures[2].parse::().unwrap()).is_none(),"Impossible"); + }, + _=>panic!("regex2[1] messed up bad"), + } }else if let Some(captures)=lazy_regex::regex!(r"^Bonus(Finish|Anticheat)(\d+)$") .captures(other){ force_can_collide=false; - match &captures[1]{ - "Finish"=>general.zone=Some(model::GameMechanicZone{mode_id:captures[2].parse::().unwrap(),behaviour:model::ZoneBehaviour::Finish}), - "Anticheat"=>general.zone=Some(model::GameMechanicZone{mode_id:captures[2].parse::().unwrap(),behaviour:model::ZoneBehaviour::Anitcheat}), - _=>panic!("regex2[1] messed up bad"), - } - }else if let Some(captures)=lazy_regex::regex!(r"^(WormholeIn)(\d+)$") - .captures(other){ - force_can_collide=false; - match &captures[1]{ - "WormholeIn"=>general.teleport_behaviour=Some(model::TeleportBehaviour::Wormhole(model::GameMechanicWormhole{destination_model_id:captures[2].parse::().unwrap()})), - _=>panic!("regex3[1] messed up bad"), - } + force_intersecting=true; + modes_builder.push_mode_update( + gameplay_modes::ModeId::new(captures[2].parse::().unwrap()), + gameplay_modes::ModeUpdate::zone( + model_id, + //zone: + match &captures[1]{ + "Finish"=>gameplay_modes::Zone::Finish, + "Anticheat"=>gameplay_modes::Zone::Anticheat, + _=>panic!("regex3[1] messed up bad"), + }, + ), + ); } - // else if let Some(captures)=lazy_regex::regex!(r"^(OrderedCheckpoint)(\d+)$") + // else if let Some(captures)=lazy_regex::regex!(r"^Stage(\d+)OrderedCheckpoint(\d+)$") // .captures(other){ // match &captures[1]{ - // "OrderedCheckpoint"=>general.checkpoint=Some(model::GameMechanicCheckpoint::Ordered{mode_id:0,checkpoint_id:captures[2].parse::().unwrap()}), + // "OrderedCheckpoint"=>modes_builder.push_stage_update( + // gameplay_modes::ModeId::MAIN, + // gameplay_modes::StageId::new(0), + // gameplay_modes::StageUpdate::ordered_checkpoint(captures[2].parse::().unwrap()), + // ), // _=>panic!("regex3[1] messed up bad"), // } // } @@ -132,45 +314,29 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,force_interse } //need some way to skip this if velocity!=Planar64Vec3::ZERO{ - general.booster=Some(model::GameMechanicBooster::Velocity(velocity)); + general.booster=Some(attr::Booster::Velocity(velocity)); } match force_can_collide{ true=>{ match name{ - "Bounce"=>contacting.contact_behaviour=Some(model::ContactingBehaviour::Elastic(u32::MAX)), - "Surf"=>contacting.contact_behaviour=Some(model::ContactingBehaviour::Surf), - "Ladder"=>contacting.contact_behaviour=Some(model::ContactingBehaviour::Ladder(model::ContactingLadder{sticky:true})), + "Bounce"=>contacting.contact_behaviour=Some(attr::ContactingBehaviour::Elastic(u32::MAX)), + "Surf"=>contacting.contact_behaviour=Some(attr::ContactingBehaviour::Surf), + "Ladder"=>contacting.contact_behaviour=Some(attr::ContactingBehaviour::Ladder(attr::ContactingLadder{sticky:true})), _=>(), } - model::CollisionAttributes::Contact{contacting,general} + attr::CollisionAttributes::Contact{contacting,general} }, false=>if force_intersecting ||general.any() ||intersecting.any() { - model::CollisionAttributes::Intersect{intersecting,general} + attr::CollisionAttributes::Intersect{intersecting,general} }else{ - model::CollisionAttributes::Decoration + attr::CollisionAttributes::Decoration }, } } -struct RobloxAssetId(u64); -struct RobloxAssetIdParseErr; -impl std::str::FromStr for RobloxAssetId { - type Err=RobloxAssetIdParseErr; - fn from_str(s: &str) -> Result{ - let regman=lazy_regex::regex!(r"(\d+)$"); - if let Some(captures) = regman.captures(s) { - if captures.len()==2{//captures[0] is all captures concatenated, and then each individual capture - if let Ok(id) = captures[0].parse::() { - return Ok(Self(id)); - } - } - } - Err(RobloxAssetIdParseErr) - } -} #[derive(Clone,Copy,PartialEq)] struct RobloxTextureTransform{ offset_u:f32, @@ -180,12 +346,12 @@ struct RobloxTextureTransform{ } impl std::cmp::Eq for RobloxTextureTransform{}//???? impl std::default::Default for RobloxTextureTransform{ - fn default() -> Self { + fn default()->Self{ Self{offset_u:0.0,offset_v:0.0,scale_u:1.0,scale_v:1.0} } } -impl std::hash::Hash for RobloxTextureTransform { - fn hash(&self, state: &mut H) { +impl std::hash::Hash for RobloxTextureTransform{ + fn hash(&self,state:&mut H) { self.offset_u.to_ne_bytes().hash(state); self.offset_v.to_ne_bytes().hash(state); self.scale_u.to_ne_bytes().hash(state); @@ -194,16 +360,16 @@ impl std::hash::Hash for RobloxTextureTransform { } #[derive(Clone,PartialEq)] struct RobloxFaceTextureDescription{ - texture:u32, + render:RenderConfigId, color:glam::Vec4, transform:RobloxTextureTransform, } impl std::cmp::Eq for RobloxFaceTextureDescription{}//???? -impl std::hash::Hash for RobloxFaceTextureDescription { - fn hash(&self, state: &mut H) { - self.texture.hash(state); +impl std::hash::Hash for RobloxFaceTextureDescription{ + fn hash(&self,state:&mut H){ + self.render.hash(state); self.transform.hash(state); - for &el in self.color.as_ref().iter() { + for &el in self.color.as_ref().iter(){ el.to_ne_bytes().hash(state); } } @@ -211,7 +377,7 @@ impl std::hash::Hash for RobloxFaceTextureDescription { impl RobloxFaceTextureDescription{ fn to_face_description(&self)->primitives::FaceDescription{ primitives::FaceDescription{ - texture:Some(self.texture), + render:self.render, transform:glam::Affine2::from_translation( glam::vec2(self.transform.offset_u,self.transform.offset_v) ) @@ -233,15 +399,29 @@ enum RobloxBasePartDescription{ Wedge(RobloxWedgeDescription), CornerWedge(RobloxCornerWedgeDescription), } -pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModelInstances{ - //IndexedModelInstances includes textures - let mut spawn_point=Planar64Vec3::ZERO; +struct ModelOwnedAttributes{ + mesh:model::MeshId, + attributes:attr::CollisionAttributes, + color:model::Color4,//transparency is in here + transform:Planar64Affine3, +} +pub fn convertOption>(dom:rbx_dom_weak::WeakDom,mut acquire_id:F)->map::CompleteMap{ + let mut modes_builder=ModesBuilder::default(); - let mut indexed_models=Vec::new(); - let mut model_id_from_description=std::collections::HashMap::::new(); + let mut models1=Vec::new(); + let mut meshes=Vec::new(); + let mut indexed_model_id_from_description=HashMap::new(); - let mut texture_id_from_asset_id=std::collections::HashMap::::new(); - let mut asset_id_from_texture_id=Vec::new(); + let mut unique_attributes=Vec::new(); + let mut attributes_id_from_attributes=HashMap::new(); + + let mut wormhole_in_model_to_id=HashMap::new(); + let mut wormhole_id_to_out_model=HashMap::new(); + + //TODO: some sort of thing like RobloxResources that describes where to get each resource + //this would be another dependency built for downloading resources to keep this one clean + let mut unique_render_groups=vec![RenderConfig::default()]; + let textureless_render_group=RenderConfigId::new(0); let mut object_refs=Vec::new(); let mut temp_objects=Vec::new(); @@ -278,31 +458,8 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel continue; } - //push TempIndexedAttributes - let mut force_intersecting=false; - let mut temp_indexing_attributes=Vec::new(); - if let Some(attr)=match &object.name[..]{ - "MapStart"=>{ - spawn_point=model_transform.transform_point3(Planar64Vec3::ZERO)+Planar64Vec3::Y*5/2; - Some(model::TempIndexedAttributes::Start(model::TempAttrStart{mode_id:0})) - }, - other=>{ - let regman=lazy_regex::regex!(r"^(BonusStart|Spawn|ForceSpawn|WormholeOut)(\d+)$"); - if let Some(captures) = regman.captures(other) { - match &captures[1]{ - "BonusStart"=>Some(model::TempIndexedAttributes::Start(model::TempAttrStart{mode_id:captures[2].parse::().unwrap()})), - "Spawn"|"ForceSpawn"=>Some(model::TempIndexedAttributes::Spawn(model::TempAttrSpawn{mode_id:0,stage_id:captures[2].parse::().unwrap()})), - "WormholeOut"=>Some(model::TempIndexedAttributes::Wormhole(model::TempAttrWormhole{wormhole_id:captures[2].parse::().unwrap()})), - _=>None, - } - }else{ - None - } - } - }{ - force_intersecting=true; - temp_indexing_attributes.push(attr); - } + //at this point a new model is going to be generated for sure. + let model_id=model::ModelId::new(models1.len() as u32); //TODO: also detect "CylinderMesh" etc here let shape=match &object.class[..]{ @@ -346,15 +503,14 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel decal.properties.get("Color3"), decal.properties.get("Transparency"), ) { - if let Ok(asset_id)=content.clone().into_string().parse::(){ - let texture_id=if let Some(&texture_id)=texture_id_from_asset_id.get(&asset_id.0){ - texture_id - }else{ - let texture_id=asset_id_from_texture_id.len() as u32; - texture_id_from_asset_id.insert(asset_id.0,texture_id); - asset_id_from_texture_id.push(asset_id.0); - texture_id + if let Some(texture_id)=acquire_id(content.as_ref()){ + //this is equivalent to a get_or_create pattern because there is a singular no-texture RenderId + //so RenderId==TextureId+1 + //not the most failsafe code but this is just for the map tool lmao + if unique_render_groups.len()==texture_id.get() as usize+1{ + unique_render_groups.push(RenderConfig::texture(texture_id)); }; + let render_id=RenderConfigId::new(texture_id.get()+1); let normal_id=normalid.to_u32(); if normal_id<6{ let (roblox_texture_color,roblox_texture_transform)=if decal.class=="Texture"{ @@ -394,7 +550,7 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel (glam::Vec4::ONE,RobloxTextureTransform::default()) }; part_texture_description[normal_id as usize]=Some(RobloxFaceTextureDescription{ - texture:texture_id, + render:render_id, color:roblox_texture_color, transform:roblox_texture_transform, }); @@ -436,13 +592,13 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel ]), }; //make new model if unit cube has not been created before - let model_id=if let Some(&model_id)=model_id_from_description.get(&basepart_texture_description){ + let indexed_model_id=if let Some(&indexed_model_id)=indexed_model_id_from_description.get(&basepart_texture_description){ //push to existing texture model - model_id + indexed_model_id }else{ - let model_id=indexed_models.len(); - model_id_from_description.insert(basepart_texture_description.clone(),model_id);//borrow checker going crazy - indexed_models.push(match basepart_texture_description{ + let indexed_model_id=model::MeshId::new(meshes.len() as u32); + indexed_model_id_from_description.insert(basepart_texture_description.clone(),indexed_model_id);//borrow checker going crazy + meshes.push(match basepart_texture_description{ RobloxBasePartDescription::Sphere(part_texture_description) |RobloxBasePartDescription::Cylinder(part_texture_description) |RobloxBasePartDescription::Part(part_texture_description)=>{ @@ -460,7 +616,7 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel }, match roblox_face_description{ Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), - None=>primitives::FaceDescription::default(), + None=>primitives::FaceDescription::new_with_render_id(textureless_render_group), }); } primitives::generate_partial_unit_cube(cube_face_description) @@ -479,7 +635,7 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel }, match roblox_face_description{ Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), - None=>primitives::FaceDescription::default(), + None=>primitives::FaceDescription::new_with_render_id(textureless_render_group), }); } primitives::generate_partial_unit_wedge(wedge_face_description) @@ -498,27 +654,68 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> model::IndexedModel }, match roblox_face_description{ Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), - None=>primitives::FaceDescription::default(), + None=>primitives::FaceDescription::new_with_render_id(textureless_render_group), }); } primitives::generate_partial_unit_cornerwedge(cornerwedge_face_description) }, }); - model_id + indexed_model_id }; - indexed_models[model_id].instances.push(model::ModelInstance { + let attributes=get_attributes( + &object, + *can_collide, + Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(), + model_id, + &mut modes_builder, + &mut wormhole_in_model_to_id, + &mut wormhole_id_to_out_model, + ); + models1.push(ModelOwnedAttributes{ + mesh:indexed_model_id, transform:model_transform, color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency), - attributes:get_attributes(&object.name,*can_collide,Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(),force_intersecting), - temp_indexing:temp_indexing_attributes, + attributes, }); } } } - model::IndexedModelInstances{ - textures:asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(), - models:indexed_models, - spawn_point, - modes:Vec::new(), + let models=models1.into_iter().enumerate().map(|(model_id,mut model1)|{ + let model_id=model::ModelId::new(model_id as u32); + //update attributes with wormhole id + //TODO: errors/prints + if let Some(wormhole_id)=wormhole_in_model_to_id.get(&model_id){ + if let Some(&wormhole_out_model_id)=wormhole_id_to_out_model.get(wormhole_id){ + match &mut model1.attributes{ + attr::CollisionAttributes::Contact{contacting:_,general} + |attr::CollisionAttributes::Intersect{intersecting:_,general} + =>general.wormhole=Some(attr::Wormhole{destination_model:wormhole_out_model_id}), + attr::CollisionAttributes::Decoration=>println!("Not a wormhole"), + } + } + } + + //index the attributes + let attributes_id=if let Some(&attributes_id)=attributes_id_from_attributes.get(&model1.attributes){ + attributes_id + }else{ + let attributes_id=attr::CollisionAttributesId::new(unique_attributes.len() as u32); + attributes_id_from_attributes.insert(model1.attributes.clone(),attributes_id); + unique_attributes.push(model1.attributes); + attributes_id + }; + model::Model{ + mesh:model1.mesh, + transform:model1.transform, + color:model1.color, + attributes:attributes_id, + } + }).collect(); + map::CompleteMap{ + render_configs:unique_render_groups,//asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(), + meshes, + models, + modes:modes_builder.build(), + attributes:unique_attributes, } } From 0f3bd4420e38c48900ccb5783993f5edc5a71bd7 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 05:38:35 -0800 Subject: [PATCH 05/49] use unreachable instead of panic --- src/rbx.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rbx.rs b/src/rbx.rs index ec8c051..510db03 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -534,7 +534,7 @@ pub fn convertOption>(dom:rbx_dom_weak::WeakDo 3=>(size.z,size.y),//left 4=>(size.x,size.z),//bottom 5=>(size.x,size.y),//front - _=>panic!("unreachable"), + _=>unreachable!(), }; ( glam::vec4(decal_color3.r,decal_color3.g,decal_color3.b,1.0-*decal_transparency), @@ -612,7 +612,7 @@ pub fn convertOption>(dom:rbx_dom_weak::WeakDo 3=>primitives::CubeFace::Left, 4=>primitives::CubeFace::Bottom, 5=>primitives::CubeFace::Front, - _=>panic!("unreachable"), + _=>unreachable!(), }, match roblox_face_description{ Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), @@ -631,7 +631,7 @@ pub fn convertOption>(dom:rbx_dom_weak::WeakDo 2=>primitives::WedgeFace::Back, 3=>primitives::WedgeFace::Left, 4=>primitives::WedgeFace::Bottom, - _=>panic!("unreachable"), + _=>unreachable!(), }, match roblox_face_description{ Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), @@ -650,7 +650,7 @@ pub fn convertOption>(dom:rbx_dom_weak::WeakDo 2=>primitives::CornerWedgeFace::TopLeft, 3=>primitives::CornerWedgeFace::Bottom, 4=>primitives::CornerWedgeFace::Front, - _=>panic!("unreachable"), + _=>unreachable!(), }, match roblox_face_description{ Some(roblox_texture_transform)=>roblox_texture_transform.to_face_description(), From ed0dcdd051c6567bbbde81c49f511e8b31224dde Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 05:40:48 -0800 Subject: [PATCH 06/49] not todo --- src/primitives.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/primitives.rs b/src/primitives.rs index 518841c..2951071 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -207,8 +207,6 @@ impl FaceDescription{ } } } -//TODO: it's probably better to use a shared vertex buffer between all primitives and use indexed rendering instead of generating a unique vertex buffer for each primitive. -//implementation: put all roblox primitives into one model.groups <- this won't work but I forget why pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{ let mut generated_pos=Vec::new(); let mut generated_tex=Vec::new(); From 048e4083909d29cf8251582d64b5106f274aa56f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 05:43:37 -0800 Subject: [PATCH 07/49] prefer this code --- src/primitives.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/primitives.rs b/src/primitives.rs index 2951071..772c694 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -215,7 +215,7 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{ let mut generated_vertices=Vec::new(); let mut polygon_groups=Vec::new(); let mut graphics_groups=Vec::new(); - let mut physics_groups=vec![IndexedPhysicsGroup::default()]; + let mut physics_group=IndexedPhysicsGroup::default(); let mut transforms=Vec::new(); //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. for (face_id,face_description) in face_descriptions.pairs(){ @@ -271,7 +271,7 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{ render:face_description.render, groups:vec![group_id], }); - physics_groups[0].groups.push(group_id); + physics_group.groups.push(group_id); } Mesh{ unique_pos:generated_pos, @@ -281,7 +281,7 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{ unique_vertices:generated_vertices, polygon_groups, graphics_groups, - physics_groups, + physics_groups:vec![physics_group], } } //don't think too hard about the copy paste because this is all going into the map tool eventually... @@ -328,7 +328,7 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh let mut generated_vertices=Vec::new(); let mut polygon_groups=Vec::new(); let mut graphics_groups=Vec::new(); - let mut physics_groups=vec![IndexedPhysicsGroup::default()]; + let mut physics_group=IndexedPhysicsGroup::default(); let mut transforms=Vec::new(); //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. for (face_id,face_description) in face_descriptions.pairs(){ @@ -384,7 +384,7 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh render:face_description.render, groups:vec![group_id], }); - physics_groups[0].groups.push(group_id); + physics_group.groups.push(group_id); } Mesh{ unique_pos:generated_pos, @@ -394,7 +394,7 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh unique_vertices:generated_vertices, polygon_groups, graphics_groups, - physics_groups, + physics_groups:vec![physics_group], } } @@ -439,7 +439,7 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri let mut generated_vertices=Vec::new(); let mut polygon_groups=Vec::new(); let mut graphics_groups=Vec::new(); - let mut physics_groups=vec![IndexedPhysicsGroup::default()]; + let mut physics_group=IndexedPhysicsGroup::default(); let mut transforms=Vec::new(); //note that on a cube every vertex is guaranteed to be unique, so there's no need to hash them against existing vertices. for (face_id,face_description) in face_descriptions.pairs(){ @@ -495,7 +495,7 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri render:face_description.render, groups:vec![group_id], }); - physics_groups[0].groups.push(group_id); + physics_group.groups.push(group_id); } Mesh{ unique_pos:generated_pos, @@ -505,6 +505,6 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri unique_vertices:generated_vertices, polygon_groups, graphics_groups, - physics_groups, + physics_groups:vec![physics_group], } } From 3b038687b6a7f58255464a0ab2f2836b7f96d5cb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 06:58:39 -0800 Subject: [PATCH 08/49] rust master --- src/primitives.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/primitives.rs b/src/primitives.rs index 772c694..023945d 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -226,9 +226,9 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{ //create new transform_index let transform_index=transforms.len(); transforms.push(face_description.transform); - for tex in CUBE_DEFAULT_TEXTURE_COORDS{ - generated_tex.push(face_description.transform.transform_point2(tex)); - } + generated_tex.extend(CUBE_DEFAULT_TEXTURE_COORDS.map(|tex| + face_description.transform.transform_point2(tex) + )); transform_index } as u32; let color_index=if let Some(color_index)=generated_color.iter().position(|&color|color==face_description.color){ @@ -339,9 +339,9 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh //create new transform_index let transform_index=transforms.len(); transforms.push(face_description.transform); - for tex in CUBE_DEFAULT_TEXTURE_COORDS{ - generated_tex.push(face_description.transform.transform_point2(tex)); - } + generated_tex.extend(CUBE_DEFAULT_TEXTURE_COORDS.map(|tex| + face_description.transform.transform_point2(tex) + )); transform_index } as u32; let color_index=if let Some(color_index)=generated_color.iter().position(|&color|color==face_description.color){ @@ -450,9 +450,9 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri //create new transform_index let transform_index=transforms.len(); transforms.push(face_description.transform); - for tex in CUBE_DEFAULT_TEXTURE_COORDS{ - generated_tex.push(face_description.transform.transform_point2(tex)); - } + generated_tex.extend(CUBE_DEFAULT_TEXTURE_COORDS.map(|tex| + face_description.transform.transform_point2(tex) + )); transform_index } as u32; let color_index=if let Some(color_index)=generated_color.iter().position(|&color|color==face_description.color){ From 1c33646765ee6b976b276d8faede1144bc962eb4 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 21:27:30 -0800 Subject: [PATCH 09/49] pass as ref --- src/rbx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rbx.rs b/src/rbx.rs index 510db03..d67c980 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -405,7 +405,7 @@ struct ModelOwnedAttributes{ color:model::Color4,//transparency is in here transform:Planar64Affine3, } -pub fn convertOption>(dom:rbx_dom_weak::WeakDom,mut acquire_id:F)->map::CompleteMap{ +pub fn convertOption>(dom:&rbx_dom_weak::WeakDom,mut acquire_id:F)->map::CompleteMap{ let mut modes_builder=ModesBuilder::default(); let mut models1=Vec::new(); From 0b630576d4b2402277d55f0a53e9d048a31af9aa Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 21:27:28 -0800 Subject: [PATCH 10/49] wrapped types + implement error trait --- src/lib.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3b35ed8..20f397a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,24 +3,34 @@ use std::io::Read; mod rbx; mod primitives; +pub struct Dom(rbx_dom_weak::WeakDom); + #[derive(Debug)] -pub enum Error{ +pub enum ReadError{ RbxBinary(rbx_binary::DecodeError), RbxXml(rbx_xml::DecodeError), Io(std::io::Error), UnknownFileFormat, } +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{} -fn load_dom(input:R)->Result{ +pub fn read(input:R)->Result{ let mut buf=std::io::BufReader::new(input); - let peek=std::io::BufRead::fill_buf(&mut buf).map_err(Error::Io)?; + let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?; match &peek[0..8]{ - b"return rbx_binary::from_reader(buf).map_err(Error::RbxBinary), - b"return rbx_xml::from_reader_default(buf).map_err(Error::RbxXml), - _=>Err(Error::UnknownFileFormat), + b"rbx_binary::from_reader(buf).map(Dom).map_err(ReadError::RbxBinary), + b"rbx_xml::from_reader_default(buf).map(Dom).map_err(ReadError::RbxXml), + _=>Err(ReadError::UnknownFileFormat), } } -pub fn readOption>(input:R,acquire_id:F)->Result{ - Ok(rbx::convert(load_dom(input)?,acquire_id)) +//ConvertError + +pub fn convertOption>(dom:&Dom,acquire_id:F)->strafesnet_common::map::CompleteMap{ + rbx::convert(&dom.0,acquire_id) } \ No newline at end of file From bcaa28cf6a9f5f06161cc9375a5b720826108629 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 14 Feb 2024 23:38:29 -0800 Subject: [PATCH 11/49] implement new loading api --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 4 ++-- src/rbx.rs | 56 ++++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 180a3bd..00f0b4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,7 +420,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 0897aab..56c9c60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ rbx_binary = "0.7.4" rbx_dom_weak = "2.7.0" rbx_reflection_database = "0.2.10" rbx_xml = "0.13.3" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "47cdea0c8a5d10a2440ca6270a975d560aa3642d" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "093a54c527134ef7020a22a0f5778df8cba60228" } diff --git a/src/lib.rs b/src/lib.rs index 20f397a..412cb55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,6 +31,6 @@ pub fn read(input:R)->Result{ //ConvertError -pub fn convertOption>(dom:&Dom,acquire_id:F)->strafesnet_common::map::CompleteMap{ - rbx::convert(&dom.0,acquire_id) +pub fn convert)->strafesnet_common::model::RenderConfigId>(dom:&Dom,acquire_render_config_id:F)->rbx::PartialMap1{ + rbx::convert(&dom.0,acquire_render_config_id) } \ No newline at end of file diff --git a/src/rbx.rs b/src/rbx.rs index d67c980..57b9a56 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -405,7 +405,7 @@ struct ModelOwnedAttributes{ color:model::Color4,//transparency is in here transform:Planar64Affine3, } -pub fn convertOption>(dom:&rbx_dom_weak::WeakDom,mut acquire_id:F)->map::CompleteMap{ +pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak::WeakDom,mut acquire_render_config_id:F)->PartialMap1{ let mut modes_builder=ModesBuilder::default(); let mut models1=Vec::new(); @@ -418,10 +418,8 @@ pub fn convertOption>(dom:&rbx_dom_weak::WeakD let mut wormhole_in_model_to_id=HashMap::new(); let mut wormhole_id_to_out_model=HashMap::new(); - //TODO: some sort of thing like RobloxResources that describes where to get each resource - //this would be another dependency built for downloading resources to keep this one clean - let mut unique_render_groups=vec![RenderConfig::default()]; - let textureless_render_group=RenderConfigId::new(0); + //just going to leave it like this for now instead of reworking the data structures for this whole thing + let textureless_render_group=acquire_render_config_id(None); let mut object_refs=Vec::new(); let mut temp_objects=Vec::new(); @@ -503,14 +501,7 @@ pub fn convertOption>(dom:&rbx_dom_weak::WeakD decal.properties.get("Color3"), decal.properties.get("Transparency"), ) { - if let Some(texture_id)=acquire_id(content.as_ref()){ - //this is equivalent to a get_or_create pattern because there is a singular no-texture RenderId - //so RenderId==TextureId+1 - //not the most failsafe code but this is just for the map tool lmao - if unique_render_groups.len()==texture_id.get() as usize+1{ - unique_render_groups.push(RenderConfig::texture(texture_id)); - }; - let render_id=RenderConfigId::new(texture_id.get()+1); + let render_id=acquire_render_config_id(Some(content.as_ref())); let normal_id=normalid.to_u32(); if normal_id<6{ let (roblox_texture_color,roblox_texture_transform)=if decal.class=="Texture"{ @@ -557,7 +548,6 @@ pub fn convertOption>(dom:&rbx_dom_weak::WeakD }else{ println!("NormalId={} unsupported for shape={:?}",normal_id,shape); } - } } } } @@ -711,11 +701,45 @@ pub fn convertOption>(dom:&rbx_dom_weak::WeakD attributes:attributes_id, } }).collect(); - map::CompleteMap{ - render_configs:unique_render_groups,//asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(), + PartialMap1{ meshes, models, modes:modes_builder.build(), attributes:unique_attributes, } } + +pub struct PartialMap1{ + meshes:Vec, + models:Vec, + modes:gameplay_modes::Modes, + attributes:Vec, +} +impl PartialMap1{ + pub fn add_render_configs_and_textures( + self, + render_configs:impl IntoIterator, + textures:impl IntoIterator)>, + )->map::CompleteMap{ + let (textures,texture_id_map):(Vec>,HashMap) + =textures.into_iter().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.meshes, + models:self.models, + //the roblox legacy texture thing always works + textures, + render_configs, + } + } +} \ No newline at end of file From 34017ea72ce9b65fedcd6e376b4230fdb1cf6b5d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 14 Feb 2024 23:40:25 -0800 Subject: [PATCH 12/49] v0.2.0 new loading function signatures --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00f0b4e..efa1353 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.1.0" +version = "0.2.0" dependencies = [ "glam", "lazy-regex", diff --git a/Cargo.toml b/Cargo.toml index 56c9c60..697ee6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.1.0" +version = "0.2.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From e0739fa792ad506e210f076b90697194005bb7de Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 15 Feb 2024 00:40:37 -0800 Subject: [PATCH 13/49] use utf8 patched version --- Cargo.lock | 18 ++++++------------ Cargo.toml | 8 ++++---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efa1353..99790ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,8 +272,7 @@ dependencies = [ [[package]] name = "rbx_binary" version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6314dd6bf5c21d0598cdb53cf5d241aa643ba41da8b8abf7402b4a35096f03f6" +source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "log", "lz4", @@ -287,8 +286,7 @@ dependencies = [ [[package]] name = "rbx_dom_weak" version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b67b56bac99849c2e3c57547b036927f71c57cf7f4d900d04e3e4ee774ec316" +source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "rbx_types", "serde", @@ -297,8 +295,7 @@ dependencies = [ [[package]] name = "rbx_reflection" version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d41509c991b53a7276a746a795eae2b9204f398164920f61976995b47fe1722" +source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "rbx_types", "serde", @@ -308,8 +305,7 @@ dependencies = [ [[package]] name = "rbx_reflection_database" version = "0.2.10+roblox-607" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e20c06fa41f7aadc79005c8354f592b2c2f4d0c61e1080ed5718dafc30aea0" +source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "lazy_static", "rbx_reflection", @@ -320,8 +316,7 @@ dependencies = [ [[package]] name = "rbx_types" version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca23bfd469d067d81ef14f65fe09aeddc25abcf576a889d1a7664fe021cf18c" +source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "base64", "bitflags", @@ -335,8 +330,7 @@ dependencies = [ [[package]] name = "rbx_xml" version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c03f95500961c32340791d1fabd4587f6873bdbff077ecca6ae32db7960dea" +source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "base64", "log", diff --git a/Cargo.toml b/Cargo.toml index 697ee6d..3667961 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] glam = "0.25.0" lazy-regex = "3.1.0" -rbx_binary = "0.7.4" -rbx_dom_weak = "2.7.0" -rbx_reflection_database = "0.2.10" -rbx_xml = "0.13.3" +rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } +rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } +rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } +rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "093a54c527134ef7020a22a0f5778df8cba60228" } From 261e42c33d3528f7ddbd3c1e16141d68281ae6a4 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 15 Feb 2024 00:46:43 -0800 Subject: [PATCH 14/49] unused import --- src/rbx.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rbx.rs b/src/rbx.rs index 57b9a56..00c0714 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -6,7 +6,6 @@ use strafesnet_common::gameplay_modes; use strafesnet_common::gameplay_style; use strafesnet_common::gameplay_attributes as attr; use strafesnet_common::integer::{Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3}; -use strafesnet_common::model::RenderConfig; use strafesnet_common::model::RenderConfigId; use strafesnet_common::updatable::Updatable; From cc7713ca733fa455d34c1b51b8bdf8930787be5f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 21 Feb 2024 02:34:17 -0800 Subject: [PATCH 15/49] jump_limit changes --- src/rbx.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rbx.rs b/src/rbx.rs index 00c0714..8c41b20 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -197,7 +197,7 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana gameplay_modes::ModeId::MAIN, gameplay_modes::ModeUpdate::element( model_id, - gameplay_modes::StageElement::new(gameplay_modes::StageId::FIRST,false,gameplay_modes::StageElementBehaviour::Platform),//roblox does not know which stage the platform belongs to + gameplay_modes::StageElement::new(gameplay_modes::StageId::FIRST,false,gameplay_modes::StageElementBehaviour::Platform,None),//roblox does not know which stage the platform belongs to ), ); }, @@ -255,6 +255,7 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana "Platform"=>gameplay_modes::StageElementBehaviour::Platform, _=>panic!("regex1[2] messed up bad"), }, + None ); modes_builder.push_mode_update( gameplay_modes::ModeId::MAIN, @@ -268,10 +269,15 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana match &captures[1]{ "Jump"=>modes_builder.push_mode_update( gameplay_modes::ModeId::MAIN, - gameplay_modes::ModeUpdate::jump_limit( + gameplay_modes::ModeUpdate::element( model_id, //jump_limit: - captures[2].parse::().unwrap() + gameplay_modes::StageElement::new( + gameplay_modes::StageId::FIRST, + false, + gameplay_modes::StageElementBehaviour::Check, + Some(captures[2].parse::().unwrap()) + ) ), ), "WormholeIn"=>{ From 5ed15e783d1ad100585d09eff3bdca4a62caaba5 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 2 Mar 2024 05:01:44 -0800 Subject: [PATCH 16/49] update common --- Cargo.lock | 58 +++++++++++++++++++++++++++++------------------------- Cargo.toml | 2 +- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99790ad..0bcff0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,6 +41,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "blake3" version = "1.5.0" @@ -62,12 +68,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" [[package]] name = "cfg-if" @@ -139,15 +142,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[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 = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lz4" @@ -177,9 +180,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", ] @@ -213,18 +216,18 @@ dependencies = [ [[package]] name = "profiling" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0f7f43585c34e4fdd7497d746bc32e14458cf11c69341cc0587b1d825dde42" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" dependencies = [ "profiling-procmacros", ] [[package]] name = "profiling-procmacros" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce97fecd27bc49296e5e20518b5a1bb54a14f7d5fe6228bc9686ee2a74915cc8" +checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", "syn", @@ -319,7 +322,7 @@ version = "1.8.0" source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" dependencies = [ "base64", - "bitflags", + "bitflags 1.3.2", "blake3", "lazy_static", "rand", @@ -393,18 +396,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", @@ -414,8 +417,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=ef922135e6d19f296d8e4d90df0d0d71fa3412e2#ef922135e6d19f296d8e4d90df0d0d71fa3412e2" dependencies = [ + "bitflags 2.4.2", "glam", "id", ] @@ -435,9 +439,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", @@ -446,18 +450,18 @@ 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", diff --git a/Cargo.toml b/Cargo.toml index 3667961..00d94f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "093a54c527134ef7020a22a0f5778df8cba60228" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "ef922135e6d19f296d8e4d90df0d0d71fa3412e2" } From fab60f19eee924137e5201378ba6dee644847088 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 9 Mar 2024 10:06:41 -0800 Subject: [PATCH 17/49] misc --- src/rbx.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/rbx.rs b/src/rbx.rs index 8c41b20..f7626c7 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -19,7 +19,7 @@ fn class_is_a(class: &str, superclass: &str) -> bool { return class_is_a(&class_super, superclass) } } - return false + false } fn recursive_collect_superclass(objects: &mut std::vec::Vec,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance, superclass: &str){ let mut stack=vec![instance]; @@ -465,20 +465,18 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: let model_id=model::ModelId::new(models1.len() as u32); //TODO: also detect "CylinderMesh" etc here - let shape=match &object.class[..]{ - "Part"=>{ - if let Some(rbx_dom_weak::types::Variant::Enum(shape))=object.properties.get("Shape"){ - match shape.to_u32(){ - 0=>primitives::Primitives::Sphere, - 1=>primitives::Primitives::Cube, - 2=>primitives::Primitives::Cylinder, - 3=>primitives::Primitives::Wedge, - 4=>primitives::Primitives::CornerWedge, - _=>panic!("Funky roblox PartType={};",shape.to_u32()), - } - }else{ - panic!("Part has no Shape!"); + let shape=match object.class.as_str(){ + "Part"=>if let Some(rbx_dom_weak::types::Variant::Enum(shape))=object.properties.get("Shape"){ + match shape.to_u32(){ + 0=>primitives::Primitives::Sphere, + 1=>primitives::Primitives::Cube, + 2=>primitives::Primitives::Cylinder, + 3=>primitives::Primitives::Wedge, + 4=>primitives::Primitives::CornerWedge, + other=>panic!("Funky roblox PartType={};",other), } + }else{ + panic!("Part has no Shape!"); }, "TrussPart"=>primitives::Primitives::Cube, "WedgePart"=>primitives::Primitives::Wedge, From c835183abd843953ec500b0dbfb73faa3feff1bb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 13 Mar 2024 13:36:25 -0700 Subject: [PATCH 18/49] add rbx_mesh dep --- Cargo.lock | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 1 + 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bcff0f..88f02fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "array-init" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" + [[package]] name = "arrayref" version = "0.3.7" @@ -35,6 +41,30 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[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 = "1.3.2" @@ -60,6 +90,12 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "bytemuck" +version = "1.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" + [[package]] name = "byteorder" version = "1.5.0" @@ -84,6 +120,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "getrandom" version = "0.2.12" @@ -108,7 +150,7 @@ source = "git+https://git.itzana.me/Quaternions/id?rev=1f710976cc786c8853dab73d6 dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.52", ] [[package]] @@ -131,7 +173,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 2.0.52", ] [[package]] @@ -193,6 +235,12 @@ 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 = "paste" version = "1.0.14" @@ -230,7 +278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn", + "syn 2.0.52", ] [[package]] @@ -295,6 +343,15 @@ dependencies = [ "serde", ] +[[package]] +name = "rbx_mesh" +version = "0.1.0" +source = "git+https://github.com/krakow10/rbx_mesh?rev=0e1c66d9acc7e1f2c187dd0899a9434d93ae0453#0e1c66d9acc7e1f2c187dd0899a9434d93ae0453" +dependencies = [ + "binrw", + "lazy-regex", +] + [[package]] name = "rbx_reflection" version = "4.5.0" @@ -411,7 +468,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.52", ] [[package]] @@ -432,11 +489,23 @@ dependencies = [ "lazy-regex", "rbx_binary", "rbx_dom_weak", + "rbx_mesh", "rbx_reflection_database", "rbx_xml", "strafesnet_common", ] +[[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.52" @@ -465,7 +534,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.52", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 00d94f0..2443787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,4 @@ rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "84164317868 rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "ef922135e6d19f296d8e4d90df0d0d71fa3412e2" } +rbx_mesh = { git = "https://github.com/krakow10/rbx_mesh", rev = "0e1c66d9acc7e1f2c187dd0899a9434d93ae0453" } From 775d1972dcb89b9afc69b89a79d1bdcfbd8910be Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 13 Mar 2024 13:33:51 -0700 Subject: [PATCH 19/49] update common --- Cargo.lock | 3 ++- Cargo.toml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88f02fc..068a65f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ dependencies = [ [[package]] name = "strafesnet_common" version = "0.1.0" -source = "git+https://git.itzana.me/StrafesNET/common?rev=ef922135e6d19f296d8e4d90df0d0d71fa3412e2#ef922135e6d19f296d8e4d90df0d0d71fa3412e2" +source = "git+https://git.itzana.me/StrafesNET/common?rev=a9f3e61f2bb1074025b6cb466a5e3f2abc988c34#a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" dependencies = [ "bitflags 2.4.2", "glam", @@ -485,6 +485,7 @@ dependencies = [ name = "strafesnet_rbx_loader" version = "0.2.0" dependencies = [ + "bytemuck", "glam", "lazy-regex", "rbx_binary", diff --git a/Cargo.toml b/Cargo.toml index 2443787..ca8ab99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,6 @@ rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "ef922135e6d19f296d8e4d90df0d0d71fa3412e2" } rbx_mesh = { git = "https://github.com/krakow10/rbx_mesh", rev = "0e1c66d9acc7e1f2c187dd0899a9434d93ae0453" } +strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" } +bytemuck = "1.14.3" From 1f2ad779f1119d795b666df073df6cbfb91f3598 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 13 Mar 2024 13:34:06 -0700 Subject: [PATCH 20/49] roblox mesh converter + loading --- src/lib.rs | 25 ++++- src/mesh.rs | 210 ++++++++++++++++++++++++++++++++++++++++ src/rbx.rs | 269 +++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 448 insertions(+), 56 deletions(-) create mode 100644 src/mesh.rs diff --git a/src/lib.rs b/src/lib.rs index 412cb55..c04c7d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,21 @@ use std::io::Read; mod rbx; +mod mesh; mod primitives; +pub mod data{ + pub struct RobloxMeshBytes(Vec); + impl RobloxMeshBytes{ + pub fn new(bytes:Vec)->Self{ + Self(bytes) + } + pub(crate) fn cursor(self)->std::io::Cursor>{ + std::io::Cursor::new(self.0) + } + } +} + pub struct Dom(rbx_dom_weak::WeakDom); #[derive(Debug)] @@ -31,6 +44,14 @@ pub fn read(input:R)->Result{ //ConvertError -pub fn convert)->strafesnet_common::model::RenderConfigId>(dom:&Dom,acquire_render_config_id:F)->rbx::PartialMap1{ - rbx::convert(&dom.0,acquire_render_config_id) +pub fn convert( + dom:&Dom, + acquire_render_config_id:AcquireRenderConfigId, + acquire_mesh_id:AcquireMeshId +)->rbx::PartialMap1 +where + AcquireRenderConfigId:FnMut(Option<&str>)->strafesnet_common::model::RenderConfigId, + AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId, +{ + rbx::convert(&dom.0,acquire_render_config_id,acquire_mesh_id) } \ No newline at end of file diff --git a/src/mesh.rs b/src/mesh.rs new file mode 100644 index 0000000..3215118 --- /dev/null +++ b/src/mesh.rs @@ -0,0 +1,210 @@ +use std::collections::HashMap; + +use rbx_mesh::mesh::{Vertex2, Vertex2Truncated}; +use strafesnet_common::{integer::Planar64Vec3,model::{self, ColorId, IndexedVertex, NormalId, PolygonGroup, PolygonList, PositionId, TextureCoordinateId, VertexId}}; + +#[derive(Debug)] +pub enum Error{ + Planar64Vec3(strafesnet_common::integer::Planar64TryFromFloatError), + RbxMesh(rbx_mesh::mesh::Error) +} +impl std::fmt::Display for Error{ + fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ + write!(f,"{self:?}") + } +} +impl std::error::Error for Error{} + +fn ingest_vertices2< + AcquirePosId, + AcquireTexId, + AcquireNormalId, + AcquireColorId, + AcquireVertexId, +>( + vertices:Vec, + acquire_pos_id:&mut AcquirePosId, + acquire_tex_id:&mut AcquireTexId, + acquire_normal_id:&mut AcquireNormalId, + acquire_color_id:&mut AcquireColorId, + acquire_vertex_id:&mut AcquireVertexId, +)->Result,Error> +where + AcquirePosId:FnMut([f32;3])->Result, + AcquireTexId:FnMut([f32;2])->TextureCoordinateId, + AcquireNormalId:FnMut([f32;3])->Result, + AcquireColorId:FnMut([f32;4])->ColorId, + AcquireVertexId:FnMut(IndexedVertex)->VertexId, +{ + //this monster is collecting a map of old_vertices_index -> unique_vertices_index + //while also doing the inserting unique entries into lists simultaneously + Ok(vertices.into_iter().enumerate().map(|(vertex_id,vertex)|Ok(( + rbx_mesh::mesh::VertexId2(vertex_id as u32), + acquire_vertex_id(IndexedVertex{ + pos:acquire_pos_id(vertex.pos)?, + tex:acquire_tex_id(vertex.tex), + normal:acquire_normal_id(vertex.norm)?, + color:acquire_color_id(vertex.color.map(|f|f as f32/255.0f32)) + }), + ))).collect::>()?) +} +fn ingest_vertices_truncated2< + AcquirePosId, + AcquireTexId, + AcquireNormalId, + AcquireVertexId, +>( + vertices:Vec, + acquire_pos_id:&mut AcquirePosId, + acquire_tex_id:&mut AcquireTexId, + acquire_normal_id:&mut AcquireNormalId, + static_color_id:ColorId,//pick one color and fill everything with it + acquire_vertex_id:&mut AcquireVertexId, +)->Result,Error> +where + AcquirePosId:FnMut([f32;3])->Result, + AcquireTexId:FnMut([f32;2])->TextureCoordinateId, + AcquireNormalId:FnMut([f32;3])->Result, + AcquireVertexId:FnMut(IndexedVertex)->VertexId, +{ + //this monster is collecting a map of old_vertices_index -> unique_vertices_index + //while also doing the inserting unique entries into lists simultaneously + Ok(vertices.into_iter().enumerate().map(|(vertex_id,vertex)|Ok(( + rbx_mesh::mesh::VertexId2(vertex_id as u32), + acquire_vertex_id(IndexedVertex{ + pos:acquire_pos_id(vertex.pos)?, + tex:acquire_tex_id(vertex.tex), + normal:acquire_normal_id(vertex.norm)?, + color:static_color_id + }), + ))).collect::>()?) +} + +fn ingest_faces2_lods3( + polygon_groups:&mut Vec, + vertex_id_map:&HashMap, + faces:&Vec, + lods:&Vec +){ + //faces have to be split into polygon groups based on lod + polygon_groups.extend(lods.windows(2).map(|lod_pair| + PolygonGroup::PolygonList(PolygonList::new(faces[lod_pair[0].0 as usize..lod_pair[1].0 as usize].iter().map(|face| + vec![vertex_id_map[&face.0],vertex_id_map[&face.1],vertex_id_map[&face.2]] + ).collect())) + )) +} + +pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result{ + //generate that mesh boi + let mut unique_pos=Vec::new(); + let mut pos_id_from=HashMap::new(); + let mut unique_tex=Vec::new(); + let mut tex_id_from=HashMap::new(); + let mut unique_normal=Vec::new(); + let mut normal_id_from=HashMap::new(); + let mut unique_color=Vec::new(); + let mut color_id_from=HashMap::new(); + let mut unique_vertices=Vec::new(); + let mut vertex_id_from=HashMap::new(); + let mut polygon_groups=Vec::new(); + let mut acquire_pos_id=|pos|{ + let p=Planar64Vec3::try_from(pos).map_err(Error::Planar64Vec3)?; + Ok(PositionId::new(*pos_id_from.entry(p).or_insert_with(||{ + let pos_id=unique_pos.len(); + unique_pos.push(p); + pos_id + }) as u32)) + }; + let mut acquire_tex_id=|tex|{ + let h=bytemuck::cast::<[f32;2],[u32;2]>(tex); + TextureCoordinateId::new(*tex_id_from.entry(h).or_insert_with(||{ + let tex_id=unique_tex.len(); + unique_tex.push(glam::Vec2::from_array(tex)); + tex_id + }) as u32) + }; + let mut acquire_normal_id=|normal|{ + let n=Planar64Vec3::try_from(normal).map_err(Error::Planar64Vec3)?; + Ok(NormalId::new(*normal_id_from.entry(n).or_insert_with(||{ + let normal_id=unique_normal.len(); + unique_normal.push(n); + normal_id + }) as u32)) + }; + let mut acquire_color_id=|color|{ + let h=bytemuck::cast::<[f32;4],[u32;4]>(color); + ColorId::new(*color_id_from.entry(h).or_insert_with(||{ + let color_id=unique_color.len(); + unique_color.push(glam::Vec4::from_array(color)); + color_id + }) as u32) + }; + let mut acquire_vertex_id=|vertex:IndexedVertex|{ + VertexId::new(*vertex_id_from.entry(vertex.clone()).or_insert_with(||{ + let vertex_id=unique_vertices.len(); + unique_vertices.push(vertex); + vertex_id + }) as u32) + }; + match rbx_mesh::read_versioned(roblox_mesh_bytes.cursor()).map_err(Error::RbxMesh)?{ + rbx_mesh::mesh::VersionedMesh::Version1(mesh)=>{ + let color_id=acquire_color_id([1.0f32;4]); + polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(mesh.vertices.chunks_exact(3).map(|trip|{ + let mut ingest_vertex1=|vertex:&rbx_mesh::mesh::Vertex1|Ok(acquire_vertex_id(IndexedVertex{ + pos:acquire_pos_id(vertex.pos)?, + tex:acquire_tex_id([vertex.tex[0],vertex.tex[1]]), + normal:acquire_normal_id(vertex.norm)?, + color:color_id, + })); + Ok(vec![ingest_vertex1(&trip[0])?,ingest_vertex1(&trip[1])?,ingest_vertex1(&trip[2])?]) + }).collect::>()?))); + }, + rbx_mesh::mesh::VersionedMesh::Version2(mesh)=>{ + let vertex_id_map=match mesh.header.sizeof_vertex{ + rbx_mesh::mesh::SizeOfVertex2::Truncated=>{ + //pick white and make all the vertices white + let color_id=acquire_color_id([1.0f32;4]); + ingest_vertices_truncated2(mesh.vertices_truncated,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,color_id,&mut acquire_vertex_id) + }, + rbx_mesh::mesh::SizeOfVertex2::Full=>ingest_vertices2(mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id), + }?; + //one big happy group for all the faces + polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(mesh.faces.into_iter().map(|face| + vec![vertex_id_map[&face.0],vertex_id_map[&face.1],vertex_id_map[&face.2]] + ).collect()))); + }, + rbx_mesh::mesh::VersionedMesh::Version3(mesh)=>{ + let vertex_id_map=match mesh.header.sizeof_vertex{ + rbx_mesh::mesh::SizeOfVertex2::Truncated=>{ + let color_id=acquire_color_id([1.0f32;4]); + ingest_vertices_truncated2(mesh.vertices_truncated,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,color_id,&mut acquire_vertex_id) + }, + rbx_mesh::mesh::SizeOfVertex2::Full=>ingest_vertices2(mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id), + }?; + ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods); + }, + rbx_mesh::mesh::VersionedMesh::Version4(mesh)=>{ + let vertex_id_map=ingest_vertices2( + mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id + )?; + ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods); + }, + rbx_mesh::mesh::VersionedMesh::Version5(mesh)=>{ + let vertex_id_map=ingest_vertices2( + mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id + )?; + ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods); + }, + } + Ok(model::Mesh{ + unique_pos, + unique_normal, + unique_tex, + unique_color, + unique_vertices, + polygon_groups, + //these should probably be moved to the model... + graphics_groups:Vec::new(), + physics_groups:Vec::new(), + }) +} \ No newline at end of file diff --git a/src/rbx.rs b/src/rbx.rs index f7626c7..d63c4ae 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -134,8 +134,7 @@ impl ModesBuilder{ self.stage_updates.push((mode_id,stage_id,stage_update)); } } -fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Planar64Vec3,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap,wormhole_id_to_out_model:&mut HashMap)->attr::CollisionAttributes{ - let name=object.name.as_str(); +fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap,wormhole_id_to_out_model:&mut HashMap)->attr::CollisionAttributes{ let mut general=attr::GeneralAttributes::default(); let mut intersecting=attr::IntersectingAttributes::default(); let mut contacting=attr::ContactingAttributes::default(); @@ -404,24 +403,49 @@ enum RobloxBasePartDescription{ Wedge(RobloxWedgeDescription), CornerWedge(RobloxCornerWedgeDescription), } +enum Shape{ + Primitive(primitives::Primitives), + MeshPart, +} +enum MeshAvailability{ + Immediate, + Deferred(RenderConfigId), +} +struct DeferredModelDeferredAttributes{ + render:RenderConfigId, + model:ModelDeferredAttributes, +} +struct ModelDeferredAttributes{ + mesh:model::MeshId, + deferred_attributes:GetAttributesArgs, + color:model::Color4,//transparency is in here + transform:Planar64Affine3, +} struct ModelOwnedAttributes{ mesh:model::MeshId, attributes:attr::CollisionAttributes, color:model::Color4,//transparency is in here transform:Planar64Affine3, } -pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak::WeakDom,mut acquire_render_config_id:F)->PartialMap1{ - let mut modes_builder=ModesBuilder::default(); +struct GetAttributesArgs{ + name:Box, + can_collide:bool, + velocity:Planar64Vec3, +} +pub fn convert( + dom:&rbx_dom_weak::WeakDom, + mut acquire_render_config_id:AcquireRenderConfigId, + mut acquire_mesh_id:AcquireMeshId, +)->PartialMap1 +where + AcquireRenderConfigId:FnMut(Option<&str>)->model::RenderConfigId, + AcquireMeshId:FnMut(&str)->model::MeshId, +{ - let mut models1=Vec::new(); - let mut meshes=Vec::new(); - let mut indexed_model_id_from_description=HashMap::new(); - - let mut unique_attributes=Vec::new(); - let mut attributes_id_from_attributes=HashMap::new(); - - let mut wormhole_in_model_to_id=HashMap::new(); - let mut wormhole_id_to_out_model=HashMap::new(); + let mut deferred_models_deferred_attributes=Vec::new(); + let mut primitive_models_deferred_attributes=Vec::new(); + let mut primitive_meshes=Vec::new(); + let mut mesh_id_from_description=HashMap::new(); //just going to leave it like this for now instead of reworking the data structures for this whole thing let textureless_render_group=acquire_render_config_id(None); @@ -462,31 +486,35 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: } //at this point a new model is going to be generated for sure. - let model_id=model::ModelId::new(models1.len() as u32); + let model_id=model::ModelId::new(primitive_models_deferred_attributes.len() as u32); //TODO: also detect "CylinderMesh" etc here let shape=match object.class.as_str(){ "Part"=>if let Some(rbx_dom_weak::types::Variant::Enum(shape))=object.properties.get("Shape"){ - match shape.to_u32(){ + Shape::Primitive(match shape.to_u32(){ 0=>primitives::Primitives::Sphere, 1=>primitives::Primitives::Cube, 2=>primitives::Primitives::Cylinder, 3=>primitives::Primitives::Wedge, 4=>primitives::Primitives::CornerWedge, other=>panic!("Funky roblox PartType={};",other), - } + }) }else{ panic!("Part has no Shape!"); }, - "TrussPart"=>primitives::Primitives::Cube, - "WedgePart"=>primitives::Primitives::Wedge, - "CornerWedgePart"=>primitives::Primitives::CornerWedge, + "TrussPart"=>Shape::Primitive(primitives::Primitives::Cube), + "WedgePart"=>Shape::Primitive(primitives::Primitives::Wedge), + "CornerWedgePart"=>Shape::Primitive(primitives::Primitives::CornerWedge), + "MeshPart"=>Shape::MeshPart, _=>{ println!("Unsupported BasePart ClassName={}; defaulting to cube",object.class); - primitives::Primitives::Cube + Shape::Primitive(primitives::Primitives::Cube) } }; + let (availability,mesh_id)=match shape{ + Shape::Primitive(primitive_shape)=>{ + //TODO: TAB TAB //use the biggest one and cut it down later... let mut part_texture_description:RobloxPartDescription=[None,None,None,None,None,None]; temp_objects.clear(); @@ -549,7 +577,7 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: transform:roblox_texture_transform, }); }else{ - println!("NormalId={} unsupported for shape={:?}",normal_id,shape); + println!("NormalId={} unsupported for shape={:?}",normal_id,primitive_shape); } } } @@ -563,7 +591,7 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: f4,//Cube::Bottom f5,//Cube::Front ]=part_texture_description; - let basepart_texture_description=match shape{ + let basepart_description=match primitive_shape{ primitives::Primitives::Sphere=>RobloxBasePartDescription::Sphere([f0,f1,f2,f3,f4,f5]), primitives::Primitives::Cube=>RobloxBasePartDescription::Part([f0,f1,f2,f3,f4,f5]), primitives::Primitives::Cylinder=>RobloxBasePartDescription::Cylinder([f0,f1,f2,f3,f4,f5]), @@ -585,13 +613,13 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: ]), }; //make new model if unit cube has not been created before - let indexed_model_id=if let Some(&indexed_model_id)=indexed_model_id_from_description.get(&basepart_texture_description){ + let mesh_id=if let Some(&mesh_id)=mesh_id_from_description.get(&basepart_description){ //push to existing texture model - indexed_model_id + mesh_id }else{ - let indexed_model_id=model::MeshId::new(meshes.len() as u32); - indexed_model_id_from_description.insert(basepart_texture_description.clone(),indexed_model_id);//borrow checker going crazy - meshes.push(match basepart_texture_description{ + let mesh_id=model::MeshId::new(primitive_meshes.len() as u32); + mesh_id_from_description.insert(basepart_description.clone(),mesh_id);//borrow checker going crazy + let mesh=match basepart_description{ RobloxBasePartDescription::Sphere(part_texture_description) |RobloxBasePartDescription::Cylinder(part_texture_description) |RobloxBasePartDescription::Part(part_texture_description)=>{ @@ -652,34 +680,166 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: } primitives::generate_partial_unit_cornerwedge(cornerwedge_face_description) }, - }); - indexed_model_id + }; + primitive_meshes.push(mesh); + mesh_id }; - let attributes=get_attributes( - &object, - *can_collide, - Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(), + (MeshAvailability::Immediate,mesh_id) + }, + Shape::MeshPart=>if let ( + Some(rbx_dom_weak::types::Variant::Content(mesh_asset_id)), + Some(rbx_dom_weak::types::Variant::Content(texture_asset_id)), + )=( + object.properties.get("MeshId"), + object.properties.get("TextureID"), + ){ + ( + MeshAvailability::Deferred(acquire_render_config_id(Some(texture_asset_id.as_ref()))), + acquire_mesh_id(mesh_asset_id.as_ref()), + ) + }else{ + panic!("Mesh has no Mesh or Texture"); + }, + }; + let model_deferred_attributes=ModelDeferredAttributes{ + mesh:mesh_id, + transform:model_transform, + color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency), + deferred_attributes:GetAttributesArgs{ + name:object.name.as_str().into(), + can_collide:*can_collide, + velocity:Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(), + }, + }; + match availability{ + MeshAvailability::Immediate=>primitive_models_deferred_attributes.push(model_deferred_attributes), + MeshAvailability::Deferred(render)=>deferred_models_deferred_attributes.push(DeferredModelDeferredAttributes{ + render, + model:model_deferred_attributes + }), + } + } + } + } + PartialMap1{ + primitive_meshes, + primitive_models_deferred_attributes, + deferred_models_deferred_attributes, + } +} +struct MeshWithAabb{ + mesh:model::Mesh, + aabb:strafesnet_common::aabb::Aabb, +} +pub struct PartialMap1{ + primitive_meshes:Vec, + primitive_models_deferred_attributes:Vec, + deferred_models_deferred_attributes:Vec, +} +impl PartialMap1{ + pub fn add_meshpart_meshes_and_calculate_attributes( + mut self, + meshpart_meshes:impl IntoIterator, + )->PartialMap2{ + //calculate attributes + let mut modes_builder=ModesBuilder::default(); + let mut unique_attributes=Vec::new(); + let mut attributes_id_from_attributes=HashMap::new(); + + let mut wormhole_in_model_to_id=HashMap::new(); + let mut wormhole_id_to_out_model=HashMap::new(); + + //decode roblox meshes + //generate mesh_id_map based on meshes that failed to load + let loaded_meshes:HashMap= + meshpart_meshes.into_iter().flat_map(|(old_mesh_id,roblox_mesh_bytes)| + match crate::mesh::convert(roblox_mesh_bytes){ + Ok(mesh)=>{ + let mut aabb=strafesnet_common::aabb::Aabb::default(); + for &pos in &mesh.unique_pos{ + aabb.grow(pos); + } + Some((old_mesh_id,MeshWithAabb{ + mesh, + aabb, + })) + }, + Err(e)=>{ + println!("Error converting mesh: {e:?}"); + None + }, + } + ).collect(); + + let mut mesh_id_from_render_config_id=HashMap::new(); + //ignore meshes that fail to load completely for now + let mut acquire_mesh_id_from_render_config_id=|old_mesh_id,render|{ + loaded_meshes.get(&old_mesh_id).map(|mesh_with_aabb|( + *mesh_id_from_render_config_id.entry(old_mesh_id).or_insert_with(||HashMap::new()) + .entry(render).or_insert_with(||{ + let mesh_id=model::MeshId::new(self.primitive_meshes.len() as u32); + let mut mesh_clone=mesh_with_aabb.mesh.clone(); + //add a render group lool + mesh_clone.graphics_groups.push(model::IndexedGraphicsGroup{ + render, + //the lowest lod is highest quality + groups:vec![model::PolygonGroupId::new(0)] + }); + self.primitive_meshes.push(mesh_clone); + mesh_id + }), + &mesh_with_aabb.aabb, + )) + }; + //now that the meshes are loaded, these models can be generated + let models_owned_attributes:Vec= + self.deferred_models_deferred_attributes.into_iter().flat_map(|deferred_model_deferred_attributes|{ + //meshes need to be cloned from loaded_meshes with a new id when they are used with a new render_id + //insert into primitive_meshes + let (mesh,aabb)=acquire_mesh_id_from_render_config_id( + deferred_model_deferred_attributes.model.mesh, + deferred_model_deferred_attributes.render + )?; + let size=aabb.size(); + Some(ModelDeferredAttributes{ + mesh, + deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes, + color:deferred_model_deferred_attributes.model.color, + transform:Planar64Affine3::new( + Planar64Mat3::from_cols( + deferred_model_deferred_attributes.model.transform.matrix3.x_axis*2/size.x(), + deferred_model_deferred_attributes.model.transform.matrix3.y_axis*2/size.y(), + deferred_model_deferred_attributes.model.transform.matrix3.z_axis*2/size.z() + ), + deferred_model_deferred_attributes.model.transform.translation + ), + }) + }).chain(self.primitive_models_deferred_attributes.into_iter()) + .enumerate().map(|(model_id,model_deferred_attributes)|{ + let model_id=model::ModelId::new(model_id as u32); + ModelOwnedAttributes{ + mesh:model_deferred_attributes.mesh, + attributes:get_attributes( + &model_deferred_attributes.deferred_attributes.name, + model_deferred_attributes.deferred_attributes.can_collide, + model_deferred_attributes.deferred_attributes.velocity, model_id, &mut modes_builder, &mut wormhole_in_model_to_id, &mut wormhole_id_to_out_model, - ); - models1.push(ModelOwnedAttributes{ - mesh:indexed_model_id, - transform:model_transform, - color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency), - attributes, - }); + ), + color:model_deferred_attributes.color, + transform:model_deferred_attributes.transform, } - } - } - let models=models1.into_iter().enumerate().map(|(model_id,mut model1)|{ + }).collect(); + let models=models_owned_attributes.into_iter().enumerate().map(|(model_id,mut model_owned_attributes)|{ + //TODO: TAB let model_id=model::ModelId::new(model_id as u32); //update attributes with wormhole id //TODO: errors/prints if let Some(wormhole_id)=wormhole_in_model_to_id.get(&model_id){ if let Some(&wormhole_out_model_id)=wormhole_id_to_out_model.get(wormhole_id){ - match &mut model1.attributes{ + match &mut model_owned_attributes.attributes{ attr::CollisionAttributes::Contact{contacting:_,general} |attr::CollisionAttributes::Intersect{intersecting:_,general} =>general.wormhole=Some(attr::Wormhole{destination_model:wormhole_out_model_id}), @@ -689,36 +849,37 @@ pub fn convert)->model::RenderConfigId>(dom:&rbx_dom_weak:: } //index the attributes - let attributes_id=if let Some(&attributes_id)=attributes_id_from_attributes.get(&model1.attributes){ + let attributes_id=if let Some(&attributes_id)=attributes_id_from_attributes.get(&model_owned_attributes.attributes){ attributes_id }else{ let attributes_id=attr::CollisionAttributesId::new(unique_attributes.len() as u32); - attributes_id_from_attributes.insert(model1.attributes.clone(),attributes_id); - unique_attributes.push(model1.attributes); + attributes_id_from_attributes.insert(model_owned_attributes.attributes.clone(),attributes_id); + unique_attributes.push(model_owned_attributes.attributes); attributes_id }; model::Model{ - mesh:model1.mesh, - transform:model1.transform, - color:model1.color, + mesh:model_owned_attributes.mesh, + transform:model_owned_attributes.transform, + color:model_owned_attributes.color, attributes:attributes_id, } }).collect(); - PartialMap1{ - meshes, + PartialMap2{ + meshes:self.primitive_meshes, models, modes:modes_builder.build(), attributes:unique_attributes, } + } } -pub struct PartialMap1{ +pub struct PartialMap2{ meshes:Vec, models:Vec, modes:gameplay_modes::Modes, attributes:Vec, } -impl PartialMap1{ +impl PartialMap2{ pub fn add_render_configs_and_textures( self, render_configs:impl IntoIterator, From 9aca2575a89c1ad6907c10c593b5d788693fccaa Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 13 Mar 2024 13:38:52 -0700 Subject: [PATCH 21/49] v0.3.0 roblox mesh support --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 068a65f..88142e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.2.0" +version = "0.3.0" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index ca8ab99..db320b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.2.0" +version = "0.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 127534632e2a065b13f020cdbb06ed20c16ada3f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 13 Mar 2024 13:56:52 -0700 Subject: [PATCH 22/49] use rbx_mesh crate --- Cargo.lock | 3 ++- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88142e2..60acb38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -346,7 +346,8 @@ dependencies = [ [[package]] name = "rbx_mesh" version = "0.1.0" -source = "git+https://github.com/krakow10/rbx_mesh?rev=0e1c66d9acc7e1f2c187dd0899a9434d93ae0453#0e1c66d9acc7e1f2c187dd0899a9434d93ae0453" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8817de3f268556eadae24049a7658c2ffc248d135fc3baac8129e476eab86e09" dependencies = [ "binrw", "lazy-regex", diff --git a/Cargo.toml b/Cargo.toml index db320b8..78cf7ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,6 @@ rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } -rbx_mesh = { git = "https://github.com/krakow10/rbx_mesh", rev = "0e1c66d9acc7e1f2c187dd0899a9434d93ae0453" } +rbx_mesh = "0.1.0" strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" } bytemuck = "1.14.3" From 12b04a97d639c28afef7ad292462d8df2cfb64e2 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 29 Mar 2024 01:40:56 -0700 Subject: [PATCH 23/49] update rbx deps --- Cargo.lock | 12 ++++++------ Cargo.toml | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60acb38..9c5e9f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,7 +323,7 @@ dependencies = [ [[package]] name = "rbx_binary" version = "0.7.4" -source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" +source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" dependencies = [ "log", "lz4", @@ -337,7 +337,7 @@ dependencies = [ [[package]] name = "rbx_dom_weak" version = "2.7.0" -source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" +source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" dependencies = [ "rbx_types", "serde", @@ -356,7 +356,7 @@ dependencies = [ [[package]] name = "rbx_reflection" version = "4.5.0" -source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" +source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" dependencies = [ "rbx_types", "serde", @@ -366,7 +366,7 @@ dependencies = [ [[package]] name = "rbx_reflection_database" version = "0.2.10+roblox-607" -source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" +source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" dependencies = [ "lazy_static", "rbx_reflection", @@ -377,7 +377,7 @@ dependencies = [ [[package]] name = "rbx_types" version = "1.8.0" -source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" +source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" dependencies = [ "base64", "bitflags 1.3.2", @@ -391,7 +391,7 @@ dependencies = [ [[package]] name = "rbx_xml" version = "0.13.3" -source = "git+https://github.com/krakow10/rbx-dom?rev=841643178680c9f3143422778f9c52f949b222b9#841643178680c9f3143422778f9c52f949b222b9" +source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" dependencies = [ "base64", "log", diff --git a/Cargo.toml b/Cargo.toml index 78cf7ef..d3be200 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,10 @@ edition = "2021" [dependencies] glam = "0.25.0" lazy-regex = "3.1.0" -rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } -rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } -rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } -rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "841643178680c9f3143422778f9c52f949b222b9" } +rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } +rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } +rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } +rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } rbx_mesh = "0.1.0" strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" } bytemuck = "1.14.3" From 44b2ae1c10e3f1219b89b761038c8c454975a9f4 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 29 Mar 2024 01:44:38 -0700 Subject: [PATCH 24/49] use strafesnet registry --- .cargo/config.toml | 2 ++ Cargo.lock | 46 +++++++++++++++++++++++++++------------------- Cargo.toml | 16 ++++++++++------ 3 files changed, 39 insertions(+), 25 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 9c5e9f4..16666cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "base64" @@ -79,9 +79,9 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "blake3" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" dependencies = [ "arrayref", "arrayvec", @@ -104,9 +104,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.88" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -146,7 +146,8 @@ checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" [[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", @@ -323,7 +324,8 @@ dependencies = [ [[package]] name = "rbx_binary" version = "0.7.4" -source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "18b401155b93f7151217bf51e36bdfa7bddcaf5f0d26b563c9ac3b08a3701c27" dependencies = [ "log", "lz4", @@ -337,7 +339,8 @@ dependencies = [ [[package]] name = "rbx_dom_weak" version = "2.7.0" -source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "850d0a6c8d22592b125c9a82f8654857a7aba10f061b930cc2b86438e54157f1" dependencies = [ "rbx_types", "serde", @@ -356,7 +359,8 @@ dependencies = [ [[package]] name = "rbx_reflection" version = "4.5.0" -source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "80d31f6675c27c9f60b2322feb5565f4a4389ccbb75de4e737915e9208f0831f" dependencies = [ "rbx_types", "serde", @@ -366,7 +370,8 @@ dependencies = [ [[package]] name = "rbx_reflection_database" version = "0.2.10+roblox-607" -source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "f4da9f73ca317c158b922b757fe02317f7d3bc31d3f9fdb4a748d48b3951b8b8" dependencies = [ "lazy_static", "rbx_reflection", @@ -377,7 +382,8 @@ dependencies = [ [[package]] name = "rbx_types" version = "1.8.0" -source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "6d0d394018a8df53fcd91e990301fe6e47b94e15067edfcb019e6238ae60e8bb" dependencies = [ "base64", "bitflags 1.3.2", @@ -391,7 +397,8 @@ dependencies = [ [[package]] name = "rbx_xml" version = "0.13.3" -source = "git+https://github.com/krakow10/rbx-dom?rev=aabfee718f1d1c4eb79ec7b378d596582ecab059#aabfee718f1d1c4eb79ec7b378d596582ecab059" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "d6d1a15f58a1e4b4f578abe6eb5e1461cb16eea82fb4a147d5995c9b79f08d1f" dependencies = [ "base64", "log", @@ -474,8 +481,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 2.4.2", "glam", @@ -521,18 +529,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d3be200..bf58ec1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,16 +2,20 @@ name = "strafesnet_rbx_loader" version = "0.3.0" edition = "2021" +repository = "https://git.itzana.me/StrafesNET/rbx_loader" +license = "MIT OR Apache-2.0" +description = "Convert Roblox place and model 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] +bytemuck = "1.14.3" glam = "0.25.0" lazy-regex = "3.1.0" -rbx_binary = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } -rbx_dom_weak = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } -rbx_reflection_database = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } -rbx_xml = { git = "https://github.com/krakow10/rbx-dom", rev = "aabfee718f1d1c4eb79ec7b378d596582ecab059" } +rbx_binary = { version = "0.7.4", registry = "strafesnet" } +rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.0" -strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a9f3e61f2bb1074025b6cb466a5e3f2abc988c34" } -bytemuck = "1.14.3" +rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } +rbx_xml = { version = "0.13.3", registry = "strafesnet" } +strafesnet_common = { version = "0.1.2", registry = "strafesnet" } From 77d120597d12d3668a2badf8c21a99ed3b2bb7e2 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 29 Mar 2024 02:54:36 -0700 Subject: [PATCH 25/49] update rbx_mesh --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16666cf..c53b613 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -348,9 +348,9 @@ dependencies = [ [[package]] name = "rbx_mesh" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8817de3f268556eadae24049a7658c2ffc248d135fc3baac8129e476eab86e09" +checksum = "b9f5cad033f5b4e15d13176f1f15aa1c6b9f025ce6b7ae64a5ce00f97367f2d0" dependencies = [ "binrw", "lazy-regex", diff --git a/Cargo.toml b/Cargo.toml index bf58ec1..ce8971e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ glam = "0.25.0" lazy-regex = "3.1.0" rbx_binary = { version = "0.7.4", registry = "strafesnet" } rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } -rbx_mesh = "0.1.0" +rbx_mesh = "0.1.1" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } strafesnet_common = { version = "0.1.2", registry = "strafesnet" } From 24b28f28dd88928234bf825a64a783de4104968b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 22 Jul 2024 13:49:41 -0700 Subject: [PATCH 26/49] update deps --- Cargo.lock | 154 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 8 +-- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c53b613..03ce298 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -19,9 +19,9 @@ checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" @@ -31,9 +31,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" @@ -43,9 +43,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "binrw" -version = "0.13.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173901312e9850391d4d7c1318c4e099fdc037d61870fca427429830efdb4e5f" +checksum = "3f36b7cb3ab9ff6a2858650d8dc360e783a5d14dc29594db48c56a3c233cc265" dependencies = [ "array-init", "binrw_derive", @@ -54,9 +54,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", @@ -73,15 +73,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[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 = "blake3" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" +checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" dependencies = [ "arrayref", "arrayvec", @@ -92,9 +92,9 @@ 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" [[package]] name = "byteorder" @@ -104,9 +104,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.90" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cfg-if" @@ -122,15 +122,15 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[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 = "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", @@ -139,9 +139,9 @@ 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 = "id" @@ -151,7 +151,7 @@ checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -174,32 +174,32 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[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 = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lz4" -version = "1.24.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" +checksum = "958b4caa893816eea05507c20cfe47574a43d9a697138a7872990bba8a0ece68" dependencies = [ "libc", "lz4-sys", @@ -207,9 +207,9 @@ dependencies = [ [[package]] name = "lz4-sys" -version = "1.9.4" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +checksum = "109de74d5d2353660401699a4174a4ff23fcc649caf553df71933c7fb45ad868" dependencies = [ "cc", "libc", @@ -217,15 +217,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", ] @@ -244,9 +244,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "ppv-lite86" @@ -256,9 +256,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[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", ] @@ -279,14 +279,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[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", ] @@ -348,9 +348,9 @@ dependencies = [ [[package]] name = "rbx_mesh" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5cad033f5b4e15d13176f1f15aa1c6b9f025ce6b7ae64a5ce00f97367f2d0" +checksum = "864ead0e98afce28c960f653d6203483834890d07f87b60e2f01415530a2fe9d" dependencies = [ "binrw", "lazy-regex", @@ -410,9 +410,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -422,9 +422,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -433,15 +433,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rmp" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" dependencies = [ "byteorder", "num-traits", @@ -450,9 +450,9 @@ dependencies = [ [[package]] name = "rmp-serde" -version = "1.1.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" +checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" dependencies = [ "byteorder", "rmp", @@ -461,38 +461,38 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[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 2.4.2", + "bitflags 2.6.0", "glam", "id", ] [[package]] name = "strafesnet_rbx_loader" -version = "0.3.0" +version = "0.3.1" dependencies = [ "bytemuck", "glam", @@ -518,9 +518,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", @@ -529,22 +529,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -561,6 +561,6 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "xml-rs" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" diff --git a/Cargo.toml b/Cargo.toml index ce8971e..9449ccd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.0" +version = "0.3.1" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" @@ -11,11 +11,11 @@ authors = ["Rhys Lloyd "] [dependencies] bytemuck = "1.14.3" -glam = "0.25.0" +glam = "0.28.0" lazy-regex = "3.1.0" rbx_binary = { version = "0.7.4", registry = "strafesnet" } rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } -rbx_mesh = "0.1.1" +rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -strafesnet_common = { version = "0.1.2", registry = "strafesnet" } +strafesnet_common = { version = "0.1.3", registry = "strafesnet" } From 5193d0be7111cc172d64c7dedcbefd5b789f7e3a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 27 Jul 2024 18:19:50 -0700 Subject: [PATCH 27/49] update deps --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/rbx.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03ce298..f513553 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -481,9 +481,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 2.6.0", "glam", @@ -492,7 +492,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.1" +version = "0.3.2" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index 9449ccd..3deb92e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.1" +version = "0.3.2" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" @@ -18,4 +18,4 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -strafesnet_common = { version = "0.1.3", registry = "strafesnet" } +strafesnet_common = { version = "0.2.0", registry = "strafesnet" } diff --git a/src/rbx.rs b/src/rbx.rs index d63c4ae..5035b28 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -163,7 +163,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode force_intersecting=true; modes_builder.insert_mode( gameplay_modes::ModeId::MAIN, - gameplay_modes::Mode::new( + gameplay_modes::Mode::empty( gameplay_style::StyleModifiers::roblox_bhop(), model_id ) @@ -209,7 +209,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode force_intersecting=true; modes_builder.insert_mode( gameplay_modes::ModeId::new(captures[2].parse::().unwrap()), - gameplay_modes::Mode::new( + gameplay_modes::Mode::empty( gameplay_style::StyleModifiers::roblox_bhop(), model_id ) @@ -241,7 +241,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode modes_builder.insert_stage( gameplay_modes::ModeId::MAIN, stage_id, - gameplay_modes::Stage::new(model_id), + gameplay_modes::Stage::empty(model_id), ); //TODO: let denormalize handle this gameplay_modes::StageElementBehaviour::SpawnAt @@ -847,7 +847,7 @@ impl PartialMap1{ } } } - + //index the attributes let attributes_id=if let Some(&attributes_id)=attributes_id_from_attributes.get(&model_owned_attributes.attributes){ attributes_id @@ -901,9 +901,9 @@ impl PartialMap2{ attributes:self.attributes, meshes:self.meshes, models:self.models, - //the roblox legacy texture thing always works + //the roblox legacy texture thing always works textures, render_configs, } } -} \ No newline at end of file +} From 5ee149b66e0d0675ddb9e9f026e2c4329cc40a65 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 7 Aug 2024 18:41:04 -0700 Subject: [PATCH 28/49] update deps --- Cargo.lock | 59 ++++++++++++++++++++++++++++++++++++++---------------- Cargo.toml | 4 ++-- 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f513553..8c2582e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,9 +92,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" [[package]] name = "byteorder" @@ -104,9 +104,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.6" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" [[package]] name = "cfg-if" @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "lazy-regex" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c" +checksum = "576c8060ecfdf2e56995cf3274b4f2d71fa5e4fa3607c1c0b63c10180ee58741" dependencies = [ "lazy-regex-proc_macros", "once_cell", @@ -167,9 +167,9 @@ dependencies = [ [[package]] name = "lazy-regex-proc_macros" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b" +checksum = "9efb9e65d4503df81c615dc33ff07042a9408ac7f26b45abee25566f7fbfd12c" dependencies = [ "proc-macro2", "quote", @@ -250,9 +250,12 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" @@ -410,9 +413,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -481,10 +484,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 2.6.0", "glam", "id", @@ -492,7 +496,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.2" +version = "0.3.3" dependencies = [ "bytemuck", "glam", @@ -561,6 +565,27 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "xml-rs" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" +checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] diff --git a/Cargo.toml b/Cargo.toml index 3deb92e..1afabd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.2" +version = "0.3.3" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" @@ -18,4 +18,4 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -strafesnet_common = { version = "0.2.0", registry = "strafesnet" } +strafesnet_common = { version = "0.3.0", registry = "strafesnet" } From f8f44b7b456029cb481ea41bb5b75306508a2f92 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 9 Aug 2024 14:33:50 -0700 Subject: [PATCH 29/49] update deps --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c2582e..8e4c2e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -464,18 +464,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.205" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" dependencies = [ "proc-macro2", "quote", From 418450e7d320c178ade9205bcf17d9baa259b235 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 9 Aug 2024 14:34:01 -0700 Subject: [PATCH 30/49] update common --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/rbx.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e4c2e8..d23ba63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -484,9 +484,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 2.6.0", diff --git a/Cargo.toml b/Cargo.toml index 1afabd9..0caaba7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,4 +18,4 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -strafesnet_common = { version = "0.3.0", registry = "strafesnet" } +strafesnet_common = { version = "0.4.0", registry = "strafesnet" } diff --git a/src/rbx.rs b/src/rbx.rs index 5035b28..76e5861 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -328,13 +328,13 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode "Ladder"=>contacting.contact_behaviour=Some(attr::ContactingBehaviour::Ladder(attr::ContactingLadder{sticky:true})), _=>(), } - attr::CollisionAttributes::Contact{contacting,general} + attr::CollisionAttributes::Contact(attr::ContactAttributes{contacting,general}) }, false=>if force_intersecting ||general.any() ||intersecting.any() { - attr::CollisionAttributes::Intersect{intersecting,general} + attr::CollisionAttributes::Intersect(attr::IntersectAttributes{intersecting,general}) }else{ attr::CollisionAttributes::Decoration }, @@ -840,8 +840,8 @@ impl PartialMap1{ if let Some(wormhole_id)=wormhole_in_model_to_id.get(&model_id){ if let Some(&wormhole_out_model_id)=wormhole_id_to_out_model.get(wormhole_id){ match &mut model_owned_attributes.attributes{ - attr::CollisionAttributes::Contact{contacting:_,general} - |attr::CollisionAttributes::Intersect{intersecting:_,general} + attr::CollisionAttributes::Contact(attr::ContactAttributes{contacting:_,general}) + |attr::CollisionAttributes::Intersect(attr::IntersectAttributes{intersecting:_,general}) =>general.wormhole=Some(attr::Wormhole{destination_model:wormhole_out_model_id}), attr::CollisionAttributes::Decoration=>println!("Not a wormhole"), } From deabb1769ae403db1e31aec6b6ad8f6bb72c211f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 9 Aug 2024 14:34:12 -0700 Subject: [PATCH 31/49] v0.3.4 update common --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d23ba63..bb615ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -496,7 +496,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.3" +version = "0.3.4" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index 0caaba7..c3febae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.3" +version = "0.3.4" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From b9f9b2ba7e4f9ee4b317c0582e0fa3d43cc8a09f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 16 Sep 2024 18:26:07 -0700 Subject: [PATCH 32/49] update deps --- Cargo.lock | 110 ++++++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb615ac..973021d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,15 +19,15 @@ checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[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" @@ -79,9 +79,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "blake3" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -92,9 +92,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" [[package]] name = "byteorder" @@ -104,9 +104,12 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.8" +version = "1.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" +checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -116,9 +119,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "either" @@ -151,14 +154,14 @@ checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "lazy-regex" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576c8060ecfdf2e56995cf3274b4f2d71fa5e4fa3607c1c0b63c10180ee58741" +checksum = "8d8e41c97e6bc7ecb552016274b99fbb5d035e8de288c582d9b933af6677bfda" dependencies = [ "lazy-regex-proc_macros", "once_cell", @@ -167,14 +170,14 @@ dependencies = [ [[package]] name = "lazy-regex-proc_macros" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9efb9e65d4503df81c615dc33ff07042a9408ac7f26b45abee25566f7fbfd12c" +checksum = "76e1d8b05d672c53cb9c7b920bbba8783845ae4f0b076e02a3db1d02c81b4163" dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -185,9 +188,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "log" @@ -197,19 +200,18 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lz4" -version = "1.26.0" +version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958b4caa893816eea05507c20cfe47574a43d9a697138a7872990bba8a0ece68" +checksum = "a231296ca742e418c43660cb68e082486ff2538e8db432bc818580f3965025ed" dependencies = [ - "libc", "lz4-sys", ] [[package]] name = "lz4-sys" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109de74d5d2353660401699a4174a4ff23fcc649caf553df71933c7fb45ad868" +checksum = "fcb44a01837a858d47e5a630d2ccf304c8efcc4b83b8f9f75b7a9ee4fcc6e57d" dependencies = [ "cc", "libc", @@ -282,14 +284,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[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", ] @@ -341,9 +343,9 @@ dependencies = [ [[package]] name = "rbx_dom_weak" -version = "2.7.0" +version = "2.9.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "850d0a6c8d22592b125c9a82f8654857a7aba10f061b930cc2b86438e54157f1" +checksum = "2a6b916687c98aaea36f9c03e80906bfafab057bebee248628c8c04def807f43" dependencies = [ "rbx_types", "serde", @@ -361,9 +363,9 @@ dependencies = [ [[package]] name = "rbx_reflection" -version = "4.5.0" +version = "4.7.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "80d31f6675c27c9f60b2322feb5565f4a4389ccbb75de4e737915e9208f0831f" +checksum = "c1b43fe592a4ce6fe54eb215fb82735efbb516d2cc045a94e3dc0234ff293620" dependencies = [ "rbx_types", "serde", @@ -372,9 +374,9 @@ dependencies = [ [[package]] name = "rbx_reflection_database" -version = "0.2.10+roblox-607" +version = "0.2.12+roblox-638" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "f4da9f73ca317c158b922b757fe02317f7d3bc31d3f9fdb4a748d48b3951b8b8" +checksum = "2e772bb9e1bc0ebe65d338f876d1bb1ea22e15a8f9a82e8245028010c2fea3c9" dependencies = [ "lazy_static", "rbx_reflection", @@ -384,9 +386,9 @@ dependencies = [ [[package]] name = "rbx_types" -version = "1.8.0" +version = "1.10.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "6d0d394018a8df53fcd91e990301fe6e47b94e15067edfcb019e6238ae60e8bb" +checksum = "d7a390c44034fa448c53bd0983dfc2d70d8d6b2f65be4f164d4bec8b6a2a2d09" dependencies = [ "base64", "bitflags 1.3.2", @@ -464,29 +466,35 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.205" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.205" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "strafesnet_common" -version = "0.4.0" +version = "0.4.1" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "ea4126f6fbf9aecf89c9e319290f0221d177dcaa8659b4b9e3d82acc37829f12" +checksum = "9a2621612e675a8f804abbbbe3b60caeafe58a2422cccbe453268d6f457df4f3" dependencies = [ "arrayvec", "bitflags 2.6.0", @@ -522,9 +530,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -548,14 +556,14 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[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 = "wasi" @@ -565,9 +573,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "xml-rs" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601" +checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" [[package]] name = "zerocopy" @@ -587,5 +595,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] From 7bd456ee8c3557889a3f49724b1ce10f3df16f7a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 17 Sep 2024 18:27:56 -0700 Subject: [PATCH 33/49] roblox emulator --- Cargo.lock | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/lib.rs | 16 +++++- 3 files changed, 162 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 973021d..aa1b4d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,6 +90,16 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bytemuck" version = "1.18.0" @@ -192,12 +202,31 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets", +] + [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "luau0-src" +version = "0.10.3+luau640" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f39d12b514a676c943990cfbe6200fedcb9c293c8c9219d29be512a6969be92" +dependencies = [ + "cc", +] + [[package]] name = "lz4" version = "1.27.0" @@ -223,6 +252,32 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "mlua" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d111deb18a9c9bd33e1541309f4742523bfab01d276bfa9a27519f6de9c11dc7" +dependencies = [ + "bstr", + "libloading", + "mlua-sys", + "num-traits", + "once_cell", + "rustc-hash", +] + +[[package]] +name = "mlua-sys" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe026d6bd1583a9cf9080e189030ddaea7e6f5f0deb366a8e26f8a26c4135b8" +dependencies = [ + "cc", + "cfg-if", + "luau0-src", + "pkg-config", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -250,6 +305,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -464,6 +525,26 @@ dependencies = [ "serde", ] +[[package]] +name = "roblox_emulator" +version = "0.1.0" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "9071bd2716bfd691b4ec872dfb8141188294bb050a6fba0ae3bb0c956c109a3d" +dependencies = [ + "glam", + "mlua", + "rbx_dom_weak", + "rbx_reflection", + "rbx_reflection_database", + "rbx_types", +] + +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "serde" version = "1.0.210" @@ -514,6 +595,7 @@ dependencies = [ "rbx_mesh", "rbx_reflection_database", "rbx_xml", + "roblox_emulator", "strafesnet_common", ] @@ -571,6 +653,70 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "xml-rs" version = "0.8.22" diff --git a/Cargo.toml b/Cargo.toml index c3febae..758fd78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,4 +18,5 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } +roblox_emulator = { version = "0.1.0", registry = "strafesnet" } strafesnet_common = { version = "0.4.0", registry = "strafesnet" } diff --git a/src/lib.rs b/src/lib.rs index c04c7d9..885c463 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,20 @@ pub mod data{ } pub struct Dom(rbx_dom_weak::WeakDom); +impl Dom{ + pub fn run_scripts(self)->Self{ + let runner=roblox_emulator::runner::Runner::new().unwrap(); + let mut context=roblox_emulator::context::Context::new(self.0); + for script in context.scripts(){ + let (modified_context,script_error)=runner.run_script(script,context); + context=modified_context; + if let Err(e)=script_error{ + e.print(); + } + } + Self(context.into_inner()) + } +} #[derive(Debug)] pub enum ReadError{ @@ -54,4 +68,4 @@ where AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId, { rbx::convert(&dom.0,acquire_render_config_id,acquire_mesh_id) -} \ No newline at end of file +} From f0d0c925dcd688a92dca92ecd69574ffee14019b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 20 Sep 2024 11:46:55 -0700 Subject: [PATCH 34/49] v0.3.5 roblox emulator --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa1b4d7..9293a4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,7 +585,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.4" +version = "0.3.5" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index 758fd78..4cff0ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.4" +version = "0.3.5" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From 652bf5a0d367938c7fc52fab544272431a823d1d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 21 Sep 2024 12:40:51 -0700 Subject: [PATCH 35/49] v0.3.6 update roblox emulator api --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/lib.rs | 9 +++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9293a4d..d8f560a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.1.0" +version = "0.2.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "9071bd2716bfd691b4ec872dfb8141188294bb050a6fba0ae3bb0c956c109a3d" +checksum = "62ab7e851fb72ba7d690734e1d33d8bd47e83a25b7dbdb28b4771fd3425f7538" dependencies = [ "glam", "mlua", @@ -585,7 +585,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.5" +version = "0.3.6" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index 4cff0ea..d6633c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.5" +version = "0.3.6" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" @@ -18,5 +18,5 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -roblox_emulator = { version = "0.1.0", registry = "strafesnet" } +roblox_emulator = { version = "0.2.0", registry = "strafesnet" } strafesnet_common = { version = "0.4.0", registry = "strafesnet" } diff --git a/src/lib.rs b/src/lib.rs index 885c463..28e9a72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,17 +18,14 @@ pub mod data{ pub struct Dom(rbx_dom_weak::WeakDom); impl Dom{ - pub fn run_scripts(self)->Self{ + pub fn run_scripts(&mut self){ let runner=roblox_emulator::runner::Runner::new().unwrap(); - let mut context=roblox_emulator::context::Context::new(self.0); + let context=roblox_emulator::context::Context::from_mut(&mut self.0); for script in context.scripts(){ - let (modified_context,script_error)=runner.run_script(script,context); - context=modified_context; - if let Err(e)=script_error{ + if let Err(e)=runner.run_script(script,context){ e.print(); } } - Self(context.into_inner()) } } From a30893dcdf9c022dff596bd6adef3ab2436f9ae4 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 21 Sep 2024 15:09:40 -0700 Subject: [PATCH 36/49] v0.3.7 update roblox emulator --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8f560a..30e739d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.2.0" +version = "0.2.1" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "62ab7e851fb72ba7d690734e1d33d8bd47e83a25b7dbdb28b4771fd3425f7538" +checksum = "1e58c0b42dbe1d5b91439131e108a8ded2d2b1613ebb2718149d84e0a4a6bfb8" dependencies = [ "glam", "mlua", @@ -585,7 +585,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.6" +version = "0.3.7" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index d6633c9..64e01f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.6" +version = "0.3.7" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" @@ -18,5 +18,5 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -roblox_emulator = { version = "0.2.0", registry = "strafesnet" } +roblox_emulator = { version = "0.2.1", registry = "strafesnet" } strafesnet_common = { version = "0.4.0", registry = "strafesnet" } diff --git a/src/lib.rs b/src/lib.rs index 28e9a72..153f607 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ impl Dom{ let context=roblox_emulator::context::Context::from_mut(&mut self.0); for script in context.scripts(){ if let Err(e)=runner.run_script(script,context){ - e.print(); + println!("runner error: {e}"); } } } From ea76d137fdeb90174a8e45622937673b35736753 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 16:17:59 -0700 Subject: [PATCH 37/49] sort_by_key --- src/rbx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rbx.rs b/src/rbx.rs index 76e5861..46b5476 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -63,7 +63,7 @@ impl ModesBuilder{ //collect modes and stages into contiguous arrays let mut unique_modes:Vec<(gameplay_modes::ModeId,gameplay_modes::Mode)> =self.modes.into_iter().collect(); - unique_modes.sort_by(|a,b|a.0.cmp(&b.0)); + unique_modes.sort_by_key(|&(mode_id,_)|mode_id); let (mut modes,final_mode_id_from_builder_mode_id):(Vec,HashMap) =unique_modes.into_iter().enumerate() .map(|(final_mode_id,(builder_mode_id,mut mode))|{ From dcad5fc8ec459cafe03e774b34e3012a38a924c2 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 30 Sep 2024 10:49:29 -0700 Subject: [PATCH 38/49] update common --- Cargo.lock | 119 ++++++++++++++++++++++++++++++++-------------- Cargo.toml | 2 +- src/mesh.rs | 8 ++-- src/primitives.rs | 50 +++++++++---------- src/rbx.rs | 36 +++++++------- 5 files changed, 131 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30e739d..c3e40d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,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 = "base64" @@ -90,6 +90,12 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "bnum" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50202def95bf36cb7d1d7a7962cea1c36a3f8ad42425e5d2b71d7acb8041b5b8" + [[package]] name = "bstr" version = "1.10.0" @@ -114,9 +120,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.19" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "shlex", ] @@ -139,6 +145,18 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[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 = "getrandom" version = "0.2.15" @@ -164,7 +182,7 @@ checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -187,7 +205,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -198,9 +216,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" @@ -212,6 +230,17 @@ dependencies = [ "windows-targets", ] +[[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 = "log" version = "0.4.22" @@ -229,18 +258,18 @@ dependencies = [ [[package]] name = "lz4" -version = "1.27.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a231296ca742e418c43660cb68e082486ff2538e8db432bc818580f3965025ed" +checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725" dependencies = [ "lz4-sys", ] [[package]] name = "lz4-sys" -version = "1.11.0" +version = "1.11.1+lz4-1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb44a01837a858d47e5a630d2ccf304c8efcc4b83b8f9f75b7a9ee4fcc6e57d" +checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" dependencies = [ "cc", "libc", @@ -289,9 +318,12 @@ dependencies = [ [[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" @@ -307,9 +339,15 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "ppv-lite86" @@ -345,7 +383,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -387,6 +425,12 @@ dependencies = [ "getrandom", ] +[[package]] +name = "ratio_ops" +version = "0.1.0" +source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" +checksum = "01239195d6afe0509e7e3511b716c0540251dfe7ece0a9a5a27116afb766c42c" + [[package]] name = "rbx_binary" version = "0.7.4" @@ -476,9 +520,9 @@ dependencies = [ [[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", @@ -488,9 +532,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", @@ -499,9 +543,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 = "rmp" @@ -527,9 +571,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.2.1" +version = "0.2.2" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "1e58c0b42dbe1d5b91439131e108a8ded2d2b1613ebb2718149d84e0a4a6bfb8" +checksum = "1f084d8b843fd96371cca381799313c9b3d0634d2da23ac0c6334bdaf0a2225e" dependencies = [ "glam", "mlua", @@ -562,7 +606,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -573,14 +617,17 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "strafesnet_common" -version = "0.4.1" +version = "0.5.1" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "9a2621612e675a8f804abbbbe3b60caeafe58a2422cccbe453268d6f457df4f3" +checksum = "eaf0b69648e1b6b61b6f05868a5fc5496bc90b0586cfc69533b5cd7a3c006f86" dependencies = [ "arrayvec", "bitflags 2.6.0", + "fixed_wide", "glam", "id", + "linear_ops", + "ratio_ops", ] [[package]] @@ -612,9 +659,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -623,22 +670,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.77", + "syn 2.0.79", ] [[package]] @@ -741,5 +788,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] diff --git a/Cargo.toml b/Cargo.toml index 64e01f7..ff23049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,4 +19,4 @@ rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } roblox_emulator = { version = "0.2.1", registry = "strafesnet" } -strafesnet_common = { version = "0.4.0", registry = "strafesnet" } +strafesnet_common = { version = "0.5.1", registry = "strafesnet" } diff --git a/src/mesh.rs b/src/mesh.rs index 3215118..ae5d161 100644 --- a/src/mesh.rs +++ b/src/mesh.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use rbx_mesh::mesh::{Vertex2, Vertex2Truncated}; -use strafesnet_common::{integer::Planar64Vec3,model::{self, ColorId, IndexedVertex, NormalId, PolygonGroup, PolygonList, PositionId, TextureCoordinateId, VertexId}}; +use strafesnet_common::{integer::vec3,model::{self, ColorId, IndexedVertex, NormalId, PolygonGroup, PolygonList, PositionId, TextureCoordinateId, VertexId}}; #[derive(Debug)] pub enum Error{ @@ -108,7 +108,7 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->ResultResultResultMesh{ unit_cube(render) diff --git a/src/rbx.rs b/src/rbx.rs index 46b5476..0535724 100644 --- a/src/rbx.rs +++ b/src/rbx.rs @@ -5,7 +5,7 @@ use strafesnet_common::model; use strafesnet_common::gameplay_modes; use strafesnet_common::gameplay_style; use strafesnet_common::gameplay_attributes as attr; -use strafesnet_common::integer::{Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3}; +use strafesnet_common::integer::{self,vec3,Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3}; use strafesnet_common::model::RenderConfigId; use strafesnet_common::updatable::Updatable; @@ -36,15 +36,15 @@ fn recursive_collect_superclass(objects: &mut std::vec::VecPlanar64Affine3{ Planar64Affine3::new( - Planar64Mat3::from_cols( - Planar64Vec3::try_from([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x]).unwrap() - *Planar64::try_from(size.x/2.0).unwrap(), - Planar64Vec3::try_from([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y]).unwrap() - *Planar64::try_from(size.y/2.0).unwrap(), - Planar64Vec3::try_from([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z]).unwrap() - *Planar64::try_from(size.z/2.0).unwrap(), - ), - Planar64Vec3::try_from([cf.position.x,cf.position.y,cf.position.z]).unwrap() + Planar64Mat3::from_cols([ + vec3::try_from_f32_array([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x]).unwrap() + *integer::try_from_f32(size.x/2.0).unwrap(), + vec3::try_from_f32_array([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y]).unwrap() + *integer::try_from_f32(size.y/2.0).unwrap(), + vec3::try_from_f32_array([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z]).unwrap() + *integer::try_from_f32(size.z/2.0).unwrap(), + ].map(|t|t.fix_1())), + vec3::try_from_f32_array([cf.position.x,cf.position.y,cf.position.z]).unwrap() ) } struct ModeBuilder{ @@ -317,7 +317,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode } } //need some way to skip this - if velocity!=Planar64Vec3::ZERO{ + if velocity!=vec3::ZERO{ general.booster=Some(attr::Booster::Velocity(velocity)); } match force_can_collide{ @@ -473,7 +473,7 @@ where { let model_transform=planar64_affine3_from_roblox(cf,size); - if model_transform.matrix3.determinant()==Planar64::ZERO{ + if model_transform.matrix3.det().is_zero(){ let mut parent_ref=object.parent(); let mut full_path=object.name.clone(); while let Some(parent)=dom.get_by_ref(parent_ref){ @@ -708,7 +708,7 @@ where deferred_attributes:GetAttributesArgs{ name:object.name.as_str().into(), can_collide:*can_collide, - velocity:Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(), + velocity:vec3::try_from_f32_array([velocity.x,velocity.y,velocity.z]).unwrap(), }, }; match availability{ @@ -806,11 +806,11 @@ impl PartialMap1{ deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes, color:deferred_model_deferred_attributes.model.color, transform:Planar64Affine3::new( - Planar64Mat3::from_cols( - deferred_model_deferred_attributes.model.transform.matrix3.x_axis*2/size.x(), - deferred_model_deferred_attributes.model.transform.matrix3.y_axis*2/size.y(), - deferred_model_deferred_attributes.model.transform.matrix3.z_axis*2/size.z() - ), + Planar64Mat3::from_cols([ + (deferred_model_deferred_attributes.model.transform.matrix3.x_axis*2/size.x).divide().fix_1(), + (deferred_model_deferred_attributes.model.transform.matrix3.y_axis*2/size.y).divide().fix_1(), + (deferred_model_deferred_attributes.model.transform.matrix3.z_axis*2/size.z).divide().fix_1() + ]), deferred_model_deferred_attributes.model.transform.translation ), }) From 5fd51c20858237a77a56236df6c398644b42ce98 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 16:31:48 -0700 Subject: [PATCH 39/49] v0.4.0 update common --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3e40d9..4f6eef6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -632,7 +632,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.3.7" +version = "0.4.0" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index ff23049..2271ee3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.3.7" +version = "0.4.0" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From 65d2b71de9e9af8fc66aa6a580af83472f6fd5c6 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 16:52:44 -0700 Subject: [PATCH 40/49] update deps --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f6eef6..43d1cf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,9 +170,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 = "id" @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.2.2" +version = "0.2.3" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "1f084d8b843fd96371cca381799313c9b3d0634d2da23ac0c6334bdaf0a2225e" +checksum = "2fa2c785a17f607aad6bdd19eef6d19f9476f308ce38de139df931a99132bd46" dependencies = [ "glam", "mlua", @@ -617,9 +617,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "strafesnet_common" -version = "0.5.1" +version = "0.5.2" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "eaf0b69648e1b6b61b6f05868a5fc5496bc90b0586cfc69533b5cd7a3c006f86" +checksum = "91cc1f3699bd8248da18bf5d11273264396a257b5d47b8558acb2cb4e1761219" dependencies = [ "arrayvec", "bitflags 2.6.0", diff --git a/Cargo.toml b/Cargo.toml index 2271ee3..fc5b536 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ authors = ["Rhys Lloyd "] [dependencies] bytemuck = "1.14.3" -glam = "0.28.0" +glam = "0.29.0" lazy-regex = "3.1.0" rbx_binary = { version = "0.7.4", registry = "strafesnet" } rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } From f25954e1a8004647aa896d9d8a9e172a6b4271c5 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 16:53:03 -0700 Subject: [PATCH 41/49] v0.4.1 update deps --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43d1cf6..2633d59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -632,7 +632,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.4.0" +version = "0.4.1" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index fc5b536..b13e466 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.4.0" +version = "0.4.1" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From d5a3b797daf06a8552c5e125e2f04646059e64d0 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 3 Oct 2024 19:35:52 -0700 Subject: [PATCH 42/49] update roblox_emulator --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/lib.rs | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2633d59..196c7cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.2.3" +version = "0.3.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "2fa2c785a17f607aad6bdd19eef6d19f9476f308ce38de139df931a99132bd46" +checksum = "ba81a9134bb07930669340c7aad34719e74690f68771c6ef7b093f00ddba9e65" dependencies = [ "glam", "mlua", diff --git a/Cargo.toml b/Cargo.toml index b13e466..3f868db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,5 +18,5 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -roblox_emulator = { version = "0.2.1", registry = "strafesnet" } +roblox_emulator = { version = "0.3.0", registry = "strafesnet" } strafesnet_common = { version = "0.5.1", registry = "strafesnet" } diff --git a/src/lib.rs b/src/lib.rs index 153f607..a4d5a3b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,9 +20,11 @@ pub struct Dom(rbx_dom_weak::WeakDom); impl Dom{ pub fn run_scripts(&mut self){ let runner=roblox_emulator::runner::Runner::new().unwrap(); - let context=roblox_emulator::context::Context::from_mut(&mut self.0); - for script in context.scripts(){ - if let Err(e)=runner.run_script(script,context){ + let context=roblox_emulator::context::Context::from_mut(&mut self.dom); + let scripts=context.scripts(); + let runnable=runner.runnable_context(context,services).unwrap(); + for script in scripts{ + if let Err(e)=runnable.run_script(script){ println!("runner error: {e}"); } } From 35c19abaf1cc1b743c2a23ad406faa4d40cb476a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 3 Oct 2024 19:35:59 -0700 Subject: [PATCH 43/49] make a distinction between Model and Place --- src/lib.rs | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a4d5a3b..8cab9fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ use std::io::Read; +use rbx_dom_weak::WeakDom; mod rbx; mod mesh; @@ -16,9 +17,29 @@ pub mod data{ } } -pub struct Dom(rbx_dom_weak::WeakDom); -impl Dom{ - pub fn run_scripts(&mut self){ +pub struct Model{ + dom:WeakDom, +} +impl Model{ + fn new(dom:WeakDom)->Self{ + Self{dom} + } + pub fn into_place(self)->(Place,roblox_emulator::place::Services){ + let (dom,services)=roblox_emulator::place::new_place_with_instances_in_workspace(self.dom); + (Place{dom},services) + } +} +impl AsRef for Model{ + fn as_ref(&self)->&WeakDom{ + &self.dom + } +} + +pub struct Place{ + dom:WeakDom, +} +impl Place{ + pub fn run_scripts(&mut self,services:roblox_emulator::place::Services){ let runner=roblox_emulator::runner::Runner::new().unwrap(); let context=roblox_emulator::context::Context::from_mut(&mut self.dom); let scripts=context.scripts(); @@ -30,6 +51,11 @@ impl Dom{ } } } +impl AsRef for Place{ + fn as_ref(&self)->&WeakDom{ + &self.dom + } +} #[derive(Debug)] pub enum ReadError{ @@ -45,12 +71,12 @@ impl std::fmt::Display for ReadError{ } impl std::error::Error for ReadError{} -pub fn read(input:R)->Result{ +pub fn read(input:R)->Result{ let mut buf=std::io::BufReader::new(input); let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?; match &peek[0..8]{ - b"rbx_binary::from_reader(buf).map(Dom).map_err(ReadError::RbxBinary), - b"rbx_xml::from_reader_default(buf).map(Dom).map_err(ReadError::RbxXml), + b"rbx_binary::from_reader(buf).map(Model::new).map_err(ReadError::RbxBinary), + b"rbx_xml::from_reader_default(buf).map(Model::new).map_err(ReadError::RbxXml), _=>Err(ReadError::UnknownFileFormat), } } @@ -58,7 +84,7 @@ pub fn read(input:R)->Result{ //ConvertError pub fn convert( - dom:&Dom, + dom:impl AsRef, acquire_render_config_id:AcquireRenderConfigId, acquire_mesh_id:AcquireMeshId )->rbx::PartialMap1 @@ -66,5 +92,5 @@ where AcquireRenderConfigId:FnMut(Option<&str>)->strafesnet_common::model::RenderConfigId, AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId, { - rbx::convert(&dom.0,acquire_render_config_id,acquire_mesh_id) + rbx::convert(&dom.as_ref(),acquire_render_config_id,acquire_mesh_id) } From 7a3184efd5f53ce2c3277da0376ce1c8dee2a238 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 3 Oct 2024 19:37:10 -0700 Subject: [PATCH 44/49] v0.5.0 convert to Place --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 196c7cd..3cb3bf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -632,7 +632,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.4.1" +version = "0.5.0" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index 3f868db..e24f4f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.4.1" +version = "0.5.0" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From d002216bd9214a57cb9488b6e23c92e3f6320e85 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 3 Oct 2024 20:22:45 -0700 Subject: [PATCH 45/49] place includes services... duh --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/lib.rs | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cb3bf2..c7ae28f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.3.0" +version = "0.3.1" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "ba81a9134bb07930669340c7aad34719e74690f68771c6ef7b093f00ddba9e65" +checksum = "b58d7bb42d458984e629a012757474710fd0e429c2c824a2529574be5e7c2fd6" dependencies = [ "glam", "mlua", diff --git a/Cargo.toml b/Cargo.toml index e24f4f6..f1914cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,5 +18,5 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -roblox_emulator = { version = "0.3.0", registry = "strafesnet" } +roblox_emulator = { version = "0.3.1", registry = "strafesnet" } strafesnet_common = { version = "0.5.1", registry = "strafesnet" } diff --git a/src/lib.rs b/src/lib.rs index 8cab9fd..0fec914 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,9 +24,9 @@ impl Model{ fn new(dom:WeakDom)->Self{ Self{dom} } - pub fn into_place(self)->(Place,roblox_emulator::place::Services){ + pub fn into_place(self)->Place{ let (dom,services)=roblox_emulator::place::new_place_with_instances_in_workspace(self.dom); - (Place{dom},services) + Place{dom,services} } } impl AsRef for Model{ @@ -37,11 +37,13 @@ impl AsRef for Model{ pub struct Place{ dom:WeakDom, + services:roblox_emulator::place::Services, } impl Place{ - pub fn run_scripts(&mut self,services:roblox_emulator::place::Services){ + pub fn run_scripts(&mut self){ + let Place{dom,services}=self; let runner=roblox_emulator::runner::Runner::new().unwrap(); - let context=roblox_emulator::context::Context::from_mut(&mut self.dom); + let context=roblox_emulator::context::Context::from_mut(dom); let scripts=context.scripts(); let runnable=runner.runnable_context(context,services).unwrap(); for script in scripts{ From 14cc0776a6bed5dbefba684af1d270e1ab0d8ff7 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 3 Oct 2024 20:30:48 -0700 Subject: [PATCH 46/49] v0.5.1 place includes services --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7ae28f..ae44c7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -632,7 +632,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.5.0" +version = "0.5.1" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index f1914cc..140ae91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.5.0" +version = "0.5.1" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From 7e094941467af493fdb6cb0105dbade1799de806 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 4 Oct 2024 16:32:34 -0700 Subject: [PATCH 47/49] update roblox_emulator --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/lib.rs | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ae44c7e..59593fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "roblox_emulator" -version = "0.3.1" +version = "0.4.0" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "b58d7bb42d458984e629a012757474710fd0e429c2c824a2529574be5e7c2fd6" +checksum = "df647d25a9bc8871a838a830ae90776cd31c44d1a74268bd783d1cadcd8fcd93" dependencies = [ "glam", "mlua", diff --git a/Cargo.toml b/Cargo.toml index 140ae91..c7c6411 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,5 +18,5 @@ rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_mesh = "0.1.2" rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" } -roblox_emulator = { version = "0.3.1", registry = "strafesnet" } +roblox_emulator = { version = "0.4.0", registry = "strafesnet" } strafesnet_common = { version = "0.5.1", registry = "strafesnet" } diff --git a/src/lib.rs b/src/lib.rs index 0fec914..06fbb07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,9 @@ impl Model{ Self{dom} } pub fn into_place(self)->Place{ - let (dom,services)=roblox_emulator::place::new_place_with_instances_in_workspace(self.dom); + let Self{mut dom}=self; + let context=roblox_emulator::context::Context::from_mut(&mut dom); + let services=context.convert_into_place(); Place{dom,services} } } @@ -37,15 +39,22 @@ impl AsRef for Model{ pub struct Place{ dom:WeakDom, - services:roblox_emulator::place::Services, + services:roblox_emulator::context::Services, } impl Place{ + fn new(dom:WeakDom)->Option{ + let context=roblox_emulator::context::Context::from_ref(&dom); + Some(Self{ + services:context.find_services()?, + dom, + }) + } pub fn run_scripts(&mut self){ let Place{dom,services}=self; let runner=roblox_emulator::runner::Runner::new().unwrap(); let context=roblox_emulator::context::Context::from_mut(dom); let scripts=context.scripts(); - let runnable=runner.runnable_context(context,services).unwrap(); + let runnable=runner.runnable_context_with_services(context,services).unwrap(); for script in scripts{ if let Err(e)=runnable.run_script(script){ println!("runner error: {e}"); From 7980770b8d10a18d5248a879cc59353be24d650c Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 4 Oct 2024 16:58:01 -0700 Subject: [PATCH 48/49] v0.5.2 update roblox_emulator --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59593fb..192af3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -632,7 +632,7 @@ dependencies = [ [[package]] name = "strafesnet_rbx_loader" -version = "0.5.1" +version = "0.5.2" dependencies = [ "bytemuck", "glam", diff --git a/Cargo.toml b/Cargo.toml index c7c6411..13096e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strafesnet_rbx_loader" -version = "0.5.1" +version = "0.5.2" edition = "2021" repository = "https://git.itzana.me/StrafesNET/rbx_loader" license = "MIT OR Apache-2.0" From 831cbfef58b7503ee39339e632071e2fb5d5002a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 2 Jan 2025 19:45:22 -0800 Subject: [PATCH 49/49] rbx_loader: move into folder --- .gitignore => lib/rbx_loader/.gitignore | 0 Cargo.lock => lib/rbx_loader/Cargo.lock | 0 Cargo.toml => lib/rbx_loader/Cargo.toml | 0 LICENSE-APACHE => lib/rbx_loader/LICENSE-APACHE | 0 LICENSE-MIT => lib/rbx_loader/LICENSE-MIT | 0 README.md => lib/rbx_loader/README.md | 0 {src => lib/rbx_loader/src}/lib.rs | 0 {src => lib/rbx_loader/src}/mesh.rs | 0 {src => lib/rbx_loader/src}/primitives.rs | 0 {src => lib/rbx_loader/src}/rbx.rs | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => lib/rbx_loader/.gitignore (100%) rename Cargo.lock => lib/rbx_loader/Cargo.lock (100%) rename Cargo.toml => lib/rbx_loader/Cargo.toml (100%) rename LICENSE-APACHE => lib/rbx_loader/LICENSE-APACHE (100%) rename LICENSE-MIT => lib/rbx_loader/LICENSE-MIT (100%) rename README.md => lib/rbx_loader/README.md (100%) rename {src => lib/rbx_loader/src}/lib.rs (100%) rename {src => lib/rbx_loader/src}/mesh.rs (100%) rename {src => lib/rbx_loader/src}/primitives.rs (100%) rename {src => lib/rbx_loader/src}/rbx.rs (100%) diff --git a/.gitignore b/lib/rbx_loader/.gitignore similarity index 100% rename from .gitignore rename to lib/rbx_loader/.gitignore diff --git a/Cargo.lock b/lib/rbx_loader/Cargo.lock similarity index 100% rename from Cargo.lock rename to lib/rbx_loader/Cargo.lock diff --git a/Cargo.toml b/lib/rbx_loader/Cargo.toml similarity index 100% rename from Cargo.toml rename to lib/rbx_loader/Cargo.toml diff --git a/LICENSE-APACHE b/lib/rbx_loader/LICENSE-APACHE similarity index 100% rename from LICENSE-APACHE rename to lib/rbx_loader/LICENSE-APACHE diff --git a/LICENSE-MIT b/lib/rbx_loader/LICENSE-MIT similarity index 100% rename from LICENSE-MIT rename to lib/rbx_loader/LICENSE-MIT diff --git a/README.md b/lib/rbx_loader/README.md similarity index 100% rename from README.md rename to lib/rbx_loader/README.md diff --git a/src/lib.rs b/lib/rbx_loader/src/lib.rs similarity index 100% rename from src/lib.rs rename to lib/rbx_loader/src/lib.rs diff --git a/src/mesh.rs b/lib/rbx_loader/src/mesh.rs similarity index 100% rename from src/mesh.rs rename to lib/rbx_loader/src/mesh.rs diff --git a/src/primitives.rs b/lib/rbx_loader/src/primitives.rs similarity index 100% rename from src/primitives.rs rename to lib/rbx_loader/src/primitives.rs diff --git a/src/rbx.rs b/lib/rbx_loader/src/rbx.rs similarity index 100% rename from src/rbx.rs rename to lib/rbx_loader/src/rbx.rs