summaryrefslogtreecommitdiff
path: root/src/particle/particle.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-18 18:27:27 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-18 18:27:27 +0300
commitcc6b5ebf94ad24180a4db69aa87cae07e3c876d2 (patch)
tree3728c0cba25aa488a1a3be36d0b528fffb190404 /src/particle/particle.cpp
parent3632ab0a66bd3a14c8848982b15bfa30715dded7 (diff)
downloadplus-cc6b5ebf94ad24180a4db69aa87cae07e3c876d2.tar.gz
plus-cc6b5ebf94ad24180a4db69aa87cae07e3c876d2.tar.bz2
plus-cc6b5ebf94ad24180a4db69aa87cae07e3c876d2.tar.xz
plus-cc6b5ebf94ad24180a4db69aa87cae07e3c876d2.zip
Reduce number of rand() calls in Particle::update.
Diffstat (limited to 'src/particle/particle.cpp')
-rw-r--r--src/particle/particle.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index 425be6c91..aeb79a1b1 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -160,12 +160,13 @@ void Particle::updateSelf() restrict2
if (mRandomness > 0)
{
- mVelocity.x += static_cast<float>((rand() % mRandomness - rand()
- % mRandomness)) / 1000.0F;
- mVelocity.y += static_cast<float>((rand() % mRandomness - rand()
- % mRandomness)) / 1000.0F;
- mVelocity.z += static_cast<float>((rand() % mRandomness - rand()
- % mRandomness)) / 1000.0F;
+ const int rand2 = mRandomness * 2;
+ mVelocity.x += static_cast<float>(rand() % rand2 - mRandomness)
+ / 1000.0F;
+ mVelocity.y += static_cast<float>(rand() % rand2 - mRandomness)
+ / 1000.0F;
+ mVelocity.z += static_cast<float>(rand() % rand2 - mRandomness)
+ / 1000.0F;
}
mVelocity.z -= mGravity;