chore(examples): updated basic_xpbd example to use v0.13
This commit is contained in:
parent
a28505fc39
commit
dec0818222
|
@ -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" }
|
||||
bevy_gltf_worlflow_examples_common = { path = "../../common" }
|
||||
bevy_xpbd_3d = "0.4"
|
||||
rand = "0.8.5"
|
|
@ -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()
|
||||
|
|
|
@ -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<Time<Physics>>) {
|
|||
info!("unpausing physics");
|
||||
time.unpause();
|
||||
}
|
||||
|
||||
pub fn toggle_physics_debug(
|
||||
mut config_store: ResMut<GizmoConfigStore>,
|
||||
keycode: Res<ButtonInput<KeyCode>>,
|
||||
) {
|
||||
if keycode.just_pressed(KeyCode::KeyD) {
|
||||
let config = config_store.config_mut::<PhysicsGizmos>().0;
|
||||
config.enabled = !config.enabled;
|
||||
println!("BLAAA");
|
||||
/*
|
||||
.insert_gizmo_group(
|
||||
PhysicsGizmos {
|
||||
aabb_color: Some(Color::WHITE),
|
||||
..default()
|
||||
},
|
||||
GizmoConfig::default(),
|
||||
)*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 ?) !!!
|
||||
|
|
|
@ -39,12 +39,12 @@ pub fn setup_game(
|
|||
}
|
||||
|
||||
pub fn spawn_test(
|
||||
keycode: Res<Input<KeyCode>>,
|
||||
keycode: Res<ButtonInput<KeyCode>>,
|
||||
mut commands: Commands,
|
||||
|
||||
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
|
||||
) {
|
||||
if keycode.just_pressed(KeyCode::T) {
|
||||
if keycode.just_pressed(KeyCode::KeyT) {
|
||||
let world = game_world.single_mut();
|
||||
let world = world.1[0];
|
||||
|
||||
|
|
|
@ -89,24 +89,10 @@ pub fn teardown_main_menu(bla: Query<Entity, With<InMainMenu>>, mut commands: Co
|
|||
}
|
||||
|
||||
pub fn main_menu(
|
||||
keycode: Res<Input<KeyCode>>,
|
||||
|
||||
keycode: Res<ButtonInput<KeyCode>>,
|
||||
mut next_app_state: ResMut<NextState<AppState>>,
|
||||
// mut next_game_state: ResMut<NextState<GameState>>,
|
||||
// mut save_requested_events: EventWriter<SaveRequest>,
|
||||
// mut load_requested_events: EventWriter<LoadRequest>,
|
||||
) {
|
||||
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() })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue