summaryrefslogtreecommitdiff
path: root/src/particle
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-22 02:12:41 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-22 02:12:41 +0300
commit238642d6a99d3f764529a339d0802d3e3909f391 (patch)
treef115374ffdf930f530bfc916065823032fc303cb /src/particle
parentad56ac4bda60beddf33640df346801af1ece9ccf (diff)
downloadManaVerse-238642d6a99d3f764529a339d0802d3e3909f391.tar.gz
ManaVerse-238642d6a99d3f764529a339d0802d3e3909f391.tar.bz2
ManaVerse-238642d6a99d3f764529a339d0802d3e3909f391.tar.xz
ManaVerse-238642d6a99d3f764529a339d0802d3e3909f391.zip
Use strong typed enum ParticlePhysics.
Diffstat (limited to 'src/particle')
-rw-r--r--src/particle/particle.cpp5
-rw-r--r--src/particle/particleengine.cpp6
-rw-r--r--src/particle/particleengine.h4
3 files changed, 10 insertions, 5 deletions
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