diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/Cargo.toml b/examples/bevy_gltf_blueprints/basic_xpbd_physics/Cargo.toml index 1806caf..c6547b0 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/Cargo.toml +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/Cargo.toml @@ -7,4 +7,6 @@ license = "MIT OR Apache-2.0" [dependencies] bevy="0.13" bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } -bevy_gltf_worlflow_examples_common = { path = "../../common" } \ No newline at end of file +bevy_gltf_worlflow_examples_common = { path = "../../common" } +bevy_xpbd_3d = "0.4" +rand = "0.8.5" \ No newline at end of file diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/mod.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/mod.rs index 0571ebc..7087b26 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/mod.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/mod.rs @@ -4,11 +4,14 @@ pub use physics::*; use bevy::prelude::*; use bevy_gltf_blueprints::*; +use bevy_xpbd_3d::plugins::PhysicsDebugPlugin; + pub struct CorePlugin; impl Plugin for CorePlugin { fn build(&self, app: &mut App) { app.add_plugins(( PhysicsPlugin, + //PhysicsDebugPlugin::default(), BlueprintsPlugin { library_folder: "models/library".into(), ..Default::default() diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/controls.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/controls.rs index 1936001..6ff265d 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/controls.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/controls.rs @@ -1,5 +1,10 @@ +use bevy::ecs::system::Res; +use bevy::gizmos::config::{GizmoConfig, GizmoConfigStore}; +use bevy::input::keyboard::KeyCode; +use bevy::input::ButtonInput; use bevy::log::info; use bevy::{prelude::ResMut, time::Time}; + use bevy_xpbd_3d::prelude::Physics; use bevy_xpbd_3d::prelude::*; @@ -12,3 +17,22 @@ pub fn resume_physics(mut time: ResMut>) { info!("unpausing physics"); time.unpause(); } + +pub fn toggle_physics_debug( + mut config_store: ResMut, + keycode: Res>, +) { + if keycode.just_pressed(KeyCode::KeyD) { + let config = config_store.config_mut::().0; + config.enabled = !config.enabled; + println!("BLAAA"); + /* + .insert_gizmo_group( + PhysicsGizmos { + aabb_color: Some(Color::WHITE), + ..default() + }, + GizmoConfig::default(), + )*/ + } +} diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/mod.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/mod.rs index 702294c..7ba0beb 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/mod.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/mod.rs @@ -22,6 +22,7 @@ impl Plugin for PhysicsPlugin { Update, physics_replace_proxies.after(GltfBlueprintsSet::AfterSpawn), ) + .add_systems(Update, toggle_physics_debug) .add_systems(OnEnter(GameState::InGame), resume_physics) .add_systems(OnExit(GameState::InGame), pause_physics); } diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/physics_replace_proxies.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/physics_replace_proxies.rs index 5ec77f3..3e281dc 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/physics_replace_proxies.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/core/physics/physics_replace_proxies.rs @@ -48,7 +48,7 @@ pub fn physics_replace_proxies( match collider_proxy { Collider::Ball(radius) => { info!("generating collider from proxy: ball"); - xpbd_collider = XpbdCollider::ball(*radius); + xpbd_collider = XpbdCollider::sphere(*radius); commands.entity(entity) .insert(xpbd_collider) //.insert(ActiveEvents::COLLISION_EVENTS) // FIXME: this is just for demo purposes (also is there something like that in xpbd ?) !!! diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_game.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_game.rs index 64559c5..e093b2d 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_game.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_game.rs @@ -39,12 +39,12 @@ pub fn setup_game( } pub fn spawn_test( - keycode: Res>, + keycode: Res>, mut commands: Commands, mut game_world: Query<(Entity, &Children), With>, ) { - if keycode.just_pressed(KeyCode::T) { + if keycode.just_pressed(KeyCode::KeyT) { let world = game_world.single_mut(); let world = world.1[0]; diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_main_menu.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_main_menu.rs index c1a4b8b..32142cd 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_main_menu.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/game/in_main_menu.rs @@ -89,24 +89,10 @@ pub fn teardown_main_menu(bla: Query>, mut commands: Co } pub fn main_menu( - keycode: Res>, - + keycode: Res>, mut next_app_state: ResMut>, - // mut next_game_state: ResMut>, - // mut save_requested_events: EventWriter, - // mut load_requested_events: EventWriter, ) { - if keycode.just_pressed(KeyCode::Return) { + if keycode.just_pressed(KeyCode::Enter) { next_app_state.set(AppState::AppLoading); - // next_game_state.set(GameState::None); - } - - if keycode.just_pressed(KeyCode::L) { - next_app_state.set(AppState::AppLoading); - // load_requested_events.send(LoadRequest { path: "toto".into() }) - } - - if keycode.just_pressed(KeyCode::S) { - // save_requested_events.send(SaveRequest { path: "toto".into() }) } } diff --git a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/main.rs b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/main.rs index 8fca426..9320156 100644 --- a/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/main.rs +++ b/examples/bevy_gltf_blueprints/basic_xpbd_physics/src/main.rs @@ -1,5 +1,4 @@ use bevy::prelude::*; -use bevy_editor_pls::prelude::*; use bevy_gltf_worlflow_examples_common::CommonPlugin; mod core; @@ -15,8 +14,6 @@ fn main() { App::new() .add_plugins(( DefaultPlugins.set(AssetPlugin::default()), - // editor - EditorPlugin::default(), // our custom plugins CommonPlugin, CorePlugin, // reusable plugins