mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Precalculate mapblock relative size. This permit to remove many s16 calculs on runtime
This commit is contained in:
parent
88a6b9f52d
commit
ca63f7f10d
2 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue