Moved osgParticle across to standard OSG coding style.
This commit is contained in:
@@ -13,49 +13,49 @@ using namespace osg;
|
||||
|
||||
osgParticle::ParticleProcessor::ParticleProcessor()
|
||||
: osg::Node(),
|
||||
rf_(RELATIVE_RF),
|
||||
enabled_(true),
|
||||
t0_(-1),
|
||||
ps_(0),
|
||||
need_ltw_matrix_(false),
|
||||
need_wtl_matrix_(false),
|
||||
current_nodevisitor_(0),
|
||||
endless_(true),
|
||||
lifeTime_(0.0),
|
||||
startTime_(0.0),
|
||||
currentTime_(0.0),
|
||||
resetTime_(0.0)
|
||||
_rf(RELATIVE_RF),
|
||||
_enabled(true),
|
||||
_t0(-1),
|
||||
_ps(0),
|
||||
_need_ltw_matrix(false),
|
||||
_need_wtl_matrix(false),
|
||||
_current_nodevisitor(0),
|
||||
_endless(true),
|
||||
_lifeTime(0.0),
|
||||
_startTime(0.0),
|
||||
_currentTime(0.0),
|
||||
_resetTime(0.0)
|
||||
{
|
||||
setCullingActive(false);
|
||||
}
|
||||
|
||||
osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor ©, const osg::CopyOp ©op)
|
||||
osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor& copy, const osg::CopyOp& copyop)
|
||||
: osg::Node(copy, copyop),
|
||||
rf_(copy.rf_),
|
||||
enabled_(copy.enabled_),
|
||||
t0_(copy.t0_),
|
||||
ps_(static_cast<ParticleSystem *>(copyop(copy.ps_.get()))),
|
||||
need_ltw_matrix_(copy.need_ltw_matrix_),
|
||||
need_wtl_matrix_(copy.need_wtl_matrix_),
|
||||
current_nodevisitor_(0),
|
||||
endless_(copy.endless_),
|
||||
lifeTime_(copy.lifeTime_),
|
||||
startTime_(copy.startTime_),
|
||||
currentTime_(copy.currentTime_),
|
||||
resetTime_(copy.resetTime_)
|
||||
_rf(copy._rf),
|
||||
_enabled(copy._enabled),
|
||||
_t0(copy._t0),
|
||||
_ps(static_cast<ParticleSystem* >(copyop(copy._ps.get()))),
|
||||
_need_ltw_matrix(copy._need_ltw_matrix),
|
||||
_need_wtl_matrix(copy._need_wtl_matrix),
|
||||
_current_nodevisitor(0),
|
||||
_endless(copy._endless),
|
||||
_lifeTime(copy._lifeTime),
|
||||
_startTime(copy._startTime),
|
||||
_currentTime(copy._currentTime),
|
||||
_resetTime(copy._resetTime)
|
||||
{
|
||||
}
|
||||
|
||||
void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv)
|
||||
void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
// typecast the NodeVisitor to CullVisitor
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
|
||||
// continue only if the visitor actually is a cull visitor
|
||||
if (cv) {
|
||||
|
||||
// continue only if the particle system is valid
|
||||
if (ps_.valid())
|
||||
if (_ps.valid())
|
||||
{
|
||||
|
||||
if (nv.getFrameStamp())
|
||||
@@ -65,42 +65,45 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv)
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
|
||||
// reset this processor if we've reached the reset point
|
||||
if ((currentTime_ >= resetTime_) && (resetTime_ > 0)) {
|
||||
currentTime_ = 0;
|
||||
t0_ = -1;
|
||||
if ((_currentTime >= _resetTime) && (_resetTime > 0))
|
||||
{
|
||||
_currentTime = 0;
|
||||
_t0 = -1;
|
||||
}
|
||||
|
||||
// skip if we haven't initialized t0_ yet
|
||||
if (t0_ != -1) {
|
||||
// skip if we haven't initialized _t0 yet
|
||||
if (_t0 != -1)
|
||||
{
|
||||
|
||||
// check whether the processor is alive
|
||||
bool alive = false;
|
||||
if (currentTime_ >= startTime_) {
|
||||
if (endless_ || (currentTime_ < (startTime_ + lifeTime_)))
|
||||
if (_currentTime >= _startTime)
|
||||
{
|
||||
if (_endless || (_currentTime < (_startTime + _lifeTime)))
|
||||
alive = true;
|
||||
}
|
||||
|
||||
// update current time
|
||||
currentTime_ += t - t0_;
|
||||
_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())) {
|
||||
|
||||
_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;
|
||||
_need_ltw_matrix = true;
|
||||
_need_wtl_matrix = true;
|
||||
_current_nodevisitor = &nv;
|
||||
|
||||
// do some process (unimplemented in this base class)
|
||||
process(t - t0_);
|
||||
process(t - _t0);
|
||||
}
|
||||
}
|
||||
|
||||
// update t0_
|
||||
t0_ = t;
|
||||
// update _t0
|
||||
_t0 = t;
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user