My project is to achieve synchronization between maya and ue4. When maya modified the geometry info of an object, I need to sync it in ue4. Here is code for point sync:
UStaticMesh* StaticMesh = MeshComponent->GetStaticMesh();
FStaticMeshSourceModel& SrcModel = StaticMesh->SourceModels[0];
SrcModel.RawMeshBulkData->LoadRawMesh(*RawMesh);
// Load new points
RawMesh->VertexPositions.Empty();
auto Points = Prim->GetAttribute_Point3fArray(OmniverseTokens().points);
RawMesh->VertexPositions.Reserve(Points.Num());
for (auto& Point : Points)
{
RawMesh->VertexPositions.Add(OmniverseConversionTransform.TransformPosition(FVector(Point.x, Point.y, Point.z)));
}
SrcModel.RawMeshBulkData->SaveRawMesh(*RawMesh);
StaticMesh->Build(true);
My question is each time I need to loadRawMesh
and then update it , then SaveRawMesh
. which means I need to copy the whole raw data two times, Is there a better way?