From 0fdcba197f03435d2efeca9de61dc584bd594708 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 10 Sep 2024 18:59:16 +0200 Subject: [PATCH] Fix VBO hint in content_cao --- src/client/content_cao.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index b87d36c4f..467c74c42 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -814,15 +814,21 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) } /* Set VBO hint */ - // - if shaders are disabled we modify the mesh often - // - sprites are also modified often - // - the wieldmesh sets its own hint - // - bone transformations do not need to modify the vertex data + // wieldmesh sets its own hint, no need to handle it if (m_enable_shaders && (m_meshnode || m_animated_meshnode)) { - if (m_meshnode) + // sprite uses vertex animation + if (m_meshnode && m_prop.visual != "upright_sprite") m_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC); - if (m_animated_meshnode) - m_animated_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC); + + if (m_animated_meshnode) { + auto *mesh = m_animated_meshnode->getMesh(); + // skinning happens on the CPU + if (m_animated_meshnode->getJointCount() > 0) + mesh->setHardwareMappingHint(scene::EHM_STREAM, scene::EBT_VERTEX); + else + mesh->setHardwareMappingHint(scene::EHM_STATIC, scene::EBT_VERTEX); + mesh->setHardwareMappingHint(scene::EHM_STATIC, scene::EBT_INDEX); + } } /* don't update while punch texture modifier is active */