parallel update

main
Zynh Ludwig 2024-09-03 01:25:23 -07:00
parent f7c548074d
commit 7d5335fb2e
1 changed files with 2 additions and 2 deletions

View File

@ -61,11 +61,11 @@ fn cohesion(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration),
fn alignment(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration), With<Boid>>) {} fn alignment(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration), With<Boid>>) {}
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) { fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
for (mut transform, velocity) in &mut boids { boids.par_iter_mut().for_each(|(mut transform, velocity)| {
transform.translation += velocity.0.extend(0.) * time.delta_seconds(); transform.translation += velocity.0.extend(0.) * time.delta_seconds();
transform.rotation = transform.rotation =
Quat::from_rotation_z(velocity.0.to_angle() - std::f32::consts::FRAC_PI_2); Quat::from_rotation_z(velocity.0.to_angle() - std::f32::consts::FRAC_PI_2);
} });
} }
fn setup( fn setup(