From: Perttu Ahola Date: Sat, 23 Jul 2011 16:04:37 +0000 (+0300) Subject: merged the content type extension and delta X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=2587bb361cfc96b3a695d1476e39b9c0ecaa6553;p=zefram%2Fminetest%2Fminetest_engine.git merged the content type extension and delta --- 2587bb361cfc96b3a695d1476e39b9c0ecaa6553 diff --cc src/content_mapblock.cpp index 38bc9620,d8bf71dc..4a9fa5e9 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@@ -895,14 -904,56 +905,56 @@@ void mapblock_mesh_generate_special(Mes vertices[i].Pos.rotateXZBy(90); } else if(j == 4) + + 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_general, vertices, 4, indices, 6); + } + } + #endif - else if(n.d == CONTENT_PAPYRUS) ++ else if(n.getContent() == CONTENT_PAPYRUS) + { + u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); + video::SColor c(255,l,l,l); + + for(u32 j=0; j<4; j++) + { + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, + pa_papyrus.x0(), pa_papyrus.y1()), + video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, + pa_papyrus.x1(), pa_papyrus.y1()), + video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, + pa_papyrus.x1(), pa_papyrus.y0()), + video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, + pa_papyrus.x0(), pa_papyrus.y0()), + }; + + if(j == 0) { for(u16 i=0; i<4; i++) - vertices[i].Pos.rotateYZBy(-90); + vertices[i].Pos.rotateXZBy(45); } - else if(j == 5) + else if(j == 1) { for(u16 i=0; i<4; i++) - vertices[i].Pos.rotateYZBy(90); + vertices[i].Pos.rotateXZBy(-45); + } + else if(j == 2) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(135); + } + else if(j == 3) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(-135); } for(u16 i=0; i<4; i++) @@@ -912,11 -963,113 +964,113 @@@ u16 indices[] = {0,1,2,2,3,0}; // Add to mesh collector - collector.append(material_general, vertices, 4, indices, 6); + collector.append(material_papyrus, vertices, 4, indices, 6); } } - #endif - else if(n.d == CONTENT_RAIL) ++ else if(n.getContent() == CONTENT_RAIL) + { + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); + video::SColor c(255,l,l,l); + + bool is_rail_x [] = { false, false }; /* x-1, x+1 */ + bool is_rail_z [] = { false, false }; /* z-1, z+1 */ + + MapNode n_minus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x-1,y,z)); + MapNode n_plus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x+1,y,z)); + MapNode n_minus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z-1)); + MapNode n_plus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z+1)); + - if(n_minus_x.d == CONTENT_RAIL) ++ if(n_minus_x.getContent() == CONTENT_RAIL) + is_rail_x[0] = true; - if(n_plus_x.d == CONTENT_RAIL) ++ if(n_plus_x.getContent() == CONTENT_RAIL) + is_rail_x[1] = true; - if(n_minus_z.d == CONTENT_RAIL) ++ if(n_minus_z.getContent() == CONTENT_RAIL) + is_rail_z[0] = true; - if(n_plus_z.d == CONTENT_RAIL) ++ 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 + if(adjacencies < 2) + 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])) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + else + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png")); + } + else if(adjacencies == 3) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png")); + else if(adjacencies == 4) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png")); + // Rotate textures + int angle = 0; + + if(adjacencies == 1) + { + if(is_rail_x[0] || is_rail_x[1]) + angle = 90; + } + else if(adjacencies == 2) + { + if(is_rail_x[0] && is_rail_x[1]) + angle = 90; + else if(is_rail_x[0] && is_rail_z[0]) + angle = 270; + else if(is_rail_x[0] && is_rail_z[1]) + angle = 180; + else if(is_rail_x[1] && is_rail_z[1]) + angle = 90; + } + else if(adjacencies == 3) + { + if(!is_rail_x[0]) + angle=0; + if(!is_rail_x[1]) + angle=180; + if(!is_rail_z[0]) + angle=90; + if(!is_rail_z[1]) + angle=270; + } + + if(angle != 0) { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(angle); + } + + for(s32 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + u16 indices[] = {0,1,2,2,3,0}; + collector.append(material_rail, vertices, 4, indices, 6); + } } } #endif diff --cc src/content_mapnode.cpp index e2aed245,79e10fd6..8701ab88 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@@ -31,59 -31,6 +31,65 @@@ void setStoneLikeDiggingProperties(Digg void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness); void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness); +content_t trans_table_19[][2] = { + {CONTENT_GRASS, 1}, + {CONTENT_TREE, 4}, + {CONTENT_LEAVES, 5}, + {CONTENT_GRASS_FOOTSTEPS, 6}, + {CONTENT_MESE, 7}, + {CONTENT_MUD, 8}, + {CONTENT_CLOUD, 10}, + {CONTENT_COALSTONE, 11}, + {CONTENT_WOOD, 12}, + {CONTENT_SAND, 13}, + {CONTENT_COBBLE, 18}, + {CONTENT_STEEL, 19}, + {CONTENT_GLASS, 20}, + {CONTENT_MOSSYCOBBLE, 22}, + {CONTENT_GRAVEL, 23}, ++ {CONTENT_SANDSTONE, 24}, ++ {CONTENT_CACTUS, 25}, ++ {CONTENT_BRICK, 26}, ++ {CONTENT_CLAY, 27}, ++ {CONTENT_PAPYRUS, 28}, ++ {CONTENT_BOOKSHELF, 29}, +}; + +MapNode mapnode_translate_from_internal(MapNode n_from, u8 version) +{ + MapNode result = n_from; + if(version <= 19) + { + content_t c_from = n_from.getContent(); + for(u32 i=0; i box; + + box = core::aabbox3d(vertices[0]); + box.addInternalPoint(vertices[1]); + + if(distance < mindistance) + { + if(box.intersectsWithLine(shootline)) + { + nodefound = true; + nodepos = np; + neighbourpos = np; + mindistance = distance; + nodehilightbox = box; + } + } + } /* Regular blocks */ diff --cc src/main.cpp index 5aff62bf,9a1e1960..783faa4e --- a/src/main.cpp +++ b/src/main.cpp @@@ -355,8 -337,14 +355,14 @@@ TODO: Restart irrlicht completely when TODO: Merge bahamada's audio stuff (clean patch available) -TODO: Merge key configuration menu (no clean patch available) +TODO: Move content_features to mapnode_content_features.{h,cpp} or so + TODO: Add some kind of content range validation to mapnode serialization + + TODO: Make sure menu text position is fixed + + TODO: Fix sector over limits error + Making it more portable: ------------------------ diff --cc src/mapgen.cpp index d4143b6d,8dda93c9..bc4f8228 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@@ -1894,7 -1938,7 +1938,7 @@@ void make_block(BlockMakeData *data { u32 i = data->vmanip->m_area.index(p); MapNode *n = &data->vmanip->m_data[i]; - if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_IGNORE) - if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE && n->d != CONTENT_IGNORE) ++ if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_WATERSOURCE && n->getContent() != CONTENT_IGNORE) { found = true; break; @@@ -1909,13 -1951,29 +1951,29 @@@ { u32 i = data->vmanip->m_area.index(p); MapNode *n = &data->vmanip->m_data[i]; - if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS) - continue; + - if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND) ++ if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS && n->getContent() != CONTENT_SAND) + continue; + + // Papyrus grows only on mud and in water - if(n->d == CONTENT_MUD && y <= WATER_LEVEL) ++ if(n->getContent() == CONTENT_MUD && y <= WATER_LEVEL) + { + p.Y++; + make_papyrus(vmanip, p); + } + // Trees grow only on mud and grass, on land - else if((n->d == CONTENT_MUD || n->d == CONTENT_GRASS) && y > WATER_LEVEL + 2) ++ else if((n->getContent() == CONTENT_MUD || n->getContent() == CONTENT_GRASS) && y > WATER_LEVEL + 2) + { + p.Y++; + make_tree(vmanip, p); + } + // Cactii grow only on sand, on land - else if(n->d == CONTENT_SAND && y > WATER_LEVEL + 2) ++ else if(n->getContent() == CONTENT_SAND && y > WATER_LEVEL + 2) + { + p.Y++; + make_cactus(vmanip, p); + } } - // Tree will be placed one higher - p.Y++; - // Make a tree - make_tree(vmanip, p); } #if 0 diff --cc src/mapnode.h index 1b10a546,33128049..3b7ef587 --- a/src/mapnode.h +++ b/src/mapnode.h @@@ -146,8 -150,10 +146,10 @@@ struct ContentFeature NodeMetadata *initial_metadata; // If the content is liquid, this is the flowing version of the liquid. - // If content is flowing liquid, this is the same content. - u8 liquid_alternative_flowing; + // If content is liquid, this is the same content. + content_t liquid_alternative_flowing; + // If the content is liquid, this is the source version of the liquid. - u8 liquid_alternative_source; ++ content_t liquid_alternative_source; // Amount of light the node emits u8 light_source;