diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp index 2085ad14a..09873a5de 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp @@ -1543,20 +1543,16 @@ std::pair EveChildMesh::GetRestPoseBoneTransforms() con return std::make_pair( nullptr, 0 ); } - // Skinned shaders without an animation get rest-pose (identity) skin matrices, sized to the - // geometry's bone bindings. Unskinned geometry drawn with a skinned shader (e.g. a SOF hull - // flagged isSkinned) has no bindings and no blend indices in the vertex stream, so every - // vertex reads bone 0 - a single identity matrix covers it. + // Fixes skinned shader used with uninitialized animationUpdater (no skeleton), or used with no boneBindings. Otherwise shader would read garbage. size_t boneCount = 1; - auto cmfData = m_mesh->GetGeometryResource()->GetCMFData(); - auto meshIndex = m_mesh->GetMeshIndex(); - if( cmfData && meshIndex < cmfData->meshes.size() ) + auto meshData = m_mesh->GetGeometryResource()->GetMeshData( m_mesh->GetMeshIndex() ); + if( meshData ) { - boneCount = std::max( cmfData->meshes[meshIndex].boneBindings.size(), 1 ); + boneCount = std::max( meshData->m_jointBindings.size(), 1 ); } if( m_restPoseBoneTransforms.size() != boneCount ) { - m_restPoseBoneTransforms.assign( boneCount, Float4x3( Matrix() ) ); + m_restPoseBoneTransforms.assign( boneCount, Float4x3( IdentityMatrix() ) ); } return std::make_pair( m_restPoseBoneTransforms.data(), boneCount ); }