[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] particles
I'm getting the distinct impression Numeric v22 is just plain broken :(
. For instance, your "where" approach won't work (Numeric complains
about dead not having the correct dimensions (it's trying to fit 3
doubles for every item)), neither did the put calls I was originally
using (they ravel the entire matrix before operation). What's more,
every in-place multiple/add/subtract is leaking memory. Will have to
try regressing to v21.
BTW, semantics of the two aproaches are slightly different (trivially)
in that my approach "cleans up" the particles as soon as they become
dead, instead of letting them continue downward until they're re-born
(trivial in that your approach can do the same w/out significant change).
The pointer to RandomArray was definitely good. With just that change
the average frame rate for 10,000 particles goes up to ~12fps...
velocities = (RandomArray.random( (len(dead),3) ) + [-.5, 0.0,
-.5 ]) * initialVelocityVector
## velocities = array([ ((r() - .5)*2, r()*20,(r()-.5)*2) for x
in dead],'d')
Getting rid of the put/copy functions (which were added after I
discovered the weird limitations of Numeric's put) should do a lot to
speed things up as well.
Oh, and keep in mind that this is with the new OpenGLContext, currently
only available from CVS (hopefully I can do a release in the next couple
days), so getting the old one running won't likely do that much good :) .
Enjoy,
Mike
Pete Shinners wrote:
your performance seems a bit lower than i'd expect, i've got to get my
pyopengl going and play with it myself. in the meantime, the
bottleneck really looks like it's the "dead" handling section. hmmm..
pos = self.points.coord.point
clr = self.points.color.color
#random value for all particles, be sure to import RandomArray
rnd = RandomArray.random(pos.shape)
#set "dead" to be around 1/4 of all points below floor
dead = pos[:,1] <= 0.0 and rnd[:,0] <= 0.25
#move dead to emitter point and reset color
self.points.coord.point = where(dead, emitter, pos)
self.points.color.color = where(dead, initialColor, clr)
#set random velocities
newvel = rnd + (-.5, .1, -.5) * (2, 20, 2)
self.velocities = where(dead, newvel, self.velocities)
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org