From 6b538b5827a32fc73e90ff959aa2fd3a1f0ded8f Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 27 Jan 2014 23:42:26 -0400 Subject: [PATCH] The emission rate for ParticleSystems is no longer restricted to integer numbers. --- src/modules/graphics/opengl/ParticleSystem.cpp | 6 +++--- src/modules/graphics/opengl/ParticleSystem.h | 6 +++--- src/modules/graphics/opengl/wrap_ParticleSystem.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/graphics/opengl/ParticleSystem.cpp b/src/modules/graphics/opengl/ParticleSystem.cpp index 04bdbee87..cf613da04 100644 --- a/src/modules/graphics/opengl/ParticleSystem.cpp +++ b/src/modules/graphics/opengl/ParticleSystem.cpp @@ -432,14 +432,14 @@ ParticleSystem::InsertMode ParticleSystem::getInsertMode() const return insertMode; } -void ParticleSystem::setEmissionRate(int rate) +void ParticleSystem::setEmissionRate(float rate) { - if (rate < 0) + if (rate < 0.0f) throw love::Exception("Invalid emission rate"); emissionRate = rate; } -int ParticleSystem::getEmissionRate() const +float ParticleSystem::getEmissionRate() const { return emissionRate; } diff --git a/src/modules/graphics/opengl/ParticleSystem.h b/src/modules/graphics/opengl/ParticleSystem.h index 1314578a9..8180f52df 100644 --- a/src/modules/graphics/opengl/ParticleSystem.h +++ b/src/modules/graphics/opengl/ParticleSystem.h @@ -131,12 +131,12 @@ public: * Sets the emission rate. * @param rate The amount of particles per second. **/ - void setEmissionRate(int rate); + void setEmissionRate(float rate); /** * Returns the number of particles created per second. **/ - int getEmissionRate() const; + float getEmissionRate() const; /** * Sets the lifetime of the particle emitter (-1 means eternal) @@ -547,7 +547,7 @@ protected: uint32 activeParticles; // The emission rate (particles/sec). - int emissionRate; + float emissionRate; // Used to determine when a particle should be emitted. float emitCounter; diff --git a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp index 91517d60c..8f38aa70d 100644 --- a/src/modules/graphics/opengl/wrap_ParticleSystem.cpp +++ b/src/modules/graphics/opengl/wrap_ParticleSystem.cpp @@ -127,7 +127,7 @@ int w_ParticleSystem_getInsertMode(lua_State *L) int w_ParticleSystem_setEmissionRate(lua_State *L) { ParticleSystem *t = luax_checkparticlesystem(L, 1); - int arg1 = luaL_checkint(L, 2); + float arg1 = (float) luaL_checknumber(L, 2); EXCEPT_GUARD(t->setEmissionRate(arg1);) return 0; } @@ -135,7 +135,7 @@ int w_ParticleSystem_setEmissionRate(lua_State *L) int w_ParticleSystem_getEmissionRate(lua_State *L) { ParticleSystem *t = luax_checkparticlesystem(L, 1); - lua_pushinteger(L, t->getEmissionRate()); + lua_pushnumber(L, t->getEmissionRate()); return 1; }