diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..4c8d0e1 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,4 @@ +imports_granularity = "Crate" +group_imports = "StdExternalCrate" +wrap_comments = true +edition = "2021" diff --git a/assets/models/toid.glb b/assets/models/toid.glb new file mode 100644 index 0000000..e879db6 Binary files /dev/null and b/assets/models/toid.glb differ diff --git a/src/lib.rs b/src/lib.rs index ce122b1..dd7d699 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,15 +8,15 @@ use bevy_spatial::{kdtree::KDTree3, SpatialAccess}; pub type NNTree = KDTree3; // toid stuff -const SPEED: f32 = 5.0; +const SPEED: f32 = 2.0; const SPEED_DIFF_RANGE: f32 = 0.1; // +/- 10% const MAX_DELTA_V: f32 = std::f32::consts::PI * 2.0; // basically 360 degrees/sec // how far from origin before really wanting to come back -const RADIUS: f32 = 50.0; +const RADIUS: f32 = 40.0; // how close to try to stay to your buddies -const BUDDY_RADIUS: f32 = 30.0; +const BUDDY_RADIUS: f32 = 10.0; const MIN_ALTITUDE: f32 = 3.5; @@ -43,6 +43,9 @@ pub struct Toid { pub buddies: usize, } +#[derive(Debug, Default, Clone, Copy, Deref, DerefMut, Resource)] +pub struct LookAt(Vec3); + pub fn turkey_time( commands: &mut Commands, scene: &Handle, @@ -67,10 +70,11 @@ pub fn turkey_time( scene: scene.to_owned(), ..Default::default() }) - .insert(Transform::from_rotation(Quat::from_axis_angle( - Vec3::Y, - -std::f32::consts::FRAC_PI_2, - ))); + .insert(Transform::default()); + // .insert(Transform::from_rotation(Quat::from_axis_angle( + // Vec3::Y, + // -std::f32::consts::FRAC_PI_2, + // ))); }) .id() } @@ -101,7 +105,7 @@ pub fn update_vel( } // avoid flying into neighbors - let min_dist = speed / 2.0; + let min_dist = speed; for neighbor in index .within_distance(pos, min_dist) .iter() @@ -151,15 +155,19 @@ pub fn update_vel( pub fn update_pos( mut toids: Query<(&mut Transform, &Velocity, Entity), With>, mut positions: ResMut, + mut lookat: ResMut, time: Res