cache? acclertion 👍

This commit is contained in:
Zynh Ludwig 2024-09-02 23:48:24 -07:00
parent b2b59d68d5
commit f6feef04e5

View file

@ -20,19 +20,19 @@ struct Boid;
struct Velocity(Vec2);
#[derive(Component, Default)]
struct SeperationCache(Vec2);
struct SeperationAcceleration(Vec2);
#[derive(Component, Default)]
struct CohesionCache(Vec2);
struct CohesionAcceleration(Vec2);
#[derive(Component, Default)]
struct AlignmentCache(Vec2);
struct AlignmentAcceleration(Vec2);
#[derive(Bundle, Default)]
struct BoidCacheBundle {
s_cache: SeperationCache,
c_cache: CohesionCache,
a_cache: AlignmentCache,
struct BoidAccelerationBundle {
s_cache: SeperationAcceleration,
c_cache: CohesionAcceleration,
a_cache: AlignmentAcceleration,
}
#[derive(Bundle, Default)]
@ -40,10 +40,10 @@ struct BoidBundle {
mesh: MaterialMesh2dBundle<ColorMaterial>,
velocity: Velocity,
boid: Boid,
cache: BoidCacheBundle,
cache: BoidAccelerationBundle,
}
fn seperation(mut boids: Query<(&Transform, &mut SeperationCache), With<Boid>>) {}
fn seperation(mut boids: Query<(&Transform, &mut SeperationAcceleration), With<Boid>>) {}
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
for (mut transform, velocity) in &mut boids {