Re: [osg-users] Possible memory growth issue with sorted Particles
Hi Frank, On 2 March 2012 22:50, Frank Sullivan knarf.navil...@gmail.com wrote: The above workaround seems to work pretty well. However, it is necessary to give dead particles a depth of -FLT_MIN so that they don't get sorted behind particles that are behind the camera (and thus have negative depth). When you have a solution you are happy with could you post the full modified files to osg-submissions, thanks. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible memory growth issue with sorted Particles
Certainly! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46016#46016 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible memory growth issue with sorted Particles
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
Re: [osg-users] Possible memory growth issue with sorted Particles
Thanks Robert, It looks like, when the particles are sorted, dead particles are given a depth of 0 so that they are automatically placed at the beginning of the list. This will be useful, I think, because it looks like the purpose of the _deadparts stack is to keep track of which particles are dead, so that when the ParticleSystem wants to reuse a dead particle, it doesn't have to do a linear search through the particle list to find them. However, if I know that the dead particles (if any) are at the beginning of the list, then I can just take a look at the first item on the list. If it's dead, resurrect it. Otherwise, create a new one. So I might try subclassing ParticleSystem and overriding the CreateParticle method. In it, I'll check the sorting mode. If it's NO_SORT, then I'll use the _deadparts stack as usual. Otherwise, I'll just check the first particle in the list to see if it's dead. I won't have a chance to try this for a few hours because I have to run off to school, but I will let everyone know how it works out. Thanks again, Frank -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45987#45987 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Possible memory growth issue with sorted Particles
Hi Everybody, The above workaround seems to work pretty well. However, it is necessary to give dead particles a depth of -FLT_MIN so that they don't get sorted behind particles that are behind the camera (and thus have negative depth). Frank -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46004#46004 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Possible memory growth issue with sorted Particles
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