update bevy 0.11 - fix compile errors
This commit is contained in:
@@ -27,9 +27,15 @@ use crate::box2d_backend::Box2dWorld;
|
||||
use crate::harness::Harness;
|
||||
#[cfg(all(feature = "dim3", feature = "other-backends"))]
|
||||
use crate::physx_backend::PhysxWorld;
|
||||
use bevy::pbr::wireframe::WireframePlugin;
|
||||
use bevy::render::camera::Camera;
|
||||
use bevy_egui::EguiContext;
|
||||
use bevy_core_pipeline::prelude::Camera2dBundle;
|
||||
use bevy_core_pipeline::prelude::Camera3dBundle;
|
||||
use bevy_core_pipeline::prelude::ClearColor;
|
||||
use bevy_egui::EguiContexts;
|
||||
use bevy_pbr::wireframe::WireframePlugin;
|
||||
use bevy_pbr::AmbientLight;
|
||||
use bevy_pbr::DirectionalLight;
|
||||
use bevy_pbr::DirectionalLightBundle;
|
||||
|
||||
#[cfg(feature = "dim2")]
|
||||
use crate::camera2d::{OrbitCamera, OrbitCameraPlugin};
|
||||
@@ -372,25 +378,25 @@ impl TestbedApp {
|
||||
};
|
||||
|
||||
let window_plugin = WindowPlugin {
|
||||
window: WindowDescriptor {
|
||||
primary_window: Some(Window {
|
||||
title,
|
||||
..Default::default()
|
||||
},
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut app = App::new();
|
||||
app.insert_resource(ClearColor(Color::rgb(0.15, 0.15, 0.15)))
|
||||
.insert_resource(Msaa { samples: 4 })
|
||||
.insert_resource(Msaa::Sample4)
|
||||
.insert_resource(AmbientLight {
|
||||
brightness: 0.3,
|
||||
..Default::default()
|
||||
})
|
||||
.add_plugins(DefaultPlugins.set(window_plugin))
|
||||
.add_plugin(OrbitCameraPlugin)
|
||||
.add_plugin(WireframePlugin)
|
||||
.add_plugin(bevy_egui::EguiPlugin)
|
||||
.add_plugin(debug_render::RapierDebugRenderPlugin::default());
|
||||
.add_plugins(OrbitCameraPlugin)
|
||||
.add_plugins(WireframePlugin)
|
||||
.add_plugins(bevy_egui::EguiPlugin);
|
||||
// .add_plugins(debug_render::RapierDebugRenderPlugin::default());
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
app.add_plugin(bevy_webgl2::WebGL2Plugin);
|
||||
@@ -398,15 +404,16 @@ impl TestbedApp {
|
||||
#[cfg(feature = "other-backends")]
|
||||
app.insert_non_send_resource(self.other_backends);
|
||||
|
||||
app.add_startup_system(setup_graphics_environment)
|
||||
app.add_systems(Startup, setup_graphics_environment)
|
||||
.insert_non_send_resource(self.graphics)
|
||||
.insert_resource(self.state)
|
||||
.insert_non_send_resource(self.harness)
|
||||
.insert_resource(self.builders)
|
||||
.insert_non_send_resource(self.plugins)
|
||||
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
|
||||
.add_system_to_stage("physics", update_testbed)
|
||||
.add_system(egui_focus);
|
||||
// .add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
|
||||
// .add_system_to_stage("physics", update_testbed)
|
||||
.add_systems(PreUpdate, update_testbed)
|
||||
.add_systems(Update, egui_focus);
|
||||
init(&mut app);
|
||||
app.run();
|
||||
}
|
||||
@@ -709,10 +716,10 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
KeyCode::Space => {
|
||||
desired_movement += Vector::y() * 2.0;
|
||||
}
|
||||
KeyCode::RControl => {
|
||||
KeyCode::ControlRight => {
|
||||
desired_movement -= Vector::y();
|
||||
}
|
||||
KeyCode::RShift => {
|
||||
KeyCode::ShiftRight => {
|
||||
speed /= 10.0;
|
||||
}
|
||||
_ => {}
|
||||
@@ -750,10 +757,10 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
KeyCode::Space => {
|
||||
desired_movement += Vector::y() * 2.0;
|
||||
}
|
||||
KeyCode::RControl => {
|
||||
KeyCode::ControlRight => {
|
||||
desired_movement -= Vector::y();
|
||||
}
|
||||
KeyCode::RShift => {
|
||||
KeyCode::ShiftLeft => {
|
||||
speed /= 10.0;
|
||||
}
|
||||
_ => {}
|
||||
@@ -1004,15 +1011,17 @@ fn setup_graphics_environment(mut commands: Commands) {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 10000.0,
|
||||
// Configure the projection to better fit the scene
|
||||
shadow_projection: OrthographicProjection {
|
||||
left: -HALF_SIZE,
|
||||
right: HALF_SIZE,
|
||||
bottom: -HALF_SIZE,
|
||||
top: HALF_SIZE,
|
||||
near: -10.0 * HALF_SIZE,
|
||||
far: 100.0 * HALF_SIZE,
|
||||
..Default::default()
|
||||
},
|
||||
// shadow_projection: OrthographicProjection {
|
||||
// area: Rect::new(
|
||||
// -HALF_SIZE,
|
||||
// HALF_SIZE,
|
||||
// -HALF_SIZE,
|
||||
// HALF_SIZE,
|
||||
// ),
|
||||
// near: -10.0 * HALF_SIZE,
|
||||
// far: 100.0 * HALF_SIZE,
|
||||
// ..Default::default()
|
||||
// },
|
||||
shadows_enabled: true,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -1073,7 +1082,7 @@ fn setup_graphics_environment(mut commands: Commands) {
|
||||
});
|
||||
}
|
||||
|
||||
fn egui_focus(mut ui_context: ResMut<EguiContext>, mut cameras: Query<&mut OrbitCamera>) {
|
||||
fn egui_focus(mut ui_context: EguiContexts, mut cameras: Query<&mut OrbitCamera>) {
|
||||
let mut camera_enabled = true;
|
||||
if ui_context.ctx_mut().wants_pointer_input() {
|
||||
camera_enabled = false;
|
||||
@@ -1083,9 +1092,11 @@ fn egui_focus(mut ui_context: ResMut<EguiContext>, mut cameras: Query<&mut Orbit
|
||||
}
|
||||
}
|
||||
|
||||
use bevy::window::PrimaryWindow;
|
||||
|
||||
fn update_testbed(
|
||||
mut commands: Commands,
|
||||
windows: Res<Windows>,
|
||||
windows: Query<&Window, With<PrimaryWindow>>,
|
||||
// mut pipelines: ResMut<Assets<RenderPipelineDescriptor>>,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<BevyMaterial>>,
|
||||
@@ -1095,7 +1106,7 @@ fn update_testbed(
|
||||
mut harness: NonSendMut<Harness>,
|
||||
#[cfg(feature = "other-backends")] mut other_backends: NonSendMut<OtherBackends>,
|
||||
mut plugins: NonSendMut<Plugins>,
|
||||
mut ui_context: ResMut<EguiContext>,
|
||||
mut ui_context: EguiContexts,
|
||||
mut gfx_components: Query<(&mut Transform,)>,
|
||||
mut cameras: Query<(&Camera, &GlobalTransform, &mut OrbitCamera)>,
|
||||
keys: Res<Input<KeyCode>>,
|
||||
@@ -1407,7 +1418,7 @@ fn update_testbed(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(window) = windows.get_primary() {
|
||||
if let Ok(window) = windows.get_single() {
|
||||
for (camera, camera_pos, _) in cameras.iter_mut() {
|
||||
highlight_hovered_body(
|
||||
&mut *materials,
|
||||
@@ -1419,7 +1430,7 @@ fn update_testbed(
|
||||
camera_pos,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
graphics.draw(
|
||||
&harness.physics.bodies,
|
||||
|
||||
Reference in New Issue
Block a user