summaryrefslogtreecommitdiff
path: root/src/mapblock.h
diff options
context:
space:
mode:
authornerzhul <loic.blot@unix-experience.fr>2015-07-29 10:49:40 +0200
committernerzhul <loic.blot@unix-experience.fr>2015-07-29 11:45:44 +0200
commitca63f7f10d912382ebc24a54995f7153598ed429 (patch)
tree1ecebcbbf5f2234ecca0a34d612c7b77c41ec4c5 /src/mapblock.h
parent88a6b9f52d6ffd4e351155dee661fe8ea084a9aa (diff)
downloadminetest-ca63f7f10d912382ebc24a54995f7153598ed429.tar.gz
minetest-ca63f7f10d912382ebc24a54995f7153598ed429.tar.bz2
minetest-ca63f7f10d912382ebc24a54995f7153598ed429.zip
Precalculate mapblock relative size. This permit to remove many s16 calculs on runtime
Diffstat (limited to 'src/mapblock.h')
-rw-r--r--src/mapblock.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mapblock.h b/src/mapblock.h
index 92ca4b485..ba33c01a2 100644
--- a/src/mapblock.h
+++ b/src/mapblock.h
@@ -258,7 +258,7 @@ public:
inline v3s16 getPosRelative()
{
- return m_pos * MAP_BLOCKSIZE;
+ return m_pos_relative;
}
inline core::aabbox3d<s16> getBox()
@@ -564,6 +564,14 @@ private:
// Position in blocks on parent
v3s16 m_pos;
+ /* This is the precalculated m_pos_relative value
+ * This caches the value, improving performance by removing 3 s16 multiplications
+ * at runtime on each getPosRelative call
+ * For a 5 minutes runtime with valgrind this removes 3 * 19M s16 multiplications
+ * The gain can be estimated in Release Build to 3 * 100M multiply operations for 5 mins
+ */
+ v3s16 m_pos_relative;
+
IGameDef *m_gamedef;
/*