n: getNodeParent(p)
n2: getNodeParent(p + face_dir)
face_dir: axis oriented unit vector from p to p2
+
+ returns encoded light value.
*/
u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
v3s16 face_dir)
//u8 li = decode_light(light);
u8 li = light;
- u8 alpha = 255;
-
+ u8 alpha = tile.alpha;
+ /*u8 alpha = 255;
if(tile.id == TILE_WATER)
- {
- alpha = 128;
- }
+ alpha = WATER_ALPHA;*/
video::SColor c = video::SColor(alpha,li,li,li);
TileSpec MapBlock::getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir)
{
TileSpec spec;
-
- /*//DEBUG
- {
- spec.id = TILE_STONE;
- return spec;
- }*/
-
- spec.feature = TILEFEAT_NONE;
- //spec.id = TILE_STONE;
- spec.id = mn.getTile(face_dir);
-
+ spec = mn.getTile(face_dir);
+
/*
Check temporary modifications on this node
*/
struct NodeMod mod = n->getValue();
if(mod.type == NODEMOD_CHANGECONTENT)
{
- spec.id = content_tile(mod.param, face_dir);
+ //spec = content_tile(mod.param, face_dir);
+ MapNode mn2(mod.param);
+ spec = mn2.getTile(face_dir);
}
if(mod.type == NODEMOD_CRACK)
{
- spec.feature = TILEFEAT_CRACK;
- spec.param.crack.progression = mod.param;
+ std::ostringstream os;
+ os<<"[[mod:crack"<<mod.param;
+ spec.name += os.str();
}
}
*/
{
+ //TimeTaker timer2("updateMesh() collect");
+
// Lock this, as m_temp_mods will be used directly
JMutexAutoLock lock(m_temp_mods_mutex);
if(fastfaces_new.size() > 0)
{
+ // avg 0ms (100ms spikes when loading textures the first time)
+ //TimeTaker timer2("updateMesh() mesh building");
+
for(u32 i=0; i<fastfaces_new.size(); i++)
{
FastFace &f = fastfaces_new[i];
const u16 indices[] = {0,1,2,2,3,0};
-
- if(f.tile.feature == TILEFEAT_NONE)
- {
- collector.append(tile_material_get(f.tile.id), f.vertices, 4,
- indices, 6);
- }
- else if(f.tile.feature == TILEFEAT_CRACK)
- {
- const char *path = tile_texture_path_get(f.tile.id);
-
- u16 progression = f.tile.param.crack.progression;
-
- std::string name = (std::string)path + "_cracked_"
- + (char)('0' + progression);
-
- TextureMod *mod = new CrackTextureMod(progression);
- video::ITexture *texture = g_irrlicht->getTexture(
- TextureSpec(name, path, mod));
-
- video::SMaterial material = tile_material_get(f.tile.id);
- material.setTexture(0, texture);
-
- collector.append(material, f.vertices, 4, indices, 6);
- }
- else
- {
- // No such feature
- assert(0);
- }
+ video::ITexture *texture = g_irrlicht->getTexture(f.tile.name);
+ video::SMaterial material;
+ material.Lighting = false;
+ material.BackfaceCulling = false;
+ material.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
+ material.setFlag(video::EMF_FOG_ENABLE, true);
+ material.setTexture(0, texture);
+ if(f.tile.alpha != 255)
+ material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
+
+ collector.append(material, f.vertices, 4, indices, 6);
}
}
TODO: Optimize by using same meshbuffer for same textures
*/
+ // 0ms
+ //TimeTaker timer2("updateMesh() adding special stuff");
+
for(s16 z=0; z<MAP_BLOCKSIZE; z++)
for(s16 y=0; y<MAP_BLOCKSIZE; y++)
for(s16 x=0; x<MAP_BLOCKSIZE; x++)
MapNode &n = getNodeRef(x,y,z);
+ /*
+ Add torches to mesh
+ */
if(n.d == CONTENT_TORCH)
{
video::SColor c(255,255,255,255);
// Add to mesh collector
collector.append(material, vertices, 4, indices, 6);
}
+ /*
+ Add flowing water to mesh
+ */
else if(n.d == CONTENT_WATER)
{
bool top_is_water = false;
if(n.d == CONTENT_WATER || n.d == CONTENT_WATERSOURCE)
top_is_water = true;
}catch(InvalidPositionException &e){}
-
- video::SColor c(128,255,255,255);
+
+ u8 l = decode_light(n.getLightBlend(daynight_ratio));
+ video::SColor c(WATER_ALPHA,l,l,l);
// Neighbor water levels (key = relative position)
// Includes current node
material.setFlag(video::EMF_LIGHTING, false);
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material.setFlag(video::EMF_FOG_ENABLE, true);
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
material.setTexture(0,
g_irrlicht->getTexture(porting::getDataPath("water.png").c_str()));
material.setFlag(video::EMF_LIGHTING, false);
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material.setFlag(video::EMF_FOG_ENABLE, true);
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
material.setTexture(0,
g_irrlicht->getTexture(porting::getDataPath("water.png").c_str()));
s16 y = MAP_BLOCKSIZE-1;
for(; y>=0; y--)
{
- if(is_ground_content(getNodeRef(p2d.X, y, p2d.Y).d))
+ //if(is_ground_content(getNodeRef(p2d.X, y, p2d.Y).d))
+ if(content_features(getNodeRef(p2d.X, y, p2d.Y).d).walkable)
{
if(y == MAP_BLOCKSIZE-1)
return -2;
if(version >= 10)
{
- // Get and compress pressure
- SharedBuffer<u8> pressuredata(nodecount);
+ // Get and compress param2
+ SharedBuffer<u8> param2data(nodecount);
for(u32 i=0; i<nodecount; i++)
{
- pressuredata[i] = data[i].pressure;
+ param2data[i] = data[i].param2;
}
- compress(pressuredata, os, version);
+ compress(param2data, os, version);
}
}
// All other versions (newest)
databuf[i+nodecount] = data[i].param;
}
- // Get pressure
+ // Get param2
for(u32 i=0; i<nodecount; i++)
{
- databuf[i+nodecount*2] = data[i].pressure;
+ databuf[i+nodecount*2] = data[i].param2;
}
/*
if(version >= 10)
{
- // Uncompress and set pressure data
+ // Uncompress and set param2 data
std::ostringstream os(std::ios_base::binary);
decompress(is, os, version);
std::string s = os.str();
("MapBlock::deSerialize: invalid format");
for(u32 i=0; i<s.size(); i++)
{
- data[i].pressure = s[i];
+ data[i].param2 = s[i];
}
}
}
{
data[i].param = s[i+nodecount];
}
- // Set pressure
+ // Set param2
for(u32 i=0; i<nodecount; i++)
{
- data[i].pressure = s[i+nodecount*2];
+ data[i].param2 = s[i+nodecount*2];
}
}
}