ソースを参照

Added 'int index' member to be used for sprite rendering.

Josh Wilson 20 年 前
コミット
8c4ba1acd2

+ 8 - 0
panda/src/particlesystem/baseParticle.I

@@ -28,6 +28,10 @@ INLINE void BaseParticle::set_alive(bool alive) {
   _alive = alive;
   _alive = alive;
 }
 }
 
 
+INLINE void BaseParticle::set_index(int index) {
+  _index = index;
+}
+
 INLINE float BaseParticle::get_age() const {
 INLINE float BaseParticle::get_age() const {
   return _age;
   return _age;
 }
 }
@@ -40,6 +44,10 @@ INLINE bool BaseParticle::get_alive() const {
   return _alive;
   return _alive;
 }
 }
 
 
+INLINE int BaseParticle::get_index() const {
+  return _index;
+}
+
 INLINE float BaseParticle::get_parameterized_age() const {
 INLINE float BaseParticle::get_parameterized_age() const {
   if (_lifespan <= 0) return 1.0;
   if (_lifespan <= 0) return 1.0;
   return _age / _lifespan;
   return _age / _lifespan;

+ 8 - 6
panda/src/particlesystem/baseParticle.cxx

@@ -24,8 +24,8 @@
 // Description : Default Constructor
 // Description : Default Constructor
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 BaseParticle::
 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
 // Description : Copy Constructor
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 BaseParticle::
 BaseParticle::
-BaseParticle(const BaseParticle &copy) {
-  _age = copy._age;
-  _lifespan = copy._lifespan;
-  _alive = copy._alive;
+BaseParticle(const BaseParticle &copy) :
+  _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<<"_age "<<_age<<"\n";
   out.width(indent+2); out<<""; out<<"_lifespan "<<_lifespan<<"\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<<"_alive "<<_alive<<"\n";
+  out.width(indent+2); out<<""; out<<"_index "<<_index<<"\n";
   out.width(indent+2); out<<""; out<<"_last_position "<<_last_position<<"\n";
   out.width(indent+2); out<<""; out<<"_last_position "<<_last_position<<"\n";
   PhysicsObject::write(out, indent+2);
   PhysicsObject::write(out, indent+2);
   #endif //] NDEBUG
   #endif //] NDEBUG

+ 5 - 1
panda/src/particlesystem/baseParticle.h

@@ -33,10 +33,13 @@ public:
   INLINE void set_age(float age);
   INLINE void set_age(float age);
   INLINE void set_lifespan(float lifespan);
   INLINE void set_lifespan(float lifespan);
   INLINE void set_alive(bool alive);
   INLINE void set_alive(bool alive);
+  INLINE void set_index(int index);
+
 
 
   INLINE float get_age() const;
   INLINE float get_age() const;
   INLINE float get_lifespan() const;
   INLINE float get_lifespan() const;
   INLINE bool get_alive() const;
   INLINE bool get_alive() const;
+  INLINE int get_index() const; 
 
 
   INLINE float get_parameterized_age() const;
   INLINE float get_parameterized_age() const;
   INLINE float get_parameterized_vel() const;
   INLINE float get_parameterized_vel() const;
@@ -56,7 +59,7 @@ public:
   virtual void write(ostream &out, int indent=0) const;
   virtual void write(ostream &out, int indent=0) const;
 
 
 protected:
 protected:
-  BaseParticle(int lifespan = 1, bool alive = false);
+  BaseParticle(float lifespan = 1.0f, bool alive = false);
   BaseParticle(const BaseParticle &copy);
   BaseParticle(const BaseParticle &copy);
   virtual ~BaseParticle();
   virtual ~BaseParticle();
 
 
@@ -65,6 +68,7 @@ private:
   float _age;
   float _age;
   float _lifespan;
   float _lifespan;
   bool _alive;
   bool _alive;
+  int _index;
 
 
   LPoint3f _last_position;
   LPoint3f _last_position;
 };
 };