Hi guys,
I wanted to ask how do I update procedural mesh selection in c++? This code compiles but crashes UE. Could not find any documentation regarding UPDATING in c++ so I was following blueprint interface (I found a lot about creating mesh section). I am aware that this update in the code should do absolutely nothing (since I am using the same verts), but I wanted to demonstrate where it crashes.
Any idea what am I doing wrong?
Cheers,
Crispy
#include "ProceduralMeshTest.h"
// Sets default values
AProceduralMeshTest::AProceduralMeshTest()
{
// 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;
RootComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
UProceduralMeshComponent* mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("ProceduralMesh"));
TArray<FVector> Verts;
TArray<int> Triangles;
Verts.Add(FVector(100.0f, 100.0f, 400.0f));
Verts.Add(FVector(-100.0f, -100.0f, 400.0f));
Verts.Add(FVector(-100.0f, 100.0f, 400.0f));
Triangles.Add(0);
Triangles.Add(1);
Triangles.Add(2);
mesh->CreateMeshSection(0, Verts, Triangles, TArray<FVector>(), TArray<FVector2D>(), TArray<FColor>(), TArray<FProcMeshTangent>(), true);
//Crash
mesh->UpdateMeshSection(0, Verts, TArray<FVector>(), TArray<FVector2D>(), TArray<FColor>(), TArray<FProcMeshTangent>());
}
This is the crash log.
UE4Editor_ProceduralMeshComponent!FProceduralMeshSceneProxy::UpdateSection_RenderThread()
UE4Editor_ProceduralMeshComponent!TGraphTask<`UProceduralMeshComponent::UpdateMeshSection'::`5'::EURCMacro_FProcMeshSectionUpdate>::ExecuteTask()
UE4Editor_Core!FTaskThread::ProcessTasks() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\async\taskgraph.cpp:539]
UE4Editor_Core!FTaskThread::ProcessTasksUntilQuit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\async\taskgraph.cpp:340]
UE4Editor_RenderCore!RenderingThreadMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\rendercore\private\renderingthread.cpp:310]
UE4Editor_RenderCore!FRenderingThread::Run() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\rendercore\private\renderingthread.cpp:411]
UE4Editor_Core!FRunnableThreadWin::Run() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:74]
Anyone?
The update method calls render thread that is present only during gameplay. Therefore I could not update during construction.
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
FProcMeshSectionUpdate,
FProceduralMeshSceneProxy*, ProcMeshSceneProxy, (FProceduralMeshSceneProxy*)SceneProxy,
FProcMeshSectionUpdateData*, SectionData, SectionData,
{
ProcMeshSceneProxy->UpdateSection_RenderThread(SectionData);
}
);