So I got around to checking out your #boids project. You definitely have better performance than me from the SpatialHashSet you use.
I believe you can generalize this further for better performance by making the spatial structure recursive. Here's an example I whipped up a year or two back. Only works in 2d, but could be easily refactored to 3d as well:
https://gitlab.com/chihuamaranian/collisionlib2d
It's a #quadtree #spatialpartitioning structure.
#boids #quadtree #spatialpartitioning #gamedev #programming