CreateSection in ProceduralMeshComponent seems to have a bug

Hello,

first, this Bug Report describes the same problem (Replacing Procedural Mesh Component Sections Removes other sections - Programming & Scripting - Unreal Engine Forums ). However, since chrisrf had answered the question himself and there doesn’t seem to be any more responses by the Devs, I thought I would open up a new request, escpecially as I - at least seem to - have fixed that bug pretty simple.
In fact it seems that SetNum does decrease the array size regardless of bAllowShrinking, therefore calling CreateSection with an Index smaller than the MaxIndex removes all sections with a greater index than the index given to CreateSection.
I simply added
if (SectionIndex >= ProcMeshSections.Num())
before calling SetNum on ProcMeshSecctions and this fixed the problem for me.
Apart from my specific problem this seems pretty reasonable to me as the number of elements should only be increased if we don’t have enough, which is not the case when the SectionIndex in CreateMeshSection is smaller than the number of elements in ProcMeshSections.

I created a pull request for that fix here: https://github.com/EpicGames/UnrealEngine/pull/2004

Hi Taces,

Thanks for the pull request. We have assigned an Engineer to look it over, but it may take some time since most of the Engineers are quite busy at the moment.

Thanks, it has been merged, if anybody stumbles upon this thread.