[C++] Persistant Morph Target Data

Hi Community and UE Team,

I have a quick question regarding USkeletalMesh. I was wondering where one needs to store Morph Target data to have it be persistent between unreal editor sessions.

I currently have code that merges multiple Skeletal Meshes together and saves out the data onto the FSkeletalMeshLODModel which allows it to be loaded again in the next sessions.

I have some simple tests with baking down SKMs which are working, and are persistant.

The trouble I face at the moment is when I add a Morph target using C++

```C++
auto* MorphTarget1 = NewObject(MergeMesh, “Section0”);
auto* MorphTarget2 = NewObject(MergeMesh, “Section1”);

MorphTarget1->PopulateDeltas({FMorphTargetDelta({0.f,1.f,0.f},{0.f,0.f,1.f}, 0)}, 0,MergeMesh->GetImportedModel()->LODModels[0].Sections, true);
MorphTarget2->PopulateDeltas({FMorphTargetDelta({0.f,0.f,1.f},{0.f,0.f,1.f}, 0)}, 0,MergeMesh->GetImportedModel()->LODModels[0].Sections, true);

MergeMesh->RegisterMorphTarget(MorphTarget1, false);
MergeMesh->RegisterMorphTarget(MorphTarget2, false);

MergeMesh->InitMorphTargetsAndRebuildRenderData();

```
The Morph targets are added and I can test activate them and see the first vertex being modified. When I start editor again the blendshapes are no longer added.

Any help will be greatly appreciated

Thanks

Never mind, it looks like it is the Morph Targets are being saved out onto the uasset, and the issue is at asset LoadInternal time. Somthing is causing the MT’s to be removed. I am still going through the Load Internal methods to narrow down the issue.

I was wondering if anyone might know what might cause the MT’s to be removed, I think it may have something to do with the custom constructed FSkeletalMeshLODModel, and overlapping vertices.

Solution Found.

  • As the SKM’s I am working with are generated by merging multiple SKMs together, they have no source data.
  • When the merged SKM gets loaded, as it has no source data Unreal assumes it is a Reduced SKM, resulting in the MorphTargets being removed if the RemapMorphTargets is not set to True.

I was wondering if anyone else has encountered this, and if there is a better or alternative way of achieving this?

I have thought about populating the source data instead of the ImportModel, but at this moment in time that investigation will have to wait.