Fix for GHI-4644: mesh optimization breaking skin influences (DCO fix) (#6336)
* Average incoming skin influences when multiple vertices have been welded. This is one option which will average out the weights even if two welded vertices have differing boneIds, but we probably also need to add the influences earlier in the process and enforce a process where the vertices do not get welded if they have influences with differing boneIds Signed-off-by: Tommy Walton <waltont@amazon.com> * Move skin influences from MeshBuilderSkinningInfo to the vertex attribute layers so they are considered when choosing which vertices can be welded and so they are not duplicated when compatible vertices have been welded Signed-off-by: Tommy Walton <waltont@amazon.com> * Updating unit tests Signed-off-by: Tommy Walton <waltont@amazon.com> * Remove unused functions Signed-off-by: Tommy Walton <waltont@amazon.com> * Update based on feedback from burelc Signed-off-by: Tommy Walton <waltont@amazon.com>
This commit is contained in:
@@ -948,19 +948,17 @@ namespace AZ
|
||||
{
|
||||
AZStd::vector<uint16_t>& skinJointIndices = productMesh.m_skinJointIndices;
|
||||
AZStd::vector<float>& skinWeights = productMesh.m_skinWeights;
|
||||
const auto& sourceMeshData = sourceMesh.m_meshData;
|
||||
|
||||
size_t numInfluencesAdded = 0;
|
||||
for (const auto& skinData : sourceMesh.m_skinData)
|
||||
{
|
||||
const AZ::u32 controlPointIndex = sourceMeshData->GetControlPointIndex(static_cast<int>(vertexIndex));
|
||||
const size_t numSkinInfluences = skinData->GetLinkCount(controlPointIndex);
|
||||
const size_t numSkinInfluences = skinData->GetLinkCount(vertexIndex);
|
||||
|
||||
size_t numInfluencesExcess = 0;
|
||||
|
||||
for (size_t influenceIndex = 0; influenceIndex < numSkinInfluences; ++influenceIndex)
|
||||
{
|
||||
const AZ::SceneAPI::DataTypes::ISkinWeightData::Link& link = skinData->GetLink(controlPointIndex, influenceIndex);
|
||||
const AZ::SceneAPI::DataTypes::ISkinWeightData::Link& link = skinData->GetLink(vertexIndex, influenceIndex);
|
||||
|
||||
const float weight = link.weight;
|
||||
const AZStd::string& boneName = skinData->GetBoneName(link.boneId);
|
||||
|
||||
Reference in New Issue
Block a user