diff options
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/defaults.cpp | 4 | ||||
-rw-r--r-- | src/enums/particle/particlephysics.h | 34 | ||||
-rw-r--r-- | src/particle/particle.cpp | 5 | ||||
-rw-r--r-- | src/particle/particleengine.cpp | 6 | ||||
-rw-r--r-- | src/particle/particleengine.h | 4 |
7 files changed, 49 insertions, 6 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51ce6b1df..a9215a1a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1249,6 +1249,7 @@ SET(SRCS render/rendererslistsdl2.h enums/particle/alivestatus.h enums/particle/particlechangefunc.h + enums/particle/particlephysics.h enums/particle/particletype.h enums/render/rendertype.h particle/particle.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b925110f2..1dc393a80 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -762,6 +762,7 @@ BASE_SRC += events/actionevent.h \ render/rendererslistsdl2.h \ enums/particle/alivestatus.h \ enums/particle/particlechangefunc.h \ + enums/particle/particlephysics.h \ enums/particle/particletype.h \ enums/render/blitmode.h \ enums/render/rendertype.h \ diff --git a/src/defaults.cpp b/src/defaults.cpp index 8cdc6bf78..03e78bacb 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -36,6 +36,8 @@ #include "enums/input/inputaction.h" +#include "enums/particle/particlephysics.h" + #include "render/graphics.h" #include "const/net/net.h" @@ -120,7 +122,7 @@ DefaultsData* getConfigDefaults() AddDEF("afkMessage", "I am away from keyboard."); AddDEF("afkFormat", 0); AddDEF("particleMaxCount", 3000); - AddDEF("particleFastPhysics", 1); + AddDEF("particleFastPhysics", CAST_S32(ParticlePhysics::Normal)); AddDEF("particleEmitterSkip", 1); AddDEF("particleeffects", true); AddDEF("mapparticleeffects", true); diff --git a/src/enums/particle/particlephysics.h b/src/enums/particle/particlephysics.h new file mode 100644 index 000000000..55eb43d69 --- /dev/null +++ b/src/enums/particle/particlephysics.h @@ -0,0 +1,34 @@ +/* + * The ManaPlus Client + * Copyright (C) 2016-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_PARTICLE_PARTICLEPHYSICS_H +#define ENUMS_PARTICLE_PARTICLEPHYSICS_H + +#include "enums/simpletypes/enumdefines.h" + +enumStart(ParticlePhysics) +{ + Best = 0, + Normal = 1, + Fast = 2, +} +enumEnd(ParticlePhysics); + +#endif // ENUMS_PARTICLE_PARTICLEPHYSICS_H diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 3019aeda0..40b1b7a5a 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -140,11 +140,11 @@ void Particle::updateSelf() restrict2 switch (ParticleEngine::fastPhysics) { - case 1: + case ParticlePhysics::Normal: invHypotenuse = fastInvSqrt( dist.x * dist.x + dist.y * dist.y + dist.z * dist.z); break; - case 2: + case ParticlePhysics::Fast: if (dist.x == 0.0f) { invHypotenuse = 0; @@ -155,6 +155,7 @@ void Particle::updateSelf() restrict2 + static_cast<float>(fabs(dist.y)) + static_cast<float>(fabs(dist.z))); break; + case ParticlePhysics::Best: default: invHypotenuse = 1.0F / static_cast<float>(sqrt( dist.x * dist.x + dist.y * dist.y + dist.z * dist.z)); diff --git a/src/particle/particleengine.cpp b/src/particle/particleengine.cpp index 02e21e0bc..b54e36d27 100644 --- a/src/particle/particleengine.cpp +++ b/src/particle/particleengine.cpp @@ -44,7 +44,7 @@ class Image; int ParticleEngine::particleCount = 0; int ParticleEngine::maxCount = 0; -int ParticleEngine::fastPhysics = 0; +ParticlePhysicsT ParticleEngine::fastPhysics = ParticlePhysics::Best; int ParticleEngine::emitterSkip = 1; bool ParticleEngine::enabled = true; const float ParticleEngine::PARTICLE_SKY = 800.0F; @@ -67,7 +67,9 @@ ParticleEngine::~ParticleEngine() void ParticleEngine::setupEngine() restrict2 { ParticleEngine::maxCount = config.getIntValue("particleMaxCount"); - ParticleEngine::fastPhysics = config.getIntValue("particleFastPhysics"); + ParticleEngine::fastPhysics = fromInt(config.getIntValue( + "particleFastPhysics"), + ParticlePhysics); ParticleEngine::emitterSkip = config.getIntValue("particleEmitterSkip") + 1; if (ParticleEngine::emitterSkip == 0) diff --git a/src/particle/particleengine.h b/src/particle/particleengine.h index 02d0dcb5b..19a9c4e9f 100644 --- a/src/particle/particleengine.h +++ b/src/particle/particleengine.h @@ -23,6 +23,8 @@ #ifndef PARTICLE_PARTICLEENGINE_H #define PARTICLE_PARTICLEENGINE_H +#include "enums/particle/particlephysics.h" + #include <list> #include <string> @@ -45,7 +47,7 @@ class ParticleEngine final { public: static const float PARTICLE_SKY; // Maximum Z position of particles - static int fastPhysics; // Mode of squareroot calculation + static ParticlePhysicsT fastPhysics; // Mode of squareroot calculation static int particleCount; // Current number of particles static int maxCount; // Maximum number of particles static int emitterSkip; // Duration of pause between two |