diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index 08c6cb6a..e6187442 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -111,7 +111,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d //emission rate const XmlNode *emissionRateNode= particleSystemNode->getChild("emission-rate"); - emissionRate= emissionRateNode->getAttribute("value")->getIntValue(); + emissionRate= emissionRateNode->getAttribute("value")->getFloatValue(); //energy max const XmlNode *energyMaxNode= particleSystemNode->getChild("energy-max"); @@ -234,7 +234,7 @@ void ParticleSystemTypeSplash::load(const string &dir, const string &path,Render //emission rate fade const XmlNode *emissionRateFadeNode= particleSystemNode->getChild("emission-rate-fade"); - emissionRateFade= emissionRateFadeNode->getAttribute("value")->getIntValue(); + emissionRateFade= emissionRateFadeNode->getAttribute("value")->getFloatValue(); //spread values const XmlNode *verticalSpreadNode= particleSystemNode->getChild("vertical-spread"); diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index 2a2b8e2e..c03b8592 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -57,7 +57,7 @@ protected: float sizeNoEnergy; float speed; float gravity; - int emissionRate; + float emissionRate; int energyMax; int energyVar; string mode; @@ -102,7 +102,7 @@ public: SplashParticleSystem *create(); private: - int emissionRateFade; + float emissionRateFade; float verticalSpreadA; float verticalSpreadB; float horizontalSpreadA; diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index b8b83470..caa7c4aa 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -110,7 +110,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin //emission rate const XmlNode *emissionRateNode= particleSystemNode->getChild("emission-rate"); - emissionRate= emissionRateNode->getAttribute("value")->getIntValue(); + emissionRate= emissionRateNode->getAttribute("value")->getFloatValue(); //energy max const XmlNode *energyMaxNode= particleSystemNode->getChild("energy-max"); diff --git a/source/glest_game/graphics/unit_particle_type.h b/source/glest_game/graphics/unit_particle_type.h index c136e273..eedf6bd8 100644 --- a/source/glest_game/graphics/unit_particle_type.h +++ b/source/glest_game/graphics/unit_particle_type.h @@ -55,7 +55,7 @@ protected: float sizeNoEnergy; float speed; float gravity; - int emissionRate; + float emissionRate; int energyMax; int energyVar; bool relative; diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index 4cf2f557..8662ac1e 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -112,7 +112,8 @@ protected: Vec3f pos; Vec4f color; Vec4f colorNoEnergy; - int emissionRate; + float emissionRate; + float emissionState; int maxParticleEnergy; int varParticleEnergy; float particleSize; @@ -149,7 +150,7 @@ public: void setPos(Vec3f pos); void setColor(Vec4f color); void setColorNoEnergy(Vec4f color); - void setEmissionRate(int emissionRate); + void setEmissionRate(float emissionRate); void setMaxParticleEnergy(int maxParticleEnergy); void setVarParticleEnergy(int varParticleEnergy); void setParticleSize(float particleSize); @@ -397,7 +398,7 @@ public: private: ProjectileParticleSystem *prevParticleSystem; - int emissionRateFade; + float emissionRateFade; float verticalSpreadA; float verticalSpreadB; float horizontalSpreadA; @@ -411,7 +412,7 @@ public: virtual void initParticle(Particle *p, int particleIndex); virtual void updateParticle(Particle *p); - void setEmissionRateFade(int emissionRateFade) {this->emissionRateFade= emissionRateFade;} + void setEmissionRateFade(float emissionRateFade) {this->emissionRateFade= emissionRateFade;} void setVerticalSpreadA(float verticalSpreadA) {this->verticalSpreadA= verticalSpreadA;} void setVerticalSpreadB(float verticalSpreadB) {this->verticalSpreadB= verticalSpreadB;} void setHorizontalSpreadA(float horizontalSpreadA) {this->horizontalSpreadA= horizontalSpreadA;} diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 1842df61..fa2490ef 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -57,7 +57,8 @@ ParticleSystem::ParticleSystem(int particleCount) { pos= Vec3f(0.0f); color= Vec4f(1.0f); colorNoEnergy= Vec4f(0.0f); - emissionRate= 15; + emissionRate= 15.0f; + emissionState= 1.0f; speed= 1.0f; teamcolorNoEnergy=false; teamcolorEnergy=false; @@ -94,10 +95,19 @@ void ParticleSystem::update() { } if(state != ParticleSystem::sFade){ - for(int i = 0; i < emissionRate; ++i){ + emissionState=emissionState+emissionRate; + int emissionIntValue=emissionState; + for(int i = 0; i < emissionIntValue; i++){ Particle *p = createParticle(); initParticle(p, i); } + emissionState=emissionState-(float)emissionIntValue; + if(aliveParticleCount==0){ + Particle *p = createParticle(); + initParticle(p, 0); + emissionState=0; + } + } } } @@ -143,7 +153,7 @@ void ParticleSystem::setColorNoEnergy(Vec4f colorNoEnergy){ this->colorNoEnergy= colorNoEnergy; } -void ParticleSystem::setEmissionRate(int emissionRate){ +void ParticleSystem::setEmissionRate(float emissionRate){ this->emissionRate= emissionRate; } @@ -531,7 +541,7 @@ RainParticleSystem::RainParticleSystem(int particleCount):ParticleSystem(particl setWind(0.0f, 0.0f); setRadius(20.0f); - setEmissionRate(25); + setEmissionRate(25.0f); setParticleSize(3.0f); setColor(Vec4f(0.5f, 0.5f, 0.5f, 0.3f)); setSpeed(0.2f); @@ -583,7 +593,7 @@ SnowParticleSystem::SnowParticleSystem(int particleCount):ParticleSystem(particl setWind(0.0f, 0.0f); setRadius(30.0f); - setEmissionRate(2); + setEmissionRate(2.0f); setParticleSize(0.2f); setColor(Vec4f(0.8f, 0.8f, 0.8f, 0.8f)); setSpeed(0.05f); @@ -672,7 +682,7 @@ AttackParticleSystem::Primitive AttackParticleSystem::strToPrimitive(const strin // =========================================================================== ProjectileParticleSystem::ProjectileParticleSystem(int particleCount): AttackParticleSystem(particleCount){ - setEmissionRate(20); + setEmissionRate(20.0f); setColor(Vec4f(1.0f, 0.3f, 0.0f, 0.5f)); setMaxParticleEnergy(100); setVarParticleEnergy(50);