aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-05-17 09:46:07 +0200
committerCrozet Sébastien <developer@crozet.re>2021-05-17 09:46:07 +0200
commitabb4742758a755fe30b984dd537d8bc68d2ad030 (patch)
tree87db5879662ce2bc949adb85eb71e69c58b764ae
parentdc9552e175132c20df3b0379fb3467b229287405 (diff)
downloadrapier-abb4742758a755fe30b984dd537d8bc68d2ad030.tar.gz
rapier-abb4742758a755fe30b984dd537d8bc68d2ad030.tar.bz2
rapier-abb4742758a755fe30b984dd537d8bc68d2ad030.zip
Fix warnings when compiling tests.
-rw-r--r--src_testbed/testbed.rs24
-rw-r--r--src_testbed/ui.rs2
2 files changed, 17 insertions, 9 deletions
diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs
index 2a9be9e..6e314c8 100644
--- a/src_testbed/testbed.rs
+++ b/src_testbed/testbed.rs
@@ -120,12 +120,13 @@ pub struct TestbedState {
}
struct SceneBuilders(Vec<(&'static str, fn(&mut Testbed))>);
+
+#[cfg(feature = "other-backends")]
struct OtherBackends {
- #[cfg(all(feature = "dim2", feature = "other-backends"))]
+ #[cfg(feature = "dim2")]
box2d: Option<Box2dWorld>,
- #[cfg(all(feature = "dim3", feature = "other-backends"))]
+ #[cfg(feature = "dim3")]
physx: Option<PhysxWorld>,
- #[cfg(feature = "other-backends")]
nphysics: Option<NPhysicsWorld>,
}
struct Plugins(Vec<Box<dyn TestbedPlugin>>);
@@ -143,6 +144,7 @@ pub struct Testbed<'a, 'b, 'c, 'd> {
graphics: Option<TestbedGraphics<'a, 'b, 'c, 'd>>,
harness: &'a mut Harness,
state: &'a mut TestbedState,
+ #[cfg(feature = "other-backends")]
other_backends: &'a mut OtherBackends,
plugins: &'a mut Plugins,
}
@@ -152,6 +154,7 @@ pub struct TestbedApp {
graphics: GraphicsManager,
state: TestbedState,
harness: Harness,
+ #[cfg(feature = "other-backends")]
other_backends: OtherBackends,
plugins: Plugins,
}
@@ -195,12 +198,12 @@ impl TestbedApp {
};
let harness = Harness::new_empty();
+ #[cfg(feature = "other-backends")]
let other_backends = OtherBackends {
- #[cfg(all(feature = "dim2", feature = "other-backends"))]
+ #[cfg(feature = "dim2")]
box2d: None,
- #[cfg(all(feature = "dim3", feature = "other-backends"))]
+ #[cfg(feature = "dim3")]
physx: None,
- #[cfg(feature = "other-backends")]
nphysics: None,
};
@@ -210,6 +213,7 @@ impl TestbedApp {
graphics,
state,
harness,
+ #[cfg(feature = "other-backends")]
other_backends,
}
}
@@ -291,6 +295,7 @@ impl TestbedApp {
graphics: None,
state: &mut self.state,
harness: &mut self.harness,
+ #[cfg(feature = "other-backends")]
other_backends: &mut self.other_backends,
plugins: &mut self.plugins,
};
@@ -407,11 +412,13 @@ impl TestbedApp {
#[cfg(target_arch = "wasm32")]
app.add_plugin(bevy_webgl2::WebGL2Plugin);
+ #[cfg(feature = "other-backends")]
+ app.insert_non_send_resource(self.other_backends);
+
app.add_startup_system(setup_graphics_environment.system())
.insert_non_send_resource(self.graphics)
.insert_resource(self.state)
.insert_non_send_resource(self.harness)
- .insert_non_send_resource(self.other_backends)
.insert_resource(self.builders)
.insert_non_send_resource(self.plugins)
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
@@ -843,7 +850,7 @@ fn update_testbed(
mut graphics: NonSendMut<GraphicsManager>,
mut state: ResMut<TestbedState>,
mut harness: NonSendMut<Harness>,
- mut other_backends: NonSendMut<OtherBackends>,
+ #[cfg(feature = "other-backends")] mut other_backends: NonSendMut<OtherBackends>,
mut plugins: NonSendMut<Plugins>,
ui_context: Res<EguiContext>,
mut gfx_components: Query<(&mut Transform,)>,
@@ -936,6 +943,7 @@ fn update_testbed(
graphics: Some(graphics_context),
state: &mut *state,
harness: &mut *harness,
+ #[cfg(feature = "other-backends")]
other_backends: &mut *other_backends,
plugins: &mut *plugins,
};
diff --git a/src_testbed/ui.rs b/src_testbed/ui.rs
index 66482ba..18b1084 100644
--- a/src_testbed/ui.rs
+++ b/src_testbed/ui.rs
@@ -10,7 +10,7 @@ use bevy_egui::{egui, EguiContext};
pub fn update_ui(ui_context: &EguiContext, state: &mut TestbedState, harness: &mut Harness) {
egui::Window::new("Parameters").show(ui_context.ctx(), |ui| {
if state.backend_names.len() > 1 && !state.example_names.is_empty() {
- #[cfg(feature = "dim3")]
+ #[cfg(all(feature = "dim3", feature = "other-backends"))]
let prev_selected_backend = state.selected_backend;
let mut changed = false;
egui::ComboBox::from_label("backend")