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

View file

@ -1,6 +1,7 @@
use bevy::{
diagnostic::FrameTimeDiagnosticsPlugin,
prelude::{App, IntoSystemDescriptor, Plugin, ReflectResource, Resource},
ecs::reflect::ReflectResource,
prelude::{App, Plugin, Resource},
reflect::Reflect,
};
use bevy_rapier3d::prelude::{NoUserData, RapierPhysicsPlugin};
@ -30,18 +31,17 @@ impl Plugin for CyberActionPlugin {
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_startup_system(timestep_setup)
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_system(surface_fix.label("surface_fix"))
.add_system(gravity.label("gravity").before("cat"))
.add_system(cyber_lean.before("cat").after("gravity"))
.add_system(falling_cat.label("cat"))
.add_system(input_forces.label("iforces").after("cat"))
.add_system(
tunnel_out
.label("tunnel")
.before("surface_fix")
.after("drag"),
.add_systems(
(
gravity,
cyber_lean,
falling_cat,
input_forces,
drag,
tunnel_out,
surface_fix,
)
.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 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;
pub(crate) use self::components::*;
@ -21,6 +21,6 @@ impl Plugin for CyberBikePlugin {
fn build(&self, app: &mut App) {
app.insert_resource(WheelConfig::default())
.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
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 {
Hero,
Debug,
}
impl Default for CyberCameras {
fn default() -> Self {
Self::Hero
}
}
#[derive(Debug, Resource)]
pub struct DebugCamOffset {
pub rot: f32,

View file

@ -98,7 +98,7 @@ impl Plugin for CyberGlamorPlugin {
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_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;
@ -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>) {
for GamepadEvent {
gamepad: _,
event_type: ev,
} in events.iter()
{
match *ev {
GamepadEventType::ButtonChanged(GamepadButtonType::RightTrigger2, val) => {
for pad_event in events.iter() {
match pad_event {
GamepadEvent::Button(GamepadButtonType::RightTrigger2, val) => {
istate.throttle = val;
}
GamepadEventType::ButtonChanged(GamepadButtonType::LeftTrigger2, val) => {
GamepadEvent::Button(GamepadButtonType::LeftTrigger2, val) => {
istate.throttle = -val;
}
GamepadEventType::ButtonChanged(GamepadButtonType::East, val) => {
GamepadEvent::Button(GamepadButtonType::East, val) => {
if val > 0.5 {
istate.brake = true;
} else {
istate.brake = false;
}
}
GamepadEventType::AxisChanged(GamepadAxisType::LeftStickX, val) => {
GamepadEvent::Axis(GamepadAxisType::LeftStickX, val) => {
istate.yaw = val;
}
// ignore spurious vertical movement for now
GamepadEventType::AxisChanged(GamepadAxisType::LeftStickY, val) => {
GamepadEvent::Axis(GamepadAxisType::LeftStickY, val) => {
istate.pitch = val;
}
_ => {
info!("unhandled gamepad event: {:?}", ev);
info!("unhandled gamepad event: {:?}", pad_event);
}
}
}
//dbg!(&istate);
}
pub struct CyberInputPlugin;

View file

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