FSkeletalMeshMerge and MorphTargets

I have also been doing the same thing, but found no way to do it. In 4.16 I was able to manually recreate the morph targets post merge. But in 4.18 this functionally has broken and I’m not sure why.

Here is what the 4.18 code looked like for morph copying. It should be noted that it is recreating the morphs rather than copying as not doing so causes the meshes to dirty. I can’t share the code due to contract agreements but some notes which may be helpful:

I needed to declare some externs and may have also had to edit the engine code for the following, it’s been a while between multiple engine versions so not sure.

	extern ENGINE_API FMorphTargetDelta* GetMorphTargetDelta(int32 LODIndex, int32& OutNumDeltas); 
	extern ENGINE_API bool HasDataForLOD(int32 LODIndex); 

I had to create an array to track the vertex location for each LOD level. I’d loop through the merged meshes and add the NumVertices for each LOD level. It seems the vertices here are ordered by LOD level. So after processing each mesh you need to add the vertices to an array that adds the number of vertices for that LOD, so the next mesh can add that value to the SourceIdx for the morph target.

I looped through each of the piece meshes and grabbed the LOD info, then created a new MorphTargetDelta that copied the information the original but on SourceIDX it added the vertex count we had stored in the array. Then rather than calling RegisterMorphTarget I made a trimmed version it which would simply set the mesh for it add it to MorphTargets and then add it to MorphTargetsIndexMap. If you call register morph target it’s going to keep rebuilding your morph targets and dirtying the mesh every time you add one.

This would set up the morph targets up, and then you could use SetMorphTarget on them post-merge. That worked fine in 4.16. It broke when we moved to 4.18 and I haven’t been able to figure out why yet. But it should help get you on the right track.