ParticleGroup Class Reference

#include <ParticleGroup.h>

List of all members.

Public Member Functions

 ParticleGroup ()
 ParticleGroup (size_t maxp)
 ParticleGroup (const ParticleGroup &rhs)
 ~ParticleGroup ()
ParticleGroupoperator= (const ParticleGroup &rhs)
size_t GetMaxParticles ()
ParticleListGetList ()
void SetBirthCallback (P_PARTICLE_CALLBACK cbb, void *cbb_data)
void SetDeathCallback (P_PARTICLE_CALLBACK cbd, void *cbd_data)
void SetMaxParticles (size_t maxp)
size_t size () const
ParticleList::iterator begin ()
ParticleList::iterator end ()
void Remove (ParticleList::iterator it)
bool Add (const pVec &pos, const pVec &posB, const pVec &up, const pVec &vel, const pVec &rvel, const pVec &size, const pVec &color, const float alpha=1.0f, const float age=0.0f, const float mass=1.0f, const long data=0)
bool Add (const Particle &P)

Private Attributes

ParticleList list
size_t max_particles
P_PARTICLE_CALLBACK cb_birth
P_PARTICLE_CALLBACK cb_death
void * cb_birth_data
void * cb_death_data


Detailed Description

Definition at line 21 of file ParticleGroup.h.


Constructor & Destructor Documentation

ParticleGroup::ParticleGroup (  )  [inline]

Definition at line 32 of file ParticleGroup.h.

References cb_birth, cb_birth_data, cb_death, cb_death_data, max_particles, and NULL.

00033     {
00034         max_particles = 0;
00035         cb_birth = NULL;
00036         cb_death = NULL;
00037         cb_birth_data = NULL;
00038         cb_death_data = NULL;
00039     }

ParticleGroup::ParticleGroup ( size_t  maxp  )  [inline]

Definition at line 41 of file ParticleGroup.h.

References cb_birth, cb_birth_data, cb_death, cb_death_data, list, max_particles, and NULL.

00041                                : max_particles(maxp)
00042     {
00043         cb_birth = NULL;
00044         cb_death = NULL;
00045         cb_birth_data = NULL;
00046         cb_death_data = NULL;
00047         list.reserve(max_particles);
00048     }

ParticleGroup::ParticleGroup ( const ParticleGroup rhs  )  [inline]

Definition at line 49 of file ParticleGroup.h.

References cb_birth, cb_birth_data, cb_death, cb_death_data, and max_particles.

00049                                             : list(rhs.list)
00050     {
00051         cb_birth = rhs.cb_birth;
00052         cb_death = rhs.cb_death;
00053         cb_birth_data = rhs.cb_birth_data;
00054         cb_death_data = rhs.cb_death_data;
00055         max_particles = rhs.max_particles;
00056     }

ParticleGroup::~ParticleGroup (  )  [inline]

Definition at line 58 of file ParticleGroup.h.

References cb_death, cb_death_data, and list.

00059     {
00060         if (cb_death) {
00061             ParticleList::iterator it;
00062             for (it = list.begin(); it != list.end(); ++it)
00063                 (*cb_death)((*it), cb_death_data);
00064         }
00065     }


Member Function Documentation

ParticleGroup& ParticleGroup::operator= ( const ParticleGroup rhs  )  [inline]

Definition at line 67 of file ParticleGroup.h.

References cb_birth, cb_birth_data, cb_death, cb_death_data, list, and max_particles.

00068     {
00069         if (this != &rhs) {
00070             if (cb_death) {
00071                 ParticleList::iterator it;
00072                 for (it = list.begin(); it != list.end(); ++it)
00073                     (*cb_death)((*it), cb_death_data);
00074             }
00075             list = rhs.list;
00076             cb_birth = rhs.cb_birth;
00077             cb_death = rhs.cb_death;
00078             cb_birth_data = rhs.cb_birth_data;
00079             cb_death_data = rhs.cb_death_data;
00080             max_particles = rhs.max_particles;
00081         }
00082         return *this;
00083     }

size_t ParticleGroup::GetMaxParticles (  )  [inline]

Definition at line 85 of file ParticleGroup.h.

References max_particles.

Referenced by pCopyGroup().

00085 { return max_particles; }

Here is the caller graph for this function:

ParticleList& ParticleGroup::GetList (  )  [inline]

Definition at line 86 of file ParticleGroup.h.

References list.

Referenced by pCopyGroup(), pGetParticles(), and pReset().

00086 { return list; }

Here is the caller graph for this function:

void ParticleGroup::SetBirthCallback ( P_PARTICLE_CALLBACK  cbb,
void *  cbb_data 
) [inline]

Definition at line 88 of file ParticleGroup.h.

References cb_birth, and cb_birth_data.

Referenced by pBirthCallback().

00089     {
00090         cb_birth = cbb;
00091         cb_birth_data = cbb_data;
00092     }

Here is the caller graph for this function:

void ParticleGroup::SetDeathCallback ( P_PARTICLE_CALLBACK  cbd,
void *  cbd_data 
) [inline]

Definition at line 94 of file ParticleGroup.h.

References cb_death, and cb_death_data.

Referenced by pDeathCallback().

00095     {
00096         cb_death = cbd;
00097         cb_death_data = cbd_data;
00098     }

Here is the caller graph for this function:

void ParticleGroup::SetMaxParticles ( size_t  maxp  )  [inline]

Definition at line 100 of file ParticleGroup.h.

References cb_death, cb_death_data, list, and max_particles.

Referenced by pSetMaxParticles().

00101     {
00102         max_particles = maxp;
00103         if(list.size() > max_particles) {
00104             if (cb_death) {
00105                 ParticleList::iterator it;
00106                 for (it = list.begin() + max_particles; it != list.end(); ++it)
00107                     (*cb_death)((*it), cb_death_data);
00108             }
00109             list.resize(max_particles);
00110         }
00111         list.reserve(max_particles);
00112     }

Here is the caller graph for this function:

size_t ParticleGroup::size (  )  const [inline]

Definition at line 114 of file ParticleGroup.h.

References list.

Referenced by pCopyGroup(), pGetParticlePointer(), and pGetParticles().

00114 { return list.size(); }

Here is the caller graph for this function:

ParticleList::iterator ParticleGroup::begin ( void   )  [inline]

Definition at line 115 of file ParticleGroup.h.

References list.

Referenced by ParticleState::ExecuteActionList(), pGetParticlePointer(), and ParticleState::SendAction().

00115 { return list.begin(); }

Here is the caller graph for this function:

ParticleList::iterator ParticleGroup::end ( void   )  [inline]

Definition at line 116 of file ParticleGroup.h.

References list.

Referenced by ParticleState::ExecuteActionList(), and ParticleState::SendAction().

00116 { return list.end(); }

Here is the caller graph for this function:

void ParticleGroup::Remove ( ParticleList::iterator  it  )  [inline]

Definition at line 118 of file ParticleGroup.h.

References cb_death, cb_death_data, and list.

00119     {
00120         if (cb_death)
00121             (*cb_death)((*it), cb_death_data);
00122 
00123         // Copy the one from the end to here.
00124         if(it != list.end() - 1) {
00125             *it = *(list.end() - 1);
00126         }
00127 
00128         // Delete the one at the end
00129         list.pop_back();
00130     }

bool ParticleGroup::Add ( const pVec pos,
const pVec posB,
const pVec up,
const pVec vel,
const pVec rvel,
const pVec size,
const pVec color,
const float  alpha = 1.0f,
const float  age = 0.0f,
const float  mass = 1.0f,
const long  data = 0 
) [inline]

Definition at line 132 of file ParticleGroup.h.

References cb_birth, cb_birth_data, list, and max_particles.

Referenced by pCopyGroup(), and pVertex().

00140     {
00141         if (list.size() >= max_particles)
00142             return false;
00143         else {
00144             list.push_back(Particle(pos, posB, up, up, vel, vel, rvel, rvel, size, color, alpha, age, mass, data, 0.0f));
00145             Particle &p = list.back();
00146             if (cb_birth)
00147                 (*cb_birth)(p, cb_birth_data);
00148             return true;
00149         }
00150     }

Here is the caller graph for this function:

bool ParticleGroup::Add ( const Particle P  )  [inline]

Definition at line 152 of file ParticleGroup.h.

References cb_birth, cb_birth_data, list, and max_particles.

00153     {
00154         if (list.size() >= max_particles)
00155             return false;
00156         else {
00157             list.push_back(P);
00158             Particle &p = list.back();
00159             if (cb_birth)
00160                 (*cb_birth)(p, cb_birth_data);
00161             return true;
00162         }
00163     }


Member Data Documentation

ParticleList ParticleGroup::list [private]

Definition at line 23 of file ParticleGroup.h.

Referenced by Add(), begin(), end(), GetList(), operator=(), ParticleGroup(), Remove(), SetMaxParticles(), size(), and ~ParticleGroup().

size_t ParticleGroup::max_particles [private]

Definition at line 25 of file ParticleGroup.h.

Referenced by Add(), GetMaxParticles(), operator=(), ParticleGroup(), and SetMaxParticles().

P_PARTICLE_CALLBACK ParticleGroup::cb_birth [private]

Definition at line 26 of file ParticleGroup.h.

Referenced by Add(), operator=(), ParticleGroup(), and SetBirthCallback().

P_PARTICLE_CALLBACK ParticleGroup::cb_death [private]

Definition at line 27 of file ParticleGroup.h.

Referenced by operator=(), ParticleGroup(), Remove(), SetDeathCallback(), SetMaxParticles(), and ~ParticleGroup().

void* ParticleGroup::cb_birth_data [private]

Definition at line 28 of file ParticleGroup.h.

Referenced by Add(), operator=(), ParticleGroup(), and SetBirthCallback().

void* ParticleGroup::cb_death_data [private]

Definition at line 29 of file ParticleGroup.h.

Referenced by operator=(), ParticleGroup(), Remove(), SetDeathCallback(), SetMaxParticles(), and ~ParticleGroup().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:51:25 2008 for Armagetron Advanced by  doxygen 1.5.4