#include "mapblock.h"
#include "map.h"
-// For g_materials
+// For g_settings and g_irrlicht
#include "main.h"
#include "light.h"
#include <sstream>
v3f posRelative_f(getPosRelative().X, getPosRelative().Y,
getPosRelative().Z); // floating point conversion
-
/*
Avoid interlocks by copying m_temp_mods
*/
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
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
// Special case for source nodes
if(content == CONTENT_WATERSOURCE)
{
- cornerlevel = 0.5*BS;
+ cornerlevel = (-0.5+node_water_level)*BS;
valid_count = 1;
break;
}
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);
+ }
}
/*
#include "porting.h"
#include <string>
#include "mineral.h"
+// For g_settings
+#include "main.h"
ContentFeatures::~ContentFeatures()
{
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;