mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Remove the unnecessary MeshCollector::append overload
This commit is contained in:
parent
436b391a80
commit
cbc074feb5
3 changed files with 13 additions and 56 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue