aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-02-04 01:48:52 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-02-04 01:48:52 +0200
commit6545ea12e984fab63ed2a21d334de47f9bb342c1 (patch)
tree75f2dad4256fc939e0d7482bbec69f542185585c
parent102c5e31fe75bc5c02ddb27afe69968ca8dedeed (diff)
downloadminetest-6545ea12e984fab63ed2a21d334de47f9bb342c1.tar.gz
minetest-6545ea12e984fab63ed2a21d334de47f9bb342c1.tar.bz2
minetest-6545ea12e984fab63ed2a21d334de47f9bb342c1.zip
nicer looking water
-rw-r--r--minetest.conf.example1
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/map.cpp2
-rw-r--r--src/mapblock.cpp56
-rw-r--r--src/mapnode.cpp7
5 files changed, 60 insertions, 7 deletions
diff --git a/minetest.conf.example b/minetest.conf.example
index 0cdccf20c..9a1a0dfd8 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -23,6 +23,7 @@
#client_delete_unused_sectors_timeout = 1200
#enable_fog = true
+#new_style_water = true
# Server side stuff
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 0665cd02e..70f5e0aeb 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -36,6 +36,7 @@ void set_default_settings()
g_settings.setDefault("random_input", "false");
g_settings.setDefault("client_delete_unused_sectors_timeout", "1200");
g_settings.setDefault("enable_fog", "true");
+ g_settings.setDefault("new_style_water", "true");
// Server stuff
g_settings.setDefault("creative_mode", "false");
diff --git a/src/map.cpp b/src/map.cpp
index d03bc0ce2..3a3169200 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2058,7 +2058,7 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0)
MapNode treenode(CONTENT_TREE);
MapNode leavesnode(CONTENT_LEAVES);
- s16 trunk_h = myrand_range(2, 6);
+ s16 trunk_h = myrand_range(3, 6);
v3s16 p1 = p0;
for(s16 ii=0; ii<trunk_h; ii++)
{
diff --git a/src/mapblock.cpp b/src/mapblock.cpp
index a5f1066bd..da7d22ac5 100644
--- a/src/mapblock.cpp
+++ b/src/mapblock.cpp
@@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock.h"
#include "map.h"
-// For g_materials
+// For g_settings and g_irrlicht
#include "main.h"
#include "light.h"
#include <sstream>
@@ -600,7 +600,6 @@ void MapBlock::updateMesh(u32 daynight_ratio)
v3f posRelative_f(getPosRelative().X, getPosRelative().Y,
getPosRelative().Z); // floating point conversion
-
/*
Avoid interlocks by copying m_temp_mods
*/
@@ -610,6 +609,11 @@ void MapBlock::updateMesh(u32 daynight_ratio)
m_temp_mods.copy(temp_mods);
}
+ bool new_style_water = g_settings.getBool("new_style_water");
+ float node_water_level = 1.0;
+ if(new_style_water)
+ node_water_level = 0.8;
+
/*
We are including the faces of the trailing edges of the block.
This means that when something changes, the caller must
@@ -846,9 +850,10 @@ void MapBlock::updateMesh(u32 daynight_ratio)
content = n2.d;
if(n2.d == CONTENT_WATERSOURCE)
- level = 0.5 * BS;
+ level = (-0.5+node_water_level) * BS;
else if(n2.d == CONTENT_WATER)
- level = (-0.5 + ((float)n2.param2 + 0.5) / 8.0) * BS;
+ level = (-0.5 + ((float)n2.param2 + 0.5) / 8.0
+ * node_water_level) * BS;
// Check node above neighbor.
// NOTE: This doesn't get executed if neighbor
@@ -889,7 +894,7 @@ void MapBlock::updateMesh(u32 daynight_ratio)
// Special case for source nodes
if(content == CONTENT_WATERSOURCE)
{
- cornerlevel = 0.5*BS;
+ cornerlevel = (-0.5+node_water_level)*BS;
valid_count = 1;
break;
}
@@ -1045,6 +1050,47 @@ void MapBlock::updateMesh(u32 daynight_ratio)
collector.append(material_w1, vertices, 4, indices, 6);
}
}
+ /*
+ Add water sources to mesh
+ */
+ else if(n.d == CONTENT_WATERSOURCE && new_style_water)
+ {
+ //bool top_is_water = false;
+ bool top_is_air = false;
+ try{
+ MapNode n = getNodeParent(v3s16(x,y+1,z));
+ /*if(n.d == CONTENT_WATER || n.d == CONTENT_WATERSOURCE)
+ top_is_water = true;*/
+ if(n.d == CONTENT_AIR)
+ top_is_air = true;
+ }catch(InvalidPositionException &e){}
+
+ /*if(top_is_water == true)
+ continue;*/
+ if(top_is_air == false)
+ continue;
+
+ u8 l = decode_light(n.getLightBlend(daynight_ratio));
+ video::SColor c(WATER_ALPHA,l,l,l);
+
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(-BS/2,0,-BS/2, 0,0,0, c, 0,1),
+ video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c, 1,1),
+ video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,0),
+ video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,0),
+ };
+
+ for(s32 i=0; i<4; i++)
+ {
+ vertices[i].Pos.Y += (-0.5+node_water_level)*BS;
+ vertices[i].Pos += intToFloat(p + getPosRelative());
+ }
+
+ u16 indices[] = {0,1,2,2,3,0};
+ // Add to mesh collector
+ collector.append(material_w1, vertices, 4, indices, 6);
+ }
}
/*
diff --git a/src/mapnode.cpp b/src/mapnode.cpp
index 6f34aa039..d585238ae 100644
--- a/src/mapnode.cpp
+++ b/src/mapnode.cpp
@@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include <string>
#include "mineral.h"
+// For g_settings
+#include "main.h"
ContentFeatures::~ContentFeatures()
{
@@ -139,10 +141,13 @@ void init_mapnode(IIrrlichtWrapper *irrlicht)
f->buildable_to = true;
f->liquid_type = LIQUID_FLOWING;
+ bool new_style_water = g_settings.getBool("new_style_water");
+
i = CONTENT_WATERSOURCE;
f = &g_content_features[i];
//f->setTexture(0, irrlicht->getTextureId("water.png"), WATER_ALPHA);
- f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA);
+ if(new_style_water == false)
+ f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA);
f->setInventoryTexture(irrlicht->getTextureId("water.png"));
f->param_type = CPT_LIGHT;
f->light_propagates = true;