From 554f7f120c4bc99a2c9c944b951662b95a03a9d4 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 18 Oct 2011 13:56:35 +0300 Subject: [PATCH] Improve rendering and fix tiling in mesh generation --- src/clouds.cpp | 4 + src/content_mapblock.cpp | 225 +++++++++++++++++++-------------------- src/content_mapnode.cpp | 14 +++ src/mapblock_mesh.cpp | 36 ++++++- src/tile.h | 4 +- 5 files changed, 167 insertions(+), 116 deletions(-) diff --git a/src/clouds.cpp b/src/clouds.cpp index d754cc15e..8981b42d9 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "noise.h" #include "constants.h" #include "debug.h" +#include "profiler.h" +#include "main.h" // For g_profiler Clouds::Clouds( scene::ISceneNode* parent, @@ -76,6 +78,8 @@ void Clouds::render() if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID) return; + ScopeProfiler sp(g_profiler, "Rendering of clouds, avg", SPT_AVG); + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setMaterial(m_material); diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 0c96c568f..ad4601d06 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -143,7 +143,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, // New-style leaves material video::SMaterial material_leaves1; material_leaves1.setFlag(video::EMF_LIGHTING, false); - //material_leaves1.setFlag(video::EMF_BACK_FACE_CULLING, false); material_leaves1.setFlag(video::EMF_BILINEAR_FILTER, false); material_leaves1.setFlag(video::EMF_FOG_ENABLE, true); material_leaves1.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; @@ -229,25 +228,54 @@ void mapblock_mesh_generate_special(MeshMakeData *data, v3s16 p(x,y,z); MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes+p); - + /* Add torches to mesh */ if(n.getContent() == CONTENT_TORCH) { + v3s16 dir = unpackDir(n.param2); + + const char *texturename = "torch.png"; + if(dir == v3s16(0,-1,0)){ + texturename = "torch_on_floor.png"; + } else if(dir == v3s16(0,1,0)){ + texturename = "torch_on_ceiling.png"; + // For backwards compatibility + } else if(dir == v3s16(0,0,0)){ + texturename = "torch_on_floor.png"; + } else { + texturename = "torch.png"; + } + + AtlasPointer ap = g_texturesource->getTexture(texturename); + + // Set material + video::SMaterial material; + material.setFlag(video::EMF_LIGHTING, false); + material.setFlag(video::EMF_BACK_FACE_CULLING, true); + material.setFlag(video::EMF_BILINEAR_FILTER, false); + material.setFlag(video::EMF_FOG_ENABLE, true); + //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + material.MaterialType + = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + material.setTexture(0, ap.atlas); + video::SColor c(255,255,255,255); // Wall at X+ of node video::S3DVertex vertices[4] = { - video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, 0,1), - video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, 1,1), - video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, 1,0), - video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, 0,0), + video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, + ap.x0(), ap.y1()), + video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, + ap.x1(), ap.y1()), + video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, + ap.x1(), ap.y0()), + video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, + ap.x0(), ap.y0()), }; - v3s16 dir = unpackDir(n.param2); - for(s32 i=0; i<4; i++) { if(dir == v3s16(1,0,0)) @@ -266,29 +294,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); } - // Set material - video::SMaterial material; - material.setFlag(video::EMF_LIGHTING, false); - material.setFlag(video::EMF_BACK_FACE_CULLING, false); - material.setFlag(video::EMF_BILINEAR_FILTER, false); - //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - material.MaterialType - = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - - if(dir == v3s16(0,-1,0)) - material.setTexture(0, - g_texturesource->getTextureRaw("torch_on_floor.png")); - else if(dir == v3s16(0,1,0)) - material.setTexture(0, - g_texturesource->getTextureRaw("torch_on_ceiling.png")); - // For backwards compatibility - else if(dir == v3s16(0,0,0)) - material.setTexture(0, - g_texturesource->getTextureRaw("torch_on_floor.png")); - else - material.setTexture(0, - g_texturesource->getTextureRaw("torch.png")); - u16 indices[] = {0,1,2,2,3,0}; // Add to mesh collector collector.append(material, vertices, 4, indices, 6); @@ -298,6 +303,18 @@ void mapblock_mesh_generate_special(MeshMakeData *data, */ else if(n.getContent() == CONTENT_SIGN_WALL) { + AtlasPointer ap = g_texturesource->getTexture("sign_wall.png"); + + // Set material + video::SMaterial material; + material.setFlag(video::EMF_LIGHTING, false); + material.setFlag(video::EMF_BACK_FACE_CULLING, true); + material.setFlag(video::EMF_BILINEAR_FILTER, false); + material.setFlag(video::EMF_FOG_ENABLE, true); + material.MaterialType + = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + material.setTexture(0, ap.atlas); + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); video::SColor c = MapBlock_LightColor(255, l); @@ -305,10 +322,14 @@ void mapblock_mesh_generate_special(MeshMakeData *data, // Wall at X+ of node video::S3DVertex vertices[4] = { - video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1), - video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1), - video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0), - video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), + video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, + ap.x0(), ap.y1()), + video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, + ap.x1(), ap.y1()), + video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, + ap.x1(), ap.y0()), + video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, + ap.x0(), ap.y0()), }; v3s16 dir = unpackDir(n.param2); @@ -331,19 +352,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); } - // Set material - video::SMaterial material; - 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_ALPHA_CHANNEL; - material.MaterialType - = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - - material.setTexture(0, - g_texturesource->getTextureRaw("sign_wall.png")); - u16 indices[] = {0,1,2,2,3,0}; // Add to mesh collector collector.append(material, vertices, 4, indices, 6); @@ -525,10 +533,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, 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),*/ video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, pa_liquid1.x0(), pa_liquid1.y1()), video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, @@ -610,10 +614,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, { 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),*/ video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, pa_liquid1.x0(), pa_liquid1.y1()), video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, @@ -668,10 +668,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, 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),*/ video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, pa_liquid1.x0(), pa_liquid1.y1()), video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, @@ -705,10 +701,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, { video::S3DVertex vertices[4] = { - /*video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, 0,1), - video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 1,1), - video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, 1,0), - video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, 0,0),*/ video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, pa_leaves1.x0(), pa_leaves1.y1()), video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, @@ -927,10 +919,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, video::S3DVertex vertices[4] = { - /*video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, 0,1), - video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 1,1), - video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, 1,0), - video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, 0,0),*/ video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, ap.x0(), ap.y1()), video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, @@ -1034,13 +1022,13 @@ void mapblock_mesh_generate_special(MeshMakeData *data, video::S3DVertex vertices[4] = { video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, - pa_papyrus.x0(), pa_papyrus.y1()), + pa_junglegrass.x0(), pa_junglegrass.y1()), video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, - pa_papyrus.x1(), pa_papyrus.y1()), + pa_junglegrass.x1(), pa_junglegrass.y1()), video::S3DVertex(BS/2,BS/1,0, 0,0,0, c, - pa_papyrus.x1(), pa_papyrus.y0()), + pa_junglegrass.x1(), pa_junglegrass.y0()), video::S3DVertex(-BS/2,BS/1,0, 0,0,0, c, - pa_papyrus.x0(), pa_papyrus.y0()), + pa_junglegrass.x0(), pa_junglegrass.y0()), }; if(j == 0) @@ -1077,9 +1065,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, } else if(n.getContent() == CONTENT_RAIL) { - u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); - video::SColor c = MapBlock_LightColor(255, l); - bool is_rail_x [] = { false, false }; /* x-1, x+1 */ bool is_rail_z [] = { false, false }; /* z-1, z+1 */ @@ -1097,43 +1082,50 @@ void mapblock_mesh_generate_special(MeshMakeData *data, if(n_plus_z.getContent() == CONTENT_RAIL) is_rail_z[1] = true; - float d = (float)BS/16; - video::S3DVertex vertices[4] = - { - video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c, - 0, 1), - video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c, - 1, 1), - video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c, - 1, 0), - video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c, - 0, 0), - }; - - video::SMaterial material_rail; - material_rail.setFlag(video::EMF_LIGHTING, false); - material_rail.setFlag(video::EMF_BACK_FACE_CULLING, false); - material_rail.setFlag(video::EMF_BILINEAR_FILTER, false); - material_rail.setFlag(video::EMF_FOG_ENABLE, true); - material_rail.MaterialType - = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - int adjacencies = is_rail_x[0] + is_rail_x[1] + is_rail_z[0] + is_rail_z[1]; // Assign textures + const char *texturename = "rail.png"; if(adjacencies < 2) - material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + texturename = "rail.png"; else if(adjacencies == 2) { if((is_rail_x[0] && is_rail_x[1]) || (is_rail_z[0] && is_rail_z[1])) - material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + texturename = "rail.png"; else - material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png")); + texturename = "rail_curved.png"; } else if(adjacencies == 3) - material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png")); + texturename = "rail_t_junction.png"; else if(adjacencies == 4) - material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png")); + texturename = "rail_crossing.png"; + + AtlasPointer ap = g_texturesource->getTexture(texturename); + + video::SMaterial material_rail; + material_rail.setFlag(video::EMF_LIGHTING, false); + material_rail.setFlag(video::EMF_BACK_FACE_CULLING, true); + material_rail.setFlag(video::EMF_BILINEAR_FILTER, false); + material_rail.setFlag(video::EMF_FOG_ENABLE, true); + material_rail.MaterialType + = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + material_rail.setTexture(0, ap.atlas); + + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); + video::SColor c = MapBlock_LightColor(255, l); + + float d = (float)BS/16; + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c, + ap.x0(), ap.y1()), + video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c, + ap.x1(), ap.y1()), + video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c, + ap.x1(), ap.y0()), + video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c, + ap.x0(), ap.y0()), + }; // Rotate textures int angle = 0; @@ -1180,6 +1172,17 @@ void mapblock_mesh_generate_special(MeshMakeData *data, collector.append(material_rail, vertices, 4, indices, 6); } else if (n.getContent() == CONTENT_LADDER) { + AtlasPointer ap = g_texturesource->getTexture("ladder.png"); + + // Set material + video::SMaterial material_ladder; + material_ladder.setFlag(video::EMF_LIGHTING, false); + material_ladder.setFlag(video::EMF_BACK_FACE_CULLING, true); + material_ladder.setFlag(video::EMF_BILINEAR_FILTER, false); + material_ladder.setFlag(video::EMF_FOG_ENABLE, true); + material_ladder.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + material_ladder.setTexture(0, ap.atlas); + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); video::SColor c(255,l,l,l); @@ -1188,10 +1191,14 @@ void mapblock_mesh_generate_special(MeshMakeData *data, // Assume wall is at X+ video::S3DVertex vertices[4] = { - video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1), - video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1), - video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0), - video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), + video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, + ap.x0(), ap.y1()), + video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, + ap.x1(), ap.y1()), + video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, + ap.x1(), ap.y0()), + video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, + ap.x0(), ap.y0()), }; v3s16 dir = unpackDir(n.param2); @@ -1214,14 +1221,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data, vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); } - video::SMaterial material_ladder; - material_ladder.setFlag(video::EMF_LIGHTING, false); - material_ladder.setFlag(video::EMF_BACK_FACE_CULLING, false); - material_ladder.setFlag(video::EMF_BILINEAR_FILTER, false); - material_ladder.setFlag(video::EMF_FOG_ENABLE, true); - material_ladder.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - material_ladder.setTexture(0, g_texturesource->getTextureRaw("ladder.png")); - u16 indices[] = {0,1,2,2,3,0}; // Add to mesh collector collector.append(material_ladder, vertices, 4, indices, 6); diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index 139c46fb2..ec0a7df05 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -220,6 +220,7 @@ void content_mapnode_init() i = CONTENT_JUNGLEGRASS; f = &content_features(i); f->setInventoryTexture("junglegrass.png"); + f->used_texturenames["junglegrass.png"] = true; f->light_propagates = true; f->param_type = CPT_LIGHT; //f->is_ground_content = true; @@ -265,6 +266,7 @@ void content_mapnode_init() i = CONTENT_PAPYRUS; f = &content_features(i); f->setInventoryTexture("papyrus.png"); + f->used_texturenames["papyrus.png"] = true; f->light_propagates = true; f->param_type = CPT_LIGHT; f->is_ground_content = true; @@ -307,11 +309,13 @@ void content_mapnode_init() f->solidness = 0; // drawn separately, makes no faces f->air_equivalent = true; // grass grows underneath f->setInventoryTexture("fence.png"); + f->used_texturenames["fence.png"] = true; setWoodLikeDiggingProperties(f->digging_properties, 0.75); i = CONTENT_RAIL; f = &content_features(i); f->setInventoryTexture("rail.png"); + f->used_texturenames["rail.png"] = true; f->light_propagates = true; f->param_type = CPT_LIGHT; f->is_ground_content = true; @@ -324,6 +328,7 @@ void content_mapnode_init() i = CONTENT_LADDER; f = &content_features(i); f->setInventoryTexture("ladder.png"); + f->used_texturenames["ladder.png"] = true; f->light_propagates = true; f->param_type = CPT_LIGHT; f->is_ground_content = true; @@ -466,6 +471,7 @@ void content_mapnode_init() i = CONTENT_LAVA; f = &content_features(i); f->setInventoryTextureCube("lava.png", "lava.png", "lava.png"); + f->used_texturenames["lava.png"] = true; f->param_type = CPT_LIGHT; f->light_propagates = false; f->light_source = LIGHT_MAX-1; @@ -502,6 +508,7 @@ void content_mapnode_init() i = CONTENT_LAVASOURCE; f = &content_features(i); f->setInventoryTextureCube("lava.png", "lava.png", "lava.png"); + f->used_texturenames["ladder.png"] = true; if(new_style_water) { f->solidness = 0; // drawn separately, makes no faces @@ -555,6 +562,10 @@ void content_mapnode_init() i = CONTENT_TORCH; f = &content_features(i); f->setInventoryTexture("torch_on_floor.png"); + f->used_texturenames["torch_on_floor.png"] = true; + f->used_texturenames["torch_on_ceiling.png"] = true; + f->used_texturenames["torch_on_floor.png"] = true; + f->used_texturenames["torch.png"] = true; f->param_type = CPT_LIGHT; f->light_propagates = true; f->sunlight_propagates = true; @@ -569,6 +580,7 @@ void content_mapnode_init() i = CONTENT_SIGN_WALL; f = &content_features(i); f->setInventoryTexture("sign_wall.png"); + f->used_texturenames["sign_wall.png"] = true; f->param_type = CPT_LIGHT; f->light_propagates = true; f->sunlight_propagates = true; @@ -671,6 +683,7 @@ void content_mapnode_init() f->param_type = CPT_LIGHT; f->setAllTextures("sapling.png"); f->setInventoryTexture("sapling.png"); + f->used_texturenames["sapling.png"] = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; f->light_propagates = true; f->air_equivalent = false; @@ -681,6 +694,7 @@ void content_mapnode_init() i = CONTENT_APPLE; f = &content_features(i); f->setInventoryTexture("apple.png"); + f->used_texturenames["apple.png"] = true; f->param_type = CPT_LIGHT; f->light_propagates = true; f->sunlight_propagates = true; diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index 2bee572f0..7ee49986f 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "main.h" // For g_settings and g_texturesource #include "content_mapblock.h" #include "settings.h" +#include "profiler.h" void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block) { @@ -527,7 +528,7 @@ void updateFastFaceRow( next_tile); if(next_makes_face == makes_face - && next_p_corrected == p_corrected + && next_p_corrected == p_corrected + translate_dir && next_face_dir_corrected == face_dir_corrected && next_lights[0] == lights[0] && next_lights[1] == lights[1] @@ -537,6 +538,29 @@ void updateFastFaceRow( { next_is_different = false; } + else{ + /*if(makes_face){ + g_profiler->add("Meshgen: diff: next_makes_face != makes_face", + next_makes_face != makes_face ? 1 : 0); + g_profiler->add("Meshgen: diff: n_p_corr != p_corr + t_dir", + (next_p_corrected != p_corrected + translate_dir) ? 1 : 0); + g_profiler->add("Meshgen: diff: next_f_dir_corr != f_dir_corr", + next_face_dir_corrected != face_dir_corrected ? 1 : 0); + g_profiler->add("Meshgen: diff: next_lights[] != lights[]", + (next_lights[0] != lights[0] || + next_lights[0] != lights[0] || + next_lights[0] != lights[0] || + next_lights[0] != lights[0]) ? 1 : 0); + g_profiler->add("Meshgen: diff: !(next_tile == tile)", + !(next_tile == tile) ? 1 : 0); + }*/ + } + /*g_profiler->add("Meshgen: Total faces checked", 1); + if(makes_face) + g_profiler->add("Meshgen: Total makes_face checked", 1);*/ + } else { + /*if(makes_face) + g_profiler->add("Meshgen: diff: last position", 1);*/ } continuous_tiles_count++; @@ -568,6 +592,8 @@ void updateFastFaceRow( v3f pf(p_corrected.X, p_corrected.Y, p_corrected.Z); // Center point of face (kind of) v3f sp = pf - ((f32)continuous_tiles_count / 2. - 0.5) * translate_dir_f; + if(continuous_tiles_count != 1) + sp += translate_dir_f; v3f scale(1,1,1); if(translate_dir.X != 0) @@ -586,6 +612,11 @@ void updateFastFaceRow( makeFastFace(tile, lights[0], lights[1], lights[2], lights[3], sp, face_dir_corrected, scale, posRelative_f, dest); + + g_profiler->avg("Meshgen: faces drawn by tiling", 0); + for(int i=1; iavg("Meshgen: faces drawn by tiling", 1); + } } continuous_tiles_count = 0; @@ -707,10 +738,13 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) video::SMaterial material; material.setFlag(video::EMF_LIGHTING, false); + material.setFlag(video::EMF_BACK_FACE_CULLING, true); material.setFlag(video::EMF_BILINEAR_FILTER, false); material.setFlag(video::EMF_FOG_ENABLE, true); //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF); //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE); + material.MaterialType + = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; for(u32 i=0; i