Browse Source

The emission rate for ParticleSystems is no longer restricted to integer numbers.

Alex Szpakowski 11 years ago
parent
commit
6b538b5827

+ 3 - 3
src/modules/graphics/opengl/ParticleSystem.cpp

@@ -432,14 +432,14 @@ ParticleSystem::InsertMode ParticleSystem::getInsertMode() const
 	return insertMode;
 	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");
 		throw love::Exception("Invalid emission rate");
 	emissionRate = rate;
 	emissionRate = rate;
 }
 }
 
 
-int ParticleSystem::getEmissionRate() const
+float ParticleSystem::getEmissionRate() const
 {
 {
 	return emissionRate;
 	return emissionRate;
 }
 }

+ 3 - 3
src/modules/graphics/opengl/ParticleSystem.h

@@ -131,12 +131,12 @@ public:
 	 * Sets the emission rate.
 	 * Sets the emission rate.
 	 * @param rate The amount of particles per second.
 	 * @param rate The amount of particles per second.
 	 **/
 	 **/
-	void setEmissionRate(int rate);
+	void setEmissionRate(float rate);
 
 
 	/**
 	/**
 	 * Returns the number of particles created per second.
 	 * Returns the number of particles created per second.
 	 **/
 	 **/
-	int getEmissionRate() const;
+	float getEmissionRate() const;
 
 
 	/**
 	/**
 	 * Sets the lifetime of the particle emitter (-1 means eternal)
 	 * Sets the lifetime of the particle emitter (-1 means eternal)
@@ -547,7 +547,7 @@ protected:
 	uint32 activeParticles;
 	uint32 activeParticles;
 
 
 	// The emission rate (particles/sec).
 	// The emission rate (particles/sec).
-	int emissionRate;
+	float emissionRate;
 
 
 	// Used to determine when a particle should be emitted.
 	// Used to determine when a particle should be emitted.
 	float emitCounter;
 	float emitCounter;

+ 2 - 2
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)
 int w_ParticleSystem_setEmissionRate(lua_State *L)
 {
 {
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
-	int arg1 = luaL_checkint(L, 2);
+	float arg1 = (float) luaL_checknumber(L, 2);
 	EXCEPT_GUARD(t->setEmissionRate(arg1);)
 	EXCEPT_GUARD(t->setEmissionRate(arg1);)
 	return 0;
 	return 0;
 }
 }
@@ -135,7 +135,7 @@ int w_ParticleSystem_setEmissionRate(lua_State *L)
 int w_ParticleSystem_getEmissionRate(lua_State *L)
 int w_ParticleSystem_getEmissionRate(lua_State *L)
 {
 {
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
-	lua_pushinteger(L, t->getEmissionRate());
+	lua_pushnumber(L, t->getEmissionRate());
 	return 1;
 	return 1;
 }
 }