summaryrefslogtreecommitdiff
path: root/src/voxel.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-07-26 07:35:09 +0200
committerGitHub <noreply@github.com>2017-07-26 07:35:09 +0200
commit9a17b65f26eea5b9d7176e7df205f72ed2ff6c0f (patch)
treef9f0f9100348b05c9eecfb179e0e59ab24a2d2f3 /src/voxel.cpp
parent0c99da4255319d898f3ed47bc7c42757df91e2df (diff)
downloadminetest-9a17b65f26eea5b9d7176e7df205f72ed2ff6c0f.tar.gz
minetest-9a17b65f26eea5b9d7176e7df205f72ed2ff6c0f.tar.bz2
minetest-9a17b65f26eea5b9d7176e7df205f72ed2ff6c0f.zip
VoxelManip cleanups (const ref, const move) + function removal (#6169)
* VoxelManip cleanups (const ref, const move) permitting to improve a little bit performance * VoxelArea: precalculate extent (performance enhancement) This permits to reduce extend high cost to zero and drop many v3s16 object creation/removal to calculate extent It rebalance the client thread update to updateFastFaceRow instead of MapBlockMesh generation This will also benefits to mapgen
Diffstat (limited to 'src/voxel.cpp')
-rw-r--r--src/voxel.cpp37
1 files changed, 3 insertions, 34 deletions
diff --git a/src/voxel.cpp b/src/voxel.cpp
index 08765c98e..981bc5823 100644
--- a/src/voxel.cpp
+++ b/src/voxel.cpp
@@ -55,7 +55,7 @@ void VoxelManipulator::clear()
void VoxelManipulator::print(std::ostream &o, INodeDefManager *ndef,
VoxelPrintMode mode)
{
- v3s16 em = m_area.getExtent();
+ const v3s16 &em = m_area.getExtent();
v3s16 of = m_area.MinEdge;
o<<"size: "<<em.X<<"x"<<em.Y<<"x"<<em.Z
<<" offset: ("<<of.X<<","<<of.Y<<","<<of.Z<<")"<<std::endl;
@@ -208,7 +208,7 @@ void VoxelManipulator::addArea(const VoxelArea &area)
}
void VoxelManipulator::copyFrom(MapNode *src, const VoxelArea& src_area,
- v3s16 from_pos, v3s16 to_pos, v3s16 size)
+ v3s16 from_pos, v3s16 to_pos, const v3s16 &size)
{
/* The reason for this optimised code is that we're a member function
* and the data type/layout of m_data is know to us: it's stored as
@@ -256,7 +256,7 @@ void VoxelManipulator::copyFrom(MapNode *src, const VoxelArea& src_area,
}
void VoxelManipulator::copyTo(MapNode *dst, const VoxelArea& dst_area,
- v3s16 dst_pos, v3s16 from_pos, v3s16 size)
+ v3s16 dst_pos, v3s16 from_pos, const v3s16 &size)
{
for(s16 z=0; z<size.Z; z++)
for(s16 y=0; y<size.Y; y++)
@@ -384,37 +384,6 @@ void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
}
}
-/*
- Goes recursively through the neighbours of the node.
-
- Alters only transparent nodes.
-
- If the lighting of the neighbour is lower than the lighting of
- the node was (before changing it to 0 at the step before), the
- lighting of the neighbour is set to 0 and then the same stuff
- repeats for the neighbour.
-
- The ending nodes of the routine are stored in light_sources.
- This is useful when a light is removed. In such case, this
- routine can be called for the light node and then again for
- light_sources to re-light the area without the removed light.
-
- values of from_nodes are lighting values.
-*/
-void VoxelManipulator::unspreadLight(enum LightBank bank,
- std::map<v3s16, u8> & from_nodes,
- std::set<v3s16> & light_sources, INodeDefManager *nodemgr)
-{
- if(from_nodes.empty())
- return;
-
- for(std::map<v3s16, u8>::iterator j = from_nodes.begin();
- j != from_nodes.end(); ++j)
- {
- unspreadLight(bank, j->first, j->second, light_sources, nodemgr);
- }
-}
-
void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
INodeDefManager *nodemgr)
{