[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] is there a way to optimize this code?



On Mon, Aug 17, 2009 at 8:47 PM, Ian Mallett<geometrian@xxxxxxxxx> wrote:
> I just realized, solution two might actually be better.  It will start out
> much faster, and it's speed will converge to the speed of solution 1 as the
> number of particles increases.  If you really wanted to get fussy, particles
> that have hit the ground could be dropped out of the simulation--something
> that's impossible with solution one.  Also, instead of computing the ground,
> a simple array of height values could be substituted, so that each particle
> tests against that.  Of course, all this would have to be implemented
> intelligently; i.e., clever numpy tricks.
>
I think you're probably right, though I can't be sure until I see an
actual implementation.

> The most overkill solution is to use the GPU.  A simple framebuffer object
> and shader could update and draw all the particles basically instantly.

How about writing a fragment shader? I don't know whether this would
work or what performance would be like, since I don't have a lot of
experience writing shaders. In any case an FBO is probably fast enough
for whatever amount of particles you want to throw at it.

Hugo