The separation function causes the boids to rush away from each other
when the simulation starts because they're all stacked at the origin.
Spawn them out in a ringso that this doesn't happen nearly as
aggressively.
The cohesion function was erroneously applying forces to boids that
shouldn't be experiencing them. It shouldn't be iterating over all
boids-with-velocity and adding speed. It should be applying that force
only to the one boid that the loop is examining at that iteration.
I also cleaned up the signature to have just one query struct. I had it
split as two because I was getting issues with mutability. The fix was
to make the query mutable, and then keep the Transforms as immutable
references. This way I can reach through and update the Velocity alone.
The clumping was because the function was moving the boids together,
not apart. The chaotic movement was the result of the large coefficient
on the force.
I've updated the position integration function to account for
acceleration. I need to change it once more to represent force, instead.
The idea is that the steering functions can all do their thing and apply
a force to the boid. Then, all mobs have their acceleration (forces)
integrated up through velocity and into their new position.
This version produces clumps of fast moving boids. Boids out on their
own will slowly come to a stop. I'm not sure why either of these is the
case.
I was trying to work out a way to run the loop using iterators, but
that doesn't really matter. I had an empty loop to consume the results,
which means I just have a for loop anyway.
I understand what Daniel was talking about when they referred to the
movement being very rigid.
https://github.com/danieldidiobalsamo/boids/blob/master/src/boids_plugin.rs#L289
Their implementation has a different main loop than mine so that the
acceleration can be delayed by one frame. This way things can choose
their movements without being able to observe the ones that have already
completed theirs for the current frame. I haven't done that, and things
are weird.
I'm going to try to resolve this by moving down into an acceleration
value. Apply a force, integrate at the beginning or end of the frame.
I got the cohesion function to act on the Boids, but there's something
wrong with the math. I already had to dance around the accidental
introduction of NaN's into the system.
I'm finally starting on the actual Boids flocking algorithm parts.
I don't want to iterate over all the things, and Bevy doesn't seem to
have fast collision testing yet, so I've reached for bevy_spatial to
track my Boids.
I ignored the use of sound because I don't want to download sound files.
I'm not certain that the `steppings` module is required, but I don't
really know what it does, either.