From 7dae80f552bb264a1e8bbd1530415cc1e822f8a5 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Tue, 12 Sep 2017 12:40:21 +0200 Subject: [PATCH] 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 --- src/modules/graphics/ParticleSystem.cpp | 19 ++--------- src/modules/graphics/ParticleSystem.h | 33 -------------------- src/modules/graphics/wrap_ParticleSystem.cpp | 9 ++---- 3 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/modules/graphics/ParticleSystem.cpp b/src/modules/graphics/ParticleSystem.cpp index b619b9341..4ad88d37a 100644 --- a/src/modules/graphics/ParticleSystem.cpp +++ b/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 diff --git a/src/modules/graphics/ParticleSystem.h b/src/modules/graphics/ParticleSystem.h index 6e9f3ec94..e2f9176b2 100644 --- a/src/modules/graphics/ParticleSystem.h +++ b/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. **/ diff --git a/src/modules/graphics/wrap_ParticleSystem.cpp b/src/modules/graphics/wrap_ParticleSystem.cpp index 8724a387d..36c049205 100644 --- a/src/modules/graphics/wrap_ParticleSystem.cpp +++ b/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; }