From 248ed1a7998913b8c31bf46edd8e7b2fc39e3943 Mon Sep 17 00:00:00 2001 From: Martin Indra Date: Fri, 26 Jan 2024 13:07:04 +0100 Subject: [PATCH] Use QueryParIter::for_each() instead for_each_mut() --- crates/movement/src/altitude.rs | 8 ++++---- crates/movement/src/kinematics.rs | 2 +- crates/movement/src/obstacles.rs | 2 +- crates/movement/src/pathing.rs | 2 +- crates/movement/src/repulsion.rs | 14 +++++++------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/movement/src/altitude.rs b/crates/movement/src/altitude.rs index cd4001672..7d92b4cd7 100644 --- a/crates/movement/src/altitude.rs +++ b/crates/movement/src/altitude.rs @@ -67,8 +67,9 @@ fn update( &Transform, )>, ) { - objects.par_iter_mut().for_each_mut( - |(object_type, mut horizontal, mut climbing, transform)| { + objects + .par_iter_mut() + .for_each(|(object_type, mut horizontal, mut climbing, transform)| { let Some(flight) = solids.get(**object_type).flight() else { return; }; @@ -97,6 +98,5 @@ fn update( if climbing.speed() != desired { climbing.set_speed(desired); } - }, - ); + }); } diff --git a/crates/movement/src/kinematics.rs b/crates/movement/src/kinematics.rs index b9f1fcf04..cb6d85906 100644 --- a/crates/movement/src/kinematics.rs +++ b/crates/movement/src/kinematics.rs @@ -117,7 +117,7 @@ fn kinematics( objects .par_iter_mut() - .for_each_mut(|(movement, climbing, mut kinematics, mut velocity)| { + .for_each(|(movement, climbing, mut kinematics, mut velocity)| { let desired_h_velocity = movement.velocity(); let desired_heading = if desired_h_velocity == Vec2::ZERO { kinematics.heading() diff --git a/crates/movement/src/obstacles.rs b/crates/movement/src/obstacles.rs index 357ac70a6..fbfd37fe8 100644 --- a/crates/movement/src/obstacles.rs +++ b/crates/movement/src/obstacles.rs @@ -76,7 +76,7 @@ fn update_nearby( ) { objects .par_iter_mut() - .for_each_mut(|(entity, transform, mut cache)| { + .for_each(|(entity, transform, mut cache)| { cache.clear(); let half_extent = Vec3::splat(NEARBY_HALF_EXTENT); let mins = transform.translation - half_extent; diff --git a/crates/movement/src/pathing.rs b/crates/movement/src/pathing.rs index 328e697af..275c6ddf4 100644 --- a/crates/movement/src/pathing.rs +++ b/crates/movement/src/pathing.rs @@ -68,7 +68,7 @@ fn follow_path( ) { objects .par_iter_mut() - .for_each_mut(|(transform, mut path, mut movement)| { + .for_each(|(transform, mut path, mut movement)| { let location = transform.translation.to_flat(); let remaining = path.destination().distance(location); let advancement = path.advance(location, MAX_H_SPEED * 0.5); diff --git a/crates/movement/src/repulsion.rs b/crates/movement/src/repulsion.rs index 69e3c053e..fe3ecdf5b 100644 --- a/crates/movement/src/repulsion.rs +++ b/crates/movement/src/repulsion.rs @@ -159,7 +159,7 @@ fn repel_static( ) { objects .par_iter_mut() - .for_each_mut(|(movement, disc, static_obstacles, mut repulsion)| { + .for_each(|(movement, disc, static_obstacles, mut repulsion)| { if movement.stationary() { return; } @@ -204,7 +204,7 @@ fn repel_movable( ) { objects .par_iter_mut() - .for_each_mut(|(movement, disc, movable_obstacles, mut repulsion)| { + .for_each(|(movement, disc, movable_obstacles, mut repulsion)| { if movement.stationary() { return; } @@ -232,7 +232,7 @@ fn repel_bounds( ) { objects .par_iter_mut() - .for_each_mut(|(movement, disc, mut repulsion)| { + .for_each(|(movement, disc, mut repulsion)| { if movement.stationary() { return; } @@ -259,11 +259,11 @@ fn apply( &mut DesiredVelocity, )>, ) { - objects.par_iter_mut().for_each_mut( - |(mut repulsion, path_velocity, mut repulsion_velocity)| { + objects + .par_iter_mut() + .for_each(|(mut repulsion, path_velocity, mut repulsion_velocity)| { let velocity = repulsion.apply(path_velocity.velocity()); repulsion_velocity.update(velocity.clamp_length_max(MAX_H_SPEED)); repulsion.clear(); - }, - ); + }); }