Hi Robert,
I tried, this variant is very good:
inline int RandomRateCounter::numParticlesToCreate(double dt) const
{
float numNewParticles = std::min(dt * getRateRange().get_random(),
getRateRange().maximum);
_np += numNewParticles;
int n = static_cast<int>(_np);
_np -= n;
return n;
}
but the string _np -= n; need replaced at _np = 0;
another long period of time will be created the maximum number of particles
...
I'll be happy if these fixes will be in the new version.
Thank you.
Maxim.
2010/9/17 Robert Osfield <[email protected]>
> Hi Maximum,
>
> On Thu, Sep 16, 2010 at 8:57 PM, Maxim Gammer <[email protected]> wrote:
> > I understand it, but I do not see a better solution. How to solve this
> > problem another way? This will require very large changes in osgpartitsle
> > .... to fix one little problem ..... and this will require a lot of time
>
> A fully robust particle system will certainly take a rewrite, so right
> now it's a case of tweaking things to make them improve things w.r.t
> what happens when the time delta is very large.
>
> > I do not know who can help me in solving this problem.
> >
> > Do you think my solution at all bad?
>
> I don't think your solution makes physical or logical sense, it's the
> randomize part that I don't believe is justifiable.
>
> > I really want to solve this problem in version 3.0 ... but not knowing
> how
> > to do it ...
>
> For a quick fix my inclination is put in a clamp of the number of
> particles produced to the maximum specified in the rate counter, this
> would related to saying the maximum time delta is 1 second. Something
> like:
>
> inline int RandomRateCounter::numParticlesToCreate(double dt) const
> {
> // clamp the time delta to 1 second or below to prevent too many
> // particles being produced all at once.
> if (dt>1.0) dt = 1.0;
>
> _np += dt * getRateRange().get_random();
> int n = static_cast<int>(_np);
> _np -= n;
> return n;
> }
>
> Or take the approach of limiting the max number to maximum number that
> could be produced in one second:
>
> inline int RandomRateCounter::numParticlesToCreate(double dt) const
> {
> float numNewParticles = std::min(dt *
> getRateRange().get_random(), getRateRange().maximum);
>
> _np += numNewParticles;
> int n = static_cast<int>(_np);
> _np -= n;
> return n;
> }
>
>
> Could you try these two approach at your end to see if they work OK?
>
> Robert.
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
--
Maxim Gammer
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org