summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-18 18:27:27 +0300
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-09-30 14:56:20 +0200
commit5e465c8b260b1c906809fd288a19780581ae54f0 (patch)
tree91afca6b6e6ff9ca33378ba6d06ce43e83c1546f
parentf7bccd4c7abe33c0f435a4c584d196d611f89674 (diff)
downloadmana-5e465c8b260b1c906809fd288a19780581ae54f0.tar.gz
mana-5e465c8b260b1c906809fd288a19780581ae54f0.tar.bz2
mana-5e465c8b260b1c906809fd288a19780581ae54f0.tar.xz
mana-5e465c8b260b1c906809fd288a19780581ae54f0.zip
Reduce number of rand() calls in Particle::update
(cherry picked from M+ commit cc6b5ebf94ad24180a4db69aa87cae07e3c876d2)
-rw-r--r--src/particle.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index 61290884..40a51888 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -136,9 +136,10 @@ bool Particle::update()
if (mRandomness > 0)
{
- mVelocity.x += (rand()%mRandomness - rand()%mRandomness) / 1000.0f;
- mVelocity.y += (rand()%mRandomness - rand()%mRandomness) / 1000.0f;
- mVelocity.z += (rand()%mRandomness - rand()%mRandomness) / 1000.0f;
+ const int rand2 = mRandomness * 2;
+ mVelocity.x += (rand() % rand2 - mRandomness) / 1000.0f;
+ mVelocity.y += (rand() % rand2 - mRandomness) / 1000.0f;
+ mVelocity.z += (rand() % rand2 - mRandomness) / 1000.0f;
}
mVelocity.z -= mGravity;