parallel update
parent
f7c548074d
commit
7d5335fb2e
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue