Trying to get vertices positions from a spline mesh component static mesh

Hi all,

I’m trying to get vertices positions from a spline mesh component static mesh.

Here is my code :

TArray<FVector> UMyMaths::StaticMeshToSplineMeshVerticesPositions(USplineMeshComponent* SplineMeshComponent) {


	int l_NumVertices;
	TArray<FVector> l_Positions;

	UStaticMesh* l_StaticMesh = SplineMeshComponent->GetStaticMesh();
    const FStaticMeshLODResources& l_RenderData = l_StaticMesh->GetRenderData()->LODResources[0];
    l_NumVertices = l_RenderData.GetNumVertices();

	for (int32 Index = 0; Index < l_NumVertices; Index++)
	{
		l_Positions.Add(SplineMeshComponent->GetComponentLocation() + l_RenderData.VertexBuffers.PositionVertexBuffer.VertexPosition(Index));
		//l_Positions.Add(SplineMeshComponent->GetComponentLocation() + FVector(1,0,0));
	}

	return l_Positions;
}

This line is the issue when compiling :

l_Positions.Add(SplineMeshComponent->GetComponentLocation() + l_RenderData.VertexBuffers.PositionVertexBuffer.VertexPosition(Index));

I tried this :

l_Positions.Add(SplineMeshComponent->GetComponentLocation() + FVector(1,0,0));

And it worked . So :

l_RenderData.VertexBuffers.PositionVertexBuffer.VertexPosition(Index)

Is not a FVector, but the Unreal engine 5 documantation says it is :

Here is what compiler says :

binary '+': no operator found which takes a left-hand operand of type 'FVector' (or there is no acceptable conversion)
  C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Math\Vector.h(275): note: could be 'UE::Math::TVector<double> UE::Math::TVector<double>::operator +(const UE::Math::TVector<double> &) const'
  C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc\FrameTime.h(204): note: or       'FFrameTime operator +(FFrameTime,FFrameTime)'
  C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging\ResourceSize.h(115): note: or       'FResourceSizeEx operator +(FResourceSizeEx,const FResourceSizeEx &)'
  C:\Users\guill\OneDrive\Documents\Unreal Projects\CityBuilder\Source\CityBuilder\MyMaths.cpp(23): note: while trying to match the argument list '(FVector, const FVector3f)'

Any idea please ?

Solved. I converted it to FVector like that :

for (int32 Index = 0; Index < l_NumVertices; Index++)
	{
		l_Positions.Add(SplineMeshComponent->GetComponentLocation() + FVector(l_RenderData.VertexBuffers.PositionVertexBuffer.VertexPosition(Index).X, l_RenderData.VertexBuffers.PositionVertexBuffer.VertexPosition(Index).Y, l_RenderData.VertexBuffers.PositionVertexBuffer.VertexPosition(Index).Z));

	}

Thanks for posting this. I can confirm I encountered this same issue where VertexPosition(index) returns FVector3f instead of FVector.