X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fmapblock.cpp;h=58b23bd146e6001d50055a18357c1e1ae308bde7;hb=94c9686020798c8ec8113c242dc1dfe0c2accf71;hp=bd63bd015c04e2cb644b1ee21b68fdfcbbabd088;hpb=f2349ec5dfe9a209df8df981c11eeb888491d74e;p=minetest.git diff --git a/src/mapblock.cpp b/src/mapblock.cpp index bd63bd015..58b23bd14 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -618,50 +618,6 @@ void updateFastFaceRow( makeFastFace(tile, lights[0], lights[1], lights[2], lights[3], sp, face_dir_corrected, scale, posRelative_f, dest); - - #if 0 - // First node - v3s16 p_first = p_corrected - (continuous_tiles_count-1) - * translate_dir; - - v3s16 p_map_leftmost; - v3s16 p_map_rightmost; - p_map_leftmost = p_corrected + blockpos_nodes; - p_map_rightmost = p_first + blockpos_nodes; - - /*if(p != p_corrected) - { - if(face_dir == v3s16(0,0,1)) - { - v3s16 orig_leftmost = p_map_leftmost; - v3s16 orig_rightmost = p_map_leftmost; - p_map_leftmost = orig_rightmost; - p_map_rightmost = orig_leftmost; - } - }*/ - - if(smooth_lighting == false) - { - li0 = li1 = li2 = li3 = decode_light(light); - } - else - { - v3s16 vertex_dirs[4]; - getNodeVertexDirs(face_dir_corrected, vertex_dirs); - - li0 = getSmoothLight(p_map_rightmost, vertex_dirs[0], - vmanip, daynight_ratio); - li1 = getSmoothLight(p_map_leftmost, vertex_dirs[1], - vmanip, daynight_ratio); - li2 = getSmoothLight(p_map_leftmost, vertex_dirs[2], - vmanip, daynight_ratio); - li3 = getSmoothLight(p_map_rightmost, vertex_dirs[3], - vmanip, daynight_ratio); - } - makeFastFace(tile, li0, li1, li2, li3, - sp, face_dir_corrected, scale, - posRelative_f, dest); - #endif } continuous_tiles_count = 0; @@ -890,6 +846,7 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) FastFace &f = fastfaces_new[i]; const u16 indices[] = {0,1,2,2,3,0}; + const u16 indices_alternate[] = {0,1,3,2,3,1}; video::ITexture *texture = f.tile.texture.atlas; if(texture == NULL) @@ -898,8 +855,18 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) material.setTexture(0, texture); f.tile.applyMaterialOptions(material); + + const u16 *indices_p = indices; - collector.append(material, f.vertices, 4, indices, 6); + /* + Revert triangles for nicer looking gradient if vertices + 1 and 3 have same color or 0 and 2 have different color. + */ + if(f.vertices[0].Color != f.vertices[2].Color + || f.vertices[1].Color == f.vertices[3].Color) + indices_p = indices_alternate; + + collector.append(material, f.vertices, 4, indices_p, 6); } } @@ -934,6 +901,17 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) g_texturesource->getTextureId("leaves.png")); material_leaves1.setTexture(0, pa_leaves1.atlas); + // Glass material + video::SMaterial material_glass; + material_glass.setFlag(video::EMF_LIGHTING, false); + material_glass.setFlag(video::EMF_BILINEAR_FILTER, false); + material_glass.setFlag(video::EMF_FOG_ENABLE, true); + material_glass.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + AtlasPointer pa_glass = g_texturesource->getTexture( + g_texturesource->getTextureId("glass.png")); + material_glass.setTexture(0, pa_glass.atlas); + + for(s16 z=0; zm_daynight_ratio))); + video::SColor c(255,l,l,l); + + for(u32 j=0; j<6; j++) + { + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, + pa_glass.x0(), pa_glass.y1()), + video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, + pa_glass.x1(), pa_glass.y1()), + video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, + pa_glass.x1(), pa_glass.y0()), + video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, + pa_glass.x0(), pa_glass.y0()), + }; + + if(j == 0) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(0); + } + else if(j == 1) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(180); + } + else if(j == 2) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(-90); + } + else if(j == 3) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(90); + } + else if(j == 4) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateYZBy(-90); + } + else if(j == 5) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateYZBy(90); + } + + for(u16 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + u16 indices[] = {0,1,2,2,3,0}; + // Add to mesh collector + collector.append(material_glass, vertices, 4, indices, 6); + } + } + + + } /* @@ -2142,9 +2186,17 @@ void MapBlock::serialize(std::ostream &os, u8 version) { if(version <= 15) { - std::ostringstream oss(std::ios_base::binary); - m_node_metadata.serialize(oss); - os<