Create static mesh from simulated ragdoll

I am trying to save off a ragdoll as static mesh during simulation.

By default, the MeshUtilities::ConvertMeshesToStaticMesh convertrs the skinned vertices in the t-pose, rather than the simulated physics position.

Internally, it is using GetCPUSkinnedVertices which does call RefreshBoneTransforms.

What is the best way to get the vertex positions in the simulated pose?

Thanks for any tips/advice…

Necroing this thread first of all to say thank you for your finding, and secondly to confirm that skipping the RefreshBoneTransform call is enough to make this work.

So what I did is just copied the whole FMeshUtilities in my custom Editor Module and just changed that part of the code.
Note: I am still using UE4, so this might have been implemented in a later version

So inside the “SkinnedMeshToRawMeshes” function, instead of calling “GetCPUSkinnedVertices”, just replace the code with this:
Which is a copy paste of “GetCPUSkinnedVertices” minus the “RefreshBoneTransforms” call.

// Get the CPU skinned verts for this LOD
InSkinnedMeshComponent->SetForcedLOD(LODIndexRead + 1);
InSkinnedMeshComponent->UpdateLODStatus();

const bool bCachedCPUSkinning = InSkinnedMeshComponent->GetCPUSkinningEnabled();
constexpr bool bRecreateRenderStateImmediately = true;
InSkinnedMeshComponent->SetCPUSkinningEnabled(true, bRecreateRenderStateImmediately);

check(InSkinnedMeshComponent->MeshObject);
check(InSkinnedMeshComponent->MeshObject->IsCPUSkinned());

// Copy our vertices out. We know we are using CPU skinning now, so this cast is safe
TArray<FFinalSkinVertex> FinalVertices = static_cast<FSkeletalMeshObjectCPUSkin*>(
    InSkinnedMeshComponent->MeshObject)->GetCachedFinalVertices();

InSkinnedMeshComponent->SetForcedLOD(0);
InSkinnedMeshComponent->SetCPUSkinningEnabled(bCachedCPUSkinning,
    bRecreateRenderStateImmediately);