Made the ParticleSystemUpdate::addParticleSystem, removeParticleSystem, replaceParticleSystem and setParticleSystem methods all virtual to allow them to be overriden.
This commit is contained in:
@@ -44,19 +44,19 @@ namespace osgParticle
|
||||
META_Node(osgParticle,ParticleSystemUpdater);
|
||||
|
||||
/// Add a particle system to the list.
|
||||
inline bool addParticleSystem(ParticleSystem* ps);
|
||||
virtual bool addParticleSystem(ParticleSystem* ps);
|
||||
|
||||
/// Remove a particle system from the list (by pointer).
|
||||
inline bool removeParticleSystem(ParticleSystem* ps);
|
||||
virtual bool removeParticleSystem(ParticleSystem* ps);
|
||||
|
||||
/// Remove a particle system(s) from the list (by index).
|
||||
inline bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1);
|
||||
virtual bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1);
|
||||
|
||||
/// Replace ParticleSystem with another ParticleSystem.
|
||||
inline bool replaceParticleSystem(ParticleSystem* origPS, ParticleSystem* newPS);
|
||||
virtual bool replaceParticleSystem(ParticleSystem* origPS, ParticleSystem* newPS);
|
||||
|
||||
/// set a particle system by index.
|
||||
inline bool setParticleSystem( unsigned int i, ParticleSystem* ps );
|
||||
virtual bool setParticleSystem( unsigned int i, ParticleSystem* ps );
|
||||
|
||||
/// Return the number of particle systems on the list.
|
||||
inline unsigned int getNumParticleSystems() const;
|
||||
@@ -95,59 +95,6 @@ namespace osgParticle
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline bool ParticleSystemUpdater::addParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
_psv.push_back(ps);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::removeParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
unsigned int i = getParticleSystemIndex( ps );
|
||||
if( i >= _psv.size() ) return false;
|
||||
removeParticleSystem( i );
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::removeParticleSystem(unsigned int pos, unsigned int numParticleSystemsToRemove)
|
||||
{
|
||||
if( (pos < _psv.size()) && (numParticleSystemsToRemove > 0) )
|
||||
{
|
||||
unsigned int endOfRemoveRange = pos + numParticleSystemsToRemove;
|
||||
if( endOfRemoveRange > _psv.size() )
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO)<<"Warning: ParticleSystem::removeParticleSystem(i,numParticleSystemsToRemove) has been passed an excessive number"<<std::endl;
|
||||
osg::notify(osg::DEBUG_INFO)<<" of ParticleSystems to remove, trimming just to end of ParticleSystem list."<<std::endl;
|
||||
endOfRemoveRange = _psv.size();
|
||||
}
|
||||
_psv.erase(_psv.begin()+pos, _psv.begin()+endOfRemoveRange);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::replaceParticleSystem( ParticleSystem* origPS, ParticleSystem* newPS )
|
||||
{
|
||||
if( (newPS == NULL) || (origPS == newPS) ) return false;
|
||||
|
||||
unsigned int pos = getParticleSystemIndex( origPS );
|
||||
if( pos < _psv.size() )
|
||||
{
|
||||
return setParticleSystem( pos, newPS );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::setParticleSystem( unsigned int i, ParticleSystem* ps )
|
||||
{
|
||||
if( (i < _psv.size()) && ps )
|
||||
{
|
||||
_psv[i] = ps;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline unsigned int ParticleSystemUpdater::getNumParticleSystems() const
|
||||
{
|
||||
return static_cast<int>(_psv.size());
|
||||
|
||||
@@ -66,3 +66,56 @@ osg::BoundingSphere osgParticle::ParticleSystemUpdater::computeBound() const
|
||||
return osg::BoundingSphere();
|
||||
}
|
||||
|
||||
bool osgParticle::ParticleSystemUpdater::addParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
_psv.push_back(ps);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool osgParticle::ParticleSystemUpdater::removeParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
unsigned int i = getParticleSystemIndex( ps );
|
||||
if( i >= _psv.size() ) return false;
|
||||
|
||||
removeParticleSystem( i );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool osgParticle::ParticleSystemUpdater::removeParticleSystem(unsigned int pos, unsigned int numParticleSystemsToRemove)
|
||||
{
|
||||
if( (pos < _psv.size()) && (numParticleSystemsToRemove > 0) )
|
||||
{
|
||||
unsigned int endOfRemoveRange = pos + numParticleSystemsToRemove;
|
||||
if( endOfRemoveRange > _psv.size() )
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO)<<"Warning: ParticleSystem::removeParticleSystem(i,numParticleSystemsToRemove) has been passed an excessive number"<<std::endl;
|
||||
osg::notify(osg::DEBUG_INFO)<<" of ParticleSystems to remove, trimming just to end of ParticleSystem list."<<std::endl;
|
||||
endOfRemoveRange = _psv.size();
|
||||
}
|
||||
_psv.erase(_psv.begin()+pos, _psv.begin()+endOfRemoveRange);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool osgParticle::ParticleSystemUpdater::replaceParticleSystem( ParticleSystem* origPS, ParticleSystem* newPS )
|
||||
{
|
||||
if( (newPS == NULL) || (origPS == newPS) ) return false;
|
||||
|
||||
unsigned int pos = getParticleSystemIndex( origPS );
|
||||
if( pos < _psv.size() )
|
||||
{
|
||||
return setParticleSystem( pos, newPS );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool osgParticle::ParticleSystemUpdater::setParticleSystem( unsigned int i, ParticleSystem* ps )
|
||||
{
|
||||
if( (i < _psv.size()) && ps )
|
||||
{
|
||||
_psv[i] = ps;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user