+}
+
+/*
+ MeshCollector - for meshnodes and converted drawtypes.
+*/
+
+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)
+{
+ if (numIndices > 65535) {
+ dstream << "FIXME: MeshCollector::append() called with numIndices="
+ << numIndices << " (limit 65535)" << std::endl;
+ return;
+ }
+ std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
+
+ PreMeshBuffer *p = NULL;
+ for (PreMeshBuffer &pp : *buffers) {
+ if (pp.layer == layer && pp.indices.size() + numIndices <= 65535) {
+ p = &pp;
+ break;
+ }
+ }
+
+ if (p == NULL) {
+ PreMeshBuffer pp;
+ pp.layer = layer;
+ buffers->push_back(pp);
+ p = &(*buffers)[buffers->size() - 1];
+ }
+
+ f32 scale = 1.0;
+ if (use_scale)
+ scale = 1.0 / layer.scale;
+
+ video::SColor original_c = c;
+ u32 vertex_count;
+ if (m_use_tangent_vertices) {
+ vertex_count = p->tangent_vertices.size();
+ for (u32 i = 0; i < numVertices; i++) {
+ if (!light_source) {
+ c = original_c;
+ applyFacesShading(c, vertices[i].Normal);
+ }
+ video::S3DVertexTangents vert(vertices[i].Pos + pos,
+ vertices[i].Normal, c, scale * vertices[i].TCoords);
+ p->tangent_vertices.push_back(vert);
+ }
+ } else {
+ vertex_count = p->vertices.size();
+ for (u32 i = 0; i < numVertices; i++) {
+ if (!light_source) {
+ c = original_c;
+ applyFacesShading(c, vertices[i].Normal);
+ }
+ video::S3DVertex vert(vertices[i].Pos + pos, vertices[i].Normal, c,
+ scale * vertices[i].TCoords);
+ p->vertices.push_back(vert);
+ }