From 15a43c5ed02130f1b1e07a0385530da197b0c846 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Dec 2010 13:10:37 +0200 Subject: before adding day/night lighting --HG-- rename : data/light.png => data/cloud.png --- src/mapblock.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 77 insertions(+), 20 deletions(-) (limited to 'src/mapblock.cpp') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 86bd9c98c..1afe00001 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -68,7 +68,7 @@ void MapBlock::setNodeParent(v3s16 p, MapNode & n) } } -FastFace * MapBlock::makeFastFace(u16 tile, u8 light, v3f p, +FastFace * MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p, v3s16 dir, v3f scale, v3f posRelative_f) { FastFace *f = new FastFace; @@ -118,7 +118,7 @@ FastFace * MapBlock::makeFastFace(u16 tile, u8 light, v3f p, u8 alpha = 255; - if(tile == TILE_WATER) + if(tile.id == TILE_WATER) { alpha = 128; } @@ -184,25 +184,78 @@ u8 MapBlock::getFaceLight(v3s16 p, v3s16 face_dir) /* Gets node tile from any place relative to block. - Returns CONTENT_IGNORE if doesn't exist or should not be drawn. + Returns TILE_NODE if doesn't exist or should not be drawn. */ -u16 MapBlock::getNodeTile(v3s16 p, v3s16 face_dir) +TileSpec MapBlock::getNodeTile(v3s16 p, v3s16 face_dir) { + TileSpec spec; + + spec.feature = TILEFEAT_NONE; try{ MapNode n = getNodeParent(p); - //return content_tile(n.d); - return n.getTile(face_dir); + spec.id = n.getTile(face_dir); } catch(InvalidPositionException &e) { - //return CONTENT_IGNORE; - return TILE_NONE; + spec.id = TILE_NONE; } + + /* + Check temporary modifications on this node + */ + core::map::Node *n; + n = m_temp_mods.find(p); + + // If modified + if(n != NULL) + { + struct NodeMod mod = n->getValue(); + if(mod.type == NODEMOD_CHANGECONTENT) + { + spec.id = content_tile(mod.param, face_dir); + } + if(mod.type == NODEMOD_CRACK) + { + } + } + + return spec; } u8 MapBlock::getNodeContent(v3s16 p) { + /* + Check temporary modifications on this node + */ + core::map::Node *n; + n = m_temp_mods.find(p); + + // If modified + if(n != NULL) + { + struct NodeMod mod = n->getValue(); + if(mod.type == NODEMOD_CHANGECONTENT) + { + // Overrides content + return mod.param; + } + if(mod.type == NODEMOD_CRACK) + { + /* + Content doesn't change. + + face_contents works just like it should, because + there should not be faces between differently cracked + nodes. + + If a semi-transparent node is cracked in front an + another one, it really doesn't matter whether there + is a cracked face drawn in between or not. + */ + } + } + try{ MapNode n = getNodeParent(p); @@ -243,16 +296,16 @@ void MapBlock::updateFastFaceRow(v3s16 startpos, u16 continuous_tiles_count = 0; - u8 tile0 = getNodeTile(p, face_dir); - u8 tile1 = getNodeTile(p + face_dir, -face_dir); + TileSpec tile0 = getNodeTile(p, face_dir); + TileSpec tile1 = getNodeTile(p + face_dir, -face_dir); for(u16 j=0; jmaterial], f->vertices, 4, - indices, 6);*/ - /*collector.append(g_materials[f->tile], f->vertices, 4, - indices, 6);*/ - collector.append(g_tile_materials[f->tile], f->vertices, 4, - indices, 6); + + if(f->tile.feature == TILEFEAT_NONE) + { + collector.append(g_tile_materials[f->tile.id], f->vertices, 4, + indices, 6); + } + else + { + // Not implemented + assert(0); + } } collector.fillMesh(mesh_new); // Use VBO for mesh (this just would set this for ever buffer) - //mesh_new->setHardwareMappingHint(scene::EHM_STATIC); + mesh_new->setHardwareMappingHint(scene::EHM_STATIC); /*std::cout<<"MapBlock has "<getSize()<<" faces " <<"and uses "<getMeshBufferCount() -- cgit v1.2.3