Fix clippy and enable clippy on CI
This commit is contained in:
committed by
Sébastien Crozet
parent
aef873f20e
commit
da92e5c283
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::bad_bit_mask)] // otherwsie clippy complains because of TestbedStateFlags::NONE which is 0.
|
||||
|
||||
use std::env;
|
||||
use std::mem;
|
||||
use std::num::NonZeroUsize;
|
||||
@@ -107,6 +109,8 @@ pub enum RapierSolverType {
|
||||
StandardPgs,
|
||||
}
|
||||
|
||||
pub type SimulationBuilders = Vec<(&'static str, fn(&mut Testbed))>;
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct TestbedState {
|
||||
pub running: RunMode,
|
||||
@@ -135,7 +139,7 @@ pub struct TestbedState {
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct SceneBuilders(Vec<(&'static str, fn(&mut Testbed))>);
|
||||
struct SceneBuilders(SimulationBuilders);
|
||||
|
||||
#[cfg(feature = "other-backends")]
|
||||
struct OtherBackends {
|
||||
@@ -237,7 +241,7 @@ impl TestbedApp {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_builders(default: usize, builders: Vec<(&'static str, fn(&mut Testbed))>) -> Self {
|
||||
pub fn from_builders(default: usize, builders: SimulationBuilders) -> Self {
|
||||
let mut res = TestbedApp::new_empty();
|
||||
res.state
|
||||
.action_flags
|
||||
@@ -247,7 +251,7 @@ impl TestbedApp {
|
||||
res
|
||||
}
|
||||
|
||||
pub fn set_builders(&mut self, builders: Vec<(&'static str, fn(&mut Testbed))>) {
|
||||
pub fn set_builders(&mut self, builders: SimulationBuilders) {
|
||||
self.state.example_names = builders.iter().map(|e| e.0).collect();
|
||||
self.builders = SceneBuilders(builders)
|
||||
}
|
||||
@@ -280,7 +284,7 @@ impl TestbedApp {
|
||||
use std::io::{BufWriter, Write};
|
||||
// Don't enter the main loop. We will just step the simulation here.
|
||||
let mut results = Vec::new();
|
||||
let builders = mem::replace(&mut self.builders.0, Vec::new());
|
||||
let builders = mem::take(&mut self.builders.0);
|
||||
let backend_names = self.state.backend_names.clone();
|
||||
|
||||
for builder in builders {
|
||||
@@ -423,8 +427,7 @@ impl TestbedApp {
|
||||
|
||||
impl<'a, 'b, 'c, 'd, 'e, 'f> TestbedGraphics<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
pub fn set_body_color(&mut self, body: RigidBodyHandle, color: [f32; 3]) {
|
||||
self.graphics
|
||||
.set_body_color(&mut self.materials, body, color);
|
||||
self.graphics.set_body_color(self.materials, body, color);
|
||||
}
|
||||
|
||||
pub fn add_body(
|
||||
@@ -466,7 +469,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> TestbedGraphics<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
}
|
||||
|
||||
pub fn keys(&self) -> &Input<KeyCode> {
|
||||
&*self.keys
|
||||
self.keys
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +500,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
}
|
||||
|
||||
pub fn harness_mut(&mut self) -> &mut Harness {
|
||||
&mut self.harness
|
||||
self.harness
|
||||
}
|
||||
|
||||
pub fn set_world(
|
||||
@@ -1110,30 +1113,30 @@ fn update_testbed(
|
||||
// Handle inputs
|
||||
{
|
||||
let graphics_context = TestbedGraphics {
|
||||
graphics: &mut *graphics,
|
||||
graphics: &mut graphics,
|
||||
commands: &mut commands,
|
||||
meshes: &mut *meshes,
|
||||
materials: &mut *materials,
|
||||
components: &mut gfx_components,
|
||||
camera_transform: *cameras.single().1,
|
||||
camera: &mut cameras.single_mut().2,
|
||||
keys: &*keys,
|
||||
keys: &keys,
|
||||
};
|
||||
|
||||
let mut testbed = Testbed {
|
||||
graphics: Some(graphics_context),
|
||||
state: &mut *state,
|
||||
harness: &mut *harness,
|
||||
state: &mut state,
|
||||
harness: &mut harness,
|
||||
#[cfg(feature = "other-backends")]
|
||||
other_backends: &mut *other_backends,
|
||||
plugins: &mut *plugins,
|
||||
other_backends: &mut other_backends,
|
||||
plugins: &mut plugins,
|
||||
};
|
||||
|
||||
testbed.handle_common_events(&*keys);
|
||||
testbed.update_character_controller(&*keys);
|
||||
testbed.handle_common_events(&keys);
|
||||
testbed.update_character_controller(&keys);
|
||||
#[cfg(feature = "dim3")]
|
||||
{
|
||||
testbed.update_vehicle_controller(&*keys);
|
||||
testbed.update_vehicle_controller(&keys);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1144,7 +1147,7 @@ fn update_testbed(
|
||||
|
||||
for plugin in &mut plugins.0 {
|
||||
plugin.update_ui(
|
||||
&mut ui_context,
|
||||
&ui_context,
|
||||
harness,
|
||||
&mut graphics,
|
||||
&mut commands,
|
||||
@@ -1190,10 +1193,10 @@ fn update_testbed(
|
||||
.set(TestbedActionFlags::EXAMPLE_CHANGED, false);
|
||||
clear(&mut commands, &mut state, &mut graphics, &mut plugins);
|
||||
harness.clear_callbacks();
|
||||
for plugin in (*plugins).0.iter_mut() {
|
||||
for plugin in plugins.0.iter_mut() {
|
||||
plugin.clear_graphics(&mut graphics, &mut commands);
|
||||
}
|
||||
(*plugins).0.clear();
|
||||
plugins.0.clear();
|
||||
|
||||
if state.selected_example != prev_example {
|
||||
harness.physics.integration_parameters = IntegrationParameters::default();
|
||||
@@ -1219,16 +1222,16 @@ fn update_testbed(
|
||||
components: &mut gfx_components,
|
||||
camera_transform: *cameras.single().1,
|
||||
camera: &mut cameras.single_mut().2,
|
||||
keys: &*keys,
|
||||
keys: &keys,
|
||||
};
|
||||
|
||||
let mut testbed = Testbed {
|
||||
graphics: Some(graphics_context),
|
||||
state: &mut *state,
|
||||
harness: &mut *harness,
|
||||
state: &mut state,
|
||||
harness: &mut harness,
|
||||
#[cfg(feature = "other-backends")]
|
||||
other_backends: &mut *other_backends,
|
||||
plugins: &mut *plugins,
|
||||
other_backends: &mut other_backends,
|
||||
plugins: &mut plugins,
|
||||
};
|
||||
|
||||
builders.0[selected_example].1(&mut testbed);
|
||||
@@ -1371,7 +1374,7 @@ fn update_testbed(
|
||||
components: &mut gfx_components,
|
||||
camera_transform: *cameras.single().1,
|
||||
camera: &mut cameras.single_mut().2,
|
||||
keys: &*keys,
|
||||
keys: &keys,
|
||||
};
|
||||
harness.step_with_graphics(Some(&mut testbed_graphics));
|
||||
|
||||
@@ -1425,8 +1428,8 @@ fn update_testbed(
|
||||
for (camera, camera_pos, _) in cameras.iter_mut() {
|
||||
highlight_hovered_body(
|
||||
&mut *materials,
|
||||
&mut *graphics,
|
||||
&mut *state,
|
||||
&mut graphics,
|
||||
&mut state,
|
||||
&harness.physics,
|
||||
window,
|
||||
camera,
|
||||
|
||||
Reference in New Issue
Block a user