chore: clippy fixes

This commit is contained in:
Sébastien Crozet
2024-04-28 18:23:30 +02:00
committed by Sébastien Crozet
parent 929aa6b925
commit 0a9153e273
29 changed files with 38 additions and 52 deletions

View File

@@ -10,15 +10,14 @@ pub fn init_world(testbed: &mut Testbed) {
let impulse_joints = ImpulseJointSet::new(); let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new(); let multibody_joints = MultibodyJointSet::new();
let num = 80;
let rad = 0.5; // 50.0 / 2.0; // 0.5; let rad = 0.5;
let rad = 50.0 / 2.0; // 0.5;
/* /*
* Ground * Ground
*/ */
let ground_size = num as f32 * rad * 10.0; let ground_size = num as f32 * rad * 10.0;
let ground_thickness = 25.0; let ground_thickness = 1.0;
let rigid_body = RigidBodyBuilder::fixed(); let rigid_body = RigidBodyBuilder::fixed();
let ground_handle = bodies.insert(rigid_body); let ground_handle = bodies.insert(rigid_body);
@@ -31,7 +30,7 @@ pub fn init_world(testbed: &mut Testbed) {
let shiftx_centerx = [ let shiftx_centerx = [
(rad * 2.0 + 0.0002, -(num as f32) * rad * 2.0 * 1.5), (rad * 2.0 + 0.0002, -(num as f32) * rad * 2.0 * 1.5),
(rad * 2.0 + rad, num as f32 * rad * 2.0 * 1.5), (rad * 2.0 + rad, num as f32 * rad * 2.0 * 1.5),
]; ];
for (shiftx, centerx) in shiftx_centerx { for (shiftx, centerx) in shiftx_centerx {

View File

@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = ["now"], optional = true } instant = { version = "0.1", features = ["now"], optional = true }
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.32" nalgebra = "0.32"
parry2d-f64 = "0.13.1" parry2d-f64 = "0.14.0"
simba = "0.8" simba = "0.8"
approx = "0.5" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }

View File

@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = ["now"], optional = true } instant = { version = "0.1", features = ["now"], optional = true }
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.32" nalgebra = "0.32"
parry2d = "0.13.1" parry2d = "0.14.0"
simba = "0.8" simba = "0.8"
approx = "0.5" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }

View File

@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = ["now"], optional = true } instant = { version = "0.1", features = ["now"], optional = true }
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.32" nalgebra = "0.32"
parry3d-f64 = "0.13.1" parry3d-f64 = "0.14.0"
simba = "0.8" simba = "0.8"
approx = "0.5" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }

View File

@@ -52,7 +52,7 @@ vec_map = { version = "0.8", optional = true }
instant = { version = "0.1", features = ["now"], optional = true } instant = { version = "0.1", features = ["now"], optional = true }
num-traits = "0.2" num-traits = "0.2"
nalgebra = "0.32" nalgebra = "0.32"
parry3d = "0.13.1" parry3d = "0.14.0"
simba = "0.8" simba = "0.8"
approx = "0.5" approx = "0.5"
rayon = { version = "1", optional = true } rayon = { version = "1", optional = true }

View File

@@ -10,6 +10,7 @@ pub fn init_world(testbed: &mut Testbed) {
let impulse_joints = ImpulseJointSet::new(); let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new(); let multibody_joints = MultibodyJointSet::new();
#[allow(clippy::excessive_precision)]
let mut ps1 = [ let mut ps1 = [
Point::new(16.0, 0.0), Point::new(16.0, 0.0),
Point::new(14.93803712795643, 5.133601056842984), Point::new(14.93803712795643, 5.133601056842984),
@@ -22,6 +23,7 @@ pub fn init_world(testbed: &mut Testbed) {
Point::new(2.405937953536585, 39.09554102558315), Point::new(2.405937953536585, 39.09554102558315),
]; ];
#[allow(clippy::excessive_precision)]
let mut ps2 = [ let mut ps2 = [
Point::new(24.0, 0.0), Point::new(24.0, 0.0),
Point::new(22.33619528222415, 6.02299846205841), Point::new(22.33619528222415, 6.02299846205841),

View File

@@ -24,7 +24,7 @@ pub fn init_world(testbed: &mut Testbed) {
let friction = 0.6; let friction = 0.6;
let capsule = ColliderBuilder::capsule_x(hx, 0.125) let capsule = ColliderBuilder::capsule_x(hx, 0.125)
.friction(friction) .friction(friction)
.density(20.0); .density(density);
let mut prev = ground; let mut prev = ground;
for i in 0..count { for i in 0..count {
@@ -55,7 +55,7 @@ pub fn init_world(testbed: &mut Testbed) {
let handle = bodies.insert(rigid_body); let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::ball(radius) let collider = ColliderBuilder::ball(radius)
.friction(friction) .friction(friction)
.density(20.0); .density(density);
colliders.insert_with_parent(collider, handle, &mut bodies); colliders.insert_with_parent(collider, handle, &mut bodies);
let pivot = point![(2.0 * count as f32) * hx, count as f32 * hx]; let pivot = point![(2.0 * count as f32) * hx, count as f32 * hx];
@@ -64,7 +64,6 @@ pub fn init_world(testbed: &mut Testbed) {
.local_anchor2(bodies[handle].position().inverse_transform_point(&pivot)) .local_anchor2(bodies[handle].position().inverse_transform_point(&pivot))
.contacts_enabled(false); .contacts_enabled(false);
impulse_joints.insert(prev, handle, joint, true); impulse_joints.insert(prev, handle, joint, true);
prev = handle;
/* /*
* Set up the testbed. * Set up the testbed.

View File

@@ -29,7 +29,7 @@ pub fn init_world(testbed: &mut Testbed) {
.angular_damping(0.1) .angular_damping(0.1)
.translation(vector![x_base + 0.5 + 1.0 * i as f32, 20.0]); .translation(vector![x_base + 0.5 + 1.0 * i as f32, 20.0]);
let handle = bodies.insert(rigid_body); let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(0.5, 0.125).density(20.0); let collider = ColliderBuilder::cuboid(0.5, 0.125).density(density);
colliders.insert_with_parent(collider, handle, &mut bodies); colliders.insert_with_parent(collider, handle, &mut bodies);
let pivot = point![x_base + 1.0 * i as f32, 20.0]; let pivot = point![x_base + 1.0 * i as f32, 20.0];

View File

@@ -10,7 +10,6 @@ pub fn init_world(testbed: &mut Testbed) {
let impulse_joints = ImpulseJointSet::new(); let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new(); let multibody_joints = MultibodyJointSet::new();
let extent = 1.0;
let friction = 0.7; let friction = 0.7;
/* /*

View File

@@ -38,13 +38,13 @@ pub fn init_world(testbed: &mut Testbed) {
/* /*
* Create the spheres * Create the spheres
*/ */
let mut row = 0; let mut row;
let mut count = 0; let mut count = 0;
let mut column = 0; let mut column = 0;
while count < max_count { while count < max_count {
row = 0; row = 0;
for i in 0..grid_count { for _ in 0..grid_count {
let x = -8.75 + column as f32 * 18.0 / (grid_count as f32); let x = -8.75 + column as f32 * 18.0 / (grid_count as f32);
let y = 1.5 + row as f32 * 18.0 / (grid_count as f32); let y = 1.5 + row as f32 * 18.0 / (grid_count as f32);
let body = RigidBodyBuilder::dynamic() let body = RigidBodyBuilder::dynamic()

View File

@@ -11,7 +11,6 @@ pub fn init_world(testbed: &mut Testbed) {
let multibody_joints = MultibodyJointSet::new(); let multibody_joints = MultibodyJointSet::new();
let origin = vector![100_000.0, -80_000.0]; let origin = vector![100_000.0, -80_000.0];
let extent = 1.0;
let friction = 0.6; let friction = 0.6;
/* /*

View File

@@ -16,8 +16,6 @@ pub fn init_world(testbed: &mut Testbed) {
/* /*
* Ground * Ground
*/ */
let ground_width = 66.0 * extent;
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -2.0]); let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -2.0]);
let ground_handle = bodies.insert(rigid_body); let ground_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(40.0, 2.0).friction(friction); let collider = ColliderBuilder::cuboid(40.0, 2.0).friction(friction);

View File

@@ -11,12 +11,7 @@ pub fn init_world(testbed: &mut Testbed) {
let multibody_joints = MultibodyJointSet::new(); let multibody_joints = MultibodyJointSet::new();
/* /*
* Ground * Create the joint grid.
*/
let ground = bodies.insert(RigidBodyBuilder::fixed());
/*
* Create the bridge.
*/ */
let rad = 0.4; let rad = 0.4;
let numi = 100; let numi = 100;

View File

@@ -10,8 +10,6 @@ pub fn init_world(testbed: &mut Testbed) {
let impulse_joints = ImpulseJointSet::new(); let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new(); let multibody_joints = MultibodyJointSet::new();
let extent = 1.0;
/* /*
* Ground * Ground
*/ */

View File

@@ -16,9 +16,6 @@ pub fn init_world(testbed: &mut Testbed) {
/* /*
* Ground * Ground
*/ */
let ground_size = 100.1;
let ground_height = 0.1;
// let vertices = vec![ // let vertices = vec![
// point![-50.0, 0.0, -50.0], // point![-50.0, 0.0, -50.0],
// point![-50.0, 0.0, 50.0], // point![-50.0, 0.0, 50.0],

View File

@@ -21,10 +21,9 @@ pub fn do_init_world(testbed: &mut Testbed, use_convex_decomposition: bool) {
/* /*
* Ground * Ground
*/ */
let ground_size = 50.0;
let ground_height = 0.1;
//// OPTION 1: floor made of a single big box. //// OPTION 1: floor made of a single big box.
// let ground_size = 50.0;
// let ground_height = 0.1;
// let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]); // let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
// let handle = bodies.insert(rigid_body); // let handle = bodies.insert(rigid_body);
// let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size); // let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
@@ -38,7 +37,7 @@ pub fn do_init_world(testbed: &mut Testbed, use_convex_decomposition: bool) {
}); });
let heightfield = HeightField::new(heights, vector![100.0, 2.0, 100.0]); let heightfield = HeightField::new(heights, vector![100.0, 2.0, 100.0]);
let mut trimesh = TriMesh::from(heightfield); let mut trimesh = TriMesh::from(heightfield);
trimesh.set_flags(TriMeshFlags::FIX_INTERNAL_EDGES); let _ = trimesh.set_flags(TriMeshFlags::FIX_INTERNAL_EDGES);
colliders.insert(ColliderBuilder::new(SharedShape::new(trimesh.clone()))); colliders.insert(ColliderBuilder::new(SharedShape::new(trimesh.clone())));
/* /*

View File

@@ -178,10 +178,16 @@ impl IntegrationParameters {
* self.joint_damping_ratio) * self.joint_damping_ratio)
} }
/// Amount of penetration the engine wont attempt to correct (default: `0.001` multiplied by
/// [`Self::length_unit`]).
pub fn allowed_linear_error(&self) -> Real { pub fn allowed_linear_error(&self) -> Real {
self.normalized_allowed_linear_error * self.length_unit self.normalized_allowed_linear_error * self.length_unit
} }
/// Maximum amount of penetration the solver will attempt to resolve in one timestep.
///
/// This is equal to [`Self::normalized_max_penetration_correction`] multiplied by
/// [`Self::length_unit`].
pub fn max_penetration_correction(&self) -> Real { pub fn max_penetration_correction(&self) -> Real {
if self.normalized_max_penetration_correction != Real::MAX { if self.normalized_max_penetration_correction != Real::MAX {
self.normalized_max_penetration_correction * self.length_unit self.normalized_max_penetration_correction * self.length_unit
@@ -190,11 +196,13 @@ impl IntegrationParameters {
} }
} }
/// The maximal distance separating two objects that will generate predictive contacts
/// (default: `0.002m` multiped by [`Self::length_unit`]).
pub fn prediction_distance(&self) -> Real { pub fn prediction_distance(&self) -> Real {
self.normalized_prediction_distance * self.length_unit self.normalized_prediction_distance * self.length_unit
} }
/// Initialize the simulation paramaters with settings matching the TGS-soft solver /// Initialize the simulation parameters with settings matching the TGS-soft solver
/// with warmstarting. /// with warmstarting.
/// ///
/// This is the default configuration, equivalent to [`IntegrationParameters::default()`]. /// This is the default configuration, equivalent to [`IntegrationParameters::default()`].

View File

@@ -128,7 +128,7 @@ impl OneBodyConstraintBuilder {
// Normal part. // Normal part.
let normal_rhs_wo_bias; let normal_rhs_wo_bias;
{ {
let mut gcross2 = mprops2 let gcross2 = mprops2
.effective_world_inv_inertia_sqrt .effective_world_inv_inertia_sqrt
.transform_vector(dp2.gcross(-force_dir1)); .transform_vector(dp2.gcross(-force_dir1));

View File

@@ -8,7 +8,6 @@ use crate::geometry::{ContactManifold, ContactManifoldIndex};
use crate::math::{Isometry, Real, Vector, DIM, MAX_MANIFOLD_POINTS}; use crate::math::{Isometry, Real, Vector, DIM, MAX_MANIFOLD_POINTS};
use crate::utils::{self, SimdAngularInertia, SimdBasis, SimdCross, SimdDot}; use crate::utils::{self, SimdAngularInertia, SimdBasis, SimdCross, SimdDot};
use na::{DVector, Matrix2}; use na::{DVector, Matrix2};
use num::Pow;
use super::{TwoBodyConstraintElement, TwoBodyConstraintNormalPart}; use super::{TwoBodyConstraintElement, TwoBodyConstraintNormalPart};

View File

@@ -1,11 +1,9 @@
use crate::dynamics::integration_parameters::BLOCK_SOLVER_ENABLED; use crate::dynamics::integration_parameters::BLOCK_SOLVER_ENABLED;
use crate::dynamics::solver::contact_constraint::OneBodyConstraintNormalPart;
use crate::dynamics::solver::SolverVel; use crate::dynamics::solver::SolverVel;
use crate::math::{AngVector, TangentImpulse, Vector, DIM}; use crate::math::{AngVector, TangentImpulse, Vector, DIM};
use crate::utils::{SimdBasis, SimdDot, SimdRealCopy}; use crate::utils::{SimdBasis, SimdDot, SimdRealCopy};
use na::{Matrix2, Vector2}; use na::Vector2;
use num::Zero; use simba::simd::SimdValue;
use simba::simd::{SimdPartialOrd, SimdValue};
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub(crate) struct TwoBodyConstraintTangentPart<N: SimdRealCopy> { pub(crate) struct TwoBodyConstraintTangentPart<N: SimdRealCopy> {

View File

@@ -14,7 +14,6 @@ use crate::math::{
#[cfg(feature = "dim2")] #[cfg(feature = "dim2")]
use crate::utils::SimdBasis; use crate::utils::SimdBasis;
use crate::utils::{self, SimdAngularInertia, SimdCross, SimdDot}; use crate::utils::{self, SimdAngularInertia, SimdCross, SimdDot};
use na::Matrix2;
use num::Zero; use num::Zero;
use parry::math::SimdBool; use parry::math::SimdBool;
use parry::utils::SdpMatrix2; use parry::utils::SdpMatrix2;

View File

@@ -10,7 +10,6 @@ use crate::math::Real;
use crate::prelude::RigidBodyVelocity; use crate::prelude::RigidBodyVelocity;
use crate::utils::SimdAngularInertia; use crate::utils::SimdAngularInertia;
use na::DVector; use na::DVector;
use ordered_float::OrderedFloat;
pub(crate) struct VelocitySolver { pub(crate) struct VelocitySolver {
pub solver_bodies: Vec<SolverBody>, pub solver_bodies: Vec<SolverBody>,

View File

@@ -3,7 +3,7 @@ use super::{
}; };
use crate::geometry::{ use crate::geometry::{
BroadPhaseProxyIndex, Collider, ColliderBroadPhaseData, ColliderChanges, ColliderHandle, BroadPhaseProxyIndex, Collider, ColliderBroadPhaseData, ColliderChanges, ColliderHandle,
ColliderPosition, ColliderSet, ColliderShape, ColliderSet,
}; };
use crate::math::{Isometry, Real}; use crate::math::{Isometry, Real};
use crate::prelude::{BroadPhase, RigidBodySet}; use crate::prelude::{BroadPhase, RigidBodySet};
@@ -606,7 +606,7 @@ impl BroadPhase for BroadPhaseMultiSap {
prediction_distance, prediction_distance,
*handle, *handle,
&mut new_proxy_id, &mut new_proxy_id,
&co, co,
next_pos.as_ref(), next_pos.as_ref(),
) { ) {
need_region_propagation = true; need_region_propagation = true;

View File

@@ -1,5 +1,4 @@
use crate::geometry::{BroadPhasePairEvent, ColliderHandle, ColliderPair, ColliderSet}; use crate::geometry::{BroadPhasePairEvent, ColliderHandle, ColliderPair, ColliderSet};
use parry::bounding_volume::BoundingVolume;
use parry::math::Real; use parry::math::Real;
use parry::partitioning::Qbvh; use parry::partitioning::Qbvh;
use parry::partitioning::QbvhUpdateWorkspace; use parry::partitioning::QbvhUpdateWorkspace;

View File

@@ -1,9 +1,8 @@
use crate::dynamics::{RigidBodyHandle, RigidBodySet}; use crate::dynamics::{RigidBodyHandle, RigidBodySet};
use crate::geometry::{ColliderHandle, ColliderSet, Contact, ContactManifold}; use crate::geometry::{ColliderHandle, ColliderSet, Contact, ContactManifold};
use crate::math::{Point, Real, TangentImpulse, Vector, ANG_DIM}; use crate::math::{Point, Real, TangentImpulse, Vector};
use crate::pipeline::EventHandler; use crate::pipeline::EventHandler;
use crate::prelude::CollisionEventFlags; use crate::prelude::CollisionEventFlags;
use parry::math::AngVector;
use parry::query::ContactManifoldsWorkspace; use parry::query::ContactManifoldsWorkspace;
use super::CollisionEvent; use super::CollisionEvent;
@@ -304,7 +303,9 @@ pub struct SolverContact {
pub tangent_velocity: Vector<Real>, pub tangent_velocity: Vector<Real>,
/// Whether or not this contact existed during the last timestep. /// Whether or not this contact existed during the last timestep.
pub is_new: bool, pub is_new: bool,
/// Impulse used to warmstart the solve for the normal constraint.
pub warmstart_impulse: Real, pub warmstart_impulse: Real,
/// Impulse used to warmstart the solve for the friction constraints.
pub warmstart_tangent_impulse: TangentImpulse<Real>, pub warmstart_tangent_impulse: TangentImpulse<Real>,
} }

View File

@@ -166,6 +166,7 @@ pub mod math {
#[cfg(feature = "dim2")] #[cfg(feature = "dim2")]
pub type JacobianViewMut<'a, N> = na::MatrixViewMut3xX<'a, N>; pub type JacobianViewMut<'a, N> = na::MatrixViewMut3xX<'a, N>;
/// The type of impulse applied for friction constraints.
#[cfg(feature = "dim2")] #[cfg(feature = "dim2")]
pub type TangentImpulse<N> = na::Vector1<N>; pub type TangentImpulse<N> = na::Vector1<N>;
@@ -198,6 +199,7 @@ pub mod math {
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
pub type JacobianViewMut<'a, N> = na::MatrixViewMut6xX<'a, N>; pub type JacobianViewMut<'a, N> = na::MatrixViewMut6xX<'a, N>;
/// The type of impulse applied for friction constraints.
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
pub type TangentImpulse<N> = na::Vector2<N>; pub type TangentImpulse<N> = na::Vector2<N>;

View File

@@ -16,7 +16,6 @@ use parry::query::visitors::{
}; };
use parry::query::{DefaultQueryDispatcher, NonlinearRigidMotion, QueryDispatcher, TOI}; use parry::query::{DefaultQueryDispatcher, NonlinearRigidMotion, QueryDispatcher, TOI};
use parry::shape::{FeatureId, Shape, TypedSimdCompositeShape}; use parry::shape::{FeatureId, Shape, TypedSimdCompositeShape};
use parry::utils::DefaultStorage;
use std::sync::Arc; use std::sync::Arc;
/// A pipeline for performing queries on all the colliders of a scene. /// A pipeline for performing queries on all the colliders of a scene.
@@ -248,7 +247,6 @@ impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> {
type PartShape = dyn Shape; type PartShape = dyn Shape;
type PartNormalConstraints = dyn NormalConstraints; type PartNormalConstraints = dyn NormalConstraints;
type PartId = ColliderHandle; type PartId = ColliderHandle;
type QbvhStorage = DefaultStorage;
fn map_typed_part_at( fn map_typed_part_at(
&self, &self,

View File

@@ -1114,7 +1114,6 @@ fn update_testbed(
) { ) {
let meshes = &mut *meshes; let meshes = &mut *meshes;
let materials = &mut *materials; let materials = &mut *materials;
let prev_example = state.selected_example;
// Handle inputs // Handle inputs
{ {

View File

@@ -10,7 +10,6 @@ use crate::testbed::{
}; };
use crate::PhysicsState; use crate::PhysicsState;
use bevy_egui::egui::WidgetType::CollapsingHeader;
use bevy_egui::egui::{Slider, Ui}; use bevy_egui::egui::{Slider, Ui};
use bevy_egui::{egui, EguiContexts}; use bevy_egui::{egui, EguiContexts};
use rapier::dynamics::IntegrationParameters; use rapier::dynamics::IntegrationParameters;