Boids simulation system, implementing spatial partitioning and multithreading for trying to reach 60 FPS with 1000 boids.
- Spawn customizable boid swarms with adjustable parameters (count, radius, speed)
- Craig Reynolds three behaviors: Separation, Alignment, and Cohesion
- Field of View system - boids only react to neighbors within their view angle
- Object avoidance using golden ratio sphere distribution for ray casting
- Spatial grid partitioning (Chunks system)
- Multithreaded calculations using
ParallelForfor parallel behavior processing
- Spatial grid visualization with cell boundaries
Spawner Settings:
NumberOfBoids: Boid count to spawnSpawnRadius: Initial spawn area radiusBoidSpeed: Movement speed
Behavior Settings:
MaxSeparationDistance/SeparationStrengthMaxAlignmentDistance/AlignmentStrengthMaxCohesionDistance/CohesionStrengthViewAngle: Field of view in degrees (0-180)
Object Avoidance:
AvoidanceDistance: Ray cast distanceAvoidanceRayCount: Number of detection raysAvoidanceStrength: Avoidance force multiplier
Spatial Partitioning:
GridCellSize: Size of each grid cellWorldExtent: Total grid coverage area
In startup scene, there are 500 boids reaching 60 fps simulation.
Unfortunately, spawn 1000 boids affect performance and simulation reach env. 40 fps.