Compare commits

..

16 Commits

6 changed files with 332 additions and 102 deletions

265
Cargo.lock generated
View File

@ -31,9 +31,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.3.0" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]] [[package]]
name = "base64" name = "base64"
@ -90,6 +90,22 @@ dependencies = [
"constant_time_eq", "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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c"
dependencies = [
"memchr",
"serde",
]
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.18.0" version = "1.18.0"
@ -104,9 +120,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.19" version = "1.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -129,6 +145,18 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" 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]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.15" version = "0.2.15"
@ -142,9 +170,9 @@ dependencies = [
[[package]] [[package]]
name = "glam" name = "glam"
version = "0.28.0" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" checksum = "c28091a37a5d09b555cb6628fd954da299b536433834f5b8e59eba78e0cbbf8a"
[[package]] [[package]]
name = "id" name = "id"
@ -154,7 +182,7 @@ checksum = "2337e7a6c273082b672e377e159d7a168fb51438461b7c4033c79a515dd7a25a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -177,7 +205,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex", "regex",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -188,9 +216,30 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.158" version = "0.2.159"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[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 = "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]] [[package]]
name = "log" name = "log"
@ -199,19 +248,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]] [[package]]
name = "lz4" name = "luau0-src"
version = "1.27.0" version = "0.10.3+luau640"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a231296ca742e418c43660cb68e082486ff2538e8db432bc818580f3965025ed" checksum = "2f39d12b514a676c943990cfbe6200fedcb9c293c8c9219d29be512a6969be92"
dependencies = [
"cc",
]
[[package]]
name = "lz4"
version = "1.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725"
dependencies = [ dependencies = [
"lz4-sys", "lz4-sys",
] ]
[[package]] [[package]]
name = "lz4-sys" 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" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb44a01837a858d47e5a630d2ccf304c8efcc4b83b8f9f75b7a9ee4fcc6e57d" checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -223,6 +281,32 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 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]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.19" version = "0.2.19"
@ -234,9 +318,12 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.19.0" version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
dependencies = [
"portable-atomic",
]
[[package]] [[package]]
name = "owo-colors" name = "owo-colors"
@ -250,6 +337,18 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pkg-config"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "portable-atomic"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.20" version = "0.2.20"
@ -284,7 +383,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -326,6 +425,12 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "ratio_ops"
version = "0.1.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "01239195d6afe0509e7e3511b716c0540251dfe7ece0a9a5a27116afb766c42c"
[[package]] [[package]]
name = "rbx_binary" name = "rbx_binary"
version = "0.7.4" version = "0.7.4"
@ -415,9 +520,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.6" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -427,9 +532,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-automata" name = "regex-automata"
version = "0.4.7" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -438,9 +543,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.8.4" version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]] [[package]]
name = "rmp" name = "rmp"
@ -464,6 +569,26 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "roblox_emulator"
version = "0.4.0"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "df647d25a9bc8871a838a830ae90776cd31c44d1a74268bd783d1cadcd8fcd93"
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]] [[package]]
name = "serde" name = "serde"
version = "1.0.210" version = "1.0.210"
@ -481,7 +606,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -492,19 +617,22 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "strafesnet_common" name = "strafesnet_common"
version = "0.4.1" version = "0.5.2"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "9a2621612e675a8f804abbbbe3b60caeafe58a2422cccbe453268d6f457df4f3" checksum = "91cc1f3699bd8248da18bf5d11273264396a257b5d47b8558acb2cb4e1761219"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bitflags 2.6.0", "bitflags 2.6.0",
"fixed_wide",
"glam", "glam",
"id", "id",
"linear_ops",
"ratio_ops",
] ]
[[package]] [[package]]
name = "strafesnet_rbx_loader" name = "strafesnet_rbx_loader"
version = "0.3.4" version = "0.5.2"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"glam", "glam",
@ -514,6 +642,7 @@ dependencies = [
"rbx_mesh", "rbx_mesh",
"rbx_reflection_database", "rbx_reflection_database",
"rbx_xml", "rbx_xml",
"roblox_emulator",
"strafesnet_common", "strafesnet_common",
] ]
@ -530,9 +659,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.77" version = "2.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -541,22 +670,22 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.63" version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.63" version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -571,6 +700,70 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 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]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.22" version = "0.8.22"
@ -595,5 +788,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "strafesnet_rbx_loader" name = "strafesnet_rbx_loader"
version = "0.3.4" version = "0.5.2"
edition = "2021" edition = "2021"
repository = "https://git.itzana.me/StrafesNET/rbx_loader" repository = "https://git.itzana.me/StrafesNET/rbx_loader"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
@ -11,11 +11,12 @@ authors = ["Rhys Lloyd <krakow20@gmail.com>"]
[dependencies] [dependencies]
bytemuck = "1.14.3" bytemuck = "1.14.3"
glam = "0.28.0" glam = "0.29.0"
lazy-regex = "3.1.0" lazy-regex = "3.1.0"
rbx_binary = { version = "0.7.4", registry = "strafesnet" } rbx_binary = { version = "0.7.4", registry = "strafesnet" }
rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" } rbx_dom_weak = { version = "2.7.0", registry = "strafesnet" }
rbx_mesh = "0.1.2" rbx_mesh = "0.1.2"
rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" } rbx_reflection_database = { version = "0.2.10", registry = "strafesnet" }
rbx_xml = { version = "0.13.3", registry = "strafesnet" } rbx_xml = { version = "0.13.3", registry = "strafesnet" }
strafesnet_common = { version = "0.4.0", registry = "strafesnet" } roblox_emulator = { version = "0.4.0", registry = "strafesnet" }
strafesnet_common = { version = "0.5.1", registry = "strafesnet" }

View File

@ -1,4 +1,5 @@
use std::io::Read; use std::io::Read;
use rbx_dom_weak::WeakDom;
mod rbx; mod rbx;
mod mesh; mod mesh;
@ -16,19 +17,54 @@ pub mod data{
} }
} }
pub struct Dom(rbx_dom_weak::WeakDom); pub struct Model{
impl Dom{ dom:WeakDom,
pub fn run_scripts(self)->Self{ }
impl Model{
fn new(dom:WeakDom)->Self{
Self{dom}
}
pub fn into_place(self)->Place{
let Self{mut dom}=self;
let context=roblox_emulator::context::Context::from_mut(&mut dom);
let services=context.convert_into_place();
Place{dom,services}
}
}
impl AsRef<WeakDom> for Model{
fn as_ref(&self)->&WeakDom{
&self.dom
}
}
pub struct Place{
dom:WeakDom,
services:roblox_emulator::context::Services,
}
impl Place{
fn new(dom:WeakDom)->Option<Self>{
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 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(dom);
for script in context.scripts(){ let scripts=context.scripts();
let (modified_context,script_error)=runner.run_script(script,context); let runnable=runner.runnable_context_with_services(context,services).unwrap();
context=modified_context; for script in scripts{
if let Err(e)=script_error{ if let Err(e)=runnable.run_script(script){
e.print(); println!("runner error: {e}");
} }
} }
Self(context.into_inner()) }
}
impl AsRef<WeakDom> for Place{
fn as_ref(&self)->&WeakDom{
&self.dom
} }
} }
@ -46,12 +82,12 @@ impl std::fmt::Display for ReadError{
} }
impl std::error::Error for ReadError{} impl std::error::Error for ReadError{}
pub fn read<R:Read>(input:R)->Result<Dom,ReadError>{ pub fn read<R:Read>(input:R)->Result<Model,ReadError>{
let mut buf=std::io::BufReader::new(input); let mut buf=std::io::BufReader::new(input);
let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?; let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadError::Io)?;
match &peek[0..8]{ match &peek[0..8]{
b"<roblox!"=>rbx_binary::from_reader(buf).map(Dom).map_err(ReadError::RbxBinary), b"<roblox!"=>rbx_binary::from_reader(buf).map(Model::new).map_err(ReadError::RbxBinary),
b"<roblox "=>rbx_xml::from_reader_default(buf).map(Dom).map_err(ReadError::RbxXml), b"<roblox "=>rbx_xml::from_reader_default(buf).map(Model::new).map_err(ReadError::RbxXml),
_=>Err(ReadError::UnknownFileFormat), _=>Err(ReadError::UnknownFileFormat),
} }
} }
@ -59,7 +95,7 @@ pub fn read<R:Read>(input:R)->Result<Dom,ReadError>{
//ConvertError //ConvertError
pub fn convert<AcquireRenderConfigId,AcquireMeshId>( pub fn convert<AcquireRenderConfigId,AcquireMeshId>(
dom:&Dom, dom:impl AsRef<WeakDom>,
acquire_render_config_id:AcquireRenderConfigId, acquire_render_config_id:AcquireRenderConfigId,
acquire_mesh_id:AcquireMeshId acquire_mesh_id:AcquireMeshId
)->rbx::PartialMap1 )->rbx::PartialMap1
@ -67,5 +103,5 @@ where
AcquireRenderConfigId:FnMut(Option<&str>)->strafesnet_common::model::RenderConfigId, AcquireRenderConfigId:FnMut(Option<&str>)->strafesnet_common::model::RenderConfigId,
AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId, 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)
} }

View File

@ -1,7 +1,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use rbx_mesh::mesh::{Vertex2, Vertex2Truncated}; 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)] #[derive(Debug)]
pub enum Error{ pub enum Error{
@ -108,7 +108,7 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<model::Me
let mut vertex_id_from=HashMap::new(); let mut vertex_id_from=HashMap::new();
let mut polygon_groups=Vec::new(); let mut polygon_groups=Vec::new();
let mut acquire_pos_id=|pos|{ let mut acquire_pos_id=|pos|{
let p=Planar64Vec3::try_from(pos).map_err(Error::Planar64Vec3)?; let p=vec3::try_from_f32_array(pos).map_err(Error::Planar64Vec3)?;
Ok(PositionId::new(*pos_id_from.entry(p).or_insert_with(||{ Ok(PositionId::new(*pos_id_from.entry(p).or_insert_with(||{
let pos_id=unique_pos.len(); let pos_id=unique_pos.len();
unique_pos.push(p); unique_pos.push(p);
@ -124,7 +124,7 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<model::Me
}) as u32) }) as u32)
}; };
let mut acquire_normal_id=|normal|{ let mut acquire_normal_id=|normal|{
let n=Planar64Vec3::try_from(normal).map_err(Error::Planar64Vec3)?; let n=vec3::try_from_f32_array(normal).map_err(Error::Planar64Vec3)?;
Ok(NormalId::new(*normal_id_from.entry(n).or_insert_with(||{ Ok(NormalId::new(*normal_id_from.entry(n).or_insert_with(||{
let normal_id=unique_normal.len(); let normal_id=unique_normal.len();
unique_normal.push(n); unique_normal.push(n);

View File

@ -1,5 +1,5 @@
use strafesnet_common::model::{Color4,TextureCoordinate,Mesh,IndexedGraphicsGroup,IndexedPhysicsGroup,IndexedVertex,PolygonGroupId,PolygonGroup,PolygonList,IndexedVertexList,PositionId,TextureCoordinateId,NormalId,ColorId,VertexId,RenderConfigId}; 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; use strafesnet_common::integer::{vec3,Planar64Vec3};
#[derive(Debug)] #[derive(Debug)]
pub enum Primitives{ pub enum Primitives{
@ -25,22 +25,22 @@ const CUBE_DEFAULT_TEXTURE_COORDS:[TextureCoordinate;4]=[
TextureCoordinate::new(0.0,1.0), TextureCoordinate::new(0.0,1.0),
]; ];
const CUBE_DEFAULT_VERTICES:[Planar64Vec3;8]=[ const CUBE_DEFAULT_VERTICES:[Planar64Vec3;8]=[
Planar64Vec3::int(-1,-1, 1),//0 left bottom back vec3::int(-1,-1, 1),//0 left bottom back
Planar64Vec3::int( 1,-1, 1),//1 right bottom back vec3::int( 1,-1, 1),//1 right bottom back
Planar64Vec3::int( 1, 1, 1),//2 right top back vec3::int( 1, 1, 1),//2 right top back
Planar64Vec3::int(-1, 1, 1),//3 left top back vec3::int(-1, 1, 1),//3 left top back
Planar64Vec3::int(-1, 1,-1),//4 left top front vec3::int(-1, 1,-1),//4 left top front
Planar64Vec3::int( 1, 1,-1),//5 right top front vec3::int( 1, 1,-1),//5 right top front
Planar64Vec3::int( 1,-1,-1),//6 right bottom front vec3::int( 1,-1,-1),//6 right bottom front
Planar64Vec3::int(-1,-1,-1),//7 left bottom front vec3::int(-1,-1,-1),//7 left bottom front
]; ];
const CUBE_DEFAULT_NORMALS:[Planar64Vec3;6]=[ const CUBE_DEFAULT_NORMALS:[Planar64Vec3;6]=[
Planar64Vec3::int( 1, 0, 0),//CubeFace::Right vec3::int( 1, 0, 0),//CubeFace::Right
Planar64Vec3::int( 0, 1, 0),//CubeFace::Top vec3::int( 0, 1, 0),//CubeFace::Top
Planar64Vec3::int( 0, 0, 1),//CubeFace::Back vec3::int( 0, 0, 1),//CubeFace::Back
Planar64Vec3::int(-1, 0, 0),//CubeFace::Left vec3::int(-1, 0, 0),//CubeFace::Left
Planar64Vec3::int( 0,-1, 0),//CubeFace::Bottom vec3::int( 0,-1, 0),//CubeFace::Bottom
Planar64Vec3::int( 0, 0,-1),//CubeFace::Front vec3::int( 0, 0,-1),//CubeFace::Front
]; ];
const CUBE_DEFAULT_POLYS:[[[u32;3];4];6]=[ const CUBE_DEFAULT_POLYS:[[[u32;3];4];6]=[
// right (1, 0, 0) // right (1, 0, 0)
@ -96,11 +96,11 @@ pub enum WedgeFace{
Bottom, Bottom,
} }
const WEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[ const WEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[
Planar64Vec3::int( 1, 0, 0),//Wedge::Right vec3::int( 1, 0, 0),//Wedge::Right
Planar64Vec3::int( 0, 1,-1),//Wedge::TopFront vec3::int( 0, 1,-1),//Wedge::TopFront
Planar64Vec3::int( 0, 0, 1),//Wedge::Back vec3::int( 0, 0, 1),//Wedge::Back
Planar64Vec3::int(-1, 0, 0),//Wedge::Left vec3::int(-1, 0, 0),//Wedge::Left
Planar64Vec3::int( 0,-1, 0),//Wedge::Bottom vec3::int( 0,-1, 0),//Wedge::Bottom
]; ];
/* /*
local cornerWedgeVerticies = { local cornerWedgeVerticies = {
@ -120,11 +120,11 @@ pub enum CornerWedgeFace{
Front, Front,
} }
const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[ const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[
Planar64Vec3::int( 1, 0, 0),//CornerWedge::Right vec3::int( 1, 0, 0),//CornerWedge::Right
Planar64Vec3::int( 0, 1, 1),//CornerWedge::BackTop vec3::int( 0, 1, 1),//CornerWedge::BackTop
Planar64Vec3::int(-1, 1, 0),//CornerWedge::LeftTop vec3::int(-1, 1, 0),//CornerWedge::LeftTop
Planar64Vec3::int( 0,-1, 0),//CornerWedge::Bottom vec3::int( 0,-1, 0),//CornerWedge::Bottom
Planar64Vec3::int( 0, 0,-1),//CornerWedge::Front vec3::int( 0, 0,-1),//CornerWedge::Front
]; ];
pub fn unit_sphere(render:RenderConfigId)->Mesh{ pub fn unit_sphere(render:RenderConfigId)->Mesh{
unit_cube(render) unit_cube(render)

View File

@ -5,7 +5,7 @@ use strafesnet_common::model;
use strafesnet_common::gameplay_modes; use strafesnet_common::gameplay_modes;
use strafesnet_common::gameplay_style; use strafesnet_common::gameplay_style;
use strafesnet_common::gameplay_attributes as attr; 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::model::RenderConfigId;
use strafesnet_common::updatable::Updatable; use strafesnet_common::updatable::Updatable;
@ -36,15 +36,15 @@ fn recursive_collect_superclass(objects: &mut std::vec::Vec<rbx_dom_weak::types:
} }
fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_weak::types::Vector3)->Planar64Affine3{ fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_weak::types::Vector3)->Planar64Affine3{
Planar64Affine3::new( Planar64Affine3::new(
Planar64Mat3::from_cols( Planar64Mat3::from_cols([
Planar64Vec3::try_from([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x]).unwrap() vec3::try_from_f32_array([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x]).unwrap()
*Planar64::try_from(size.x/2.0).unwrap(), *integer::try_from_f32(size.x/2.0).unwrap(),
Planar64Vec3::try_from([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y]).unwrap() vec3::try_from_f32_array([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y]).unwrap()
*Planar64::try_from(size.y/2.0).unwrap(), *integer::try_from_f32(size.y/2.0).unwrap(),
Planar64Vec3::try_from([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z]).unwrap() vec3::try_from_f32_array([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z]).unwrap()
*Planar64::try_from(size.z/2.0).unwrap(), *integer::try_from_f32(size.z/2.0).unwrap(),
), ].map(|t|t.fix_1())),
Planar64Vec3::try_from([cf.position.x,cf.position.y,cf.position.z]).unwrap() vec3::try_from_f32_array([cf.position.x,cf.position.y,cf.position.z]).unwrap()
) )
} }
struct ModeBuilder{ struct ModeBuilder{
@ -63,7 +63,7 @@ impl ModesBuilder{
//collect modes and stages into contiguous arrays //collect modes and stages into contiguous arrays
let mut unique_modes:Vec<(gameplay_modes::ModeId,gameplay_modes::Mode)> let mut unique_modes:Vec<(gameplay_modes::ModeId,gameplay_modes::Mode)>
=self.modes.into_iter().collect(); =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<ModeBuilder>,HashMap<gameplay_modes::ModeId,gameplay_modes::ModeId>) let (mut modes,final_mode_id_from_builder_mode_id):(Vec<ModeBuilder>,HashMap<gameplay_modes::ModeId,gameplay_modes::ModeId>)
=unique_modes.into_iter().enumerate() =unique_modes.into_iter().enumerate()
.map(|(final_mode_id,(builder_mode_id,mut mode))|{ .map(|(final_mode_id,(builder_mode_id,mut mode))|{
@ -317,7 +317,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
} }
} }
//need some way to skip this //need some way to skip this
if velocity!=Planar64Vec3::ZERO{ if velocity!=vec3::ZERO{
general.booster=Some(attr::Booster::Velocity(velocity)); general.booster=Some(attr::Booster::Velocity(velocity));
} }
match force_can_collide{ match force_can_collide{
@ -473,7 +473,7 @@ where
{ {
let model_transform=planar64_affine3_from_roblox(cf,size); 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 parent_ref=object.parent();
let mut full_path=object.name.clone(); let mut full_path=object.name.clone();
while let Some(parent)=dom.get_by_ref(parent_ref){ while let Some(parent)=dom.get_by_ref(parent_ref){
@ -708,7 +708,7 @@ where
deferred_attributes:GetAttributesArgs{ deferred_attributes:GetAttributesArgs{
name:object.name.as_str().into(), name:object.name.as_str().into(),
can_collide:*can_collide, 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{ match availability{
@ -806,11 +806,11 @@ impl PartialMap1{
deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes, deferred_attributes:deferred_model_deferred_attributes.model.deferred_attributes,
color:deferred_model_deferred_attributes.model.color, color:deferred_model_deferred_attributes.model.color,
transform:Planar64Affine3::new( transform:Planar64Affine3::new(
Planar64Mat3::from_cols( Planar64Mat3::from_cols([
deferred_model_deferred_attributes.model.transform.matrix3.x_axis*2/size.x(), (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(), (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() (deferred_model_deferred_attributes.model.transform.matrix3.z_axis*2/size.z).divide().fix_1()
), ]),
deferred_model_deferred_attributes.model.transform.translation deferred_model_deferred_attributes.model.transform.translation
), ),
}) })