I’m using procedural mesh component for terrain that can be modified at run time. The component has 16 mesh sections so that processing the terrain changes can be done in parallel.
This is the code I’m using to make updates:
TerrainMesh->ClearMeshSection(SectionID);
TerrainMesh->CreateMeshSection(SectionID, VertexLocations, VertexIndices, VertexNormals, VertexUVs, VertexColors, VertexTangents, true);
Clearing and replacing an index removes every index after the index your replacing. For example clearing and replacing index 5 removes indexes 6-15, indexes 4 and below are unaffected. According to the documentation clear mesh does not alter the indexes of other sections.
I use clear and create because the world is sliced into layers and when changes (terrain raised or lowered) are made vertices may be removed or added to the layer.