Hi Frank,

I haven't used the sort feature personally and would suspect not many
others have as well as I'm sure they'd have spotted the same problem
as you.  I must admit that all the recent particle work I've done has
been with shaders rather than the CPU based particle systems that the
bulk of osgParticle deals with, in the longer term I'd like to replace
the osgParticle code base with a shader based approach.

Short term fixing the problem you have in front of you is what will be
required.  I haven't looked into the problem yet but off the top of my
head I would wonder if perhaps the sort could take whether the
particle is dead when taking it into account, or have the dead
particle tracking updated.

Robert.

On 2 March 2012 02:18, Frank Sullivan <knarf.navil...@gmail.com> wrote:
> Greetings,
>
> I am having some difficulty with the osgParticle classes, and I was wondering 
> if someone could give me some advice.
>
> It seems that whenever I choose a sorting mode for the particles other than 
> NO_SORT, I get a particle list that grows unbounded. In a normal situation, 
> the particle list should grow at first, and then stabilize as dead particles 
> get reused. So, for example, if I set the particle effect to emit at a rate 
> of 100 particles per second, and I give the particles a lifetime at 1 second, 
> then over the course of the first second, I should see the particle list grow 
> from 0 to 100. At that point, particles should start dying at about the same 
> rate as they are being created, and so the list should stabilize at 100-105 
> (allowing some buffer because the world isn't perfect).
>
> And indeed, this is exactly what I see when the particles aren't sorted (I 
> created a DebugParticleSystem subclass that prints out the particle list 
> counts, and other info, each frame).
>
> However, when I set the sorting mode to SORT_FRONT_TO_BACK, then I get this 
> weird behavior where the particle list grows and grows and grows and never 
> stabilizes.
>
> Looking at the code, I think I have a hypothesis, but it isn't complete. 
> Basically, after the particle list is updated, the list then gets sorted. 
> This is an in-place sort on a vector of Particle objects, which has the 
> effect (from what I can see) of invalidating the pointers in the _deadParts 
> stack. So, the pointers in the _deadParts stack end up pointing to particles 
> that are still living, and when a pointer from this stack is used to reuse a 
> dead particle, it ends up reusing a particle that is already alive.
>
> Now, I'm not exactly sure how this results in a growing particle stack, but 
> my guess is that, in reusing a particle that is already alive, you prevent it 
> from dying on schedule, and so when it comes time to create a new particle, 
> there aren't enough dead ones on the stack to reuse, and so new particles 
> have to be created from scratch.
>
> The only thing that gives me pause about this explanation is that, after a 
> Google search, I was not able to find anyone else who is having this same 
> problem. So, I am pretty sure that I'm doing something wrong here, but I'm 
> not sure what.
>
> Thank you!
>
> Cheers,
> Frank
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=45953#45953
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to