UE4 use GPU skin for skeletal mesh by default. In that case position of those skeletal mesh vertices are calculated on GPU. So we can only manually calculate the final position on CPU side again. And this would very much likely to cause a performance issue.
There is a helper function
USkeletalMeshComponent::ComputeSkinnedPositions() to get exact the vertex position. It seems to be the only way to manually get the vertice position.
It would be much cheaper to get vertice position for a cpu skinned skeletal mesh. Vertice position would be cached after skinning to a skeleton.
We can directly use the cached positions to save performance like this:
There is a
MeshObject in a
USkinnedMeshCompnent. This pointer can point to a
FSkeletalMeshObjectCPUSkin or a
FSkeletalMeshObjectGPUSkin. This object is responsible for sending stuffs like bone transforms, morph target state to render thread.
Since a cpu skinned skeletal mesh caches its vertices every time it updates dynamic data(See
FSkeletalMeshObjectCPUSkin::Update()). The final vertice position is stored and thus we have access to it.
UE4 use cpu skinning only if the feature level is not valid or the skeletal mesh got cloth to simulate. We need to explicitly set
bCPUSkinning to true if we want to enable cpu skinning manually.
But it is not enough only to set
bCPUSkinning to true. We still need to refresh render data to make it work.
An easy but expensive method would be recreating renderstate and then flushing render commands after changing this variable like this:
bCPUSkinning = true;