2
Hi! Neat idea, I love these kinds of toy systems. A couple of observations:
-
The boids don't really seem to be flocking - have you found parameter settings that make them do this?
-
There are a lot of degree-scaled angles here, which makes me suspicious. For example:
atan2
will never return a value over 180. -
That
sqrt
is probably unnecessary, and since it's happening for every pair of boids it's taking a lot of time. Maybe do squared distance comparisons instead? - More minor optimization notes: use
ipairs
to get indices for each boid so you can skip drawing unnecessary lines (from lower to higher only, or vice versa). Could also re-use a pair's distance computation the second time you see it, or just accumulate into both members of a pair at once. Don't build up lists of things to average later, when you can just keep a running total and a count in the loop. Declare variables aslocal
when possible.
1
It's like possessed Christmas Lights. Really beautiful and mesmerizing to watch. You have my star. It is your first surely to be of many.
[Please log in to post a comment]