GetCPUSkinnedVertices doesn't use morph targets like it promises. Am I missing something?

I’m trying to get the vertex data from a skeletal mesh that has been changed using morph targets. Everything I’ve tried so far just gets me the original shape. GetCPUSkinnedVertices said that is would include morph targets, but it doesn’t. I’ve made sure it’s not doing the morphs on the GPU. Any help would be appreciated.

Code:

Mesh->GetCPUSkinnedVertices(VertData, 0);

for (int i = 0; i < VertData.Num(); i++)
{
Locations.Add(VertData[i].Position);
}

and to test I’m just looping through the results in BP and drawing a debug point.

I’ve also tried ComputeSkinnedPositions, but that seems to now need me to suspend the render thread, which I’m not sure how to do.

Still not working in 4.20.

Did you ever figure this out?

Bump. Tried this is 4.22.1, my mesh has CPU access enabled, and my materials support morph targets too. Can’t seem to get this to work.

its a bug. in function USkinnedMeshComponent::GetCPUSkinnedVertices

// Recreate render state and flush the renderer
RecreateRenderState_Concurrent();

this would empty the active morph targets.

To slove this bug:

replace:

// Recreate render state and flush the renderer 
RecreateRenderState_Concurrent();

with:

// Recreate render state and flush the renderer 
// Cached the active morph targets, so that this function could work properly
TArray<FActiveMorphTarget> CachedActiveMorphTargets = ActiveMorphTargets;
TArray<float> CachedMorphTargetWeights = MorphTargetWeights;
if (bRenderStateCreated)
{
	check(IsRegistered()); // Should never have render state unless registered
	DestroyRenderState_Concurrent();
	checkf(!bRenderStateCreated, TEXT("Failed to route DestroyRenderState_Concurrent (%s)"), *GetFullName());
}

if (IsRegistered() && GetWorld()->Scene)
{
	ActiveMorphTargets = CachedActiveMorphTargets;
	MorphTargetWeights = CachedMorphTargetWeights;
	CreateRenderState_Concurrent();
	checkf(bRenderStateCreated, TEXT("Failed to route CreateRenderState_Concurrent (%s)"), *GetFullName());
}

it works for me anyway.

i’m gonna report it to epic and hope they would fix it

Thank you, works for me too. Been stuck on this forever! :smiley:

this is not fixed in UE5? I can’t get the morphs to show up.

when you say to replace the code, what do I need to do? rebuild the engine or what? Can someone explain how this works