I created a model of the impact of an electron beam (composed of single electrons represented by circles) on powder particles (made up of circles also). I did this based on a tutorial from the learnopengl.com website.
As you can see, single electrons in the form of circles interact with the powder particles (also in the form of circles). Everything works fine, but if I increase the number of particles, there are performance problems and the program starts to stutter.
This is because in each iteration loop the interactions between each electron and each circle forming a powder particle are checked. Below I paste a section of code where the loop calls are visible:
The question in: how can I improve the performance of the program?
Should I use CUDA and count each iteration on a different kernel? Is there a simpler solution?
Using CUDA seems difficult as the program uses object oriented programming and is quite complex.