- Add function IParticleSystemSceneNode::clearParticles

- Speedup deleting of particles


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3503 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2010-12-12 16:46:47 +00:00
parent f6c17ba8b5
commit cee8c4fbb5
4 changed files with 23 additions and 1 deletions

View File

@ -1,5 +1,9 @@
Changes in 1.8 (??.0?.2010)
- Speedup deleting of particles
- Add function IParticleSystemSceneNode::clearParticles
- Add function IGUIEnvironment::removeFont
- Functions in IMeshCache expecting IAnimatedMesh* parameters removed as similar functions with IMesh* can be used since a while. Fixes also problems when IAnimatedMesh* got upcasted to IMesh*. (thx @ Greenya for reporting)

View File

@ -64,6 +64,9 @@ public:
Default is true. */
virtual void setParticlesAreGlobal(bool global=true) = 0;
//! Remove all currently visible particles
virtual void clearParticles() = 0;
//! Gets the particle emitter, which creates the particles.
/** \return The particle emitter. Can be 0 if none is set. */
virtual IParticleEmitter* getEmitter() =0;

View File

@ -457,7 +457,14 @@ void CParticleSystemSceneNode::doParticleSystem(u32 time)
{
// erase is pretty expensive!
if (now > Particles[i].endTime)
Particles.erase(i);
{
// Particle order does not seem to matter.
// So we can delete by switching with last particle and deleting that one.
// This is a lot faster and speed is very important here as the erase otherwise
// can cause noticable freezes.
Particles[i] = Particles[Particles.size()-1];
Particles.erase( Particles.size()-1 );
}
else
{
Particles[i].pos += (Particles[i].vector * scale);
@ -491,6 +498,11 @@ void CParticleSystemSceneNode::setParticlesAreGlobal(bool global)
ParticlesAreGlobal = global;
}
//! Remove all currently visible particles
void CParticleSystemSceneNode::clearParticles()
{
Particles.set_used(0);
}
//! Sets the size of all particles.
void CParticleSystemSceneNode::setParticleSize(const core::dimension2d<f32> &size)

View File

@ -190,6 +190,9 @@ public:
//! ignore it. Default is true.
virtual void setParticlesAreGlobal(bool global=true);
//! Remove all currently visible particles
virtual void clearParticles();
//! Writes attributes of the scene node.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;