From abceeee92f99b84ebb79968269835a4f509bfb90 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 14 Nov 2011 00:19:48 +0200 Subject: Create framework for getting rid of global definitions of node/tool/item/whatever types --- src/mapblock_mesh.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/mapblock_mesh.cpp') diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index c81d5adc1..2f9f9ce43 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "settings.h" #include "profiler.h" #include "mapnode_contentfeatures.h" +#include "tile.h" void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block) { @@ -252,10 +253,10 @@ void makeFastFace(TileSpec tile, u8 li0, u8 li1, u8 li2, u8 li3, v3f p, Returns TILE_NODE if doesn't exist or should not be drawn. */ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, - NodeModMap &temp_mods) + NodeModMap &temp_mods, ITextureSource *tsrc) { TileSpec spec; - spec = mn.getTile(face_dir); + spec = mn.getTile(face_dir, tsrc); /* Check temporary modifications on this node @@ -272,7 +273,7 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, if(mod.type == NODEMOD_CHANGECONTENT) { MapNode mn2(mod.param); - spec = mn2.getTile(face_dir); + spec = mn2.getTile(face_dir, tsrc); } if(mod.type == NODEMOD_CRACK) { @@ -283,20 +284,20 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, // Get original texture name u32 orig_id = spec.texture.id; - std::string orig_name = g_texturesource->getTextureName(orig_id); + std::string orig_name = tsrc->getTextureName(orig_id); // Create new texture name std::ostringstream os; os<getTextureId(os.str()); + u32 new_id = tsrc->getTextureId(os.str()); /*dstream<<"MapBlock::getNodeTile(): Switching from " <getTexture(new_id); + spec.texture = tsrc->getTexture(new_id); } } @@ -412,6 +413,7 @@ void getTileInfo( VoxelManipulator &vmanip, NodeModMap &temp_mods, bool smooth_lighting, + ITextureSource *tsrc, // Output: bool &makes_face, v3s16 &p_corrected, @@ -422,8 +424,8 @@ void getTileInfo( { MapNode n0 = vmanip.getNodeNoEx(blockpos_nodes + p); MapNode n1 = vmanip.getNodeNoEx(blockpos_nodes + p + face_dir); - TileSpec tile0 = getNodeTile(n0, p, face_dir, temp_mods); - TileSpec tile1 = getNodeTile(n1, p + face_dir, -face_dir, temp_mods); + TileSpec tile0 = getNodeTile(n0, p, face_dir, temp_mods, tsrc); + TileSpec tile1 = getNodeTile(n1, p + face_dir, -face_dir, temp_mods, tsrc); // This is hackish content_t content0 = getNodeContent(p, n0, temp_mods); @@ -493,7 +495,8 @@ void updateFastFaceRow( NodeModMap &temp_mods, VoxelManipulator &vmanip, v3s16 blockpos_nodes, - bool smooth_lighting) + bool smooth_lighting, + ITextureSource *tsrc) { v3s16 p = startpos; @@ -505,7 +508,7 @@ void updateFastFaceRow( u8 lights[4] = {0,0,0,0}; TileSpec tile; getTileInfo(blockpos_nodes, p, face_dir, daynight_ratio, - vmanip, temp_mods, smooth_lighting, + vmanip, temp_mods, smooth_lighting, tsrc, makes_face, p_corrected, face_dir_corrected, lights, tile); for(u16 j=0; jm_temp_mods, data->m_vmanip, blockpos_nodes, - smooth_lighting); + smooth_lighting, + tsrc); } } /* @@ -706,7 +710,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) data->m_temp_mods, data->m_vmanip, blockpos_nodes, - smooth_lighting); + smooth_lighting, + tsrc); } } /* @@ -724,7 +729,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) data->m_temp_mods, data->m_vmanip, blockpos_nodes, - smooth_lighting); + smooth_lighting, + tsrc); } } } @@ -789,7 +795,7 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) - whatever */ - mapblock_mesh_generate_special(data, collector); + mapblock_mesh_generate_special(data, collector, tsrc); /* Add stuff from collector to mesh -- cgit v1.2.3