Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
ca63f7f1
Commit
ca63f7f1
authored
9 years ago
by
Loïc Blot
Browse files
Options
Downloads
Patches
Plain Diff
Precalculate mapblock relative size. This permit to remove many s16 calculs on runtime
parent
88a6b9f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mapblock.cpp
+1
-0
1 addition, 0 deletions
src/mapblock.cpp
src/mapblock.h
+9
-1
9 additions, 1 deletion
src/mapblock.h
with
10 additions
and
1 deletion
src/mapblock.cpp
+
1
−
0
View file @
ca63f7f1
...
...
@@ -69,6 +69,7 @@ static const char *modified_reason_strings[] = {
MapBlock
::
MapBlock
(
Map
*
parent
,
v3s16
pos
,
IGameDef
*
gamedef
,
bool
dummy
)
:
m_parent
(
parent
),
m_pos
(
pos
),
m_pos_relative
(
pos
*
MAP_BLOCKSIZE
),
m_gamedef
(
gamedef
),
m_modified
(
MOD_STATE_WRITE_NEEDED
),
m_modified_reason
(
MOD_REASON_INITIAL
),
...
...
This diff is collapsed.
Click to expand it.
src/mapblock.h
+
9
−
1
View file @
ca63f7f1
...
...
@@ -258,7 +258,7 @@ class MapBlock /*: public NodeContainer*/
inline
v3s16
getPosRelative
()
{
return
m_pos
*
MAP_BLOCKSIZE
;
return
m_pos
_relative
;
}
inline
core
::
aabbox3d
<
s16
>
getBox
()
...
...
@@ -564,6 +564,14 @@ class MapBlock /*: public NodeContainer*/
// 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
;
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment