I'm starting to work on this particle engine for Blender in Python: http://www.youtube.com/watch?v=uoK4QV3jg58&feature=channel_video_title
All data is processed by my script, Blender is just there for the visual. My problem is for now, in the video above, I calculate distance between each particle for all particles to detect if they're colliding with each other.
I'm starting to read about:
- Octree
- kdTree
- BVHTree
- AABBtree
- ...and many more
Kdtree seems to be very efficient for searching nearest neighbours but only for a static cloud. My particles always move and so must regenerate the kdTree each iteration, consuming too much process I think. I read many games use AABB tree. I'm a bit lost... I don't know what to choose. What I want is :
- Detect collision between a very large amount of particles (250 000 or more)
- No need to be realtime (anyway with 250 000 particles it's not really possible). 20min per frame for 2 million particles is not a problem for me.
- My particles are always spheres
- Detect collision between particles and polygonal objects
- Algorithm to reduce distance calculations necessary (avoiding things like calculating all particles for each other particle or polygon even when they're far away)
- My particles are dynamic and my polygon objects can be dynamic or static.
If somebody can tell me what is the best guess and where I can find Python documentation and example for it.