Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions trinity/Eve/SpaceObject/Children/EveChildMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,20 +1543,16 @@ std::pair<const Float4x3*, size_t> 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<size_t>( cmfData->meshes[meshIndex].boneBindings.size(), 1 );
boneCount = std::max<size_t>( 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 );
}
Expand Down
Loading