ok, the wheels keep going through the planet and getting stuck
I'm going to need to do like raycasting from each wheel or something to do this right.
This commit is contained in:
commit
4708eabdd9
8 changed files with 754 additions and 77 deletions
452
Cargo.lock
generated
452
Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -9,10 +9,11 @@ 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]
|
||||
debug_render = []
|
||||
inspector = []
|
||||
|
||||
[dependencies.bevy]
|
||||
version = "0.9"
|
||||
|
@ -27,7 +28,7 @@ features = [
|
|||
]
|
||||
|
||||
[dependencies.bevy_rapier3d]
|
||||
features = ["simd-nightly"]
|
||||
features = ["simd-nightly", "debug-render-3d"]
|
||||
version = "0.20"
|
||||
|
||||
# Maybe also enable only a small amount of optimization for our code:
|
||||
|
|
|
@ -2,11 +2,8 @@ use bevy::{
|
|||
diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy_rapier3d::{
|
||||
prelude::{
|
||||
use bevy_rapier3d::prelude::{
|
||||
ExternalForce, Friction, NoUserData, RapierConfiguration, RapierPhysicsPlugin, Velocity,
|
||||
},
|
||||
render::{DebugRenderMode, RapierDebugRenderPlugin},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
@ -31,6 +28,24 @@ impl Default for MovementSettings {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Resource, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
struct CatControllerSettings {
|
||||
pub kp: f32,
|
||||
pub kd: f32,
|
||||
pub kws: f32,
|
||||
}
|
||||
|
||||
impl Default for CatControllerSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
kp: 10.0,
|
||||
kd: 4.0,
|
||||
kws: 0.85,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn zero_gravity(mut config: ResMut<RapierConfiguration>) {
|
||||
config.gravity = Vec3::ZERO;
|
||||
}
|
||||
|
@ -44,9 +59,10 @@ fn gravity(
|
|||
forces.force = grav;
|
||||
}
|
||||
|
||||
fn falling_cat_pid(
|
||||
fn falling_cat(
|
||||
mut bike_query: Query<(&Transform, &mut ExternalForce, &mut CyberBikeControl)>,
|
||||
diagnostics: Res<Diagnostics>,
|
||||
_diagnostics: Res<Diagnostics>,
|
||||
settings: Res<CatControllerSettings>,
|
||||
) {
|
||||
let (xform, mut forces, mut control_vars) = bike_query.single_mut();
|
||||
let up = xform.translation.normalize();
|
||||
|
@ -54,27 +70,26 @@ fn falling_cat_pid(
|
|||
|
||||
let torque = bike_up.cross(up).normalize_or_zero();
|
||||
let cos = up.dot(bike_up);
|
||||
let cos = if cos.is_finite() { cos } else { 0.0 };
|
||||
let cos = if cos.is_finite() { cos } else { 1.0 };
|
||||
|
||||
let error = 1.0 - cos;
|
||||
|
||||
let derivative = error - control_vars.prev_error;
|
||||
control_vars.prev_error = error;
|
||||
// this integral term is not an integral, it's more like a weighted moving sum
|
||||
let integral = (control_vars.error_sum + error) * 0.8;
|
||||
control_vars.error_sum = integral; //.min(2.0).max(-2.0);
|
||||
let weighted_sum = control_vars.error_sum + error;
|
||||
control_vars.error_sum = weighted_sum * 0.8;
|
||||
|
||||
let kp = 13.1;
|
||||
let ki = 1.1;
|
||||
let kd = 8.1;
|
||||
let mag = (kp * error) + (ki * integral) + (kd * derivative);
|
||||
let mag = (settings.kp * error) + (settings.kws * weighted_sum) + (settings.kd * derivative);
|
||||
|
||||
if let Some(count) = diagnostics
|
||||
#[cfg(feature = "inspector")]
|
||||
if let Some(count) = _diagnostics
|
||||
.get(FrameTimeDiagnosticsPlugin::FRAME_COUNT)
|
||||
.and_then(|d| d.smoothed())
|
||||
.map(|x| x as u64)
|
||||
{
|
||||
if count % 30 == 0 {
|
||||
dbg!(&control_vars, mag);
|
||||
dbg!(&control_vars, mag, cos, derivative);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,23 +129,14 @@ fn drag(mut query: Query<(&Velocity, &mut ExternalForce), With<CyberBikeBody>>)
|
|||
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::<MovementSettings>()
|
||||
.init_resource::<CatControllerSettings>()
|
||||
.register_type::<CatControllerSettings>()
|
||||
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
|
||||
.add_plugin(rplugin)
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.add_startup_system(zero_gravity)
|
||||
.add_system(gravity.before("cat"))
|
||||
.add_system(falling_cat_pid.label("cat"))
|
||||
.add_system(falling_cat.label("cat"))
|
||||
.add_system(input_forces.label("iforces").after("cat"))
|
||||
.add_system(drag.label("drag").after("iforces"));
|
||||
}
|
||||
|
|
197
src/bike.rs
197
src/bike.rs
|
@ -1,9 +1,21 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_rapier3d::{geometry::Group, prelude::*};
|
||||
use std::fmt::Debug;
|
||||
|
||||
use bevy::prelude::{shape::UVSphere as Tire, *};
|
||||
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;
|
||||
type Meshterial<'a> = (
|
||||
ResMut<'a, Assets<Mesh>>,
|
||||
ResMut<'a, Assets<StandardMaterial>>,
|
||||
);
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct CyberBikeBody;
|
||||
|
@ -14,29 +26,70 @@ pub struct CyberBikeCollider;
|
|||
#[derive(Component, Debug)]
|
||||
pub struct CyberBikeModel;
|
||||
|
||||
#[derive(Debug, Component)]
|
||||
pub struct CyberWheel;
|
||||
|
||||
#[derive(Component, Debug, Default, Clone, Copy)]
|
||||
pub struct CyberBikeControl {
|
||||
pub error_sum: f32,
|
||||
pub prev_error: f32,
|
||||
}
|
||||
|
||||
#[derive(Resource, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
pub struct WheelConfig {
|
||||
pub front_forward: f32,
|
||||
pub front_stance: f32,
|
||||
pub rear_back: f32,
|
||||
pub y: f32,
|
||||
pub limits: [f32; 2],
|
||||
pub stiffness: f32,
|
||||
pub damping: f32,
|
||||
pub radius: f32,
|
||||
}
|
||||
|
||||
impl Default for WheelConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
front_forward: 0.9,
|
||||
front_stance: 0.65,
|
||||
rear_back: 1.1,
|
||||
y: -1.5,
|
||||
limits: [-1.0, 0.0],
|
||||
stiffness: 80.0,
|
||||
damping: 0.6,
|
||||
radius: 0.4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const BIKE_BODY_COLLISION_GROUP: (Group, Group) = (Group::GROUP_1, Group::GROUP_1);
|
||||
const BIKE_WHEEL_COLLISION_GROUP: (Group, Group) = (Group::GROUP_10, Group::GROUP_10);
|
||||
|
||||
fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
let xform = Transform::from_translation(Vec3::X * SPAWN_ALTITUDE)
|
||||
fn spawn_cyberbike(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
wheel_conf: Res<WheelConfig>,
|
||||
mut meshterials: Meshterial,
|
||||
) {
|
||||
let altitude = PLANET_RADIUS - 220.0;
|
||||
|
||||
let mut xform = Transform::from_translation(Vec3::X * altitude)
|
||||
.with_rotation(Quat::from_axis_angle(Vec3::Z, -89.0f32.to_radians()));
|
||||
//.with_rotation(Quat::from_axis_angle(Vec3::X, -90.0f32.to_radians()));
|
||||
|
||||
let right = xform.right() * 350.0;
|
||||
xform.translation += right;
|
||||
|
||||
let damping = Damping {
|
||||
angular_damping: 0.5,
|
||||
linear_damping: 0.1,
|
||||
};
|
||||
let not_sleeping = Sleeping::disabled();
|
||||
|
||||
let ccd = Ccd { enabled: true };
|
||||
|
||||
let bcollider_shape =
|
||||
Collider::capsule(Vec3::new(0.0, 0.0, -1.0), Vec3::new(0.0, 0.0, 1.0), 0.7);
|
||||
Collider::capsule(Vec3::new(0.0, 0.0, -1.0), Vec3::new(0.0, 0.0, 1.0), 0.50);
|
||||
|
||||
let friction = Friction {
|
||||
coefficient: 0.0,
|
||||
|
@ -91,41 +144,122 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||
.insert(CyberBikeControl::default())
|
||||
.id();
|
||||
|
||||
//return;
|
||||
let wheel_z_positions = vec![-1.0, 1.2, -1.0];
|
||||
let wheel_y = -1.0f32;
|
||||
spawn_tires(&mut commands, &xform, bike, &wheel_conf, &mut meshterials);
|
||||
}
|
||||
|
||||
fn re_tire(
|
||||
mut commands: Commands,
|
||||
wheel_conf: ResMut<WheelConfig>,
|
||||
mut meshterials: Meshterial,
|
||||
bquery: Query<(Entity, &Transform), With<CyberBikeBody>>,
|
||||
wheels: Query<Entity, With<CyberWheel>>,
|
||||
) {
|
||||
// we fuck with values in the egui inspector
|
||||
let (bike, xform) = bquery.single();
|
||||
if wheel_conf.is_changed() {
|
||||
for wheel in wheels.iter() {
|
||||
commands.entity(wheel).despawn_recursive();
|
||||
}
|
||||
spawn_tires(&mut commands, xform, bike, &wheel_conf, &mut meshterials);
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_tires(
|
||||
commands: &mut Commands,
|
||||
xform: &Transform,
|
||||
bike: Entity,
|
||||
conf: &WheelConfig,
|
||||
meshterials: &mut Meshterial,
|
||||
) {
|
||||
// re-set the collision group
|
||||
let (membership, filter) = BIKE_WHEEL_COLLISION_GROUP;
|
||||
let wheels_collision_group = CollisionGroups::new(membership, filter);
|
||||
let wheel_y = conf.y;
|
||||
let wheel_rad = conf.radius;
|
||||
let stiffness = conf.stiffness;
|
||||
let not_sleeping = Sleeping::disabled();
|
||||
let ccd = Ccd { enabled: true };
|
||||
let limits = conf.limits;
|
||||
let (meshes, materials) = meshterials;
|
||||
|
||||
for (i, &wheel_z) in wheel_z_positions.iter().enumerate() {
|
||||
let (wheel_x, wheel_rad, stiffness) = match i {
|
||||
0 => (-1.1, 0.5, 2.0),
|
||||
2 => (1.1, 0.5, 2.0),
|
||||
1 => (0.0, 0.5, 1.8),
|
||||
_ => unreachable!(),
|
||||
let tire = Tire {
|
||||
radius: wheel_rad,
|
||||
..Default::default()
|
||||
};
|
||||
let material = StandardMaterial {
|
||||
base_color: Color::Rgba {
|
||||
red: 0.01,
|
||||
green: 0.01,
|
||||
blue: 0.01,
|
||||
alpha: 1.0,
|
||||
},
|
||||
alpha_mode: AlphaMode::Opaque,
|
||||
perceptual_roughness: 0.5,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let pbr_bundle = PbrBundle {
|
||||
material: materials.add(material),
|
||||
mesh: meshes.add(Mesh::from(tire)),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut wheel_poses = Vec::with_capacity(3);
|
||||
|
||||
// left front
|
||||
{
|
||||
let wheel_x = -conf.front_stance;
|
||||
let wheel_z = -conf.front_forward;
|
||||
let offset = Vec3::new(wheel_x, wheel_y, wheel_z);
|
||||
wheel_poses.push(offset);
|
||||
}
|
||||
|
||||
// right front
|
||||
{
|
||||
let wheel_x = conf.front_stance;
|
||||
let wheel_z = -conf.front_forward;
|
||||
let offset = Vec3::new(wheel_x, wheel_y, wheel_z);
|
||||
wheel_poses.push(offset);
|
||||
}
|
||||
|
||||
// rear
|
||||
{
|
||||
let wheel_x = 0.0;
|
||||
let wheel_z = conf.rear_back;
|
||||
let offset = Vec3::new(wheel_x, wheel_y, wheel_z);
|
||||
wheel_poses.push(offset);
|
||||
}
|
||||
|
||||
for offset in wheel_poses {
|
||||
let trans = xform.translation + offset;
|
||||
let wheel_pos_in_world = Transform::from_rotation(xform.rotation).with_translation(trans);
|
||||
let wheel_damping = Damping {
|
||||
angular_damping: 0.8,
|
||||
linear_damping: 0.8,
|
||||
..Default::default()
|
||||
};
|
||||
let wheel_collider = Collider::ball(wheel_rad);
|
||||
let mass_props = ColliderMassProperties::Density(0.001);
|
||||
|
||||
let damping = 0.3;
|
||||
let damping = conf.damping;
|
||||
let prismatic = PrismaticJointBuilder::new(Vec3::Y)
|
||||
.local_anchor2(offset)
|
||||
.limits([-1.0, 0.9])
|
||||
.motor_position(0.0, stiffness, damping);
|
||||
.local_anchor1(offset)
|
||||
.limits(limits)
|
||||
.motor_position(-1.0, stiffness, damping);
|
||||
let joint = ImpulseJoint::new(bike, prismatic);
|
||||
|
||||
let _wheel_rb = commands
|
||||
let spatial_bundle = SpatialBundle {
|
||||
transform: wheel_pos_in_world,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let tire_spundle = SpatialBundle {
|
||||
transform: wheel_pos_in_world,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
commands
|
||||
.spawn(RigidBody::Dynamic)
|
||||
.insert((wheel_pos_in_world, GlobalTransform::default()))
|
||||
.insert(spatial_bundle)
|
||||
.insert((
|
||||
wheel_collider,
|
||||
mass_props,
|
||||
|
@ -135,20 +269,19 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||
joint,
|
||||
wheels_collision_group,
|
||||
))
|
||||
.id();
|
||||
.with_children(|wheel| {
|
||||
wheel.spawn(tire_spundle).insert(pbr_bundle.clone());
|
||||
})
|
||||
.insert(CyberWheel);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
app.insert_resource(WheelConfig::default())
|
||||
.register_type::<WheelConfig>()
|
||||
.add_startup_system_to_stage(StartupStage::PostStartup, spawn_cyberbike)
|
||||
.add_system(re_tire);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,23 @@ enum CyberCameras {
|
|||
Debug,
|
||||
}
|
||||
|
||||
#[derive(Debug, Resource)]
|
||||
pub struct DebugCamOffset {
|
||||
pub rot: f32,
|
||||
pub dist: f32,
|
||||
pub alt: f32,
|
||||
}
|
||||
|
||||
impl Default for DebugCamOffset {
|
||||
fn default() -> Self {
|
||||
DebugCamOffset {
|
||||
rot: 60.0,
|
||||
dist: 10.0,
|
||||
alt: 4.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CyberCameras {
|
||||
fn next(self) -> Self {
|
||||
match self {
|
||||
|
@ -45,6 +62,7 @@ fn follow_cyberbike(
|
|||
Query<(&mut Transform, &CyberCameras)>,
|
||||
)>,
|
||||
input: Res<InputState>,
|
||||
offset: Res<DebugCamOffset>,
|
||||
) {
|
||||
let bike_xform = *query.p0().single();
|
||||
let up = bike_xform.translation.normalize();
|
||||
|
@ -64,11 +82,11 @@ 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;
|
||||
ncx.translation += ncx.up() * offset.alt;
|
||||
*cam_xform = ncx;
|
||||
cam_xform.look_at(bike_xform.translation, up);
|
||||
}
|
||||
}
|
||||
|
@ -99,9 +117,12 @@ fn cycle_cam_state(mut state: ResMut<State<CyberCameras>>, mut keys: ResMut<Inpu
|
|||
}
|
||||
|
||||
pub struct CyberCamPlugin;
|
||||
|
||||
impl Plugin for CyberCamPlugin {
|
||||
fn build(&self, app: &mut bevy::prelude::App) {
|
||||
app.add_startup_system(setup_cybercams)
|
||||
// common stuff
|
||||
app.insert_resource(DebugCamOffset::default())
|
||||
.add_startup_system(setup_cybercams)
|
||||
.add_state(CyberCameras::Hero)
|
||||
.add_system(cycle_cam_state)
|
||||
.add_system(update_active_camera)
|
||||
|
|
|
@ -74,6 +74,30 @@ fn wireframify_lights(mut lights: Query<&mut AnimateCyberLightWireframe>) {
|
|||
pub struct CyberGlamorPlugin;
|
||||
impl Plugin for CyberGlamorPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
#[cfg(feature = "inspector")]
|
||||
{
|
||||
use bevy_rapier3d::render::{
|
||||
DebugRenderMode, DebugRenderStyle, RapierDebugRenderPlugin,
|
||||
};
|
||||
let style = DebugRenderStyle {
|
||||
multibody_joint_anchor_color: Color::GREEN.as_rgba_f32(),
|
||||
..Default::default()
|
||||
};
|
||||
let mode = DebugRenderMode::CONTACTS
|
||||
| DebugRenderMode::SOLVER_CONTACTS
|
||||
| DebugRenderMode::JOINTS
|
||||
| DebugRenderMode::RIGID_BODY_AXES;
|
||||
|
||||
let rplugin = RapierDebugRenderPlugin {
|
||||
style,
|
||||
always_on_top: true,
|
||||
enabled: true,
|
||||
mode,
|
||||
};
|
||||
|
||||
app.add_plugin(rplugin);
|
||||
}
|
||||
|
||||
app.add_startup_system_to_stage(StartupStage::PostStartup, wireframe_planet)
|
||||
.add_system(wireframify_lights)
|
||||
.add_plugin(PolylinePlugin);
|
||||
|
|
44
src/input.rs
44
src/input.rs
|
@ -1,4 +1,7 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy::{prelude::*, utils::HashSet};
|
||||
|
||||
use crate::camera::DebugCamOffset;
|
||||
|
||||
#[derive(Default, Debug, Resource)]
|
||||
pub(crate) struct InputState {
|
||||
pub yaw: f32,
|
||||
|
@ -7,6 +10,41 @@ pub(crate) struct InputState {
|
|||
pub pitch: f32,
|
||||
}
|
||||
|
||||
fn update_debug_cam(mut offset: ResMut<DebugCamOffset>, mut keys: ResMut<Input<KeyCode>>) {
|
||||
let keyset: HashSet<_> = keys.get_pressed().collect();
|
||||
let shifted = keyset.contains(&KeyCode::LShift) || keyset.contains(&KeyCode::RShift);
|
||||
|
||||
for key in keyset {
|
||||
match key {
|
||||
KeyCode::Left => offset.rot += 5.0,
|
||||
KeyCode::Right => offset.rot -= 5.0,
|
||||
KeyCode::Up => {
|
||||
if shifted {
|
||||
offset.alt += 0.5;
|
||||
} else {
|
||||
offset.dist -= 0.5;
|
||||
}
|
||||
}
|
||||
KeyCode::Down => {
|
||||
if shifted {
|
||||
offset.alt -= 0.5;
|
||||
} else {
|
||||
offset.dist += 0.5;
|
||||
}
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
|
||||
if keys.get_just_released().len() > 0 {
|
||||
let unpressed = keys.just_released(KeyCode::LShift) || keys.just_released(KeyCode::RShift);
|
||||
keys.reset_all();
|
||||
if shifted && !unpressed {
|
||||
keys.press(KeyCode::LShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputState>) {
|
||||
for GamepadEvent {
|
||||
gamepad: _,
|
||||
|
@ -46,6 +84,8 @@ fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputS
|
|||
pub struct CyberInputPlugin;
|
||||
impl Plugin for CyberInputPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<InputState>().add_system(update_input);
|
||||
app.init_resource::<InputState>()
|
||||
.add_system(update_input)
|
||||
.add_system(update_debug_cam);
|
||||
}
|
||||
}
|
||||
|
|
12
src/ui.rs
12
src/ui.rs
|
@ -1,5 +1,10 @@
|
|||
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,
|
||||
};
|
||||
#[cfg(feature = "inspector")]
|
||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||
use bevy_rapier3d::prelude::Velocity;
|
||||
|
||||
use crate::bike::CyberBikeBody;
|
||||
|
||||
|
@ -46,6 +51,9 @@ pub struct CyberUIPlugin;
|
|||
|
||||
impl Plugin for CyberUIPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
#[cfg(feature = "inspector")]
|
||||
app.add_plugin(WorldInspectorPlugin);
|
||||
|
||||
app.add_startup_system(setup_ui).add_system(update_ui);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue