aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2024-01-27 16:49:53 +0100
committerSébastien Crozet <sebastien@crozet.re>2024-01-27 17:13:08 +0100
commitda92e5c2837b27433286cf0dd9d887fd44dda254 (patch)
tree00428ce290288f5c64e53dee13d88ffdde4df0ca
parentaef873f20e7a1ee66b9d4c066884fa794048587b (diff)
downloadrapier-da92e5c2837b27433286cf0dd9d887fd44dda254.tar.gz
rapier-da92e5c2837b27433286cf0dd9d887fd44dda254.tar.bz2
rapier-da92e5c2837b27433286cf0dd9d887fd44dda254.zip
Fix clippy and enable clippy on CI
-rw-r--r--.github/workflows/rapier-ci-build.yml6
-rw-r--r--benchmarks2d/all_benchmarks2.rs6
-rw-r--r--benchmarks3d/all_benchmarks3.rs4
-rw-r--r--benchmarks3d/keva3.rs12
-rw-r--r--examples2d/all_examples2.rs6
-rw-r--r--examples2d/trimesh2.rs2
-rw-r--r--examples3d-f64/all_examples3-f64.rs6
-rw-r--r--examples3d/all_examples3.rs6
-rw-r--r--examples3d/ccd3.rs4
-rw-r--r--examples3d/joints3.rs11
-rw-r--r--examples3d/keva3.rs12
-rw-r--r--examples3d/rope_joints3.rs2
-rw-r--r--examples3d/vehicle_controller3.rs8
-rw-r--r--src/control/ray_cast_vehicle_controller.rs10
-rw-r--r--src/data/arena.rs2
-rw-r--r--src/data/pubsub.rs3
-rw-r--r--src/dynamics/ccd/ccd_solver.rs45
-rw-r--r--src/dynamics/ccd/toi_entry.rs6
-rw-r--r--src/dynamics/coefficient_combine_rule.rs9
-rw-r--r--src/dynamics/integration_parameters.rs3
-rw-r--r--src/dynamics/island_manager.rs2
-rw-r--r--src/dynamics/joint/fixed_joint.rs12
-rw-r--r--src/dynamics/joint/generic_joint.rs8
-rw-r--r--src/dynamics/joint/impulse_joint/impulse_joint_set.rs6
-rw-r--r--src/dynamics/joint/motor_model.rs9
-rw-r--r--src/dynamics/joint/multibody_joint/multibody.rs21
-rw-r--r--src/dynamics/joint/multibody_joint/multibody_joint_set.rs12
-rw-r--r--src/dynamics/joint/prismatic_joint.rs12
-rw-r--r--src/dynamics/joint/revolute_joint.rs14
-rw-r--r--src/dynamics/joint/rope_joint.rs12
-rw-r--r--src/dynamics/joint/spherical_joint.rs12
-rw-r--r--src/dynamics/joint/spring_joint.rs12
-rw-r--r--src/dynamics/rigid_body.rs58
-rw-r--r--src/dynamics/rigid_body_components.rs34
-rw-r--r--src/dynamics/rigid_body_set.rs2
-rw-r--r--src/dynamics/solver/contact_constraint/contact_constraints_set.rs16
-rw-r--r--src/dynamics/solver/contact_constraint/generic_one_body_constraint.rs4
-rw-r--r--src/dynamics/solver/contact_constraint/generic_two_body_constraint.rs12
-rw-r--r--src/dynamics/solver/contact_constraint/generic_two_body_constraint_element.rs20
-rw-r--r--src/dynamics/solver/contact_constraint/one_body_constraint.rs6
-rw-r--r--src/dynamics/solver/contact_constraint/one_body_constraint_element.rs4
-rw-r--r--src/dynamics/solver/contact_constraint/one_body_constraint_simd.rs12
-rw-r--r--src/dynamics/solver/contact_constraint/two_body_constraint.rs8
-rw-r--r--src/dynamics/solver/contact_constraint/two_body_constraint_element.rs4
-rw-r--r--src/dynamics/solver/contact_constraint/two_body_constraint_simd.rs24
-rw-r--r--src/dynamics/solver/interaction_groups.rs6
-rw-r--r--src/dynamics/solver/joint_constraint/joint_constraints_set.rs12
-rw-r--r--src/dynamics/solver/joint_constraint/joint_generic_constraint_builder.rs1
-rw-r--r--src/dynamics/solver/joint_constraint/joint_velocity_constraint.rs48
-rw-r--r--src/dynamics/solver/mod.rs14
-rw-r--r--src/dynamics/solver/velocity_solver.rs6
-rw-r--r--src/geometry/broad_phase_multi_sap/broad_phase.rs5
-rw-r--r--src/geometry/broad_phase_multi_sap/mod.rs12
-rw-r--r--src/geometry/broad_phase_multi_sap/sap_axis.rs5
-rw-r--r--src/geometry/broad_phase_multi_sap/sap_proxy.rs13
-rw-r--r--src/geometry/broad_phase_multi_sap/sap_region.rs1
-rw-r--r--src/geometry/collider.rs11
-rw-r--r--src/geometry/collider_set.rs4
-rw-r--r--src/geometry/interaction_groups.rs2
-rw-r--r--src/geometry/narrow_phase.rs62
-rw-r--r--src/lib.rs3
-rw-r--r--src/pipeline/collision_pipeline.rs2
-rw-r--r--src/pipeline/debug_render_pipeline/debug_render_backend.rs10
-rw-r--r--src/pipeline/debug_render_pipeline/debug_render_pipeline.rs9
-rw-r--r--src/pipeline/debug_render_pipeline/mod.rs2
-rw-r--r--src/pipeline/debug_render_pipeline/outlines.rs1
-rw-r--r--src/pipeline/physics_hooks.rs2
-rw-r--r--src/pipeline/physics_pipeline.rs13
-rw-r--r--src/pipeline/query_pipeline.rs9
-rw-r--r--src/pipeline/user_changes.rs14
-rw-r--r--src/utils.rs2
-rw-r--r--src_testbed/camera2d.rs1
-rw-r--r--src_testbed/camera3d.rs1
-rw-r--r--src_testbed/debug_render.rs6
-rw-r--r--src_testbed/graphics.rs7
-rw-r--r--src_testbed/harness/mod.rs10
-rw-r--r--src_testbed/lib.rs2
-rw-r--r--src_testbed/objects/node.rs2
-rw-r--r--src_testbed/physics/mod.rs10
-rw-r--r--src_testbed/testbed.rs59
-rw-r--r--src_testbed/ui.rs24
81 files changed, 421 insertions, 469 deletions
diff --git a/.github/workflows/rapier-ci-build.yml b/.github/workflows/rapier-ci-build.yml
index 9328bc9..1b29d15 100644
--- a/.github/workflows/rapier-ci-build.yml
+++ b/.github/workflows/rapier-ci-build.yml
@@ -23,6 +23,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: sudo apt-get install -y cmake libxcb-composite0-dev
+ - name: Clippy
+ run: cargo clippy
+ - name: Clippy rapier2d
+ run: cargo clippy -p rapier-examples-2d --features parallel,simd-stable
+ - name: Clippy rapier3d
+ run: cargo clippy -p rapier-examples-3d --features parallel,simd-stable
- name: Build rapier2d
run: cargo build --verbose -p rapier2d;
- name: Build rapier3d
diff --git a/benchmarks2d/all_benchmarks2.rs b/benchmarks2d/all_benchmarks2.rs
index ce6aaac..fcc7b95 100644
--- a/benchmarks2d/all_benchmarks2.rs
+++ b/benchmarks2d/all_benchmarks2.rs
@@ -46,8 +46,8 @@ fn demo_name_from_url() -> Option<String> {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() {
let demo = demo_name_from_command_line()
- .or_else(|| demo_name_from_url())
- .unwrap_or(String::new())
+ .or_else(demo_name_from_url)
+ .unwrap_or_default()
.to_camel_case();
let mut builders: Vec<(_, fn(&mut Testbed))> = vec![
@@ -66,7 +66,7 @@ pub fn main() {
];
// Lexicographic sort, with stress tests moved at the end of the list.
- builders.sort_by(|a, b| match (a.0.starts_with("("), b.0.starts_with("(")) {
+ builders.sort_by(|a, b| match (a.0.starts_with('('), b.0.starts_with(')')) {
(true, true) | (false, false) => a.0.cmp(b.0),
(true, false) => Ordering::Greater,
(false, true) => Ordering::Less,
diff --git a/benchmarks3d/all_benchmarks3.rs b/benchmarks3d/all_benchmarks3.rs
index bca730b..591886e 100644
--- a/benchmarks3d/all_benchmarks3.rs
+++ b/benchmarks3d/all_benchmarks3.rs
@@ -36,7 +36,7 @@ fn parse_command_line() -> Command {
while let Some(arg) = args.next() {
if &arg[..] == "--example" {
- return Command::Run(args.next().unwrap_or(String::new()));
+ return Command::Run(args.next().unwrap_or_default());
} else if &arg[..] == "--list" {
return Command::List;
}
@@ -68,7 +68,7 @@ pub fn main() {
];
// Lexicographic sort, with stress tests moved at the end of the list.
- builders.sort_by(|a, b| match (a.0.starts_with("("), b.0.starts_with("(")) {
+ builders.sort_by(|a, b| match (a.0.starts_with('('), b.0.starts_with('(')) {
(true, true) | (false, false) => a.0.cmp(b.0),
(true, false) => Ordering::Greater,
(false, true) => Ordering::Less,
diff --git a/benchmarks3d/keva3.rs b/benchmarks3d/keva3.rs
index ecd6e77..4f5cd54 100644
--- a/benchmarks3d/keva3.rs
+++ b/benchmarks3d/keva3.rs
@@ -7,9 +7,7 @@ pub fn build_block(
colliders: &mut ColliderSet,
half_extents: Vector<f32>,
shift: Vector<f32>,
- mut numx: usize,
- numy: usize,
- mut numz: usize,
+ (mut numx, numy, mut numz): (usize, usize, usize),
) {
let dimensions = [half_extents.xyz(), half_extents.zyx()];
let block_width = 2.0 * half_extents.z * numx as f32;
@@ -56,8 +54,8 @@ pub fn build_block(
// Close the top.
let dim = half_extents.zxy();
- for i in 0..(block_width / (dim.x as f32 * 2.0)) as usize {
- for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
+ for i in 0..(block_width / (dim.x * 2.0)) as usize {
+ for j in 0..(block_width / (dim.z * 2.0)) as usize {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
i as f32 * dim.x * 2.0 + dim.x + shift.x,
@@ -114,9 +112,7 @@ pub fn init_world(testbed: &mut Testbed) {
&mut colliders,
half_extents,
vector![-block_width / 2.0, block_height, -block_width / 2.0],
- numx,
- numy,
- numz,
+ (numx, numy, numz),
);
block_height += numy as f32 * half_extents.y * 2.0 + half_extents.x * 2.0;
num_blocks_built += numx * numy * numz;
diff --git a/examples2d/all_examples2.rs b/examples2d/all_examples2.rs
index 032e4d6..4cdbf98 100644
--- a/examples2d/all_examples2.rs
+++ b/examples2d/all_examples2.rs
@@ -57,8 +57,8 @@ fn demo_name_from_url() -> Option<String> {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() {
let demo = demo_name_from_command_line()
- .or_else(|| demo_name_from_url())
- .unwrap_or(String::new())
+ .or_else(demo_name_from_url)
+ .unwrap_or_default()
.to_camel_case();
let mut builders: Vec<(_, fn(&mut Testbed))> = vec![
@@ -85,7 +85,7 @@ pub fn main() {
];
// Lexicographic sort, with stress tests moved at the end of the list.
- builders.sort_by(|a, b| match (a.0.starts_with("("), b.0.starts_with("(")) {
+ builders.sort_by(|a, b| match (a.0.starts_with('('), b.0.starts_with('(')) {
(true, true) | (false, false) => a.0.cmp(b.0),
(true, false) => Ordering::Greater,
(false, true) => Ordering::Less,
diff --git a/examples2d/trimesh2.rs b/examples2d/trimesh2.rs
index 219a583..2cb8410 100644
--- a/examples2d/trimesh2.rs
+++ b/examples2d/trimesh2.rs
@@ -104,7 +104,7 @@ pub fn init_world(testbed: &mut Testbed) {
testbed.look_at(point![0.0, 20.0], 17.0);
}
-const RAPIER_SVG_STR: &'static str = r#"
+const RAPIER_SVG_STR: &str = r#"
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 527 131" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<g transform="matrix(1,0,0,1,1,-673)">
diff --git a/examples3d-f64/all_examples3-f64.rs b/examples3d-f64/all_examples3-f64.rs
index 4464d60..c381eec 100644
--- a/examples3d-f64/all_examples3-f64.rs
+++ b/examples3d-f64/all_examples3-f64.rs
@@ -43,15 +43,15 @@ fn demo_name_from_url() -> Option<String> {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() {
let demo = demo_name_from_command_line()
- .or_else(|| demo_name_from_url())
- .unwrap_or(String::new())
+ .or_else(demo_name_from_url)
+ .unwrap_or_default()
.to_camel_case();
let mut builders: Vec<(_, fn(&mut Testbed))> =
vec![("(Debug) serialized", debug_serialized3::init_world)];
// Lexicographic sort, with stress tests moved at the end of the list.
- builders.sort_by(|a, b| match (a.0.starts_with("("), b.0.starts_with("(")) {
+ builders.sort_by(|a, b| match (a.0.starts_with('('), b.0.starts_with('(')) {
(true, true) | (false, false) => a.0.cmp(b.0),
(true, false) => Ordering::Greater,
(false, true) => Ordering::Less,
diff --git a/examples3d/all_examples3.rs b/examples3d/all_examples3.rs
index 1bc8419..bac826e 100644
--- a/examples3d/all_examples3.rs
+++ b/examples3d/all_examples3.rs
@@ -86,8 +86,8 @@ fn demo_name_from_url() -> Option<String> {
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
pub fn main() {
let demo = demo_name_from_command_line()
- .or_else(|| demo_name_from_url())
- .unwrap_or(String::new())
+ .or_else(demo_name_from_url)
+ .unwrap_or_default()
.to_camel_case();
let mut builders: Vec<(_, fn(&mut Testbed))> = vec![
@@ -157,7 +157,7 @@ pub fn main() {
];
// Lexicographic sort, with stress tests moved at the end of the list.
- builders.sort_by(|a, b| match (a.0.starts_with("("), b.0.starts_with("(")) {
+ builders.sort_by(|a, b| match (a.0.starts_with('('), b.0.starts_with('(')) {
(true, true) | (false, false) => a.0.cmp(b.0),
(true, false) => Ordering::Greater,
(false, true) => Ordering::Less,
diff --git a/examples3d/ccd3.rs b/examples3d/ccd3.rs
index 4047f4b..c1a5176 100644
--- a/examples3d/ccd3.rs
+++ b/examples3d/ccd3.rs
@@ -27,9 +27,9 @@ fn create_wall(
colliders.insert_with_parent(collider, handle, bodies);
k += 1;
if k % 2 == 0 {
- testbed.set_initial_body_color(handle, [255. / 255., 131. / 255., 244.0 / 255.]);
+ testbed.set_initial_body_color(handle, [1., 131. / 255., 244.0 / 255.]);
} else {
- testbed.set_initial_body_color(handle, [131. / 255., 255. / 255., 244.0 / 255.]);
+ testbed.set_initial_body_color(handle, [131. / 255., 1., 244.0 / 255.]);
}
}
}
diff --git a/examples3d/joints3.rs b/examples3d/joints3.rs
index 18a11e7..73f48ae 100644
--- a/examples3d/joints3.rs
+++ b/examples3d/joints3.rs
@@ -482,7 +482,7 @@ fn create_actuated_revolute_joints(
} else if i == num - 1 {
let stiffness = 200.0;
let damping = 100.0;
- joint = joint.motor_position(3.14 / 2.0, stiffness, damping);
+ joint = joint.motor_position(std::f32::consts::FRAC_PI_2, stiffness, damping);
}
if i == 1 {
@@ -541,7 +541,7 @@ fn create_actuated_spherical_joints(
colliders.insert_with_parent(collider, child_handle, bodies);
if i > 0 {
- let mut joint = joint_template.clone();
+ let mut joint = joint_template;
if i == 1 {
joint = joint
@@ -554,7 +554,12 @@ fn create_actuated_spherical_joints(
joint = joint
.motor_position(JointAxis::AngX, 0.0, stiffness, damping)
.motor_position(JointAxis::AngY, 1.0, stiffness, damping)
- .motor_position(JointAxis::AngZ, 3.14 / 2.0, stiffness, damping);
+ .motor_position(
+ JointAxis::AngZ,
+ std::f32::consts::FRAC_PI_2,
+ stiffness,
+ damping,
+ );
}
if use_articulations {
diff --git a/examples3d/keva3.rs b/examples3d/keva3.rs
index ecd6e77..4f5cd54 100644
--- a/examples3d/keva3.rs
+++ b/examples3d/keva3.rs
@@ -7,9 +7,7 @@ pub fn build_block(
colliders: &mut ColliderSet,
half_extents: Vector<f32>,
shift: Vector<f32>,
- mut numx: usize,
- numy: usize,
- mut numz: usize,
+ (mut numx, numy, mut numz): (usize, usize, usize),
) {
let dimensions = [half_extents.xyz(), half_extents.zyx()];
let block_width = 2.0 * half_extents.z * numx as f32;
@@ -56,8 +54,8 @@ pub fn build_block(
// Close the top.
let dim = half_extents.zxy();
- for i in 0..(block_width / (dim.x as f32 * 2.0)) as usize {
- for j in 0..(block_width / (dim.z as f32 * 2.0)) as usize {
+ for i in 0..(block_width / (dim.x * 2.0)) as usize {
+ for j in 0..(block_width / (dim.z * 2.0)) as usize {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
i as f32 * dim.x * 2.0 + dim.x + shift.x,
@@ -114,9 +112,7 @@ pub fn init_world(testbed: &mut Testbed) {
&mut colliders,
half_extents,
vector![-block_width / 2.0, block_height, -block_width / 2.0],
- numx,
- numy,
- numz,
+ (numx, numy, numz),
);
block_height += numy as f32 * half_extents.y * 2.0 + half_extents.x * 2.0;
num_blocks_built += numx * numy * numz;
diff --git a/examples3d/rope_joints3.rs b/examples3d/rope_joints3.rs
index 9696682..11f0716 100644
--- a/examples3d/rope_joints3.rs
+++ b/examples3d/rope_joints3.rs
@@ -67,7 +67,7 @@ pub fn init_world(testbed: &mut Testbed) {
let collider = ColliderBuilder::cuboid(0.15, 0.3, 0.15);
colliders.insert_with_parent(collider, character_handle, &mut bodies);
- testbed.set_initial_body_color(character_handle, [255. / 255., 131. / 255., 244.0 / 255.]);
+ testbed.set_initial_body_color(character_handle, [1., 131. / 255., 244.0 / 255.]);
/*
* Tethered Ball
diff --git a/examples3d/vehicle_controller3.rs b/examples3d/vehicle_controller3.rs
index 1228c82..846d9fe 100644
--- a/examples3d/vehicle_controller3.rs
+++ b/examples3d/vehicle_controller3.rs
@@ -32,9 +32,11 @@ pub fn init_world(testbed: &mut Testbed) {
let collider = ColliderBuilder::cuboid(hw * 2.0, hh, hw).density(100.0);
colliders.insert_with_parent(collider, vehicle_handle, &mut bodies);
- let mut tuning = WheelTuning::default();
- tuning.suspension_stiffness = 100.0;
- tuning.suspension_damping = 10.0;
+ let tuning = WheelTuning {
+ suspension_stiffness: 100.0,
+ suspension_damping: 10.0,
+ ..WheelTuning::default()
+ };
let mut vehicle = DynamicRayCastVehicleController::new(vehicle_handle);
let wheel_positions = [
point![hw * 1.5, -hh, hw],
diff --git a/src/control/ray_cast_vehicle_controller.rs b/src/control/ray_cast_vehicle_controller.rs
index 30979e1..00b11eb 100644
--- a/src/control/ray_cast_vehicle_controller.rs
+++ b/src/control/ray_cast_vehicle_controller.rs
@@ -582,7 +582,7 @@ impl DynamicRayCastVehicleController {
wheel.side_impulse = resolve_single_bilateral(
&bodies[self.chassis],
&wheel.raycast_info.contact_poin