Quote:Original post by pinknation
it shouldn't matter if I swept through cells, or particles.. because either way I'd loop through each particle, adding the cell loop, would simply add an extra loop.
Yes, it matters a lot...even more if at each step, you compute the neighbours of every particle. So if you have one thousand particles, for each step( time step ), you, at least, allocate( and deallocate ) one thousand lists of neighbours. This is very costly.
The point was: you don't need computing neighbouring information, since you already have it. Avoiding computing redundant information, is an optimization.
I was not recommending you to add another loop to an existing one, I was simply recommending you to write a faster loop.
You don't need doing things particle-wise, because if A collides with B, then B collides with A: so computing forces, impulses or any other things to maintain your simulation in a coherent state, can be done for each couple of interacting particles, instead of doing it twice, as if the two interacting particles were not affected by the same event.
P.S: I noticed you were computing for every two possible interacting objects, their force of interaction. You should test first if they can possibly interact, and then only compute their force of interaction.
Quote:
Edit: Would AABB method of collision detection be better? Currently I am using a Spatial Index Grid.. which I've seen used in SPH systems.
I don't know if I perfectly understood your question...Your spatial index grid algorithm is a recommended one, and basically does not depend on the bounding volume you use to detect collisions.
You'll still need it( or any other possible divide and conqueer method ) no matter the bounding volume you use.
As you may know, detecting collisions between two spheres( as your collision test shows ) is faster than detecting collision between two AABBs. The only problem is that spheres give many false positives, in general. AABBs are generally better: it depends of the simulation. But if your particles are particles in the most common acception, then there's no need of using bouding volumes.
[edit]Sorry, I didn't see your post...