I have no knowledge of collision detection algorithms but I'm trying to play around with collision in a particle system in Python for educational purposes.
(我不了解碰撞检测算法,但出于教育目的,我正在尝试在Python的粒子系统中处理碰撞。)
The way I'm detecting collision right now seems very inefficient.
(我现在检测碰撞的方式似乎效率很低。)
Probably the slowest algorithm out there:(可能是最慢的算法:)
- Loop through all particles (which are circles defined by radius) in my particle list (via a for loop), call the current particle
p
(遍历我的粒子列表中的所有粒子(由半径定义的圆)(通过for循环),调用当前粒子
p
) - On every iteration, compare
p
to every other particle (another for loop)(在每次迭代中,将
p
与每个其他粒子进行比较(另一个用于循环)) - Detect collision
(检测碰撞)
With the method above, some of my particles aren't even detecting collisions when the particle count is high and FPS is low.
(使用上述方法,当粒子数较高而FPS较低时,我的某些粒子甚至无法检测到碰撞。)
Is there a way to prevent this in my current method or will I have to implement another, more efficient one (which is probably the way to go)?(在我目前的方法中是否有办法防止这种情况发生?还是我必须实施另一个更有效的方法(可能是这样做的方法)?)
ask by Sean Xie translate from so