Skip to content

Idea for a speedup - are there any issues with this? #3

@Jack-Rickwood

Description

@Jack-Rickwood

So, this lags pretty badly on my computer when you make the world size much larger than 300x300, no matter how many particles there are. I think this is just because of the sheer number of cells it needs to loop through.

So i'm wondering, is there any reason you loop through every single cell? Seems super unnecessary, why not just loop through all the cells with particles in them? The way I would implement this is by having a vector in the PhysicsSolver class, to store all the cells with particles in them. This vector would get cleared at the beginning of each loop, and then in the method to add the particles to the grid, you could just push the index of the current particle in the grid to the back of this vector.

I guess there may be some issues with threading, but my approach is to 'pad' the vector of active cells until it's a multiple of the thread count.

So, is there any issue with doing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions