From Wang Rui, reverted changes to osgPartcile that caused problems with osgparticleeffects.

This commit is contained in:
Robert Osfield
2010-09-20 11:50:24 +00:00
parent a8c8c70fb1
commit 5ecc2b9880
7 changed files with 73 additions and 70 deletions

View File

@@ -15,6 +15,7 @@ osgParticle::ParticleProcessor::ParticleProcessor()
: osg::Node(),
_rf(RELATIVE_RF),
_enabled(true),
_t0(-1),
_ps(0),
_first_ltw_compute(true),
_need_ltw_matrix(false),
@@ -35,6 +36,7 @@ osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor& copy,
: osg::Node(copy, copyop),
_rf(copy._rf),
_enabled(copy._enabled),
_t0(copy._t0),
_ps(static_cast<ParticleSystem* >(copyop(copy._ps.get()))),
_first_ltw_compute(copy._first_ltw_compute),
_need_ltw_matrix(copy._need_ltw_matrix),
@@ -77,38 +79,45 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
if ((_currentTime >= _resetTime) && (_resetTime > 0))
{
_currentTime = 0;
_t0 = -1;
}
// check whether the processor is alive
bool alive = false;
if (_currentTime >= _startTime)
// skip if we haven't initialized _t0 yet
if (_t0 != -1)
{
if (_endless || (_currentTime < (_startTime + _lifeTime)))
alive = true;
}
// update current time
_currentTime += _ps->getDeltaTime(t);
// process only if the particle system is not frozen/culled
if (alive &&
_enabled &&
!_ps->isFrozen() &&
(_ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !_ps->getFreezeOnCull()))
{
// initialize matrix flags
_need_ltw_matrix = true;
_need_wtl_matrix = true;
_current_nodevisitor = &nv;
// do some process (unimplemented in this base class)
process( _ps->getDeltaTime(t) );
} else {
//The values of _previous_wtl_matrix and _previous_ltw_matrix will be invalid
//since processing was skipped for this frame
_first_ltw_compute = true;
_first_wtl_compute = true;
// check whether the processor is alive
bool alive = false;
if (_currentTime >= _startTime)
{
if (_endless || (_currentTime < (_startTime + _lifeTime)))
alive = true;
}
// update current time
_currentTime += t - _t0;
// process only if the particle system is not frozen/culled
if (alive &&
_enabled &&
!_ps->isFrozen() &&
(_ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !_ps->getFreezeOnCull()))
{
// initialize matrix flags
_need_ltw_matrix = true;
_need_wtl_matrix = true;
_current_nodevisitor = &nv;
// do some process (unimplemented in this base class)
process( t - _t0 );
} else {
//The values of _previous_wtl_matrix and _previous_ltw_matrix will be invalid
//since processing was skipped for this frame
_first_ltw_compute = true;
_first_wtl_compute = true;
}
}
_t0 = t;
}
//added- 1/17/06- bgandere@nps.edu