From 4e3b8db2b91a0b51ce604c56cbf6d1b839d0ecaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:11:16 +0200 Subject: [PATCH] Fix upright sprite entities not animating --- src/client/content_cao.cpp | 10 ++++++++++ src/client/mesh.cpp | 10 +--------- src/client/mesh.h | 7 ------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 5c008bca9..f67e57056 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -1267,6 +1267,16 @@ void GenericCAO::step(float dtime, ClientEnvironment *env) } } +static void setMeshBufferTextureCoords(scene::IMeshBuffer *buf, const v2f *uv, u32 count) +{ + assert(buf->getVertexType() == video::EVT_STANDARD); + assert(buf->getVertexCount() == count); + auto *vertices = static_cast(buf->getVertices()); + for (u32 i = 0; i < count; i++) + vertices[i].TCoords = uv[i]; + buf->setDirty(scene::EBT_VERTEX); +} + void GenericCAO::updateTexturePos() { if(m_spritenode) diff --git a/src/client/mesh.cpp b/src/client/mesh.cpp index 711f7e1c6..99131b049 100644 --- a/src/client/mesh.cpp +++ b/src/client/mesh.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "mesh.h" +#include "S3DVertex.h" #include "debug.h" #include "log.h" #include @@ -197,15 +198,6 @@ void setMeshColor(scene::IMesh *mesh, const video::SColor &color) setMeshBufferColor(mesh->getMeshBuffer(j), color); } -void setMeshBufferTextureCoords(scene::IMeshBuffer *buf, const v2f *uv, u32 count) -{ - const u32 stride = getVertexPitchFromType(buf->getVertexType()); - assert(buf->getVertexCount() >= count); - u8 *vertices = (u8 *) buf->getVertices(); - for (u32 i = 0; i < count; i++) - ((video::S3DVertex*) (vertices + i * stride))->TCoords = uv[i]; -} - template static void applyToMesh(scene::IMesh *mesh, const F &fn) { diff --git a/src/client/mesh.h b/src/client/mesh.h index 0c3e8942e..8c4d55f0f 100644 --- a/src/client/mesh.h +++ b/src/client/mesh.h @@ -59,13 +59,6 @@ void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor &color); */ void setMeshColor(scene::IMesh *mesh, const video::SColor &color); - -/* - Sets texture coords for vertices in the mesh buffer. - `uv[]` must have `count` elements -*/ -void setMeshBufferTextureCoords(scene::IMeshBuffer *buf, const v2f *uv, u32 count); - /* Set a constant color for an animated mesh */