aboutsummaryrefslogtreecommitdiff
path: root/src/mapblock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapblock.cpp')
-rw-r--r--src/mapblock.cpp111
1 files changed, 53 insertions, 58 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index 7e23d295b..9372c8fb1 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -34,7 +34,6 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
m_pos(pos),
changed(true),
is_underground(false),
- m_mesh_expired(false),
m_day_night_differs(false),
m_objects(this)
{
@@ -42,17 +41,16 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
if(dummy == false)
reallocate();
+#ifndef SERVER
+ m_mesh_expired = false;
mesh_mutex.Init();
-
mesh = NULL;
- /*for(s32 i=0; i<DAYNIGHT_CACHE_COUNT; i++)
- {
- mesh[i] = NULL;
- }*/
+#endif
}
MapBlock::~MapBlock()
{
+#ifndef SERVER
{
JMutexAutoLock lock(mesh_mutex);
@@ -61,15 +59,8 @@ MapBlock::~MapBlock()
mesh->drop();
mesh = NULL;
}
- /*for(s32 i=0; i<DAYNIGHT_CACHE_COUNT; i++)
- {
- if(mesh[i] != NULL)
- {
- mesh[i]->drop();
- mesh[i] = NULL;
- }
- }*/
}
+#endif
if(data)
delete[] data;
@@ -136,6 +127,52 @@ MapNode MapBlock::getNodeParentNoEx(v3s16 p)
}
}
+/*
+ Parameters must consist of air and !air.
+ Order doesn't matter.
+
+ If either of the nodes doesn't exist, light is 0.
+
+ parameters:
+ daynight_ratio: 0...1000
+ n: getNodeParent(p)
+ n2: getNodeParent(p + face_dir)
+ face_dir: axis oriented unit vector from p to p2
+*/
+u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
+ v3s16 face_dir)
+{
+ try{
+ u8 light;
+ u8 l1 = n.getLightBlend(daynight_ratio);
+ u8 l2 = n2.getLightBlend(daynight_ratio);
+ if(l1 > l2)
+ light = l1;
+ else
+ light = l2;
+
+ // Make some nice difference to different sides
+
+ /*if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
+ light = diminish_light(diminish_light(light));
+ else if(face_dir.X == -1 || face_dir.Z == -1)
+ light = diminish_light(light);*/
+
+ if(face_dir.X == 1 || face_dir.X == -1 || face_dir.Y == -1)
+ light = diminish_light(diminish_light(light));
+ else if(face_dir.Z == 1 || face_dir.Z == -1)
+ light = diminish_light(light);
+
+ return light;
+ }
+ catch(InvalidPositionException &e)
+ {
+ return 0;
+ }
+}
+
+#ifndef SERVER
+
void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p,
v3s16 dir, v3f scale, v3f posRelative_f,
core::array<FastFace> &dest)
@@ -230,50 +267,6 @@ void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p,
}
/*
- Parameters must consist of air and !air.
- Order doesn't matter.
-
- If either of the nodes doesn't exist, light is 0.
-
- parameters:
- daynight_ratio: 0...1000
- n: getNodeParent(p)
- n2: getNodeParent(p + face_dir)
- face_dir: axis oriented unit vector from p to p2
-*/
-u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
- v3s16 face_dir)
-{
- try{
- u8 light;
- u8 l1 = n.getLightBlend(daynight_ratio);
- u8 l2 = n2.getLightBlend(daynight_ratio);
- if(l1 > l2)
- light = l1;
- else
- light = l2;
-
- // Make some nice difference to different sides
-
- /*if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
- light = diminish_light(diminish_light(light));
- else if(face_dir.X == -1 || face_dir.Z == -1)
- light = diminish_light(light);*/
-
- if(face_dir.X == 1 || face_dir.X == -1 || face_dir.Y == -1)
- light = diminish_light(diminish_light(light));
- else if(face_dir.Z == 1 || face_dir.Z == -1)
- light = diminish_light(light);
-
- return light;
- }
- catch(InvalidPositionException &e)
- {
- return 0;
- }
-}
-
-/*
Gets node tile from any place relative to block.
Returns TILE_NODE if doesn't exist or should not be drawn.
*/
@@ -844,6 +837,8 @@ void MapBlock::updateMesh(u32 daynight_ratio)
}
}*/
+#endif // !SERVER
+
/*
Propagates sunlight down through the block.
Doesn't modify nodes that are not affected by sunlight.