From 5c43d2ead720a3beddd7e1a8cab1feaa2a16618d Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Mon, 4 Mar 2024 17:26:55 +0100 Subject: [PATCH] chore(examples): tweaks to common code to make clippy happy --- examples/common/src/core/mod.rs | 12 +++++++++++- .../common/src/core/physics_rapier/controls.rs | 6 +++--- examples/common/src/core/physics_rapier/mod.rs | 10 +++++----- .../core/physics_rapier/physics_replace_proxies.rs | 2 +- examples/common/src/core/physics_xpbd/controls.rs | 6 +++--- examples/common/src/core/physics_xpbd/mod.rs | 14 +++++++------- .../core/physics_xpbd/physics_replace_proxies.rs | 2 +- 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/examples/common/src/core/mod.rs b/examples/common/src/core/mod.rs index ebe4524..759000a 100644 --- a/examples/common/src/core/mod.rs +++ b/examples/common/src/core/mod.rs @@ -5,11 +5,13 @@ pub use camera::*; //pub use relationships::*; #[cfg(feature = "physics_rapier")] +#[allow(ambiguous_glob_reexports)] pub mod physics_rapier; #[cfg(feature = "physics_rapier")] pub use physics_rapier::*; #[cfg(feature = "physics_xpbd")] +#[allow(ambiguous_glob_reexports)] pub mod physics_xpbd; #[cfg(feature = "physics_xpbd")] pub use physics_xpbd::*; @@ -19,6 +21,14 @@ use bevy::prelude::*; pub struct CorePlugin; impl Plugin for CorePlugin { fn build(&self, app: &mut App) { - app.add_plugins((CameraPlugin, PhysicsPlugin)); + app.add_plugins(CameraPlugin); + + #[cfg(feature = "physics_rapier")] + app.add_plugins(PhysicsPlugin); + + #[cfg(feature = "physics_xpbd")] + app.add_plugins(PhysicsPluginXPBD); + + } } diff --git a/examples/common/src/core/physics_rapier/controls.rs b/examples/common/src/core/physics_rapier/controls.rs index 2672bae..ae5ecbc 100644 --- a/examples/common/src/core/physics_rapier/controls.rs +++ b/examples/common/src/core/physics_rapier/controls.rs @@ -6,17 +6,17 @@ use bevy::{ }; use bevy_rapier3d::{prelude::RapierConfiguration, render::DebugRenderContext}; -pub fn pause_physics(mut physics_config: ResMut) { +pub(crate) fn pause_physics(mut physics_config: ResMut) { info!("pausing physics"); physics_config.physics_pipeline_active = false; } -pub fn resume_physics(mut physics_config: ResMut) { +pub(crate) fn resume_physics(mut physics_config: ResMut) { info!("unpausing physics"); physics_config.physics_pipeline_active = true; } -pub fn toggle_physics_debug( +pub(crate) fn toggle_physics_debug( mut debug_config: ResMut, keycode: Res>, ) { diff --git a/examples/common/src/core/physics_rapier/mod.rs b/examples/common/src/core/physics_rapier/mod.rs index 3b64090..bb0055d 100644 --- a/examples/common/src/core/physics_rapier/mod.rs +++ b/examples/common/src/core/physics_rapier/mod.rs @@ -1,10 +1,10 @@ -pub mod physics_replace_proxies; -pub use physics_replace_proxies::*; +pub(crate) mod physics_replace_proxies; +pub(crate) use physics_replace_proxies::*; -pub mod utils; +pub(crate) mod utils; -pub mod controls; -pub use controls::*; +pub(crate) mod controls; +pub(crate) use controls::*; use crate::state::GameState; use bevy::prelude::*; diff --git a/examples/common/src/core/physics_rapier/physics_replace_proxies.rs b/examples/common/src/core/physics_rapier/physics_replace_proxies.rs index 498c482..de019fe 100644 --- a/examples/common/src/core/physics_rapier/physics_replace_proxies.rs +++ b/examples/common/src/core/physics_rapier/physics_replace_proxies.rs @@ -26,7 +26,7 @@ pub enum AutoAABBCollider { // replaces all physics stand-ins with the actual rapier types #[allow(clippy::type_complexity)] -pub fn physics_replace_proxies( +pub(crate) fn physics_replace_proxies( meshes: Res>, mesh_handles: Query<&Handle>, mut proxy_colliders: Query< diff --git a/examples/common/src/core/physics_xpbd/controls.rs b/examples/common/src/core/physics_xpbd/controls.rs index 2846560..8fd71d8 100644 --- a/examples/common/src/core/physics_xpbd/controls.rs +++ b/examples/common/src/core/physics_xpbd/controls.rs @@ -8,17 +8,17 @@ use bevy::{prelude::ResMut, time::Time}; use bevy_xpbd_3d::prelude::Physics; use bevy_xpbd_3d::prelude::*; -pub fn pause_physics(mut time: ResMut>) { +pub(crate) fn pause_physics(mut time: ResMut>) { info!("pausing physics"); time.pause(); } -pub fn resume_physics(mut time: ResMut>) { +pub(crate) fn resume_physics(mut time: ResMut>) { info!("unpausing physics"); time.unpause(); } -pub fn toggle_physics_debug( +pub(crate) fn toggle_physics_debug( mut config_store: ResMut, keycode: Res>, ) { diff --git a/examples/common/src/core/physics_xpbd/mod.rs b/examples/common/src/core/physics_xpbd/mod.rs index ab7a95b..2e55436 100644 --- a/examples/common/src/core/physics_xpbd/mod.rs +++ b/examples/common/src/core/physics_xpbd/mod.rs @@ -1,10 +1,10 @@ -pub mod physics_replace_proxies; -pub use physics_replace_proxies::*; +pub(crate) mod physics_replace_proxies; +pub(crate) use physics_replace_proxies::*; -pub mod utils; +pub(crate) mod utils; -pub mod controls; -pub use controls::*; +pub(crate) mod controls; +pub(crate) use controls::*; use bevy::prelude::*; use bevy_xpbd_3d::prelude::*; @@ -12,8 +12,8 @@ use bevy_xpbd_3d::prelude::*; use crate::state::GameState; use bevy_gltf_blueprints::GltfBlueprintsSet; -pub struct PhysicsPlugin; -impl Plugin for PhysicsPlugin { +pub struct PhysicsPluginXPBD; +impl Plugin for PhysicsPluginXPBD { fn build(&self, app: &mut App) { app.add_plugins((PhysicsPlugins::default(), PhysicsDebugPlugin::default())) .register_type::() diff --git a/examples/common/src/core/physics_xpbd/physics_replace_proxies.rs b/examples/common/src/core/physics_xpbd/physics_replace_proxies.rs index 3e281dc..6f93740 100644 --- a/examples/common/src/core/physics_xpbd/physics_replace_proxies.rs +++ b/examples/common/src/core/physics_xpbd/physics_replace_proxies.rs @@ -25,7 +25,7 @@ pub enum AutoAABBCollider { // replaces all physics stand-ins with the actual xpbd types #[allow(clippy::type_complexity)] -pub fn physics_replace_proxies( +pub(crate) fn physics_replace_proxies( meshes: Res>, mesh_handles: Query<&Handle>, mut proxy_colliders: Query<