aboutsummaryrefslogtreecommitdiff
path: root/examples3d
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 /examples3d
parentaef873f20e7a1ee66b9d4c066884fa794048587b (diff)
downloadrapier-da92e5c2837b27433286cf0dd9d887fd44dda254.tar.gz
rapier-da92e5c2837b27433286cf0dd9d887fd44dda254.tar.bz2
rapier-da92e5c2837b27433286cf0dd9d887fd44dda254.zip
Fix clippy and enable clippy on CI
Diffstat (limited to 'examples3d')
-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
6 files changed, 23 insertions, 20 deletions
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],