0
\$\begingroup\$

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);
}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Just a couple comments to help you get this answered: 1. It looks like you are using 3rd party (not built in) components, such as URuntimeMeshShapeGenerator. Ideally you can provide a documentation link for each of these. 2. You didn't provide the compilation error. That would help identify the problem. \$\endgroup\$ Commented Aug 25, 2019 at 19:39

1 Answer 1

1
\$\begingroup\$

Change this:

URuntimeMeshShapeGenerator::CreateGridMesh(128.0f, 128.0f, 64, 64, *Section.Get());

to this:

URuntimeMeshShapeGenerator::CreateGridMesh(128.0f, 128.0f, 64, 64, Section->GetReadonlyMeshAccessor());

More Info

It looks like you are using Koderz/RuntimeMeshComponent.

The 5th parameter of URuntimeMeshShapeGenerator::CreateGridMesh is a const TSharedPtr<FRuntimeMeshAccessor>&.

The type returned from FRuntimeMeshData::BeginSectionUpdate is a TUniquePtr<FRuntimeMeshScopedUpdater>. Your Section variable also has this type.

When you call *Section.Get() for the 5th parameter, you are attempting to pass in a FRuntimeMeshScopedUpdater, which does match and results in the compilation error.

You need to get the FRuntimeMeshAccessor with FRuntimeMeshData::GetReadonlyMeshAccessor.

The Get() method you were calling was a Get() on TUniquePtr, part of the Unreal Smart Pointer Library. It did not get the FRuntimeMeshAccessor you needed.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .