I don't know to pass on the 5th parameter. I'm still new with C++ so if someone could help me with the pointer
void AGrid::GenerateMeshes_Implementation()
{
FRuntimeMeshDataPtr Data = GetRuntimeMeshComponent()->GetOrCreateRuntimeMesh()->GetRuntimeMeshData();
Data->EnterSerializedMode();
Data->CreateMeshSection(0, false, false, 1, false, true, EUpdateFrequency::Average);
auto Section = Data->BeginSectionUpdate(0);
FVector BoxSize = FVector(100, 100, 100);
URuntimeMeshShapeGenerator::CreateBoxMesh(BoxSize, *Section.Get());
URuntimeMeshShapeGenerator::CreateGridMesh(128.0f, 128.0f, 64, 64, *Section.Get()); // <---- This one
Section->Commit();
}
It says it needs to be a TSharedPtr<FRuntimeMeshAccessor>&
void URuntimeMeshShapeGenerator::CreateGridMesh(float Width, float Height, int32 NumSubdivisionsX, int32 NumSubdivisionsY, const TSharedPtr<FRuntimeMeshAccessor>& MeshBuilder)
{
MeshBuilder->EmptyVertices(CREATEGRIDMESHTRIANGLES_NUMVERTS(NumSubdivisionsX, NumSubdivisionsY));
MeshBuilder->EmptyIndices(CREATEGRIDMESHTRIANGLES_NUMTRIS(NumSubdivisionsX, NumSubdivisionsY));
FVerticesBuilderFunction VerticesBuilder = [&](const FVector& Position, const FVector& Normal, const FRuntimeMeshTangent& Tangent, const FVector2D& UV0)
{
int32 NewVertex = MeshBuilder->AddVertex(Position);
MeshBuilder->SetNormalTangent(NewVertex, Normal, Tangent);
MeshBuilder->SetUV(NewVertex, UV0);
};
FTrianglesBuilderFunction TrianglesBuilder = [&](int32 Index)
{
MeshBuilder->AddIndex(Index);
};
CreateGridMesh(Width, Height, NumSubdivisionsX, NumSubdivisionsY, VerticesBuilder, TrianglesBuilder);
}