svdragster / godot-boids-acceleration-structure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boids in Godot with Acceleration Structure

This is my second attempt at boids in godot. I've implemented an acceleration structure which is a spatial partitioning scheme which optimizes the nearest neighbor lookups. All boid locations are stored in a 2D grid which represets the space. The boids query the structure to the cells in it's vacinity. The boids then filter that list based on their view range. This way the boid isn't looping over the entire list of neighbors. It's only concered with it's immedaite surroundings.

For more information on boids see Craig Reynolds Boids. A more detailed breakdown of Boids with pseudocode can be found here.

screenshot

Running the Demo

Click F5 to run the default scene

Controls:

  • left click - place a target flag
  • right click - clear flags
  • space - toggle controls UI
  • escape - exit
  • G - toggle visible grid
  • V - toggle glow effect
  • R - respawn boids
  • Q - reset simulation (factory reset the boids)

Credits

About


Languages

Language:GDScript 100.0%