+ case NDT_MESH:
+ {
+ v3f pos = intToFloat(p, BS);
+ video::SColor c = MapBlock_LightColor(255, getInteriorLight(n, 1, nodedef), f.light_source);
+
+ u8 facedir = 0;
+ if (f.param_type_2 == CPT2_FACEDIR) {
+ facedir = n.getFaceDir(nodedef);
+ } else if (f.param_type_2 == CPT2_WALLMOUNTED) {
+ //convert wallmounted to 6dfacedir.
+ //when cache enabled, it is already converted
+ facedir = n.getWallMounted(nodedef);
+ if (!enable_mesh_cache) {
+ static const u8 wm_to_6d[6] = {20, 0, 16+1, 12+3, 8, 4+2};
+ facedir = wm_to_6d[facedir];
+ }
+ }
+
+ if (f.mesh_ptr[facedir]) {
+ // use cached meshes
+ for(u16 j = 0; j < f.mesh_ptr[0]->getMeshBufferCount(); j++) {
+ scene::IMeshBuffer *buf = f.mesh_ptr[facedir]->getMeshBuffer(j);
+ collector.append(getNodeTileN(n, p, j, data),
+ (video::S3DVertex *)buf->getVertices(), buf->getVertexCount(),
+ buf->getIndices(), buf->getIndexCount(), pos, c);
+ }
+ } else if (f.mesh_ptr[0]) {
+ // no cache, clone and rotate mesh
+ scene::IMesh* mesh = cloneMesh(f.mesh_ptr[0]);
+ rotateMeshBy6dFacedir(mesh, facedir);
+ recalculateBoundingBox(mesh);
+ meshmanip->recalculateNormals(mesh, true, false);
+ for(u16 j = 0; j < mesh->getMeshBufferCount(); j++) {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+ collector.append(getNodeTileN(n, p, j, data),
+ (video::S3DVertex *)buf->getVertices(), buf->getVertexCount(),
+ buf->getIndices(), buf->getIndexCount(), pos, c);
+ }
+ mesh->drop();
+ }
+ break;}
+ }
+ }
+
+ /*
+ Caused by incorrect alpha blending, selection mesh needs to be created as
+ last element to ensure it gets blended correct over nodes with alpha channel
+ */
+ // Create selection mesh
+ v3s16 p = data->m_highlighted_pos_relative;
+ if (data->m_show_hud &&
+ (p.X >= 0) && (p.X < MAP_BLOCKSIZE) &&
+ (p.Y >= 0) && (p.Y < MAP_BLOCKSIZE) &&
+ (p.Z >= 0) && (p.Z < MAP_BLOCKSIZE)) {
+
+ MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + p);
+ if(n.getContent() != CONTENT_AIR) {
+ // Get selection mesh light level
+ static const v3s16 dirs[7] = {
+ v3s16( 0, 0, 0),
+ v3s16( 0, 1, 0),
+ v3s16( 0,-1, 0),
+ v3s16( 1, 0, 0),
+ v3s16(-1, 0, 0),
+ v3s16( 0, 0, 1),
+ v3s16( 0, 0,-1)
+ };
+
+ u16 l = 0;
+ u16 l1 = 0;
+ for (u8 i = 0; i < 7; i++) {
+ MapNode n1 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p + dirs[i]);
+ l1 = getInteriorLight(n1, -4, nodedef);
+ if (l1 > l)
+ l = l1;
+ }
+ video::SColor c = MapBlock_LightColor(255, l, 0);
+ data->m_highlight_mesh_color = c;
+ std::vector<aabb3f> boxes = n.getSelectionBoxes(nodedef);
+ TileSpec h_tile;
+ h_tile.material_flags |= MATERIAL_FLAG_HIGHLIGHTED;
+ h_tile.texture = tsrc->getTexture("halo.png",&h_tile.texture_id);
+ v3f pos = intToFloat(p, BS);
+ f32 d = 0.05 * BS;
+ for (std::vector<aabb3f>::iterator i = boxes.begin();
+ i != boxes.end(); i++) {
+ aabb3f box = *i;
+ box.MinEdge += v3f(-d, -d, -d) + pos;
+ box.MaxEdge += v3f(d, d, d) + pos;
+ makeCuboid(&collector, box, &h_tile, 1, c, NULL);
+ }