1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

content_cao: Support texture animation for upright_sprite (#10020)

This commit is contained in:
sfan5 2020-07-30 17:39:57 +02:00 committed by GitHub
parent e5725dfb8e
commit 9bba52c400
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 14 deletions

View file

@ -1176,6 +1176,7 @@ void GenericCAO::updateTexturePos()
int row = m_tx_basepos.Y;
int col = m_tx_basepos.X;
// Yawpitch goes rightwards
if (m_tx_select_horiz_by_yawpitch) {
if (cam_to_entity.Y > 0.75)
col += 5;
@ -1206,6 +1207,27 @@ void GenericCAO::updateTexturePos()
float tys = m_tx_size.Y;
setBillboardTextureMatrix(m_spritenode, txs, tys, col, row);
}
else if (m_meshnode) {
if (m_prop.visual == "upright_sprite") {
int row = m_tx_basepos.Y;
int col = m_tx_basepos.X;
// Animation goes downwards
row += m_anim_frame;
const auto &tx = m_tx_size;
v2f t[4] = { // cf. vertices in GenericCAO::addToScene()
tx * v2f(col+1, row+1),
tx * v2f(col, row+1),
tx * v2f(col, row),
tx * v2f(col+1, row),
};
auto mesh = m_meshnode->getMesh();
setMeshBufferTextureCoords(mesh->getMeshBuffer(0), t, 4);
setMeshBufferTextureCoords(mesh->getMeshBuffer(1), t, 4);
}
}
}
// Do not pass by reference, see header.
@ -1247,7 +1269,7 @@ void GenericCAO::updateTextures(std::string mod)
}
}
if (m_animated_meshnode) {
else if (m_animated_meshnode) {
if (m_prop.visual == "mesh") {
for (u32 i = 0; i < m_prop.textures.size() &&
i < m_animated_meshnode->getMaterialCount(); ++i) {
@ -1296,8 +1318,8 @@ void GenericCAO::updateTextures(std::string mod)
}
}
}
if(m_meshnode)
{
else if (m_meshnode) {
if(m_prop.visual == "cube")
{
for (u32 i = 0; i < 6; ++i)