polyline plugin needs to be updated

This commit is contained in:
Joe Ardent 2023-03-09 13:09:28 -08:00
parent 81d5144dc6
commit aa9a89ae94
8 changed files with 1456 additions and 454 deletions

1827
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -8,28 +8,29 @@ rand = "0.8"
bevy_polyline = "0.4" bevy_polyline = "0.4"
noise = { git = "https://github.com/Razaekel/noise-rs" } noise = { git = "https://github.com/Razaekel/noise-rs" }
hexasphere = "7" hexasphere = "7"
wgpu = "0.14" wgpu = "0.15"
bevy-inspector-egui = "0.17.0" bevy-inspector-egui = "0.18"
# wgpu = "0.12" # wgpu = "0.12"
[features] [features]
inspector = [] inspector = []
[dependencies.bevy] [dependencies.bevy]
version = "0.9" version = "0.10"
default-features = false default-features = false
features = [ features = [
"bevy_gilrs", "bevy_gilrs",
"bevy_winit", "bevy_winit",
"render",
"png", "png",
"hdr", "hdr",
"x11", "x11",
"bevy_ui",
"bevy_text"
] ]
[dependencies.bevy_rapier3d] [dependencies.bevy_rapier3d]
features = ["debug-render-3d"] features = ["debug-render-3d"]
version = "0.20" version = "0.21"
# Maybe also enable only a small amount of optimization for our code: # Maybe also enable only a small amount of optimization for our code:
[profile.dev] [profile.dev]

View file

@ -1,6 +1,7 @@
use bevy::{ use bevy::{
diagnostic::FrameTimeDiagnosticsPlugin, diagnostic::FrameTimeDiagnosticsPlugin,
prelude::{App, IntoSystemDescriptor, Plugin, ReflectResource, Resource}, ecs::reflect::ReflectResource,
prelude::{App, Plugin, Resource},
reflect::Reflect, reflect::Reflect,
}; };
use bevy_rapier3d::prelude::{NoUserData, RapierPhysicsPlugin}; use bevy_rapier3d::prelude::{NoUserData, RapierPhysicsPlugin};
@ -30,18 +31,17 @@ impl Plugin for CyberActionPlugin {
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default()) .add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_startup_system(timestep_setup) .add_startup_system(timestep_setup)
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_system(surface_fix.label("surface_fix")) .add_systems(
.add_system(gravity.label("gravity").before("cat")) (
.add_system(cyber_lean.before("cat").after("gravity")) gravity,
.add_system(falling_cat.label("cat")) cyber_lean,
.add_system(input_forces.label("iforces").after("cat")) falling_cat,
.add_system( input_forces,
tunnel_out drag,
.label("tunnel") tunnel_out,
.before("surface_fix") surface_fix,
.after("drag"), )
.chain(),
) )
.add_system(surface_fix.label("surface_fix").after("cat"))
.add_system(drag.label("drag").after("iforces"));
} }
} }

View file

@ -2,7 +2,7 @@ mod body;
mod components; mod components;
mod wheels; mod wheels;
use bevy::prelude::{App, Assets, Mesh, Plugin, ResMut, StandardMaterial, StartupStage}; use bevy::prelude::{App, Assets, Mesh, Plugin, ResMut, StandardMaterial, StartupSet};
use bevy_rapier3d::prelude::Group; use bevy_rapier3d::prelude::Group;
pub(crate) use self::components::*; pub(crate) use self::components::*;
@ -21,6 +21,6 @@ impl Plugin for CyberBikePlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.insert_resource(WheelConfig::default()) app.insert_resource(WheelConfig::default())
.register_type::<WheelConfig>() .register_type::<WheelConfig>()
.add_startup_system_to_stage(StartupStage::PostStartup, spawn_cyberbike); .add_startup_system(StartupSet::PostStartup, spawn_cyberbike);
} }
} }

View file

@ -5,12 +5,18 @@ use crate::{bike::CyberBikeBody, input::InputState};
// 85 degrees in radians // 85 degrees in radians
const MAX_PITCH: f32 = 1.48353; const MAX_PITCH: f32 = 1.48353;
#[derive(Clone, Copy, Eq, PartialEq, Debug, Hash, Component)] #[derive(Clone, Copy, Eq, PartialEq, Debug, Hash, Component, States)]
enum CyberCameras { enum CyberCameras {
Hero, Hero,
Debug, Debug,
} }
impl Default for CyberCameras {
fn default() -> Self {
Self::Hero
}
}
#[derive(Debug, Resource)] #[derive(Debug, Resource)]
pub struct DebugCamOffset { pub struct DebugCamOffset {
pub rot: f32, pub rot: f32,

View file

@ -98,7 +98,7 @@ impl Plugin for CyberGlamorPlugin {
app.add_plugin(rplugin); app.add_plugin(rplugin);
} }
app.add_startup_system_to_stage(StartupStage::PostStartup, wireframe_planet) app.add_startup_system(StartupSet::PostStartup, wireframe_planet)
.add_system(wireframify_lights) .add_system(wireframify_lights)
.add_plugin(PolylinePlugin); .add_plugin(PolylinePlugin);
} }

View file

@ -1,4 +1,4 @@
use bevy::{prelude::*, utils::HashSet}; use bevy::{input::gamepad::GamepadEvent, prelude::*, utils::HashSet};
use crate::camera::DebugCamOffset; use crate::camera::DebugCamOffset;
@ -46,39 +46,33 @@ fn update_debug_cam(mut offset: ResMut<DebugCamOffset>, mut keys: ResMut<Input<K
} }
fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputState>) { fn update_input(mut events: EventReader<GamepadEvent>, mut istate: ResMut<InputState>) {
for GamepadEvent { for pad_event in events.iter() {
gamepad: _, match pad_event {
event_type: ev, GamepadEvent::Button(GamepadButtonType::RightTrigger2, val) => {
} in events.iter()
{
match *ev {
GamepadEventType::ButtonChanged(GamepadButtonType::RightTrigger2, val) => {
istate.throttle = val; istate.throttle = val;
} }
GamepadEventType::ButtonChanged(GamepadButtonType::LeftTrigger2, val) => { GamepadEvent::Button(GamepadButtonType::LeftTrigger2, val) => {
istate.throttle = -val; istate.throttle = -val;
} }
GamepadEventType::ButtonChanged(GamepadButtonType::East, val) => { GamepadEvent::Button(GamepadButtonType::East, val) => {
if val > 0.5 { if val > 0.5 {
istate.brake = true; istate.brake = true;
} else { } else {
istate.brake = false; istate.brake = false;
} }
} }
GamepadEventType::AxisChanged(GamepadAxisType::LeftStickX, val) => { GamepadEvent::Axis(GamepadAxisType::LeftStickX, val) => {
istate.yaw = val; istate.yaw = val;
} }
// ignore spurious vertical movement for now // ignore spurious vertical movement for now
GamepadEventType::AxisChanged(GamepadAxisType::LeftStickY, val) => { GamepadEvent::Axis(GamepadAxisType::LeftStickY, val) => {
istate.pitch = val; istate.pitch = val;
} }
_ => { _ => {
info!("unhandled gamepad event: {:?}", ev); info!("unhandled gamepad event: {:?}", pad_event);
} }
} }
} }
//dbg!(&istate);
} }
pub struct CyberInputPlugin; pub struct CyberInputPlugin;

View file

@ -1,6 +1,6 @@
use bevy::{ use bevy::{
ecs::schedule::StageLabel, ecs::schedule::SystemSet,
prelude::{ResMut, SystemLabel, Vec3, Windows}, prelude::{Query, Vec3, Window},
}; };
pub mod action; pub mod action;
@ -12,7 +12,7 @@ pub mod lights;
pub mod planet; pub mod planet;
pub mod ui; pub mod ui;
#[derive(Clone, Debug, Hash, PartialEq, Eq, SystemLabel, StageLabel)] #[derive(Clone, Debug, Hash, PartialEq, Eq, SystemSet)]
pub enum Label { pub enum Label {
Geometry, Geometry,
Glamor, Glamor,
@ -20,7 +20,7 @@ pub enum Label {
Action, Action,
} }
pub fn disable_mouse_trap(mut windows: ResMut<Windows>) { pub fn disable_mouse_trap(mut windows: Query<&Window>) {
let window = windows.get_primary_mut().unwrap(); let window = windows.get_primary_mut().unwrap();
window.set_cursor_grab_mode(bevy::window::CursorGrabMode::None); window.set_cursor_grab_mode(bevy::window::CursorGrabMode::None);
window.set_cursor_visibility(true); window.set_cursor_visibility(true);