CreateMeshSection() not working second time around

So I’ve created a procedural mesh in the constructor of my actor, which works fine. Then on a postedit event I recreate it using the updated settings.

Despite clearing all the mesh sections, when I run the creation code again everything executes but no mesh is made. Are there any caveats to using procedural meshes?

Here’s code:


ASkullProceduralMeshActor::ASkullProceduralMeshActor(){
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;


    ProceduralMeshParameters = FSkullProceduralMeshParamsStruct();


    ProceduralMesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("RootComponent"));
    RootComponent = ProceduralMesh;


    CreateProceduralMesh();
}

void ASkullProceduralMeshActor::PostEditChangeProperty(FPropertyChangedEvent & PropertyChangedEvent)
{
    CreateProceduralMesh();
    UE_LOG(LogTemp, Warning, TEXT("[Skull] Updated procedural mesh"));
}

void ASkullProceduralMeshActor::CreateProceduralMesh()
{
    // Make mesh data
    // Delete section
    // Create section
}



It’s pretty simple. What am I missing that causes the mesh to not be recreated on edit?

Edit: If I defer mesh creation until postedit it still doesn’t work. So proceduralmeshes can’t be populated outside of the constructor/beginplay?

Without full code it is hard to guess. Why do you clear and create mesh? Maybe try UpdateMeshSection().

Someone who knows the answer to this doesn’t need the full code. It’s just a question about proceduralmeshes that’s not covered by the documentation.

The topology is changing so that won’t work.

Hi!!

Have you found a solution? I am suffering same problem…

For me it works to override an existing section by calling CreateMeshSection with the index of an already created section anyhwere in code.
Maybe your last call to CreateMeshSection is with a small index? In the current version there is a bug that when you create a MeshSection with an index smaller than the currently created sections-1 all sections with an index greater than the specified index will be deleted, however a fix for that problem has already been merged to master. Maybe that helps you.

Hmm. I’m only using a single section, so it’s not that bug.

I’m also finding that any transforms I make in the editor aren’t saved. After a reload the position and rotation of the models has zeroed out and I’m not able to transform them any more. It’s like procedural meshes live in their own little world that has nothing to do with anything else.

The state of procedural meshes is shockingly bad and as the warning says, not ready for production. I suspect I’m going to have to try to create a static mesh using my geometry via a brush, or maybe directly. Epic don’t make it easy! I’ll get back to everyone with how that goes.