Autoformat

This commit is contained in:
2025-09-03 14:27:28 -05:00
parent f2a71e712a
commit ccd8a12b79
2 changed files with 7 additions and 11 deletions

View File

@@ -2,10 +2,10 @@ pub mod physics;
use bevy::prelude::*; use bevy::prelude::*;
use bevy_spatial::{ use bevy_spatial::{
kdtree::KDTree2, AutomaticUpdate, SpatialAccess, SpatialStructure, TransformMode, AutomaticUpdate, SpatialAccess, SpatialStructure, TransformMode, kdtree::KDTree2,
}; };
use crate::birdoids::physics::{apply_velocity, Force, Velocity}; use crate::birdoids::physics::{Force, Velocity, apply_velocity};
const BACKGROUND_COLOR: Color = Color::srgb(0.4, 0.4, 0.4); const BACKGROUND_COLOR: Color = Color::srgb(0.4, 0.4, 0.4);
const PLAYERBOID_COLOR: Color = Color::srgb(1.0, 0.0, 0.0); const PLAYERBOID_COLOR: Color = Color::srgb(1.0, 0.0, 0.0);
@@ -171,11 +171,7 @@ fn cohesion(
// Skip self-comparison. A boid should not try to separate from itself. // Skip self-comparison. A boid should not try to separate from itself.
let entt = entt let entt = entt
.expect("within_distance gave me an entity... with no entity ID... somehow"); .expect("within_distance gave me an entity... with no entity ID... somehow");
if this_entt == entt { if this_entt == entt { None } else { Some(pos) }
None
} else {
Some(pos)
}
}) })
.enumerate() .enumerate()
.fold((0, Vec2::ZERO), |(_len, com), (idx, pos)| (idx, com + pos)); .fold((0, Vec2::ZERO), |(_len, com), (idx, pos)| (idx, com + pos));
@@ -248,7 +244,7 @@ fn alignment(
if this_entt == entt { if this_entt == entt {
None None
} else { } else {
let vel = boid_velocities.get(entt).expect("Boid has no velocity!"); let vel = boid_velocities.get(entt).expect("Boid has no velocity!");
Some(vel.xy()) Some(vel.xy())
} }
}) })
@@ -333,7 +329,7 @@ mod tests {
use crate::birdoids::{cohesive_force, separation_force}; use crate::birdoids::{cohesive_force, separation_force};
use super::{physics::Force, BOID_VIEW_RANGE}; use super::{BOID_VIEW_RANGE, physics::Force};
// forces are relative to the boid's view range, so all // forces are relative to the boid's view range, so all
// distances need to be fractions of that // distances need to be fractions of that

View File

@@ -1,8 +1,8 @@
use bevy::{prelude::*, window::PrimaryWindow}; use bevy::{prelude::*, window::PrimaryWindow};
use bevy_spatial::{kdtree::KDTree2, SpatialAccess}; use bevy_spatial::{SpatialAccess, kdtree::KDTree2};
use crate::birdoids::{ use crate::birdoids::{
center_of_boids, physics::Force, physics::Velocity, velocity_of_boids, Boid, TrackedByKdTree, Boid, TrackedByKdTree, center_of_boids, physics::Force, physics::Velocity, velocity_of_boids,
}; };
const SCANRADIUS: f32 = 50.0; const SCANRADIUS: f32 = 50.0;