Browse Source

Fix return type of ParticleSystem:getAreaSpreadIsRelativeDirection, remove optional parameters from ParticleSystem:setAreaSpread (resolves #1340)

I opted to remove the optional parameters altogether since they seemed oddly
out-of-place. They used to reset the values to defaults when not supplied, and
they also weren't returned by getAreaSpread(), so
setAreaSpread(getAreaSpread()) actually changed spread parameters.

The other option was to remove the separate getters/setters for
AreaSpreadIsRelativeDirection and AreaSpreadAngle, and fully rely on
setAreaSpread for these parameters, but the rest of the ParticleSystem API
tends to keep parameters separate.

--HG--
branch : minor
Bart van Strien 8 years ago
parent
commit
7dae80f552

+ 2 - 17
src/modules/graphics/ParticleSystem.cpp

@@ -574,21 +574,6 @@ void ParticleSystem::setAreaSpread(AreaSpreadDistribution distribution, float x,
 	areaSpreadDistribution = distribution;
 }
 
-void ParticleSystem::setAreaSpread(AreaSpreadDistribution distribution, float x, float y, float angle)
-{
-	areaSpread = love::Vector2(x, y);
-	areaSpreadDistribution = distribution;
-	areaSpreadAngle = angle;
-}
-
-void ParticleSystem::setAreaSpread(AreaSpreadDistribution distribution, float x, float y, float angle, bool isRelativeDirection)
-{
-	areaSpread = love::Vector2(x, y);
-	areaSpreadDistribution = distribution;
-	areaSpreadAngle = angle;
-	areaSpreadIsRelativeDirection = isRelativeDirection;
-}
-
 ParticleSystem::AreaSpreadDistribution ParticleSystem::getAreaSpreadDistribution() const
 {
 	return areaSpreadDistribution;
@@ -601,7 +586,7 @@ const love::Vector2 &ParticleSystem::getAreaSpreadParameters() const
 
 void ParticleSystem::setAreaSpreadAngle(float angle)
 {
-	this->areaSpreadAngle = angle;
+	areaSpreadAngle = angle;
 }
 
 float ParticleSystem::getAreaSpreadAngle() const
@@ -611,7 +596,7 @@ float ParticleSystem::getAreaSpreadAngle() const
 
 void ParticleSystem::setAreaSpreadIsRelativeDirection(bool isRelativeDirection)
 {
-	this->areaSpreadIsRelativeDirection = isRelativeDirection;
+	areaSpreadIsRelativeDirection = isRelativeDirection;
 }
 
 bool ParticleSystem::getAreaSpreadIsRelativeDirection() const

+ 0 - 33
src/modules/graphics/ParticleSystem.h

@@ -208,39 +208,6 @@ public:
 	 **/
 	void setAreaSpread(AreaSpreadDistribution distribution, float x, float y);
 
-	/**
-	 * Sets the emission area spread parameters and distribution type. The interpretation of
-	 * the parameters depends on the distribution type:
-	 *
-	 * * None: Parameters are ignored. No area spread.
-	 * * Uniform: Parameters denote maximal (symmetric) displacement from emitter position.
-	 * * Normal: Parameters denote the standard deviation in x and y direction. x and y are assumed to be uncorrelated.
-	 * * borderellipse: Parameter causes particle distribution around outside of ellipse
-	 * * borderrectangle: Parameter causes particle distribution around outside of rectangle
-	 * @param x First parameter. Interpretation depends on distribution type.
-	 * @param y Second parameter. Interpretation depends on distribution type.
-	 * @param distribution Distribution type
-	 * @param angle Angle for the distribution to be rotated by
-	 **/
-	void setAreaSpread(AreaSpreadDistribution distribution, float x, float y, float angle);
-
-	/**
-	 * Sets the emission area spread parameters and distribution type. The interpretation of
-	 * the parameters depends on the distribution type:
-	 *
-	 * * None: Parameters are ignored. No area spread.
-	 * * Uniform: Parameters denote maximal (symmetric) displacement from emitter position.
-	 * * Normal: Parameters denote the standard deviation in x and y direction. x and y are assumed to be uncorrelated.
-	 * * borderellipse: Parameter causes particle distribution around outside of ellipse
-	 * * borderrectangle: Parameter causes particle distribution around outside of rectangle
-	 * @param x First parameter. Interpretation depends on distribution type.
-	 * @param y Second parameter. Interpretation depends on distribution type.
-	 * @param distribution Distribution type
-	 * @param angle Angle for the distribution to be rotated by
-	 * @param isRelativeDirection whether to set direction of each particle to away from center
-	 **/
-	void setAreaSpread(AreaSpreadDistribution distribution, float x, float y, float angle, bool isRelativeDirection);
-
 	/**
 	 * Returns area spread distribution type.
 	 **/

+ 3 - 6
src/modules/graphics/wrap_ParticleSystem.cpp

@@ -201,8 +201,7 @@ int w_ParticleSystem_setAreaSpread(lua_State *L)
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
 
 	ParticleSystem::AreaSpreadDistribution distribution = ParticleSystem::DISTRIBUTION_NONE;
-	float x = 0.f, y = 0.f, angle = 0.f;
-	bool isRelativeDirection = false;
+	float x = 0.f, y = 0.f;
 
 	const char *str = lua_isnoneornil(L, 2) ? 0 : luaL_checkstring(L, 2);
 	if (str && !ParticleSystem::getConstant(str, distribution))
@@ -214,11 +213,9 @@ int w_ParticleSystem_setAreaSpread(lua_State *L)
 		y = (float) luaL_checknumber(L, 4);
 		if (x < 0.0f || y < 0.0f)
 			return luaL_error(L, "Invalid area spread parameters (must be >= 0)");
-		angle = (float) luaL_optnumber(L, 5, 0.0);
-		isRelativeDirection = luax_optboolean(L, 6, false);
 	}
 
-	t->setAreaSpread(distribution, x, y, angle, isRelativeDirection);
+	t->setAreaSpread(distribution, x, y);
 	return 0;
 }
 
@@ -263,7 +260,7 @@ int w_ParticleSystem_setAreaSpreadIsRelativeDirection(lua_State *L)
 int w_ParticleSystem_getAreaSpreadIsRelativeDirection(lua_State *L)
 {
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
-	lua_pushnumber(L, t->getAreaSpreadIsRelativeDirection());
+	luax_pushboolean(L, t->getAreaSpreadIsRelativeDirection());
 	return 1;
 }