You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira UE-154036 #rnx #preflight 628e6445f622d972b58cb184 [CL 20368031 by halfdan ingvarsson in ue5-main branch]
49 lines
2.1 KiB
C++
49 lines
2.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SkeletalMeshOperations.h"
|
|
|
|
#include "SkeletalMeshAttributes.h"
|
|
#include "BoneWeights.h"
|
|
|
|
|
|
DEFINE_LOG_CATEGORY(LogSkeletalMeshOperations);
|
|
|
|
#define LOCTEXT_NAMESPACE "SkeletalMeshOperations"
|
|
|
|
//Add specific skeletal mesh descriptions implementation here
|
|
void FSkeletalMeshOperations::AppendSkinWeight(const FMeshDescription& SourceMesh, FMeshDescription& TargetMesh, FSkeletalMeshAppendSettings& AppendSettings)
|
|
{
|
|
TRACE_CPUPROFILER_EVENT_SCOPE_STR("FSkeletalMeshOperations::AppendSkinWeight");
|
|
FSkeletalMeshConstAttributes SourceSkeletalMeshAttributes(SourceMesh);
|
|
|
|
FSkeletalMeshAttributes TargetSkeletalMeshAttributes(TargetMesh);
|
|
TargetSkeletalMeshAttributes.Register();
|
|
|
|
FSkinWeightsVertexAttributesConstRef SourceVertexSkinWeights = SourceSkeletalMeshAttributes.GetVertexSkinWeights();
|
|
FSkinWeightsVertexAttributesRef TargetVertexSkinWeights = TargetSkeletalMeshAttributes.GetVertexSkinWeights();
|
|
|
|
TargetMesh.SuspendVertexIndexing();
|
|
|
|
for (const FVertexID SourceVertexID : SourceMesh.Vertices().GetElementIDs())
|
|
{
|
|
const FVertexID TargetVertexID = FVertexID(AppendSettings.SourceVertexIDOffset + SourceVertexID.GetValue());
|
|
FVertexBoneWeightsConst SourceBoneWeights = SourceVertexSkinWeights.Get(SourceVertexID);
|
|
TArray<UE::AnimationCore::FBoneWeight> TargetBoneWeights;
|
|
const int32 InfluenceCount = SourceBoneWeights.Num();
|
|
for (int32 InfluenceIndex = 0; InfluenceIndex < InfluenceCount; ++InfluenceIndex)
|
|
{
|
|
const FBoneIndexType SourceBoneIndex = SourceBoneWeights[InfluenceIndex].GetBoneIndex();
|
|
if(AppendSettings.SourceRemapBoneIndex.IsValidIndex(SourceBoneIndex))
|
|
{
|
|
UE::AnimationCore::FBoneWeight& TargetBoneWeight = TargetBoneWeights.AddDefaulted_GetRef();
|
|
TargetBoneWeight.SetBoneIndex(AppendSettings.SourceRemapBoneIndex[SourceBoneIndex]);
|
|
TargetBoneWeight.SetRawWeight(SourceBoneWeights[InfluenceIndex].GetRawWeight());
|
|
}
|
|
}
|
|
TargetVertexSkinWeights.Set(TargetVertexID, TargetBoneWeights);
|
|
}
|
|
|
|
TargetMesh.ResumeVertexIndexing();
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |