Merge branch 'main' into rolling_wheels
This commit is contained in:
commit
8e1bae82a6
5 changed files with 181 additions and 139 deletions
115
Cargo.lock
generated
115
Cargo.lock
generated
|
@ -937,9 +937,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
|
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cache-padded"
|
name = "cache-padded"
|
||||||
|
@ -1472,15 +1472,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-core"
|
name = "futures-core"
|
||||||
version = "0.3.25"
|
version = "0.3.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
|
checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-io"
|
name = "futures-io"
|
||||||
version = "0.3.25"
|
version = "0.3.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
|
checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-lite"
|
name = "futures-lite"
|
||||||
|
@ -1592,20 +1592,21 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gltf"
|
name = "gltf"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "00e0a0eace786193fc83644907097285396360e9e82e30f81a21e9b1ba836a3e"
|
checksum = "1fd7703af6975def3b32573c60aaa5ebfebfab5d879da1e1315d87155ba57bcd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"gltf-json",
|
"gltf-json",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gltf-derive"
|
name = "gltf-derive"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bdd53d6e284bb2bf02a6926e4cc4984978c1990914d6cd9deae4e31cf37cd113"
|
checksum = "67b33dbe598480111e3b2e5a1e9a7e52ad5df0f836e04b8c80fc96f52a9c9f2e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"inflections",
|
"inflections",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -1615,9 +1616,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gltf-json"
|
name = "gltf-json"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9949836a9ec5e7f83f76fb9bbcbc77f254a577ebbdb0820867bc11979ef97cad"
|
checksum = "5511a759d99beeeef064bd6f81e207c77e3a3431c7499d7590929e35de371f31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gltf-derive",
|
"gltf-derive",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -1851,9 +1852,9 @@ checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.60"
|
version = "0.3.61"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
|
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
@ -2320,9 +2321,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owned_ttf_parser"
|
name = "owned_ttf_parser"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a5f3c7ca08b6879e7965fb25e24d1f5eeb32ea73f9ad99b3854778a38c57e93"
|
checksum = "e25e9fb15717794fae58ab55c26e044103aad13186fbb625893f9a3bbcc24228"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ttf-parser",
|
"ttf-parser",
|
||||||
]
|
]
|
||||||
|
@ -2345,15 +2346,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot_core"
|
name = "parking_lot_core"
|
||||||
version = "0.9.6"
|
version = "0.9.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf"
|
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"windows-sys 0.42.0",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2900,9 +2901,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec_macros"
|
name = "tinyvec_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
|
@ -3060,10 +3061,16 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "urlencoding"
|
||||||
version = "1.2.2"
|
version = "2.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c"
|
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -3112,9 +3119,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.83"
|
version = "0.2.84"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
|
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
|
@ -3122,9 +3129,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.83"
|
version = "0.2.84"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
|
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"log",
|
"log",
|
||||||
|
@ -3137,9 +3144,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-futures"
|
name = "wasm-bindgen-futures"
|
||||||
version = "0.4.33"
|
version = "0.4.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
|
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
@ -3149,9 +3156,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.83"
|
version = "0.2.84"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
|
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
|
@ -3159,9 +3166,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.83"
|
version = "0.2.84"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
|
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -3172,15 +3179,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.83"
|
version = "0.2.84"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.60"
|
version = "0.3.61"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
|
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
@ -3188,9 +3195,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webbrowser"
|
name = "webbrowser"
|
||||||
version = "0.8.6"
|
version = "0.8.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "769f1a8831de12cad7bd6f9693b15b1432d93a151557810f617f626af823acae"
|
checksum = "97d1fa1e5c829b2bf9eb1e28fb950248b797cd6a04866fbdfa8bc31e5eef4c78"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
@ -3305,9 +3312,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wide"
|
name = "wide"
|
||||||
version = "0.7.5"
|
version = "0.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ae41ecad2489a1655c8ef8489444b0b113c0a0c795944a3572a0931cf7d2525c"
|
checksum = "feff0a412894d67223777b6cc8d68c0dab06d52d95e9890d5f2d47f10dd9366c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"safe_arch",
|
"safe_arch",
|
||||||
|
@ -3396,6 +3403,30 @@ dependencies = [
|
||||||
"windows_x86_64_msvc 0.42.1",
|
"windows_x86_64_msvc 0.42.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.45.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.42.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm",
|
||||||
|
"windows_aarch64_msvc 0.42.1",
|
||||||
|
"windows_i686_gnu 0.42.1",
|
||||||
|
"windows_i686_msvc 0.42.1",
|
||||||
|
"windows_x86_64_gnu 0.42.1",
|
||||||
|
"windows_x86_64_gnullvm",
|
||||||
|
"windows_x86_64_msvc 0.42.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.42.1"
|
version = "0.42.1"
|
||||||
|
|
|
@ -122,7 +122,7 @@ pub(super) fn surface_fix(
|
||||||
cgroups.memberships = Group::NONE;
|
cgroups.memberships = Group::NONE;
|
||||||
cgroups.filters = Group::NONE;
|
cgroups.filters = Group::NONE;
|
||||||
commands.entity(entity).insert(Tunneling {
|
commands.entity(entity).insert(Tunneling {
|
||||||
frames: 5,
|
frames: 6,
|
||||||
dir: -hit.1.normal,
|
dir: -hit.1.normal,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -135,22 +135,24 @@ pub(super) fn tunnel_out(
|
||||||
(
|
(
|
||||||
Entity,
|
Entity,
|
||||||
&mut Tunneling,
|
&mut Tunneling,
|
||||||
&mut CollisionGroups,
|
|
||||||
&mut ExternalForce,
|
&mut ExternalForce,
|
||||||
|
&mut CollisionGroups,
|
||||||
),
|
),
|
||||||
With<CyberWheel>,
|
With<CyberWheel>,
|
||||||
>,
|
>,
|
||||||
|
mprops: Query<&ReadMassProperties, With<CyberBikeBody>>,
|
||||||
settings: Res<MovementSettings>,
|
settings: Res<MovementSettings>,
|
||||||
) {
|
) {
|
||||||
for (entity, mut tunneling, mut cgroups, mut force) in wheel_query.iter_mut() {
|
let mprops = mprops.single();
|
||||||
|
for (entity, mut tunneling, mut force, mut cgroups) in wheel_query.iter_mut() {
|
||||||
if tunneling.frames == 0 {
|
if tunneling.frames == 0 {
|
||||||
commands.entity(entity).remove::<Tunneling>();
|
commands.entity(entity).remove::<Tunneling>();
|
||||||
cgroups.memberships = BIKE_WHEEL_COLLISION_GROUP.0;
|
force.force = Vec3::ZERO;
|
||||||
cgroups.filters = BIKE_WHEEL_COLLISION_GROUP.1;
|
(cgroups.memberships, cgroups.filters) = BIKE_WHEEL_COLLISION_GROUP;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tunneling.frames -= 1;
|
tunneling.frames -= 1;
|
||||||
force.force += tunneling.dir * settings.gravity * 1.1;
|
force.force = tunneling.dir * settings.gravity * 1.5 * mprops.0.mass;
|
||||||
#[cfg(feature = "inspector")]
|
#[cfg(feature = "inspector")]
|
||||||
dbg!(&tunneling);
|
dbg!(&tunneling);
|
||||||
}
|
}
|
||||||
|
|
86
src/bike/body.rs
Normal file
86
src/bike/body.rs
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
use bevy::{
|
||||||
|
prelude::{AssetServer, BuildChildren, Commands, Quat, Res, SpatialBundle, Transform, Vec3},
|
||||||
|
scene::SceneBundle,
|
||||||
|
};
|
||||||
|
use bevy_rapier3d::prelude::{
|
||||||
|
Ccd, Collider, ColliderMassProperties, CollisionGroups, Damping, ExternalForce, Friction,
|
||||||
|
ReadMassProperties, Restitution, RigidBody, Sleeping, TransformInterpolation, Velocity,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::{spawn_tires, CyberBikeBody, Meshterial, WheelConfig, BIKE_BODY_COLLISION_GROUP};
|
||||||
|
use crate::{action::CatControllerState, planet::PLANET_RADIUS};
|
||||||
|
|
||||||
|
pub(super) 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, 140.0f32.to_radians()));
|
||||||
|
|
||||||
|
let right = xform.right() * 350.0;
|
||||||
|
xform.translation += right;
|
||||||
|
|
||||||
|
let damping = Damping {
|
||||||
|
angular_damping: 2.0,
|
||||||
|
linear_damping: 0.1,
|
||||||
|
};
|
||||||
|
|
||||||
|
let friction = Friction {
|
||||||
|
coefficient: 0.3,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let restitution = Restitution {
|
||||||
|
coefficient: 0.0,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let mass_properties = ColliderMassProperties::Density(0.9);
|
||||||
|
|
||||||
|
let (membership, filter) = BIKE_BODY_COLLISION_GROUP;
|
||||||
|
let bike_collision_group = CollisionGroups::new(membership, filter);
|
||||||
|
|
||||||
|
let scene = asset_server.load("cb-no-y_up.glb#Scene0");
|
||||||
|
|
||||||
|
let spatialbundle = SpatialBundle {
|
||||||
|
transform: xform,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let bike = commands
|
||||||
|
.spawn(RigidBody::Dynamic)
|
||||||
|
.insert(spatialbundle)
|
||||||
|
.insert((
|
||||||
|
Collider::capsule(Vec3::new(0.0, 0.0, -1.0), Vec3::new(0.0, 0.0, 1.0), 0.50),
|
||||||
|
bike_collision_group,
|
||||||
|
mass_properties,
|
||||||
|
damping,
|
||||||
|
restitution,
|
||||||
|
friction,
|
||||||
|
Sleeping::disabled(),
|
||||||
|
Ccd { enabled: true },
|
||||||
|
ReadMassProperties::default(),
|
||||||
|
))
|
||||||
|
.insert(TransformInterpolation {
|
||||||
|
start: None,
|
||||||
|
end: None,
|
||||||
|
})
|
||||||
|
.insert(Velocity::zero())
|
||||||
|
.insert(ExternalForce::default())
|
||||||
|
.with_children(|rider| {
|
||||||
|
rider.spawn(SceneBundle {
|
||||||
|
scene,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.insert(CyberBikeBody)
|
||||||
|
.insert(CatControllerState::default())
|
||||||
|
.id();
|
||||||
|
|
||||||
|
spawn_tires(&mut commands, &xform, bike, &wheel_conf, &mut meshterials);
|
||||||
|
}
|
|
@ -1,15 +1,21 @@
|
||||||
|
mod body;
|
||||||
mod components;
|
mod components;
|
||||||
mod systems;
|
mod wheels;
|
||||||
|
|
||||||
use bevy::prelude::{App, Plugin, StartupStage};
|
use bevy::prelude::{App, Assets, Mesh, Plugin, ResMut, StandardMaterial, StartupStage};
|
||||||
use bevy_rapier3d::prelude::Group;
|
use bevy_rapier3d::prelude::Group;
|
||||||
|
|
||||||
pub use self::components::*;
|
pub(crate) use self::components::*;
|
||||||
use self::systems::spawn_cyberbike;
|
use self::{body::spawn_cyberbike, wheels::spawn_tires};
|
||||||
|
|
||||||
pub const BIKE_BODY_COLLISION_GROUP: (Group, Group) = (Group::GROUP_1, Group::GROUP_1);
|
pub const BIKE_BODY_COLLISION_GROUP: (Group, Group) = (Group::GROUP_1, Group::GROUP_1);
|
||||||
pub const BIKE_WHEEL_COLLISION_GROUP: (Group, Group) = (Group::GROUP_10, Group::GROUP_10);
|
pub const BIKE_WHEEL_COLLISION_GROUP: (Group, Group) = (Group::GROUP_10, Group::GROUP_10);
|
||||||
|
|
||||||
|
type Meshterial<'a> = (
|
||||||
|
ResMut<'a, Assets<Mesh>>,
|
||||||
|
ResMut<'a, Assets<StandardMaterial>>,
|
||||||
|
);
|
||||||
|
|
||||||
pub struct CyberBikePlugin;
|
pub struct CyberBikePlugin;
|
||||||
impl Plugin for CyberBikePlugin {
|
impl Plugin for CyberBikePlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
|
|
@ -1,96 +1,13 @@
|
||||||
use bevy::prelude::{shape::UVSphere as Tire, *};
|
use bevy::prelude::{shape::UVSphere as Tire, *};
|
||||||
use bevy_rapier3d::prelude::{
|
use bevy_rapier3d::prelude::{
|
||||||
Ccd, Collider, ColliderMassProperties, CollisionGroups, Damping, ExternalForce, Friction,
|
Ccd, Collider, ColliderMassProperties, CollisionGroups, Damping, ExternalForce, Friction,
|
||||||
MultibodyJoint, PrismaticJointBuilder, ReadMassProperties, Restitution, RigidBody, Sleeping,
|
MultibodyJoint, PrismaticJointBuilder, Restitution, RigidBody, Sleeping,
|
||||||
TransformInterpolation, Velocity,
|
TransformInterpolation,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{CyberWheel, Meshterial, WheelConfig, BIKE_WHEEL_COLLISION_GROUP};
|
||||||
CyberBikeBody, CyberWheel, WheelConfig, BIKE_BODY_COLLISION_GROUP, BIKE_WHEEL_COLLISION_GROUP,
|
|
||||||
};
|
|
||||||
use crate::{action::CatControllerState, planet::PLANET_RADIUS};
|
|
||||||
|
|
||||||
type Meshterial<'a> = (
|
pub fn spawn_tires(
|
||||||
ResMut<'a, Assets<Mesh>>,
|
|
||||||
ResMut<'a, Assets<StandardMaterial>>,
|
|
||||||
);
|
|
||||||
|
|
||||||
pub(super) 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, 140.0f32.to_radians()));
|
|
||||||
|
|
||||||
let right = xform.right() * 350.0;
|
|
||||||
xform.translation += right;
|
|
||||||
|
|
||||||
let damping = Damping {
|
|
||||||
angular_damping: 2.0,
|
|
||||||
linear_damping: 0.1,
|
|
||||||
};
|
|
||||||
|
|
||||||
let friction = Friction {
|
|
||||||
coefficient: 0.0,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let restitution = Restitution {
|
|
||||||
coefficient: 0.0,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let mass_properties = ColliderMassProperties::Density(0.9);
|
|
||||||
|
|
||||||
let (membership, filter) = BIKE_BODY_COLLISION_GROUP;
|
|
||||||
let bike_collision_group = CollisionGroups::new(membership, filter);
|
|
||||||
|
|
||||||
let scene = asset_server.load("cb-no-y_up.glb#Scene0");
|
|
||||||
|
|
||||||
let spatialbundle = SpatialBundle {
|
|
||||||
transform: xform,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let bike = commands
|
|
||||||
.spawn(RigidBody::Dynamic)
|
|
||||||
.insert(spatialbundle)
|
|
||||||
.insert((
|
|
||||||
Collider::capsule(Vec3::new(0.0, 0.0, -1.0), Vec3::new(0.0, 0.0, 1.0), 0.50),
|
|
||||||
bike_collision_group,
|
|
||||||
mass_properties,
|
|
||||||
damping,
|
|
||||||
restitution,
|
|
||||||
friction,
|
|
||||||
Sleeping::disabled(),
|
|
||||||
Ccd { enabled: true },
|
|
||||||
ReadMassProperties::default(),
|
|
||||||
))
|
|
||||||
.insert(TransformInterpolation {
|
|
||||||
start: None,
|
|
||||||
end: None,
|
|
||||||
})
|
|
||||||
.insert(Velocity::zero())
|
|
||||||
.insert(ExternalForce::default())
|
|
||||||
.with_children(|rider| {
|
|
||||||
rider.spawn(SceneBundle {
|
|
||||||
scene,
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.insert(CyberBikeBody)
|
|
||||||
.insert(CatControllerState::default())
|
|
||||||
.id();
|
|
||||||
|
|
||||||
spawn_tires(&mut commands, &xform, bike, &wheel_conf, &mut meshterials);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spawn_tires(
|
|
||||||
commands: &mut Commands,
|
commands: &mut Commands,
|
||||||
xform: &Transform,
|
xform: &Transform,
|
||||||
bike: Entity,
|
bike: Entity,
|
Loading…
Reference in a new issue