Announcement

Collapse
No announcement yet.

Fast way of accessing the vertices of a SkeletalMesh?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Fast way of accessing the vertices of a SkeletalMesh?

    Hello,

    I'm currently developing a plugin for UE4.23. I'm looking for a solution to my problem that doesn't involve modifying the source code of Unreal, the plugin needs to be able to stand on its own.

    I need to access the vertex positions of a skeletal mesh once every frame. I do not need to modify the vertices, only access/copy them. I'm currently retrieving the vertices using the following code:

    Code:
    USkeletalMeshComponent * sm_component;
    TArray<FVector> vertex_array;
    
    ...
    
    sm_component->GetCurrentRefToLocalMatrices(ref_to_local_m, 0);
    
    USkeletalMeshComponent::ComputeSkinnedPositions(sm_component,
    vertex_array, ref_to_local_m, sm_render_data->LODRenderData[0], *skin_weight_vb);
    Which fills vertex_array with the data I need. However, it is too slow for what I'm doing. The skeletal mesh contains ~15k vertices and ComputeSkinnedPositions slows down my application significantly.

    I've also tried GetCPUSkinnedVertices, but sadly, as the documentation says:

    Get CPU skinned vertices for the specified LOD level. Includes morph targets if they are enabled. Note: This function is very SLOW as it needs to flush the render thread.
    This means that I can't really use any of the two functions, unless I am doing something wrong which I can't see.

    I'm wondering if there is a faster way of retrieving the vertex positions of a skeletal mesh?

    Thank you!
    Last edited by oskarnylen; 01-09-2020, 04:04 AM.
Working...
X