Skip to content

Commit

Permalink
Use QueryParIter::for_each() instead for_each_mut()
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Jan 26, 2024
1 parent b9de61e commit 248ed1a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions crates/movement/src/altitude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -97,6 +98,5 @@ fn update(
if climbing.speed() != desired {
climbing.set_speed(desired);
}
},
);
});
}
2 changes: 1 addition & 1 deletion crates/movement/src/kinematics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion crates/movement/src/obstacles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn update_nearby<M: Send + Sync + 'static, T: Component>(
) {
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;
Expand Down
2 changes: 1 addition & 1 deletion crates/movement/src/pathing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions crates/movement/src/repulsion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -259,11 +259,11 @@ fn apply(
&mut DesiredVelocity<RepulsionVelocity>,
)>,
) {
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();
},
);
});
}

0 comments on commit 248ed1a

Please sign in to comment.