seperation

This commit is contained in:
Zynh Ludwig 2024-09-03 20:39:29 -07:00
parent 69ddd9c753
commit b0a1676fd2

View file

@ -83,12 +83,32 @@ fn build_local_cache(
});
}
fn seperation(
mut boids: Query<(&Transform, &LocalCache, &mut SeperationAcceleration), With<Boid>>,
fn cohesion(
mut boids: Query<(&Transform, &LocalCache, &mut CohesionAcceleration), With<Boid>>,
other_boids: Query<&Transform, With<Boid>>,
) {
}
fn cohesion(mut boids: Query<(&Transform, &LocalCache, &mut CohesionAcceleration), With<Boid>>) {}
fn seperation(
mut boids: Query<(&Transform, &LocalCache, &mut SeperationAcceleration), With<Boid>>,
other_boids: Query<&Transform, With<Boid>>,
) {
boids
.par_iter_mut()
.for_each(|(transform, local, mut accel)| {
accel.0 = Vec2::ZERO;
let mut count = 0;
for transform in other_boids.iter_many(&local.0[..]) {
accel.0 += transform.translation.xy();
count += 1;
}
accel.0 /= count as f32;
accel.0 = transform.translation.xy() - accel.0;
})
}
fn alignment(
mut boids: Query<(&Velocity, &LocalCache, &mut AlignmentAcceleration), With<Boid>>,