diff --git a/panda/src/particlesystem/baseParticle.I b/panda/src/particlesystem/baseParticle.I index 76d0cf23b6..57abf38584 100644 --- a/panda/src/particlesystem/baseParticle.I +++ b/panda/src/particlesystem/baseParticle.I @@ -28,6 +28,10 @@ INLINE void BaseParticle::set_alive(bool alive) { _alive = alive; } +INLINE void BaseParticle::set_index(int index) { + _index = index; +} + INLINE float BaseParticle::get_age() const { return _age; } @@ -40,6 +44,10 @@ INLINE bool BaseParticle::get_alive() const { return _alive; } +INLINE int BaseParticle::get_index() const { + return _index; +} + INLINE float BaseParticle::get_parameterized_age() const { if (_lifespan <= 0) return 1.0; return _age / _lifespan; diff --git a/panda/src/particlesystem/baseParticle.cxx b/panda/src/particlesystem/baseParticle.cxx index a09d4de853..7f92daab4f 100644 --- a/panda/src/particlesystem/baseParticle.cxx +++ b/panda/src/particlesystem/baseParticle.cxx @@ -24,8 +24,8 @@ // Description : Default Constructor //////////////////////////////////////////////////////////////////// BaseParticle:: -BaseParticle(int lifespan, bool alive) : - _age(0.0f), _lifespan(lifespan), _alive(alive) { +BaseParticle(float lifespan, bool alive) : + _age(0.0f), _lifespan(lifespan), _alive(alive), _index(0){ } //////////////////////////////////////////////////////////////////// @@ -34,10 +34,11 @@ BaseParticle(int lifespan, bool alive) : // Description : Copy Constructor //////////////////////////////////////////////////////////////////// BaseParticle:: -BaseParticle(const BaseParticle ©) { - _age = copy._age; - _lifespan = copy._lifespan; - _alive = copy._alive; +BaseParticle(const BaseParticle ©) : + _age(copy._age), + _lifespan(copy._lifespan), + _alive(copy._alive), + _index(copy._index) { } //////////////////////////////////////////////////////////////////// @@ -85,6 +86,7 @@ write(ostream &out, int indent) const { out.width(indent+2); out<<""; out<<"_age "<<_age<<"\n"; out.width(indent+2); out<<""; out<<"_lifespan "<<_lifespan<<"\n"; out.width(indent+2); out<<""; out<<"_alive "<<_alive<<"\n"; + out.width(indent+2); out<<""; out<<"_index "<<_index<<"\n"; out.width(indent+2); out<<""; out<<"_last_position "<<_last_position<<"\n"; PhysicsObject::write(out, indent+2); #endif //] NDEBUG diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index 071323c94c..d2be48b8e8 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -33,10 +33,13 @@ public: INLINE void set_age(float age); INLINE void set_lifespan(float lifespan); INLINE void set_alive(bool alive); + INLINE void set_index(int index); + INLINE float get_age() const; INLINE float get_lifespan() const; INLINE bool get_alive() const; + INLINE int get_index() const; INLINE float get_parameterized_age() const; INLINE float get_parameterized_vel() const; @@ -56,7 +59,7 @@ public: virtual void write(ostream &out, int indent=0) const; protected: - BaseParticle(int lifespan = 1, bool alive = false); + BaseParticle(float lifespan = 1.0f, bool alive = false); BaseParticle(const BaseParticle ©); virtual ~BaseParticle(); @@ -65,6 +68,7 @@ private: float _age; float _lifespan; bool _alive; + int _index; LPoint3f _last_position; };