Improve rendering and fix tiling in mesh generation

This commit is contained in:
Perttu Ahola 2011-10-18 13:56:35 +03:00
parent 05ab58cd14
commit 554f7f120c
5 changed files with 167 additions and 116 deletions

View File

@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "noise.h" #include "noise.h"
#include "constants.h" #include "constants.h"
#include "debug.h" #include "debug.h"
#include "profiler.h"
#include "main.h" // For g_profiler
Clouds::Clouds( Clouds::Clouds(
scene::ISceneNode* parent, scene::ISceneNode* parent,
@ -76,6 +78,8 @@ void Clouds::render()
if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID) if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID)
return; return;
ScopeProfiler sp(g_profiler, "Rendering of clouds, avg", SPT_AVG);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->setMaterial(m_material); driver->setMaterial(m_material);

View File

@ -143,7 +143,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
// New-style leaves material // New-style leaves material
video::SMaterial material_leaves1; video::SMaterial material_leaves1;
material_leaves1.setFlag(video::EMF_LIGHTING, false); 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_BILINEAR_FILTER, false);
material_leaves1.setFlag(video::EMF_FOG_ENABLE, true); material_leaves1.setFlag(video::EMF_FOG_ENABLE, true);
material_leaves1.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; 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); v3s16 p(x,y,z);
MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes+p); MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes+p);
/* /*
Add torches to mesh Add torches to mesh
*/ */
if(n.getContent() == CONTENT_TORCH) 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); video::SColor c(255,255,255,255);
// Wall at X+ of node // Wall at X+ of node
video::S3DVertex vertices[4] = 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,
video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, 1,1), ap.x0(), ap.y1()),
video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, 1,0), video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, 0,0), 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++) for(s32 i=0; i<4; i++)
{ {
if(dir == v3s16(1,0,0)) 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); 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}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material, vertices, 4, indices, 6); 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) 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)); u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
video::SColor c = MapBlock_LightColor(255, l); video::SColor c = MapBlock_LightColor(255, l);
@ -305,10 +322,14 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
// Wall at X+ of node // Wall at X+ of node
video::S3DVertex vertices[4] = 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,
video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1), ap.x0(), ap.y1()),
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,
video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), 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); v3s16 dir = unpackDir(n.param2);
@ -331,19 +352,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); 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}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material, vertices, 4, indices, 6); collector.append(material, vertices, 4, indices, 6);
@ -525,10 +533,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
video::S3DVertex vertices[4] = 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, video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
pa_liquid1.x0(), pa_liquid1.y1()), pa_liquid1.x0(), pa_liquid1.y1()),
video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 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 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, video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
pa_liquid1.x0(), pa_liquid1.y1()), pa_liquid1.x0(), pa_liquid1.y1()),
video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 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 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, video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
pa_liquid1.x0(), pa_liquid1.y1()), pa_liquid1.x0(), pa_liquid1.y1()),
video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 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 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, video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c,
pa_leaves1.x0(), pa_leaves1.y1()), pa_leaves1.x0(), pa_leaves1.y1()),
video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 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 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, video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c,
ap.x0(), ap.y1()), ap.x0(), ap.y1()),
video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 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 vertices[4] =
{ {
video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, 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, 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, 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, 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) if(j == 0)
@ -1077,9 +1065,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
} }
else if(n.getContent() == CONTENT_RAIL) 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_x [] = { false, false }; /* x-1, x+1 */
bool is_rail_z [] = { false, false }; /* z-1, z+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) if(n_plus_z.getContent() == CONTENT_RAIL)
is_rail_z[1] = true; is_rail_z[1] = true;
float d = (float)BS/16; int adjacencies = is_rail_x[0] + is_rail_x[1] + is_rail_z[0] + is_rail_z[1];
video::S3DVertex vertices[4] =
// Assign textures
const char *texturename = "rail.png";
if(adjacencies < 2)
texturename = "rail.png";
else if(adjacencies == 2)
{ {
video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c, if((is_rail_x[0] && is_rail_x[1]) || (is_rail_z[0] && is_rail_z[1]))
0, 1), texturename = "rail.png";
video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c, else
1, 1), texturename = "rail_curved.png";
video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c, }
1, 0), else if(adjacencies == 3)
video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c, texturename = "rail_t_junction.png";
0, 0), else if(adjacencies == 4)
}; texturename = "rail_crossing.png";
AtlasPointer ap = g_texturesource->getTexture(texturename);
video::SMaterial material_rail; video::SMaterial material_rail;
material_rail.setFlag(video::EMF_LIGHTING, false); material_rail.setFlag(video::EMF_LIGHTING, false);
material_rail.setFlag(video::EMF_BACK_FACE_CULLING, false); material_rail.setFlag(video::EMF_BACK_FACE_CULLING, true);
material_rail.setFlag(video::EMF_BILINEAR_FILTER, false); material_rail.setFlag(video::EMF_BILINEAR_FILTER, false);
material_rail.setFlag(video::EMF_FOG_ENABLE, true); material_rail.setFlag(video::EMF_FOG_ENABLE, true);
material_rail.MaterialType material_rail.MaterialType
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
material_rail.setTexture(0, ap.atlas);
int adjacencies = is_rail_x[0] + is_rail_x[1] + is_rail_z[0] + is_rail_z[1]; u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
video::SColor c = MapBlock_LightColor(255, l);
// Assign textures float d = (float)BS/16;
if(adjacencies < 2) video::S3DVertex vertices[4] =
material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png"));
else if(adjacencies == 2)
{ {
if((is_rail_x[0] && is_rail_x[1]) || (is_rail_z[0] && is_rail_z[1])) video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c,
material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); ap.x0(), ap.y1()),
else video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c,
material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png")); ap.x1(), ap.y1()),
} video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c,
else if(adjacencies == 3) ap.x1(), ap.y0()),
material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png")); video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c,
else if(adjacencies == 4) ap.x0(), ap.y0()),
material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png")); };
// Rotate textures // Rotate textures
int angle = 0; int angle = 0;
@ -1180,6 +1172,17 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
collector.append(material_rail, vertices, 4, indices, 6); collector.append(material_rail, vertices, 4, indices, 6);
} }
else if (n.getContent() == CONTENT_LADDER) { 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)); u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
video::SColor c(255,l,l,l); video::SColor c(255,l,l,l);
@ -1188,10 +1191,14 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
// Assume wall is at X+ // Assume wall is at X+
video::S3DVertex vertices[4] = 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,
video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1), ap.x0(), ap.y1()),
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,
video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), 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); v3s16 dir = unpackDir(n.param2);
@ -1214,14 +1221,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); 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}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material_ladder, vertices, 4, indices, 6); collector.append(material_ladder, vertices, 4, indices, 6);

View File

@ -220,6 +220,7 @@ void content_mapnode_init()
i = CONTENT_JUNGLEGRASS; i = CONTENT_JUNGLEGRASS;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("junglegrass.png"); f->setInventoryTexture("junglegrass.png");
f->used_texturenames["junglegrass.png"] = true;
f->light_propagates = true; f->light_propagates = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
//f->is_ground_content = true; //f->is_ground_content = true;
@ -265,6 +266,7 @@ void content_mapnode_init()
i = CONTENT_PAPYRUS; i = CONTENT_PAPYRUS;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("papyrus.png"); f->setInventoryTexture("papyrus.png");
f->used_texturenames["papyrus.png"] = true;
f->light_propagates = true; f->light_propagates = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->is_ground_content = true; f->is_ground_content = true;
@ -307,11 +309,13 @@ void content_mapnode_init()
f->solidness = 0; // drawn separately, makes no faces f->solidness = 0; // drawn separately, makes no faces
f->air_equivalent = true; // grass grows underneath f->air_equivalent = true; // grass grows underneath
f->setInventoryTexture("fence.png"); f->setInventoryTexture("fence.png");
f->used_texturenames["fence.png"] = true;
setWoodLikeDiggingProperties(f->digging_properties, 0.75); setWoodLikeDiggingProperties(f->digging_properties, 0.75);
i = CONTENT_RAIL; i = CONTENT_RAIL;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("rail.png"); f->setInventoryTexture("rail.png");
f->used_texturenames["rail.png"] = true;
f->light_propagates = true; f->light_propagates = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->is_ground_content = true; f->is_ground_content = true;
@ -324,6 +328,7 @@ void content_mapnode_init()
i = CONTENT_LADDER; i = CONTENT_LADDER;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("ladder.png"); f->setInventoryTexture("ladder.png");
f->used_texturenames["ladder.png"] = true;
f->light_propagates = true; f->light_propagates = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->is_ground_content = true; f->is_ground_content = true;
@ -466,6 +471,7 @@ void content_mapnode_init()
i = CONTENT_LAVA; i = CONTENT_LAVA;
f = &content_features(i); f = &content_features(i);
f->setInventoryTextureCube("lava.png", "lava.png", "lava.png"); f->setInventoryTextureCube("lava.png", "lava.png", "lava.png");
f->used_texturenames["lava.png"] = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->light_propagates = false; f->light_propagates = false;
f->light_source = LIGHT_MAX-1; f->light_source = LIGHT_MAX-1;
@ -502,6 +508,7 @@ void content_mapnode_init()
i = CONTENT_LAVASOURCE; i = CONTENT_LAVASOURCE;
f = &content_features(i); f = &content_features(i);
f->setInventoryTextureCube("lava.png", "lava.png", "lava.png"); f->setInventoryTextureCube("lava.png", "lava.png", "lava.png");
f->used_texturenames["ladder.png"] = true;
if(new_style_water) if(new_style_water)
{ {
f->solidness = 0; // drawn separately, makes no faces f->solidness = 0; // drawn separately, makes no faces
@ -555,6 +562,10 @@ void content_mapnode_init()
i = CONTENT_TORCH; i = CONTENT_TORCH;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("torch_on_floor.png"); 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->param_type = CPT_LIGHT;
f->light_propagates = true; f->light_propagates = true;
f->sunlight_propagates = true; f->sunlight_propagates = true;
@ -569,6 +580,7 @@ void content_mapnode_init()
i = CONTENT_SIGN_WALL; i = CONTENT_SIGN_WALL;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("sign_wall.png"); f->setInventoryTexture("sign_wall.png");
f->used_texturenames["sign_wall.png"] = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->light_propagates = true; f->light_propagates = true;
f->sunlight_propagates = true; f->sunlight_propagates = true;
@ -671,6 +683,7 @@ void content_mapnode_init()
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->setAllTextures("sapling.png"); f->setAllTextures("sapling.png");
f->setInventoryTexture("sapling.png"); f->setInventoryTexture("sapling.png");
f->used_texturenames["sapling.png"] = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->light_propagates = true; f->light_propagates = true;
f->air_equivalent = false; f->air_equivalent = false;
@ -681,6 +694,7 @@ void content_mapnode_init()
i = CONTENT_APPLE; i = CONTENT_APPLE;
f = &content_features(i); f = &content_features(i);
f->setInventoryTexture("apple.png"); f->setInventoryTexture("apple.png");
f->used_texturenames["apple.png"] = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->light_propagates = true; f->light_propagates = true;
f->sunlight_propagates = true; f->sunlight_propagates = true;

View File

@ -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 "main.h" // For g_settings and g_texturesource
#include "content_mapblock.h" #include "content_mapblock.h"
#include "settings.h" #include "settings.h"
#include "profiler.h"
void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block) void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block)
{ {
@ -527,7 +528,7 @@ void updateFastFaceRow(
next_tile); next_tile);
if(next_makes_face == makes_face 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_face_dir_corrected == face_dir_corrected
&& next_lights[0] == lights[0] && next_lights[0] == lights[0]
&& next_lights[1] == lights[1] && next_lights[1] == lights[1]
@ -537,6 +538,29 @@ void updateFastFaceRow(
{ {
next_is_different = false; 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++; continuous_tiles_count++;
@ -568,6 +592,8 @@ void updateFastFaceRow(
v3f pf(p_corrected.X, p_corrected.Y, p_corrected.Z); v3f pf(p_corrected.X, p_corrected.Y, p_corrected.Z);
// Center point of face (kind of) // Center point of face (kind of)
v3f sp = pf - ((f32)continuous_tiles_count / 2. - 0.5) * translate_dir_f; 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); v3f scale(1,1,1);
if(translate_dir.X != 0) if(translate_dir.X != 0)
@ -586,6 +612,11 @@ void updateFastFaceRow(
makeFastFace(tile, lights[0], lights[1], lights[2], lights[3], makeFastFace(tile, lights[0], lights[1], lights[2], lights[3],
sp, face_dir_corrected, scale, sp, face_dir_corrected, scale,
posRelative_f, dest); posRelative_f, dest);
g_profiler->avg("Meshgen: faces drawn by tiling", 0);
for(int i=1; i<continuous_tiles_count; i++){
g_profiler->avg("Meshgen: faces drawn by tiling", 1);
}
} }
continuous_tiles_count = 0; continuous_tiles_count = 0;
@ -707,10 +738,13 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
video::SMaterial material; video::SMaterial material;
material.setFlag(video::EMF_LIGHTING, false); 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_BILINEAR_FILTER, false);
material.setFlag(video::EMF_FOG_ENABLE, true); material.setFlag(video::EMF_FOG_ENABLE, true);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF); //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE); //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE);
material.MaterialType
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
for(u32 i=0; i<fastfaces_new.size(); i++) for(u32 i=0; i<fastfaces_new.size(); i++)
{ {

View File

@ -283,9 +283,9 @@ struct TileSpec
TileSpec(): TileSpec():
texture(0), texture(0),
alpha(255), alpha(255),
material_type(MATERIAL_ALPHA_NONE), //material_type(MATERIAL_ALPHA_NONE),
// Use this so that leaves don't need a separate material // Use this so that leaves don't need a separate material
//material_type(MATERIAL_ALPHA_SIMPLE), material_type(MATERIAL_ALPHA_SIMPLE),
material_flags( material_flags(
//0 // <- DEBUG, Use the one below //0 // <- DEBUG, Use the one below
MATERIAL_FLAG_BACKFACE_CULLING MATERIAL_FLAG_BACKFACE_CULLING