Adds "wheels" to cyberbike.
The `parallel` feature doesn't work with joints in Rapier.
This commit is contained in:
parent
8979660775
commit
315f35e8e3
8 changed files with 103 additions and 164 deletions
77
Cargo.lock
generated
77
Cargo.lock
generated
|
@ -4,9 +4,9 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ab_glyph"
|
name = "ab_glyph"
|
||||||
version = "0.2.14"
|
version = "0.2.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d54a65e0d4f66f8536c98cb3ca81ca33b7e2ca43442465507a3a62291ec0d9e4"
|
checksum = "24606928a235e73cdef55a0c909719cadd72fce573e5713d58cb2952d8f5794c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ab_glyph_rasterizer",
|
"ab_glyph_rasterizer",
|
||||||
"owned_ttf_parser",
|
"owned_ttf_parser",
|
||||||
|
@ -73,9 +73,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.55"
|
version = "1.0.56"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
|
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "approx"
|
name = "approx"
|
||||||
|
@ -128,9 +128,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-task"
|
name = "async-task"
|
||||||
version = "4.1.0"
|
version = "4.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8"
|
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
|
@ -1724,14 +1724,15 @@ checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
|
checksum = "7ba42135c6a5917b9db9cd7b293e5409e1c6b041e6f9825e92e55a894c63b6f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"miow",
|
"miow",
|
||||||
"ntapi",
|
"ntapi",
|
||||||
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1963,18 +1964,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum"
|
name = "num_enum"
|
||||||
version = "0.5.6"
|
version = "0.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad"
|
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num_enum_derive",
|
"num_enum_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum_derive"
|
name = "num_enum_derive"
|
||||||
version = "0.5.6"
|
version = "0.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21"
|
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -2003,9 +2004,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.9.0"
|
version = "1.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owned_ttf_parser"
|
name = "owned_ttf_parser"
|
||||||
|
@ -2274,7 +2275,6 @@ dependencies = [
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"parry3d",
|
"parry3d",
|
||||||
"rayon",
|
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"simba",
|
"simba",
|
||||||
"vec_map",
|
"vec_map",
|
||||||
|
@ -2295,31 +2295,6 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rayon"
|
|
||||||
version = "1.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"crossbeam-deque",
|
|
||||||
"either",
|
|
||||||
"rayon-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rayon-core"
|
|
||||||
version = "1.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-channel",
|
|
||||||
"crossbeam-deque",
|
|
||||||
"crossbeam-utils",
|
|
||||||
"lazy_static",
|
|
||||||
"num_cpus",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rectangle-pack"
|
name = "rectangle-pack"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
|
@ -2337,9 +2312,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.5.4"
|
version = "1.5.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -2683,9 +2658,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing"
|
name = "tracing"
|
||||||
version = "0.1.31"
|
version = "0.1.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f"
|
checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
@ -2695,9 +2670,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-attributes"
|
name = "tracing-attributes"
|
||||||
version = "0.1.19"
|
version = "0.1.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716"
|
checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -2706,9 +2681,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.22"
|
version = "0.1.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23"
|
checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"valuable",
|
"valuable",
|
||||||
|
@ -2824,6 +2799,12 @@ version = "0.10.2+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.79"
|
version = "0.2.79"
|
||||||
|
|
|
@ -29,7 +29,7 @@ features = [
|
||||||
git = "https://github.com/nebkor/bevy_rapier"
|
git = "https://github.com/nebkor/bevy_rapier"
|
||||||
#path = "../bevy_rapier/bevy_rapier3d"
|
#path = "../bevy_rapier/bevy_rapier3d"
|
||||||
branch = "debug-render-capsule"
|
branch = "debug-render-capsule"
|
||||||
features = ["parallel", "simd-nightly"]
|
features = ["simd-nightly"]
|
||||||
# version = "0.12"
|
# version = "0.12"
|
||||||
|
|
||||||
# Maybe also enable only a small amount of optimization for our code:
|
# Maybe also enable only a small amount of optimization for our code:
|
||||||
|
|
98
src/bike.rs
98
src/bike.rs
|
@ -3,7 +3,7 @@ use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::planet::PLANET_RADIUS;
|
use crate::planet::PLANET_RADIUS;
|
||||||
|
|
||||||
pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS * 1.015;
|
pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS * 1.015 + 90.0;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CyberBikeBody;
|
pub struct CyberBikeBody;
|
||||||
|
@ -15,8 +15,8 @@ pub struct CyberBikeCollider;
|
||||||
pub struct CyberBikeModel;
|
pub struct CyberBikeModel;
|
||||||
|
|
||||||
fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let xform = Transform::from_translation(Vec3::X * SPAWN_ALTITUDE)
|
let xform = Transform::from_translation(Vec3::Y * SPAWN_ALTITUDE)
|
||||||
.looking_at(Vec3::new(PLANET_RADIUS, 1000.0, 0.0), Vec3::X);
|
.with_rotation(Quat::from_axis_angle(Vec3::X, -80.0f32.to_radians()));
|
||||||
|
|
||||||
let mut bbody = RigidBodyBundle::default();
|
let mut bbody = RigidBodyBundle::default();
|
||||||
|
|
||||||
|
@ -72,80 +72,50 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
.insert(CyberBikeBody)
|
.insert(CyberBikeBody)
|
||||||
.id();
|
.id();
|
||||||
|
|
||||||
add_wheels(bike, &xform, &mut commands);
|
// seriously the cyberbike is so fucking huge what the heck
|
||||||
}
|
let wheel_positions = vec![-5.5, 4.7];
|
||||||
|
let wheel_rad = 0.7;
|
||||||
|
let wheel_y = -2.0;
|
||||||
|
|
||||||
fn add_wheels(bike: Entity, xform: &Transform, mut commands: &mut Commands) {
|
for wheel_z in wheel_positions {
|
||||||
let wheel_collider = ColliderBundle {
|
let offset = Vec3::new(0.0, wheel_y, wheel_z);
|
||||||
material: ColliderMaterial::new(0.0, 0.0).into(),
|
let trans = xform.translation + offset;
|
||||||
shape: ColliderShape::ball(0.25).into(),
|
let wheel_pos_in_world = Isometry::from_parts(trans.into(), xform.rotation.into());
|
||||||
mass_properties: ColliderMassProps::Density(0.1).into(),
|
let _wheel_rb = commands
|
||||||
..Default::default()
|
.spawn_bundle(RigidBodyBundle {
|
||||||
};
|
position: wheel_pos_in_world.into(),
|
||||||
|
activation: RigidBodyActivation::cannot_sleep().into(),
|
||||||
let shock = PrismaticJoint::new(Vector::y_axis())
|
ccd: RigidBodyCcd {
|
||||||
.local_anchor1(Vec3::new(-3.0, -3.0, -3.0).into())
|
|
||||||
.motor_position(-1.0, 0.02, 0.5);
|
|
||||||
|
|
||||||
let ccd = RigidBodyCcd {
|
|
||||||
ccd_enabled: true,
|
ccd_enabled: true,
|
||||||
|
ccd_max_dist: wheel_rad,
|
||||||
ccd_thickness: 0.1,
|
ccd_thickness: 0.1,
|
||||||
ccd_max_dist: 0.25,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
}
|
||||||
|
.into(),
|
||||||
let mut fw_pos = Isometry::default();
|
|
||||||
fw_pos.translation =
|
|
||||||
(xform.translation + (xform.down() * 4.5 + (xform.forward() * 2.5))).into();
|
|
||||||
|
|
||||||
let front_wheel_body = RigidBodyBundle {
|
|
||||||
//activation: RigidBodyActivation::cannot_sleep().into(),
|
|
||||||
//ccd: ccd.into(),
|
|
||||||
position: fw_pos.into(),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
})
|
||||||
|
.insert_bundle(ColliderBundle {
|
||||||
let front_wheel = commands
|
material: ColliderMaterial::new(0.0, 0.0).into(),
|
||||||
.spawn_bundle(front_wheel_body)
|
shape: ColliderShape::ball(wheel_rad).into(),
|
||||||
.insert_bundle(wheel_collider)
|
mass_properties: ColliderMassProps::Density(0.01).into(),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
.insert(ColliderPositionSync::Discrete)
|
.insert(ColliderPositionSync::Discrete)
|
||||||
.insert(ColliderDebugRender::from(Color::YELLOW))
|
.insert(ColliderDebugRender::from(Color::YELLOW))
|
||||||
.id();
|
.id();
|
||||||
|
|
||||||
//commands.spawn_bundle((JointBuilderComponent::new(shock, bike,
|
let (stiffness, damping) = (0.1, 0.4);
|
||||||
// front_wheel),));
|
|
||||||
|
|
||||||
// let bw_pos = Isometry::new(
|
let prismatic = PrismaticJoint::new(Vector::y_axis())
|
||||||
// (xform.translation + xform.down() + xform.back() * 2.0).into(),
|
.local_anchor1(offset.into())
|
||||||
// Vec3::ZERO.into(),
|
.motor_position(-0.1, stiffness, damping);
|
||||||
// );
|
|
||||||
|
|
||||||
// let back_wheel_body = RigidBodyBundle {
|
commands.spawn_bundle(((JointBuilderComponent::new(prismatic, bike, _wheel_rb)),));
|
||||||
// activation: RigidBodyActivation::cannot_sleep().into(),
|
}
|
||||||
// ccd: ccd.into(),
|
|
||||||
// position: bw_pos.into(),
|
|
||||||
// ..Default::default()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let wheel_collider = ColliderBundle {
|
|
||||||
// material: ColliderMaterial::new(0.0, 0.0).into(),
|
|
||||||
// // default shape is a 1-meter ball
|
|
||||||
// ..Default::default()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let back_wheel = commands
|
|
||||||
// .spawn_bundle(back_wheel_body)
|
|
||||||
// .insert_bundle(wheel_collider)
|
|
||||||
// .insert(ColliderPositionSync::Discrete)
|
|
||||||
// .insert(ColliderDebugRender::from(Color::RED))
|
|
||||||
// .id();
|
|
||||||
|
|
||||||
//commands.spawn_bundle((JointBuilderComponent::new(shock, bike,
|
|
||||||
// back_wheel),));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CyberCollidersPlugin;
|
pub struct CyberBikePlugin;
|
||||||
impl Plugin for CyberCollidersPlugin {
|
impl Plugin for CyberBikePlugin {
|
||||||
#[cfg(feature = "debug_render")]
|
#[cfg(feature = "debug_render")]
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugin(RapierRenderPlugin)
|
app.add_plugin(RapierRenderPlugin)
|
||||||
|
|
|
@ -114,7 +114,7 @@ pub struct CyberCamPlugin;
|
||||||
impl Plugin for CyberCamPlugin {
|
impl Plugin for CyberCamPlugin {
|
||||||
fn build(&self, app: &mut bevy::prelude::App) {
|
fn build(&self, app: &mut bevy::prelude::App) {
|
||||||
app.add_startup_system(setup_cybercams)
|
app.add_startup_system(setup_cybercams)
|
||||||
.add_state(CyberCameras::Hero)
|
.add_state(CyberCameras::Debug)
|
||||||
.add_system(cycle_cam_state)
|
.add_system(cycle_cam_state)
|
||||||
.add_system(update_active_camera)
|
.add_system(update_active_camera)
|
||||||
.add_system(follow_cyberbike);
|
.add_system(follow_cyberbike);
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
use bevy::{
|
use bevy::{
|
||||||
pbr::wireframe::{Wireframe, WireframeConfig, WireframePlugin},
|
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::mesh::{Indices, VertexAttributeValues},
|
||||||
mesh::{Indices, VertexAttributeValues},
|
|
||||||
options::WgpuOptions,
|
|
||||||
render_resource::WgpuFeatures,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use bevy_polyline::{Polyline, PolylineBundle, PolylineMaterial, PolylinePlugin};
|
use bevy_polyline::{Polyline, PolylineBundle, PolylineMaterial, PolylinePlugin};
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
@ -61,22 +56,15 @@ fn wireframe_planet(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wireframify_lights(
|
fn wireframify_lights(mut lights: Query<&mut AnimateCyberLightWireframe>) {
|
||||||
mut commands: Commands,
|
|
||||||
no_wires: Query<Entity, (With<AnimateCyberLightWireframe>, Without<Wireframe>)>,
|
|
||||||
wires: Query<Entity, (With<AnimateCyberLightWireframe>, With<Wireframe>)>,
|
|
||||||
) {
|
|
||||||
let chance = 0.005;
|
let chance = 0.005;
|
||||||
|
|
||||||
let rng = &mut thread_rng();
|
let rng = &mut thread_rng();
|
||||||
for e in no_wires.iter() {
|
|
||||||
|
for mut light in lights.iter_mut() {
|
||||||
if rng.gen::<f32>() < chance {
|
if rng.gen::<f32>() < chance {
|
||||||
commands.entity(e).insert(Wireframe);
|
let new = !light.wired;
|
||||||
}
|
light.wired = new;
|
||||||
}
|
|
||||||
for e in wires.iter() {
|
|
||||||
if rng.gen::<f32>() < chance {
|
|
||||||
commands.entity(e).remove::<Wireframe>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,17 +73,8 @@ fn wireframify_lights(
|
||||||
pub struct CyberGlamorPlugin;
|
pub struct CyberGlamorPlugin;
|
||||||
impl Plugin for CyberGlamorPlugin {
|
impl Plugin for CyberGlamorPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.insert_resource(WgpuOptions {
|
app.add_startup_system_to_stage(StartupStage::PostStartup, wireframe_planet)
|
||||||
features: WgpuFeatures::POLYGON_MODE_LINE,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.insert_resource(WireframeConfig { global: false })
|
|
||||||
.add_startup_system_to_stage(
|
|
||||||
StartupStage::PostStartup,
|
|
||||||
wireframe_planet.after("colliders"),
|
|
||||||
)
|
|
||||||
.add_system(wireframify_lights)
|
.add_system(wireframify_lights)
|
||||||
.add_plugin(PolylinePlugin)
|
.add_plugin(PolylinePlugin);
|
||||||
.add_plugin(WireframePlugin);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@ struct AnimatedCyberLight {
|
||||||
rate: f32,
|
rate: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component, Default)]
|
||||||
pub(crate) struct AnimateCyberLightWireframe;
|
pub(crate) struct AnimateCyberLightWireframe {
|
||||||
|
pub wired: bool,
|
||||||
|
}
|
||||||
|
|
||||||
fn spawn_moving_lights(
|
fn spawn_moving_lights(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
@ -82,7 +84,7 @@ fn spawn_moving_lights(
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(AnimateCyberLightWireframe);
|
.insert(AnimateCyberLightWireframe::default());
|
||||||
}); // mesh child
|
}); // mesh child
|
||||||
}); // light child
|
}); // light child
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use cyber_rider::{
|
use cyber_rider::{
|
||||||
action::{CyberActionPlugin, MovementSettings},
|
action::{CyberActionPlugin, MovementSettings},
|
||||||
|
bike::CyberBikePlugin,
|
||||||
camera::CyberCamPlugin,
|
camera::CyberCamPlugin,
|
||||||
bike::CyberCollidersPlugin,
|
|
||||||
disable_mouse_trap,
|
disable_mouse_trap,
|
||||||
planet::CyberGeomPlugin,
|
|
||||||
glamor::CyberGlamorPlugin,
|
glamor::CyberGlamorPlugin,
|
||||||
input::CyberInputPlugin,
|
input::CyberInputPlugin,
|
||||||
lights::CyberSpaceLightsPlugin,
|
lights::CyberSpaceLightsPlugin,
|
||||||
|
planet::CyberPlanetPlugin,
|
||||||
ui::CyberUIPlugin,
|
ui::CyberUIPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,14 +28,14 @@ fn main() {
|
||||||
})
|
})
|
||||||
.insert_resource(MOVEMENT_SETTINGS)
|
.insert_resource(MOVEMENT_SETTINGS)
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_plugin(CyberGeomPlugin)
|
.add_plugin(CyberPlanetPlugin)
|
||||||
.add_plugin(CyberGlamorPlugin)
|
.add_plugin(CyberGlamorPlugin)
|
||||||
.add_plugin(CyberInputPlugin)
|
.add_plugin(CyberInputPlugin)
|
||||||
.add_plugin(CyberActionPlugin)
|
.add_plugin(CyberActionPlugin)
|
||||||
.add_plugin(CyberCamPlugin)
|
.add_plugin(CyberCamPlugin)
|
||||||
.add_plugin(CyberSpaceLightsPlugin)
|
.add_plugin(CyberSpaceLightsPlugin)
|
||||||
.add_plugin(CyberUIPlugin)
|
.add_plugin(CyberUIPlugin)
|
||||||
.add_plugin(CyberCollidersPlugin)
|
.add_plugin(CyberBikePlugin)
|
||||||
.add_startup_system(disable_mouse_trap)
|
.add_startup_system(disable_mouse_trap)
|
||||||
.add_system(bevy::input::system::exit_on_esc_system);
|
.add_system(bevy::input::system::exit_on_esc_system);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,13 @@ fn spawn_planet(
|
||||||
|
|
||||||
let pbody = RigidBodyBundle {
|
let pbody = RigidBodyBundle {
|
||||||
body_type: RigidBodyType::Static.into(),
|
body_type: RigidBodyType::Static.into(),
|
||||||
|
ccd: RigidBodyCcd {
|
||||||
|
ccd_enabled: true,
|
||||||
|
ccd_thickness: 0.5,
|
||||||
|
ccd_max_dist: PLANET_RADIUS * 1.05,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,8 +68,8 @@ fn spawn_planet(
|
||||||
.insert(CyberPlanet);
|
.insert(CyberPlanet);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CyberGeomPlugin;
|
pub struct CyberPlanetPlugin;
|
||||||
impl Plugin for CyberGeomPlugin {
|
impl Plugin for CyberPlanetPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_startup_system(spawn_planet.label(Label::Geometry));
|
app.add_startup_system(spawn_planet.label(Label::Geometry));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue