From 087bbe624f6e0de50c409866faa8fce4585808c0 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 9 May 2014 16:03:54 -0700 Subject: BGE: Fixing shape key animations on meshes with no armature. Their transverts were not being updated after code changes for multi-threaded skinning. --- source/gameengine/Converter/BL_ShapeDeformer.cpp | 3 + source/gameengine/Converter/BL_SkinDeformer.cpp | 73 +++++++++++++----------- source/gameengine/Converter/BL_SkinDeformer.h | 2 + 3 files changed, 45 insertions(+), 33 deletions(-) (limited to 'source/gameengine/Converter') diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 8bb9f850bcf..b9b2732276e 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -222,6 +222,9 @@ bool BL_ShapeDeformer::Update(void) if (m_recalcNormal) RecalcNormals(); #endif + + // We also need to handle transverts now (used to be in BL_SkinDeformer::Apply()) + UpdateTransverts(); bSkinUpdate = true; } diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 8e1f51238d5..e7137a5c379 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -287,6 +287,43 @@ void BL_SkinDeformer::BGEDeformVerts() m_copyNormals = true; } +void BL_SkinDeformer::UpdateTransverts() +{ + RAS_MeshSlot::iterator it; + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + size_t i, nmat, imat; + + if (m_transverts) { + // the vertex cache is unique to this deformer, no need to update it + // if it wasn't updated! We must update all the materials at once + // because we will not get here again for the other material + nmat = m_pMeshObject->NumMaterials(); + for (imat=0; imatGetMeshMaterial(imat); + if (!mmat->m_slots[(void*)m_gameobj]) + continue; + + slot = *mmat->m_slots[(void*)m_gameobj]; + + // for each array + for (slot->begin(it); !slot->end(it); slot->next(it)) { + // for each vertex + // copy the untransformed data from the original mvert + for (i=it.startvertex; iRestorePose(); /* dynamic vertex, cannot use display list */ m_bDynamic = true; - /* indicate that the m_transverts and normals are up to date */ - RAS_MeshSlot::iterator it; - RAS_MeshMaterial *mmat; - RAS_MeshSlot *slot; - size_t i, nmat, imat; - - if (m_transverts) { - // the vertex cache is unique to this deformer, no need to update it - // if it wasn't updated! We must update all the materials at once - // because we will not get here again for the other material - nmat = m_pMeshObject->NumMaterials(); - for (imat=0; imatGetMeshMaterial(imat); - if (!mmat->m_slots[(void*)m_gameobj]) - continue; - - slot = *mmat->m_slots[(void*)m_gameobj]; - - // for each array - for (slot->begin(it); !slot->end(it); slot->next(it)) { - // for each vertex - // copy the untransformed data from the original mvert - for (i=it.startvertex; i