From 9d2e41a9713ac389a5c64cd89ed6c9b521a5624f Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Sun, 22 Jan 2023 21:06:08 -0800 Subject: [PATCH] add offset resource for debug camera --- Cargo.lock | 452 +++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + src/action.rs | 24 +-- src/bike.rs | 22 +-- src/camera.rs | 50 +++++- src/lights.rs | 6 +- src/planet.rs | 20 +-- src/ui.rs | 12 +- 8 files changed, 530 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2932fa7..8cedfe4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,6 +35,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.20" @@ -86,6 +97,26 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arboard" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" +dependencies = [ + "clipboard-win", + "core-graphics", + "image", + "log", + "objc", + "objc-foundation", + "objc_id", + "once_cell", + "parking_lot", + "thiserror", + "winapi", + "x11rb", +] + [[package]] name = "arrayvec" version = "0.7.2" @@ -142,6 +173,12 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" +[[package]] +name = "atomic_refcell" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8" + [[package]] name = "autocfg" version = "1.1.0" @@ -163,6 +200,44 @@ dependencies = [ "bevy_internal", ] +[[package]] +name = "bevy-inspector-egui" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be4f9fa859e4840e7cbcc0ddf2c8a1441ff8f663c317769c5ccc70cdf13bcf2" +dependencies = [ + "bevy-inspector-egui-derive", + "bevy_app", + "bevy_asset", + "bevy_core", + "bevy_core_pipeline", + "bevy_ecs", + "bevy_egui", + "bevy_hierarchy", + "bevy_log", + "bevy_math", + "bevy_pbr", + "bevy_reflect", + "bevy_render", + "bevy_utils", + "egui", + "image", + "once_cell", + "pretty-type-name", + "smallvec", +] + +[[package]] +name = "bevy-inspector-egui-derive" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97826e6225a5b56e77683e7b99418171f7531d48682b8531252dc6b8ef3e8113" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "bevy_app" version = "0.9.1" @@ -297,6 +372,19 @@ dependencies = [ "syn", ] +[[package]] +name = "bevy_egui" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbb8036050af170243e803eb68e0b5d34f549828a8de92479619fb6dac842f85" +dependencies = [ + "arboard", + "bevy", + "egui", + "thread_local", + "webbrowser", +] + [[package]] name = "bevy_encase_derive" version = "0.9.1" @@ -745,7 +833,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16750aae52cd35bd7b60eb61cee883420b250e11b4a290b8d44b2b2941795739" dependencies = [ - "ahash", + "ahash 0.7.6", "getrandom", "hashbrown", "instant", @@ -847,6 +935,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + [[package]] name = "cache-padded" version = "1.2.0" @@ -859,6 +953,12 @@ version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.0" @@ -871,6 +971,17 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "clipboard-win" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +dependencies = [ + "error-code", + "str-buf", + "winapi", +] + [[package]] name = "cocoa" version = "0.24.1" @@ -918,6 +1029,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "concurrent-queue" version = "1.2.4" @@ -1046,7 +1167,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.7.1", "scopeguard", ] @@ -1080,6 +1201,7 @@ name = "cyber_rider" version = "0.1.0" dependencies = [ "bevy", + "bevy-inspector-egui", "bevy_polyline", "bevy_rapier3d", "hexasphere 7.2.1", @@ -1134,6 +1256,26 @@ dependencies = [ "syn", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1146,12 +1288,41 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "ecolor" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b601108bca3af7650440ace4ca55b2daf52c36f2635be3587d77b16efd8d0691" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "egui" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65a5e883a316e53866977450eecfbcac9c48109c2ab3394af29feb83fcde4ea9" +dependencies = [ + "ahash 0.8.2", + "epaint", + "nohash-hasher", +] + [[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "emath" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277249c8c3430e7127e4f2c40a77485e7baf11ae132ce9b3253a8ed710df0a0" +dependencies = [ + "bytemuck", +] + [[package]] name = "encase" version = "0.4.1" @@ -1194,6 +1365,22 @@ dependencies = [ "regex", ] +[[package]] +name = "epaint" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de14b65fe5e423e0058f77a8beb2c863b056d0566d6c4ce0d097aa5814cb705a" +dependencies = [ + "ab_glyph", + "ahash 0.8.2", + "atomic_refcell", + "bytemuck", + "ecolor", + "emath", + "nohash-hasher", + "parking_lot", +] + [[package]] name = "erased-serde" version = "0.3.24" @@ -1203,6 +1390,16 @@ dependencies = [ "serde", ] +[[package]] +name = "error-code" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" +dependencies = [ + "libc", + "str-buf", +] + [[package]] name = "euclid" version = "0.22.7" @@ -1264,6 +1461,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures-core" version = "0.3.25" @@ -1300,6 +1506,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -1338,7 +1554,7 @@ dependencies = [ "libc", "libudev-sys", "log", - "nix", + "nix 0.25.1", "uuid", "vec_map", "wasm-bindgen", @@ -1495,7 +1711,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", "serde", ] @@ -1537,6 +1753,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "image" version = "0.24.5" @@ -1550,6 +1776,7 @@ dependencies = [ "num-traits", "png", "scoped_threadpool", + "tiff", ] [[package]] @@ -1596,12 +1823,32 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +[[package]] +name = "jni" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + [[package]] name = "jni-sys" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" + [[package]] name = "js-sys" version = "0.3.60" @@ -1727,6 +1974,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.7.1" @@ -1880,6 +2136,18 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + [[package]] name = "nix" version = "0.25.1" @@ -1892,6 +2160,12 @@ dependencies = [ "libc", ] +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "noise" version = "0.8.2" @@ -1994,6 +2268,17 @@ dependencies = [ "objc_exception", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc_exception" version = "0.1.2" @@ -2003,6 +2288,15 @@ dependencies = [ "cc", ] +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "once_cell" version = "1.17.0" @@ -2151,6 +2445,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "pretty-type-name" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8815d101cfb4cb491154896bdab292a395a7ac9ab185a9941a2f5be0135900d" + [[package]] name = "proc-macro-crate" version = "1.2.1" @@ -2297,6 +2597,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + [[package]] name = "regex" version = "1.7.1" @@ -2367,6 +2678,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scoped_threadpool" version = "0.1.9" @@ -2488,6 +2808,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "str-buf" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" + [[package]] name = "strsim" version = "0.10.0" @@ -2562,6 +2888,32 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiff" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "toml" version = "0.5.11" @@ -2656,12 +3008,27 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "unicode-bidi" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" + [[package]] name = "unicode-ident" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-width" version = "0.1.10" @@ -2674,6 +3041,17 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "uuid" version = "1.2.2" @@ -2708,6 +3086,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2790,6 +3179,30 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webbrowser" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e74f5ff7786c4c21f61ba8e30ea29c9745f06fca0a4a02d083b3c662583399e8" +dependencies = [ + "core-foundation", + "dirs", + "jni", + "log", + "ndk-context", + "objc", + "raw-window-handle 0.5.0", + "url", + "web-sys", + "windows", +] + +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + [[package]] name = "wgpu" version = "0.14.2" @@ -2919,6 +3332,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "winapi-wsapoll" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -3080,6 +3502,28 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "x11rb" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" +dependencies = [ + "gethostname", + "nix 0.24.3", + "winapi", + "winapi-wsapoll", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" +dependencies = [ + "nix 0.24.3", +] + [[package]] name = "xi-unicode" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index 6e05936..07ab615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ bevy_polyline = "0.4" noise = { git = "https://github.com/Razaekel/noise-rs" } hexasphere = "7" wgpu = "0.14" +bevy-inspector-egui = "0.17.0" # wgpu = "0.12" [features] diff --git a/src/action.rs b/src/action.rs index 6860e80..443b394 100644 --- a/src/action.rs +++ b/src/action.rs @@ -2,11 +2,8 @@ use bevy::{ diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin}, prelude::*, }; -use bevy_rapier3d::{ - prelude::{ - ExternalForce, Friction, NoUserData, RapierConfiguration, RapierPhysicsPlugin, Velocity, - }, - render::{DebugRenderMode, RapierDebugRenderPlugin}, +use bevy_rapier3d::prelude::{ + ExternalForce, Friction, NoUserData, RapierConfiguration, RapierPhysicsPlugin, Velocity, }; use crate::{ @@ -39,8 +36,8 @@ fn gravity( mut query: Query<(&Transform, &mut ExternalForce), With>, settings: Res, ) { - let (xform, mut forces) = query.single_mut(); - let grav = xform.translation.normalize() * -settings.gravity; + let (_xform, mut forces) = query.single_mut(); + let grav = Vec3::Y * -settings.gravity; forces.force = grav; } @@ -49,7 +46,7 @@ fn falling_cat_pid( diagnostics: Res, ) { let (xform, mut forces, mut control_vars) = bike_query.single_mut(); - let up = xform.translation.normalize(); + let up = Vec3::Y; let bike_up = xform.up(); let torque = bike_up.cross(up).normalize_or_zero(); @@ -114,19 +111,8 @@ fn drag(mut query: Query<(&Velocity, &mut ExternalForce), With>) pub struct CyberActionPlugin; impl Plugin for CyberActionPlugin { fn build(&self, app: &mut App) { - let mut mode = DebugRenderMode::RIGID_BODY_AXES; - //mode.insert(DebugRenderMode::COLLIDER_SHAPES); - mode.insert(DebugRenderMode::CONTACTS); - mode.insert(DebugRenderMode::JOINTS); - let rplugin = RapierDebugRenderPlugin { - always_on_top: true, - enabled: true, - mode, - ..Default::default() - }; app.init_resource::() .add_plugin(RapierPhysicsPlugin::::default()) - .add_plugin(rplugin) .add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_startup_system(zero_gravity) .add_system(gravity.before("cat")) diff --git a/src/bike.rs b/src/bike.rs index 5b3632a..5fcc3a6 100644 --- a/src/bike.rs +++ b/src/bike.rs @@ -1,9 +1,16 @@ use bevy::prelude::*; -use bevy_rapier3d::{geometry::Group, prelude::*}; +use bevy_rapier3d::{ + geometry::Group, + prelude::{ + Ccd, Collider, ColliderMassProperties, CollisionGroups, Damping, ExternalForce, Friction, + ImpulseJoint, PrismaticJointBuilder, Restitution, RigidBody, Sleeping, + TransformInterpolation, Velocity, + }, +}; use crate::planet::PLANET_RADIUS; -pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS * 1.01; +pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS * 0.2; #[derive(Component)] pub struct CyberBikeBody; @@ -24,8 +31,8 @@ const BIKE_BODY_COLLISION_GROUP: (Group, Group) = (Group::GROUP_1, Group::GROUP_ const BIKE_WHEEL_COLLISION_GROUP: (Group, Group) = (Group::GROUP_10, Group::GROUP_10); fn spawn_cyberbike(mut commands: Commands, asset_server: Res) { - let xform = Transform::from_translation(Vec3::X * SPAWN_ALTITUDE) - .with_rotation(Quat::from_axis_angle(Vec3::Z, -89.0f32.to_radians())); + let xform = Transform::from_translation(Vec3::Y * SPAWN_ALTITUDE); + //.with_rotation(Quat::from_axis_angle(Vec3::Z, -89.0f32.to_radians())); let damping = Damping { angular_damping: 0.5, @@ -141,13 +148,6 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res) { pub struct CyberBikePlugin; impl Plugin for CyberBikePlugin { - #[cfg(feature = "debug_render")] - fn build(&self, app: &mut App) { - app.add_plugin(RapierDebugRenderPlugin::default()) - .add_startup_system_to_stage(StartupStage::PostStartup, spawn_cyberbike); - } - - #[cfg(not(feature = "debug_render"))] fn build(&self, app: &mut App) { app.add_startup_system_to_stage(StartupStage::PostStartup, spawn_cyberbike); } diff --git a/src/camera.rs b/src/camera.rs index 8e3937c..51f1593 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,4 +1,5 @@ use bevy::prelude::*; +use bevy_rapier3d::render::{DebugRenderMode, DebugRenderStyle, RapierDebugRenderPlugin}; use crate::{bike::CyberBikeModel, input::InputState}; @@ -11,6 +12,21 @@ enum CyberCameras { Debug, } +#[derive(Debug, Resource)] +pub struct DebugCamOffset { + pub rot: f32, + pub dist: f32, +} + +impl Default for DebugCamOffset { + fn default() -> Self { + DebugCamOffset { + rot: 60.0, + dist: 10.0, + } + } +} + impl CyberCameras { fn next(self) -> Self { match self { @@ -45,9 +61,10 @@ fn follow_cyberbike( Query<(&mut Transform, &CyberCameras)>, )>, input: Res, + offset: Res, ) { let bike_xform = *query.p0().single(); - let up = bike_xform.translation.normalize(); + let up = Vec3::Y; for (mut cam_xform, cam_type) in query.p1().iter_mut() { match *cam_type { @@ -64,11 +81,10 @@ fn follow_cyberbike( cam_xform.rotate(Quat::from_axis_angle(axis, angle)); } CyberCameras::Debug => { - let pos = bike_xform.translation - + (bike_xform.forward() * 20.0) - + (bike_xform.left() * 2.0) - + (bike_xform.up() * 5.0); - cam_xform.translation = pos; + let mut ncx = bike_xform.to_owned(); + ncx.rotate(Quat::from_axis_angle(up, offset.rot.to_radians())); + ncx.translation += ncx.forward() * offset.dist; + *cam_xform = ncx; cam_xform.look_at(bike_xform.translation, up); } } @@ -101,7 +117,27 @@ fn cycle_cam_state(mut state: ResMut>, mut keys: ResMut, mut query: Query<(&mut Transform, &AnimatedCybe pub struct CyberSpaceLightsPlugin; impl Plugin for CyberSpaceLightsPlugin { fn build(&self, app: &mut App) { - app.add_startup_system(spawn_static_lights) - .add_startup_system(spawn_moving_lights) - .add_system(orbit_lights); + app.add_startup_system(spawn_static_lights); + //.add_startup_system(spawn_moving_lights) + //.add_system(orbit_lights); } } diff --git a/src/planet.rs b/src/planet.rs index 00a1268..dcf5317 100644 --- a/src/planet.rs +++ b/src/planet.rs @@ -1,15 +1,13 @@ use bevy::{ - prelude::{shape::Icosphere, *}, + prelude::{shape::Plane, *}, render::mesh::Indices, }; use bevy_rapier3d::prelude::*; -use hexasphere::shapes::IcoSphere; -use noise::{HybridMulti, NoiseFn, SuperSimplex}; use wgpu::PrimitiveTopology; use crate::Label; -pub const PLANET_RADIUS: f32 = 6000.0; +pub const PLANET_RADIUS: f32 = 600.0; #[derive(Component)] pub struct CyberPlanet; @@ -20,12 +18,12 @@ fn spawn_planet( mut materials: ResMut>, ) { let color = Color::rgb(0.2, 0.1, 0.2); - let isphere = Icosphere { - radius: PLANET_RADIUS, - subdivisions: 88, + let plane = Plane { + size: PLANET_RADIUS, }; - - let (mesh, shape) = gen_planet(isphere); + //let (mesh, shape) = gen_planet(plane); + let mesh = Mesh::from(plane); + let shape = Collider::from_bevy_mesh(&mesh, &ComputedColliderShape::TriMesh).unwrap(); let pbody = (RigidBody::Fixed, Ccd { enabled: true }); @@ -67,7 +65,8 @@ impl Plugin for CyberPlanetPlugin { // utils //--------------------------------------------------------------------- -fn gen_planet(sphere: Icosphere) -> (Mesh, Collider) { +/* +fn gen_planet(sphere: Plane) -> (Mesh, Collider) { // straight-up stolen from Bevy's impl of Mesh from Icosphere, so I can do the // displacement before normals are calculated. let generated = IcoSphere::new(sphere.subdivisions, |point| { @@ -120,3 +119,4 @@ fn gen_planet(sphere: Icosphere) -> (Mesh, Collider) { mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs); (mesh, shape) } +*/ diff --git a/src/ui.rs b/src/ui.rs index 50c5a3b..8b82213 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,5 +1,9 @@ -use bevy::prelude::*; -use bevy_rapier3d::prelude::*; +use bevy::prelude::{ + AlignSelf, App, AssetServer, Color, Commands, Component, Plugin, Query, Res, Style, Text, + TextBundle, TextSection, TextStyle, With, +}; +use bevy_inspector_egui::quick::WorldInspectorPlugin; +use bevy_rapier3d::prelude::Velocity; use crate::bike::CyberBikeBody; @@ -46,6 +50,8 @@ pub struct CyberUIPlugin; impl Plugin for CyberUIPlugin { fn build(&self, app: &mut App) { - app.add_startup_system(setup_ui).add_system(update_ui); + app.add_plugin(WorldInspectorPlugin) + .add_startup_system(setup_ui) + .add_system(update_ui); } }