diff --git a/Cargo.lock b/Cargo.lock index c2e59b4..001dc15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.10", "once_cell", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -117,14 +117,14 @@ dependencies = [ "getrandom 0.2.10", "once_cell", "serde", - "version_check", + "version_check 0.9.4", ] [[package]] name = "aho-corasick" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -222,9 +222,9 @@ dependencies = [ [[package]] name = "arboard" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" +checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc" dependencies = [ "clipboard-win", "core-graphics", @@ -233,7 +233,6 @@ dependencies = [ "objc", "objc-foundation", "objc_id", - "once_cell", "parking_lot 0.12.1", "thiserror", "winapi", @@ -341,9 +340,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "better-bae" @@ -414,7 +413,7 @@ checksum = "0edba455601861b8e8b76128ae5d46dd968114edde60f0ac3d2c21535a947548" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -528,7 +527,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -621,7 +620,7 @@ checksum = "c5cc78985f4d0ad1fd7b8ead06dcfaa192685775a7b1be158191c788c7d52298" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -679,7 +678,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -865,7 +864,7 @@ checksum = "d1cd460205fe05634d58b32d9bb752b1b4eaf32b2d29cbd4161ba35eb44a2f8c" dependencies = [ "quote", "rustc-hash", - "syn 2.0.29", + "syn 2.0.36", "toml_edit", ] @@ -890,9 +889,9 @@ dependencies = [ [[package]] name = "bevy_mod_billboard" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1680dd7d6ff174dc86f50465a37d89aec8b6ae22f1b62c6579152fb399bfae21" +checksum = "1461d2d757cb3ee6a8f6f5cf5589b7bf00752e2f03d633598b297b5e87f4e65b" dependencies = [ "bevy", "bitflags 2.4.0", @@ -981,7 +980,7 @@ dependencies = [ "bit-set", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", "uuid", ] @@ -1044,7 +1043,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -1234,7 +1233,20 @@ checksum = "0d104f29e231123c703e8b394e2341d2425c33c5a2e9ab8cc8d0a554bdb62a41" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", +] + +[[package]] +name = "bevy_vox_mesh" +version = "0.7.0" +source = "git+https://github.com/zzhgithub/bevy_vox_mesh.git?branch=fix#3d80c16be22b3b3198d7a760bf2cdba0f2c9d8e1" +dependencies = [ + "anyhow", + "bevy", + "block-mesh", + "dot_vox", + "ndcopy", + "ndshape", ] [[package]] @@ -1378,28 +1390,28 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" +checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -1410,9 +1422,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" @@ -1436,7 +1448,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom", + "nom 7.1.3", ] [[package]] @@ -1886,6 +1898,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "dot_vox" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c18405ef54de0398b77a3ec8394d3a1639e7bf060e1385201e8db40c44ab41" +dependencies = [ + "byteorder", + "lazy_static", + "log", + "nom 4.2.3", +] + [[package]] name = "downcast-rs" version = "1.2.0" @@ -1975,7 +1999,7 @@ checksum = "3fe2568f851fd6144a45fa91cfed8fe5ca8fc0b56ba6797bfc1ed2771b90e37c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -2011,9 +2035,9 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -2193,7 +2217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -2255,7 +2279,7 @@ dependencies = [ "libc", "libudev-sys", "log", - "nix 0.26.3", + "nix 0.26.4", "uuid", "vec_map", "wasm-bindgen", @@ -2323,7 +2347,7 @@ dependencies = [ "inflections", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -2510,7 +2534,7 @@ dependencies = [ [[package]] name = "huffman-compress" version = "0.6.1" -source = "git+https://github.com/zzhgithub/rust-huffman-compress?branch=features-serde#6b09ee0290deab72a51b5927b7553fba8c0f37c7" +source = "git+https://github.com/zzhgithub/rust-huffman-compress?branch=features-serde#a7b1a8a486b4b893ea738c8ca8c77bf05a8f8327" dependencies = [ "bit-vec", "num-traits", @@ -2745,6 +2769,7 @@ dependencies = [ "bevy_rapier3d", "bevy_renet", "bevy_sprite3d", + "bevy_vox_mesh", "bincode", "bit-vec", "block-mesh", @@ -2755,6 +2780,7 @@ dependencies = [ "futures-lite", "fxhash", "huffman-compress", + "lazy_static", "lock_api", "ndshape", "noise", @@ -2866,9 +2892,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libloading" @@ -2908,9 +2934,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -2967,9 +2993,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memoffset" @@ -3161,11 +3187,11 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abbbc55ad7b13aac85f9401c796dcda1b864e07fcad40ad47792eaa8932ea502" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ - "bitflags 2.4.0", + "bitflags 1.3.2", "cfg-if 1.0.0", "libc", ] @@ -3187,6 +3213,16 @@ dependencies = [ "rand_xorshift", ] +[[package]] +name = "nom" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +dependencies = [ + "memchr", + "version_check 0.1.5", +] + [[package]] name = "nom" version = "7.1.3" @@ -3337,7 +3373,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -3407,9 +3443,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -3708,7 +3744,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -3719,7 +3755,7 @@ checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", "quote", - "version_check", + "version_check 0.9.4", ] [[package]] @@ -3730,18 +3766,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46b2164ebdb1dfeec5e337be164292351e11daf63a05174c6776b2f47460f0c9" +checksum = "45f10e75d83c7aec79a6aa46f897075890e156b105eebe51cfa0abce51af025f" [[package]] name = "quote" @@ -3902,13 +3938,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.7", + "regex-automata 0.3.8", "regex-syntax 0.7.5", ] @@ -3923,9 +3959,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -4006,7 +4042,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bitflags 2.4.0", "serde", "serde_derive", @@ -4026,9 +4062,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.9" +version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ "bitflags 2.4.0", "errno", @@ -4116,14 +4152,14 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -4141,9 +4177,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "simba" @@ -4214,7 +4250,7 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" dependencies = [ - "version_check", + "version_check 0.9.4", ] [[package]] @@ -4340,9 +4376,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "91e02e55d62894af2a08aca894c6577281f76769ba47c94d5756bec8ac6e7373" dependencies = [ "proc-macro2", "quote", @@ -4351,9 +4387,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.29.9" +version = "0.29.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d0e9cc2273cc8d31377bdd638d72e3ac3e5607b18621062b169d02787f1bab" +checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5" dependencies = [ "cfg-if 1.0.0", "core-foundation-sys 0.8.4", @@ -4395,9 +4431,9 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] @@ -4424,13 +4460,13 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -4477,9 +4513,9 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.0.0", "toml_datetime", @@ -4506,7 +4542,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", ] [[package]] @@ -4561,9 +4597,9 @@ dependencies = [ [[package]] name = "ttf-parser" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33" +checksum = "49d64318d8311fc2668e48b63969f4343e0a85c4a109aa8460d6672e364b8bd1" [[package]] name = "twox-hash" @@ -4577,9 +4613,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -4589,9 +4625,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -4663,6 +4699,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" + [[package]] name = "version_check" version = "0.9.4" @@ -4677,9 +4719,9 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -4718,7 +4760,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", "wasm-bindgen-shared", ] @@ -4752,7 +4794,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.36", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5245,9 +5287,9 @@ checksum = "a67300977d3dc3f8034dae89778f502b6ba20b269527b3223ba59c0cf393bb8a" [[package]] name = "xml-rs" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1" +checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a" [[package]] name = "zeroize" diff --git a/Cargo.toml b/Cargo.toml index ccea00b..c8ae9a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,10 +55,14 @@ huffman-compress = { git = "https://github.com/zzhgithub/rust-huffman-compress", "serde", ] } noise = { version = "0.8.2" } +lazy_static = "1.4.0" +bevy_vox_mesh = { git = "https://github.com/zzhgithub/bevy_vox_mesh.git", branch = "fix" } + # 解决冲突 lock_api = "0.4.10" codespan-reporting = "0.11.1" + [profile.dev.package.bevy_rapier3d] opt-level = 3 diff --git a/README_CN.md b/README_CN.md index a77e36e..e829fba 100644 --- a/README_CN.md +++ b/README_CN.md @@ -21,6 +21,7 @@ cargo run --release --no-default-features --features headless --bin server For Client ```shell cargo run --release --bin client +# WGPU_BACKEND=opengl ``` # 控制 diff --git "a/assets/staff/\345\267\245\344\275\234\346\226\271\345\235\227.png" "b/assets/staff/\345\267\245\344\275\234\346\226\271\345\235\227.png" new file mode 100644 index 0000000..169bdad Binary files /dev/null and "b/assets/staff/\345\267\245\344\275\234\346\226\271\345\235\227.png" differ diff --git "a/assets/vox/\345\267\245\344\275\234\345\217\260.vox" "b/assets/vox/\345\267\245\344\275\234\345\217\260.vox" new file mode 100644 index 0000000..58ab90c Binary files /dev/null and "b/assets/vox/\345\267\245\344\275\234\345\217\260.vox" differ diff --git a/src/bin/client.rs b/src/bin/client.rs index 629c238..a61b1e0 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -24,6 +24,7 @@ use just_join::{ }, staff::StaffInfoPlugin, tools::inspector_egui::inspector_ui, + voxel_world::voxel_mesh::VoxelMeshPlugin, CLIENT_DEBUG, CLIENT_FPS, }; fn main() { @@ -53,6 +54,7 @@ fn main() { app.add_plugins(StaffInfoPlugin); app.add_plugins(UiResourcePlugin); app.add_plugins(Sprite3dPlugin); + app.add_plugins(VoxelMeshPlugin); app.add_plugins((SplashPlugin, MenuPlugin, NotificationPlugin, GamePlugin)); // 调试工具 diff --git a/src/bin/server.rs b/src/bin/server.rs index d766b3d..5c2de04 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -24,7 +24,7 @@ use just_join::{ }, sky::ServerSkyPlugins, staff::ServerStaffInfoPlugin, - voxel_world::biomes::OtherTreePlugin, + voxel_world::{biomes::OtherTreePlugin, voxel_mesh::VoxelMeshPlugin}, PROTOCOL_ID, }; use renet_visualizer::RenetServerVisualizer; @@ -43,7 +43,11 @@ use { }; #[cfg(feature = "headless")] -use bevy::MinimalPlugins; +use bevy::{ + asset::AssetPlugin, + prelude::{AddAsset, Mesh}, + MinimalPlugins, +}; fn new_renet_server() -> (RenetServer, NetcodeServerTransport) { let server = RenetServer::new(connection_config()); @@ -101,6 +105,8 @@ fn main() { #[cfg(feature = "headless")] { app.add_plugins(MinimalPlugins); + app.add_plugins(AssetPlugin::default()); + app.add_asset::(); } app.add_plugins(RenetServerPlugin); @@ -121,6 +127,7 @@ fn main() { ServerStaffRulePlugin, CossTroughCheckPlugin, OtherTreePlugin, + VoxelMeshPlugin, )); let (server, transport) = new_renet_server(); diff --git a/src/client/mesh_display.rs b/src/client/mesh_display.rs index 3e36ce4..a3f310d 100644 --- a/src/client/mesh_display.rs +++ b/src/client/mesh_display.rs @@ -7,7 +7,7 @@ use bevy::{ prelude::{ AlphaMode, AssetServer, Assets, Color, Commands, Component, Entity, Handle, IVec3, IntoSystemConfigs, Last, MaterialMeshBundle, MaterialPlugin, Mesh, Plugin, PreUpdate, Res, - ResMut, Resource, StandardMaterial, Startup, Transform, Update, + ResMut, Resource, StandardMaterial, Startup, Transform, Update, Vec3, }, tasks::{AsyncComputeTaskPool, Task}, time::{Time, Timer, TimerMode}, @@ -327,7 +327,14 @@ pub fn save_chunk_result( } #[derive(Debug, Component)] -pub struct TerrainMesh; +pub struct TerrainMesh(pub HitMeshType); + +// 可以被识别的方式! +#[derive(Debug, Clone)] +pub enum HitMeshType { + Common, + Sp(Vec3), +} #[derive(Debug, Component)] pub struct WaterMesh; @@ -372,7 +379,7 @@ pub fn update_mesh_system( material: materials.0.clone(), ..Default::default() }, - TerrainMesh, + TerrainMesh(HitMeshType::Common), RaycastMesh::::default(), // Make this mesh ray cast-able )) .id(), diff --git a/src/client/mod.rs b/src/client/mod.rs index 84318ec..a6e4c36 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -31,6 +31,7 @@ pub mod state_manager; pub mod tool_bar_manager; pub mod ui; pub mod voxels; +pub mod sp_mesh_display; // 同步创建或者删除角色 pub fn client_sync_players( diff --git a/src/client/player/mouse_control.rs b/src/client/player/mouse_control.rs index ae88421..8185da7 100644 --- a/src/client/player/mouse_control.rs +++ b/src/client/player/mouse_control.rs @@ -161,8 +161,12 @@ pub fn mouse_button_system( } if mouse_button_input.just_pressed(MouseButton::Right) { - if let Some(crate::staff::StaffType::Voxel(voxel_type)) = tool_bar_data.staff_type() { + // Note: 这里放置时尝试转换成体素再传递 + if let Some(crate::staff::StaffType::Voxel(voxel_type)) = + tool_bar_data.staff_type_try_to_voxel() + { if let Some(pos) = choose_cube.out_center { + println!("放置物品{:?}", voxel_type); // 判断当前这里是否和 其他的player的位置冲突 if check_player_put_object_available(pos.clone(), &player_query) { // 还要发送当前生效的 tool_bar的 index diff --git a/src/client/ray_cast/mod.rs b/src/client/ray_cast/mod.rs index bbda52b..98aec0d 100644 --- a/src/client/ray_cast/mod.rs +++ b/src/client/ray_cast/mod.rs @@ -1,8 +1,8 @@ use bevy::{ prelude::{ AlphaMode, Assets, Color, Commands, Entity, Gizmos, GlobalTransform, Mesh, PbrBundle, - Plugin, Query, Res, ResMut, StandardMaterial, Startup, Transform, Update, Vec3, Visibility, - With, Without, + Plugin, Quat, Query, Res, ResMut, StandardMaterial, Startup, Transform, Update, Vec3, + Visibility, With, Without, }, reflect::Reflect, render::render_resource::PrimitiveTopology, @@ -118,7 +118,7 @@ pub fn touth_mesh_ray_cast( query: Query<&GlobalTransform, With>, mut choose_cube: ResMut, mut gizmos: Gizmos, - query_mesh: Query, + query_mesh: Query<(Entity, &TerrainMesh)>, mut query_help_cube: Query< (&mut Transform, &mut Visibility), (With, Without), @@ -147,7 +147,8 @@ pub fn touth_mesh_ray_cast( }, ); - if let Some((_, hit)) = hits.first() { + if let Some((entity, hit)) = hits.first() { + let (_, mesh_data) = query_mesh.get(*entity).unwrap(); let hit_point = hit.position(); if ray_pos.distance(hit_point) <= TOUCH_RADIUS { let normal = hit.normal(); @@ -159,15 +160,27 @@ pub fn touth_mesh_ray_cast( let rate = timer.elapsed().as_millis() as f32 / timer.duration().as_millis() as f32; gizmos.circle(hit_point, normal, 0.1 * rate, Color::BLUE); } - let center_point = get_pos_chunk_center(hit_point, normal); - let out_center_point = get_pos_chunk_center(hit_point, -normal); + let center_point: Vec3; + match mesh_data.0 { + super::mesh_display::HitMeshType::Common => { + center_point = get_pos_chunk_center(hit_point, normal); + let out_center_point = get_pos_chunk_center(hit_point, -normal); + gizmos.sphere(out_center_point, Quat::IDENTITY, 0.5, Color::GREEN); + choose_cube.out_center = Some(out_center_point); + } + super::mesh_display::HitMeshType::Sp(center) => { + center_point = center; + choose_cube.out_center = None; + } + } + + gizmos.sphere(center_point, Quat::IDENTITY, 0.5, Color::DARK_GRAY); *visibility = Visibility::Visible; *chue_pos = Transform::from_translation(center_point); choose_cube.choose_on = Some(hit_point); choose_cube.center = Some(center_point); - choose_cube.out_center = Some(out_center_point); } else { hidden_help_cube(choose_cube.as_mut(), &mut visibility); } diff --git a/src/client/sp_mesh_display.rs b/src/client/sp_mesh_display.rs new file mode 100644 index 0000000..8bece55 --- /dev/null +++ b/src/client/sp_mesh_display.rs @@ -0,0 +1,256 @@ +// 特殊类型的数据的更新 + +// 1. 生成 需要更新的数据 抛出任务 +// 2. 处理任务 生成entity实体 +// 3. 处理移动出去后的清理问题 + +use bevy::{ + prelude::{ + in_state, Assets, Color, Commands, Component, DespawnRecursiveExt, Entity, + IntoSystemConfigs, OnExit, PbrBundle, Plugin, Query, Res, ResMut, Resource, + StandardMaterial, Transform, Update, Vec3, + }, + tasks::{AsyncComputeTaskPool, Task}, + utils::{HashMap, HashSet}, +}; +use ndshape::{ConstShape, ConstShape3u32}; + +use crate::{ + common::ClipSpheres, + tools::chunk_key_any_xyz_to_vec3, + voxel_world::{ + chunk::{find_chunk_keys_array_by_sphere, generate_offset_array, ChunkKey}, + chunk_map::ChunkMap, + voxel::{Voxel, VoxelDirection}, + voxel_mesh::{VoxelMeshStorge, VOXEL_MESH_MAP}, + }, + CHUNK_SIZE_U32, SP_MESH_DISTANCE, +}; + +use super::{ + mesh_display::{HitMeshType, TerrainMesh}, + state_manager::GameState, +}; + +#[derive(Debug, Clone, Resource)] +pub struct SpMeshManager { + // chunk index + pub entities: HashMap>, +} + +#[derive(Debug, Resource)] +pub struct SpMeshTasks { + pub tasks: Vec>, +} + +#[derive(Debug, Component)] +pub struct NeedDelete; +pub struct SpMeshManagerPlugin; + +impl Plugin for SpMeshManagerPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.insert_resource(SpMeshManager { + entities: HashMap::new(), + }); + app.insert_resource(SpMeshTasks { tasks: Vec::new() }); + app.add_systems( + Update, + ( + sp_mesh_tasks_update, + deal_sp_mesh_delete, + deal_sp_mesh_tasks, + despawn_sp_mesh, + ) + .run_if(in_state(GameState::Game)), + ); + app.add_systems(OnExit(GameState::Game), unset_all); + } +} + +// 通过球体生成 要关注的 +fn sp_mesh_tasks_update( + mut commands: Commands, + chunk_map: Res, + mut sp_mesh_tasks: ResMut, + clip_spheres: Res, + mut sp_mesh_manager: ResMut, +) { + let pool = AsyncComputeTaskPool::get(); + for chunk_key in find_chunk_keys_array_by_sphere( + clip_spheres.new_sphere, + generate_offset_array(SP_MESH_DISTANCE), + ) { + if let Some(voxels) = chunk_map.get(chunk_key.clone()) { + let mut old_keys: HashSet = HashSet::new(); + // 获取特殊数据 + if let Some(index_voxels_entity_map) = sp_mesh_manager.entities.get_mut(&chunk_key) { + for key in index_voxels_entity_map.keys() { + old_keys.insert(*key); + } + } + for i in 0..voxels.len() { + if VOXEL_MESH_MAP.contains_key(&voxels[i].id) { + if let Some(index_voxels_entity_map) = + sp_mesh_manager.entities.get_mut(&chunk_key) + { + // 原来有老数据 有要处理的数据 + if let Some((v, entity)) = index_voxels_entity_map.get(&(i as u32)) { + // 如果方向发生了变化里面 马上改变方向 + if v.direction != voxels[i].direction { + commands.entity(*entity).insert(get_tfr( + chunk_key.clone(), + i as u32, + voxels[i].direction, + )); + } + // 否则什么也不处理 + old_keys.remove(&(i as u32)); + } else { + // 新创建的 + println!("创建了新的sp"); + let v = voxels[i].clone(); + let task = pool.spawn(async move { (v, chunk_key.clone(), i) }); + sp_mesh_tasks.tasks.push(task); + } + } else { + // 都是新数据 + let v = voxels[i].clone(); + let task = pool.spawn(async move { (v, chunk_key.clone(), i) }); + println!("第一次创建的sp[{:?} on {}]", v, i); + sp_mesh_tasks.tasks.push(task); + } + } + } + // 有一批要删除的数据 + for del_key in old_keys.iter() { + println!("要删除的数据{:?}", old_keys); + if let Some(index_voxels_entity_map) = sp_mesh_manager.entities.get_mut(&chunk_key) + { + if let Some((_, entity)) = index_voxels_entity_map.remove(del_key) { + println!("删除的entity[{:?}]", entity); + commands.entity(entity).insert(NeedDelete); + println!("删除了mesh{}", del_key); + } + } + } + } + } +} + +fn deal_sp_mesh_delete(mut commands: Commands, mesh_query: Query) { + for entity in mesh_query.iter() { + commands.entity(entity).despawn_recursive(); + } +} + +fn deal_sp_mesh_tasks( + mut commands: Commands, + mut sp_mesh_tasks: ResMut, + mut sp_mesh_manager: ResMut, + // 配置数据 + voxel_mesh_storge: Res, + mut stdmats: ResMut>, +) { + let l = sp_mesh_tasks.tasks.len().min(32); + for ele in sp_mesh_tasks.tasks.drain(..l) { + if let Some((v, chunk_key, index)) = + futures_lite::future::block_on(futures_lite::future::poll_once(ele)) + { + if let Some(meta) = voxel_mesh_storge.data.get(&v.id) { + let entity = commands + .spawn(PbrBundle { + transform: get_tfr(chunk_key.clone(), index as u32, v.direction), + // FIXME:这里 暂时取第一个 后面要根据生成器取置换 + mesh: meta.vox_list[0].clone(), + material: stdmats.add(Color::rgb(1., 1., 1.).into()), + ..Default::default() + }) + // 修复这里的出现的中心的问题! + .insert(TerrainMesh(HitMeshType::Sp(get_pos( + chunk_key.clone(), + index as u32, + )))) + .id(); + if let Some(inner_map) = sp_mesh_manager.entities.get_mut(&chunk_key) { + if !inner_map.contains_key(&(index as u32)) { + println!("创建的entity[{:?}]", entity); + inner_map.insert(index as u32, (v, entity)); + } else { + // 这要处理不需要的数据! + commands.entity(entity).despawn(); + } + } else { + println!("第一次创建的entity[{:?}]", entity); + let mut map = HashMap::new(); + map.insert(index as u32, (v, entity)); + sp_mesh_manager.entities.insert(chunk_key, map); + } + } + } + } +} + +// 这里要处理一下 mesh的销毁 +fn despawn_sp_mesh( + mut commands: Commands, + mut sp_mesh_manager: ResMut, + clip_spheres: Res, +) { + let mut del_keys: HashSet = HashSet::new(); + for chunk_key in find_chunk_keys_array_by_sphere( + clip_spheres.old_sphere, + generate_offset_array(SP_MESH_DISTANCE), + ) { + del_keys.insert(chunk_key); + } + for chunk_key in find_chunk_keys_array_by_sphere( + clip_spheres.new_sphere, + generate_offset_array(SP_MESH_DISTANCE), + ) { + del_keys.remove(&chunk_key); + } + if del_keys.len() > 0 { + for key in del_keys { + if let Some(inner_map) = sp_mesh_manager.entities.remove(&key) { + println!("要清理的数据{}", inner_map.len()); + for (_, (_, entity)) in inner_map { + commands.entity(entity).despawn_recursive(); + } + } + } + } +} + +fn unset_all( + mut commands: Commands, + mut sp_mesh_tasks: ResMut, + mut sp_mesh_manager: ResMut, +) { + // 这里释放所有的资源 + sp_mesh_tasks.tasks.clear(); + + let keys: Vec = sp_mesh_manager.entities.keys().map(|a| a.clone()).collect(); + for chunk_key in keys.iter() { + if let Some(inner_map) = sp_mesh_manager.entities.remove(chunk_key) { + for (_, (_, entity)) in inner_map.into_iter() { + commands.entity(entity).despawn(); + } + } + } +} + +// 通过球体生成要删除的数据 +pub type SampleShape = ConstShape3u32; + +fn get_pos(chunk_key: ChunkKey, index: u32) -> Vec3 { + let xyz = SampleShape::delinearize(index); + chunk_key_any_xyz_to_vec3(chunk_key, xyz) +} + +fn get_tfr(chunk_key: ChunkKey, index: u32, direction: VoxelDirection) -> Transform { + Transform { + translation: get_pos(chunk_key, index), + rotation: direction.to_quat(), + scale: Vec3::new(1. / 32., 1. / 32., 1. / 32.), + } +} diff --git a/src/client/state_manager/game.rs b/src/client/state_manager/game.rs index c73be8c..17a741d 100644 --- a/src/client/state_manager/game.rs +++ b/src/client/state_manager/game.rs @@ -36,7 +36,7 @@ use crate::{ staff_rules::staff_rules_ui, tool_bar::{tool_bar, ToolBar}, UiPicResourceManager, - }, + }, sp_mesh_display::SpMeshManagerPlugin, }, common::ClientClipSpheresPlugin, sky::ClientSkyPlugins, @@ -90,6 +90,7 @@ impl Plugin for GamePlugin { MouseControlPlugin, ClientFilledObjectnPlugin, ToolBarSyncPlugin, + SpMeshManagerPlugin, )); app.add_systems( diff --git a/src/client/ui/tool_bar.rs b/src/client/ui/tool_bar.rs index 99ac023..6dd3056 100644 --- a/src/client/ui/tool_bar.rs +++ b/src/client/ui/tool_bar.rs @@ -1,7 +1,10 @@ use bevy::prelude::{Handle, Image, Resource}; use bevy_egui::egui; -use crate::staff::{Staff, StaffType}; +use crate::{ + staff::{Staff, StaffType}, + voxel_world::voxel::Voxel, +}; use super::tool_box::tool_box; @@ -78,6 +81,20 @@ impl ToolBar { .as_ref() .map(|staff| staff.staff_type.clone()) } + // 当前激活中的物品 + pub fn staff_type_try_to_voxel(&self) -> Option { + self.tools[self.active_index] + .staff + .as_ref() + .map(|staff| match staff.staff_type.clone() { + StaffType::Sp(x) => StaffType::Voxel(Voxel { + id: x, + direction: crate::voxel_world::voxel::VoxelDirection::Z, + }), + _ => staff.staff_type.clone(), + }) + } + pub fn active(&mut self, index: usize) { self.active_index = index; for i in 0..=9 { diff --git a/src/lib.rs b/src/lib.rs index 34f7ff3..1cc603a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub const TOUCH_RADIUS: f32 = 5.; pub const CLIENT_DEBUG: bool = false; pub const CLIENT_FPS: bool = false; // 是否每次都重新生成地形 -pub const CLIENT_MAP_GEN: bool = true; +pub const CLIENT_MAP_GEN: bool = false; // 最大物品堆放 pub const MAX_STAFF_FIXED: usize = 999; @@ -42,6 +42,8 @@ pub const NEAR_RANGE: f32 = 1.6; pub const CLOSE_RANGE: f32 = 0.2; pub const PICK_SPEED: f32 = 1.0; +pub const SP_MESH_DISTANCE: i32 = 2; + pub fn connection_config() -> ConnectionConfig { ConnectionConfig { available_bytes_per_tick: 1024 * 1024, diff --git a/src/server/async_chunk.rs b/src/server/async_chunk.rs index 5e08a3e..3d03cf2 100644 --- a/src/server/async_chunk.rs +++ b/src/server/async_chunk.rs @@ -101,6 +101,8 @@ pub fn deal_chunk_query_system( let index = SampleShape::linearize(pos) as usize; // 老的体素位置 let old_voxel = voxel[index].clone(); + println!("老的位置体素为{:?}", old_voxel); + println!("新的位置:[{:?},{}]", chunk_key, index); if voxel[index].id == BasicStone::ID { warn!("基岩无法破坏"); continue; @@ -161,10 +163,12 @@ pub fn deal_chunk_query_system( // FIXME: 这里要考虑把代码格式简化 一下 // 发送物体被打下来的消息 old_voxel chunk_key, pos, 还原物体的位置! if old_voxel.id != Voxel::EMPTY.id && voxel_type.id == Voxel::EMPTY.id { + println!("cube被打下来了: {:?}", old_voxel); // 物体时被打下来了 这里通过配置掉落 if let Some(staff_list) = staff_info_stroge.voxel_to_staff_list(old_voxel) { + println!("staff下落: {:?}", staff_list); for staff in staff_list.into_iter() { fill_event.send(ObjectFillEvent { chunk_key, diff --git a/src/server/object_filing/mod.rs b/src/server/object_filing/mod.rs index 762af67..e1def89 100644 --- a/src/server/object_filing/mod.rs +++ b/src/server/object_filing/mod.rs @@ -65,7 +65,9 @@ fn deal_object_filing(mut commands: Commands, mut fill_event: EventReader { + crate::staff::StaffType::Voxel(_) + | crate::staff::StaffType::Consumable(_) + | crate::staff::StaffType::Sp(_) => { // 渲染一个正方形的 并且添加物理引擎 gen_filled_object( &mut commands, diff --git a/src/staff/mod.rs b/src/staff/mod.rs index 3a907af..2986cff 100644 --- a/src/staff/mod.rs +++ b/src/staff/mod.rs @@ -32,8 +32,8 @@ pub enum StaffType { Voxel(Voxel), // 工具(staff id) Tool(usize), - // 特殊的可放置的物体 - Sp(usize), + // 特殊的可放置的物体 需要一个体素id对应 + Sp(u8), // 消耗品 Consumable(usize), } @@ -55,8 +55,14 @@ impl StaffInfoStroge { if self.data.contains_key(&staff.id) { warn!("{} is already registered", staff.id); } - if let StaffType::Voxel(voxel) = staff.staff_type { - self.voxel_staff.insert(voxel.id, staff.clone()); + match staff.staff_type { + StaffType::Voxel(voxel) => { + self.voxel_staff.insert(voxel.id, staff.clone()); + } + StaffType::Sp(id) => { + self.voxel_staff.insert(id, staff.clone()); + } + _ => {} } self.data.insert(staff.id, staff); } diff --git a/src/voxel_world/mod.rs b/src/voxel_world/mod.rs index 75839db..58c8472 100644 --- a/src/voxel_world/mod.rs +++ b/src/voxel_world/mod.rs @@ -6,3 +6,4 @@ pub mod map_database; pub mod map_generator; pub mod player_state; pub mod voxel; +pub mod voxel_mesh; \ No newline at end of file diff --git a/src/voxel_world/voxel.rs b/src/voxel_world/voxel.rs index 9936d37..d7dbd66 100644 --- a/src/voxel_world/voxel.rs +++ b/src/voxel_world/voxel.rs @@ -1,7 +1,11 @@ -use bevy::reflect::Reflect; +use std::f32::consts::PI; + +use bevy::{prelude::Quat, reflect::Reflect}; use block_mesh::{MergeVoxel, Voxel as MeshVoxel, VoxelVisibility}; use serde::{Deserialize, Serialize}; +use super::voxel_mesh::VOXEL_MESH_MAP; + /** * 体素类型 * @@ -38,6 +42,17 @@ pub enum VoxelDirection { NX, // 指向X的负数半轴 } +impl VoxelDirection { + pub fn to_quat(&self) -> Quat { + match self { + VoxelDirection::Z => Quat::from_rotation_y(0.0), + VoxelDirection::X => Quat::from_rotation_y(PI / 2.0), + VoxelDirection::NZ => Quat::from_rotation_y(PI), + VoxelDirection::NX => Quat::from_rotation_y(3.0 * PI / 2.0), + } + } +} + pub const VOXEL_DIRECTION_VEC: [VoxelDirection; 4] = [ VoxelDirection::Z, VoxelDirection::NZ, @@ -109,6 +124,10 @@ impl Voxel { impl MeshVoxel for Voxel { fn get_visibility(&self) -> VoxelVisibility { + // 这里控制显示问题 + if VOXEL_MESH_MAP.contains_key(&self.id) { + return VoxelVisibility::Empty; + } // 这里过滤掉水 if self.id > 0 && self.id != 5 { return VoxelVisibility::Opaque; @@ -173,3 +192,4 @@ voxel_material!(BuleGrass, 苍翠地, 9); voxel_material!(AppleWood, 苹果树原木, 10); voxel_material!(AppleLeaf, 苹果树叶子, 11); voxel_material!(TestCube, 测试方块, 12); +voxel_material!(WorkCube, 工作方块, 13); diff --git a/src/voxel_world/voxel_mesh/mod.rs b/src/voxel_world/voxel_mesh/mod.rs new file mode 100644 index 0000000..1d1de10 --- /dev/null +++ b/src/voxel_world/voxel_mesh/mod.rs @@ -0,0 +1,79 @@ +// 特别的体素类型的展示 +// 这个地方要给server和client使用 + +use bevy::{ + prelude::{AssetServer, Handle, Image, Mesh, Plugin, Res, ResMut, Resource, Startup}, + utils::HashMap, +}; +use bevy_vox_mesh::VoxMeshPlugin; +use lazy_static::lazy_static; + +use crate::voxel_world::voxel::{VoxelMaterial, WorkCube}; + +#[derive(Debug, Clone)] +pub struct VoxelMeshConfig { + // 是否生成碰撞体 + pub collider: bool, + // 模型列表 + pub vox_list: Vec, + // 图片列表 + pub image_list: Vec, +} + +lazy_static! { + pub static ref VOXEL_MESH_MAP: HashMap = { + let mut map = HashMap::new(); + // 这里加上数据 + map.insert(WorkCube::into_voxel().id,VoxelMeshConfig{ + collider: true, + vox_list: vec![String::from("vox/工作台.vox")], + image_list: Vec::new(), + }); + map + }; +} + +#[derive(Debug, Clone)] +pub struct MeshMateData { + pub vox_list: Vec>, + pub image_list: Vec>, +} + +#[derive(Debug, Clone, Resource)] +pub struct VoxelMeshStorge { + pub data: HashMap, +} + +// 加载数据 +pub struct VoxelMeshPlugin; + +impl Plugin for VoxelMeshPlugin { + fn build(&self, app: &mut bevy::prelude::App) { + app.add_plugins(VoxMeshPlugin::default()); + app.insert_resource(VoxelMeshStorge { + data: HashMap::new(), + }); + app.add_systems(Startup, init_mesh_resource); + } +} + +fn init_mesh_resource(assets: Res, mut voxel_mesh_storge: ResMut) { + for (key, config) in VOXEL_MESH_MAP.iter() { + let mut vox_list: Vec> = Vec::new(); + for vox_str in config.vox_list.iter() { + vox_list.push(assets.load(vox_str)); + } + let mut image_list: Vec> = Vec::new(); + for image_str in config.image_list.iter() { + image_list.push(assets.load(image_str)); + } + voxel_mesh_storge.data.insert( + *key, + MeshMateData { + vox_list: vox_list, + image_list: image_list, + }, + ); + } +} + diff --git a/staff.ron b/staff.ron index 49c4646..9300773 100644 --- a/staff.ron +++ b/staff.ron @@ -13,6 +13,7 @@ (id:10,name:"Apple",icon_string:"textures/苹果.png",staff_type:Consumable(0)), (id:11,name:"AppleLog",icon_string:"textures/棍子.png",staff_type:Consumable(0)), (id:12,name:"TestCube",icon_string:"textures/测试1.png",staff_type:Voxel((id:12,direction:Z))), + (id:13,name:"WorkCube",icon_string:"staff/工作方块.png",staff_type:Sp(13)), ], // 掉落配置 filled_configs:[ diff --git a/staff_rules.ron b/staff_rules.ron index 61601ff..7c75418 100644 --- a/staff_rules.ron +++ b/staff_rules.ron @@ -26,4 +26,17 @@ base_on:None, desc:"合成测试使用的摆放方块", ), + ( + id:2, + input:[ + (staff_id:11,num_needed:4), + (staff_id:8,num_needed:4), + ], + // 合成工作台 + output: [ + (staff_id:13,num_needed:1), + ], + base_on:None, + desc:"合成工作台", + ), ] \ No newline at end of file