summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2010-02-01 11:49:11 +0100
committerBertram <bertram@cegetel.net>2010-02-01 11:49:11 +0100
commit7e2a54bedefc6b5e2b34c9dafccb8322f46266e7 (patch)
tree8a016c196e36f94ac7454e2300226461e71305c8 /src/being.cpp
parent3fe06a98c0af45d7fccce99f39f402485dae71be (diff)
downloadmana-client-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.tar.gz
mana-client-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.tar.bz2
mana-client-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.tar.xz
mana-client-7e2a54bedefc6b5e2b34c9dafccb8322f46266e7.zip
Reduced CPU consumption by setting speed per ticks value only once.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 1e6da93e..6ce2120a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -534,17 +534,11 @@ void Being::logic()
// When we've not reached our destination, move to it.
if (nominalLength > 1.0f && mWalkSpeed > 0.0f)
{
- // The private mWalkSpeed member is the speed in tiles per second.
- // We translate it into pixels per tick,
- // because the logic is called every ticks.
- const float speedInTicks = ((float)DEFAULT_TILE_SIDE_LENGTH * mWalkSpeed)
- / 1000 * (float)MILLISECONDS_IN_A_TICK;
-
// The deplacement of a point along a vector is calculated
// using the Unit Vector (â) multiplied by the point speed.
// â = a / ||a|| (||a|| is the a length.)
// Then, diff = (dir/||dir||)*speed, or (dir / ||dir|| / 1/speed).
- Vector diff = (dir / (nominalLength / speedInTicks));
+ Vector diff = (dir / (nominalLength / mWalkSpeed));
// Test if we don't miss the destination by a move too far:
if (diff.length() > nominalLength)