mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-31 18:31:04 +00:00
Fix texture coordinates of cuboid drawtypes (#16091)
Fixes issues related to combining animated and world-aligned textures. Changes texture coordinates of cuboid drawtypes to stay in the [0,1] range, instead of carrying the mapblock alignment and becoming negative after transformations.
This commit is contained in:
parent
2f1171e2a7
commit
d17f22f536
4 changed files with 80 additions and 47 deletions
|
@ -14,25 +14,19 @@ void MeshCollector::append(const TileSpec &tile, const video::S3DVertex *vertice
|
|||
const TileLayer *layer = &tile.layers[layernum];
|
||||
if (layer->empty())
|
||||
continue;
|
||||
append(*layer, vertices, numVertices, indices, numIndices, layernum,
|
||||
tile.world_aligned);
|
||||
append(*layer, vertices, numVertices, indices, numIndices, layernum);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *vertices,
|
||||
u32 numVertices, const u16 *indices, u32 numIndices, u8 layernum,
|
||||
bool use_scale)
|
||||
u32 numVertices, const u16 *indices, u32 numIndices, u8 layernum)
|
||||
{
|
||||
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++) {
|
||||
p.vertices.emplace_back(vertices[i].Pos + offset, vertices[i].Normal,
|
||||
vertices[i].Color, scale * vertices[i].TCoords);
|
||||
vertices[i].Color, vertices[i].TCoords);
|
||||
m_bounding_radius_sq = std::max(m_bounding_radius_sq,
|
||||
(vertices[i].Pos - m_center_pos).getLengthSQ());
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
void append(const TileLayer &material,
|
||||
const video::S3DVertex *vertices, u32 numVertices,
|
||||
const u16 *indices, u32 numIndices,
|
||||
u8 layernum, bool use_scale = false);
|
||||
u8 layernum);
|
||||
|
||||
PreMeshBuffer &findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue