diff --git a/src/client/content_mapblock.cpp b/src/client/content_mapblock.cpp index 4d1eeec47..3b30d5170 100644 --- a/src/client/content_mapblock.cpp +++ b/src/client/content_mapblock.cpp @@ -1685,22 +1685,27 @@ void MapblockMeshGenerator::drawMeshNode() video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices(); u32 vertex_count = buf->getVertexCount(); + // Mesh is always private here. So the lighting is applied to each + // vertex right here. if (data->m_smooth_lighting) { - // Mesh is always private here. So the lighting is applied to each - // vertex right here. for (u32 k = 0; k < vertex_count; k++) { video::S3DVertex &vertex = vertices[k]; vertex.Color = blendLightColor(vertex.Pos, vertex.Normal); vertex.Pos += cur_node.origin; } - collector->append(cur_node.tile, vertices, vertex_count, - buf->getIndices(), buf->getIndexCount()); } else { - // Let the collector process colors, etc. - collector->append(cur_node.tile, vertices, vertex_count, - buf->getIndices(), buf->getIndexCount(), cur_node.origin, - cur_node.color, cur_node.f->light_source); + bool is_light_source = cur_node.f->light_source != 0; + for (u32 k = 0; k < vertex_count; k++) { + video::S3DVertex &vertex = vertices[k]; + video::SColor color = cur_node.color; + if (!is_light_source) + applyFacesShading(color, vertex.Normal); + vertex.Color = color; + vertex.Pos += cur_node.origin; + } } + collector->append(cur_node.tile, vertices, vertex_count, + buf->getIndices(), buf->getIndexCount()); } mesh->drop(); } diff --git a/src/client/meshgen/collector.cpp b/src/client/meshgen/collector.cpp index 476f3112b..5a4fb8489 100644 --- a/src/client/meshgen/collector.cpp +++ b/src/client/meshgen/collector.cpp @@ -41,45 +41,6 @@ void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *verti p.indices.push_back(indices[i] + vertex_count); } -void MeshCollector::append(const TileSpec &tile, const video::S3DVertex *vertices, - u32 numVertices, const u16 *indices, u32 numIndices, v3f pos, - video::SColor c, u8 light_source) -{ - for (int layernum = 0; layernum < MAX_TILE_LAYERS; layernum++) { - const TileLayer *layer = &tile.layers[layernum]; - if (layer->texture_id == 0) - continue; - append(*layer, vertices, numVertices, indices, numIndices, pos, c, - light_source, layernum, tile.world_aligned); - } -} - -void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *vertices, - u32 numVertices, const u16 *indices, u32 numIndices, v3f pos, - video::SColor c, u8 light_source, u8 layernum, bool use_scale) -{ - PreMeshBuffer &p = findBuffer(layer, layernum, numVertices); - - f32 scale = 1.0f; - if (use_scale) - scale = 1.0f / layer.scale; - - u32 vertex_count = p.vertices.size(); - for (u32 i = 0; i < numVertices; i++) { - video::SColor color = c; - if (!light_source) - applyFacesShading(color, vertices[i].Normal); - auto vpos = vertices[i].Pos + pos + offset; - p.vertices.emplace_back(vpos, vertices[i].Normal, color, - scale * vertices[i].TCoords); - m_bounding_radius_sq = std::max(m_bounding_radius_sq, - (vpos - m_center_pos).getLengthSQ()); - } - - for (u32 i = 0; i < numIndices; i++) - p.indices.push_back(indices[i] + vertex_count); -} - PreMeshBuffer &MeshCollector::findBuffer( const TileLayer &layer, u8 layernum, u32 numVertices) { diff --git a/src/client/meshgen/collector.h b/src/client/meshgen/collector.h index 79256e262..693e2be04 100644 --- a/src/client/meshgen/collector.h +++ b/src/client/meshgen/collector.h @@ -35,21 +35,12 @@ struct MeshCollector void append(const TileSpec &material, const video::S3DVertex *vertices, u32 numVertices, const u16 *indices, u32 numIndices); - void append(const TileSpec &material, - const video::S3DVertex *vertices, u32 numVertices, - const u16 *indices, u32 numIndices, - v3f pos, video::SColor c, u8 light_source); private: void append(const TileLayer &material, const video::S3DVertex *vertices, u32 numVertices, const u16 *indices, u32 numIndices, u8 layernum, bool use_scale = false); - void append(const TileLayer &material, - const video::S3DVertex *vertices, u32 numVertices, - const u16 *indices, u32 numIndices, - v3f pos, video::SColor c, u8 light_source, - u8 layernum, bool use_scale = false); PreMeshBuffer &findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices); };