CustBrushBuilder Error Brush

Hello,I would like to use EditorBrushBuilder (CustBrushBuilder) to build a brush ,Following code:



bool UCustBrushBuilder::Build(UWorld * InWorld, ABrush * InBrush)
{
	//TArray<FVector> LocBottomVertexs = OneVertexs;
	//LocBottomVertexs.Append(OtherVertexs);

	if(BottomVertexs.Num() < 3)
		return BadParameters(LOCTEXT("WallBottomFaceVertexsCount", "Invalid Vertex Count!"));

	BeginBrush(false, TEXT("CustBrush")); 
	
	//int32 Direction = JugePolyOrderAndAoTo(BottomVertexs);
	BuildCustBrush(+1, BottomVertexs);
	return EndBrush(InWorld, InBrush);
}




void UCustBrushBuilder::BuildCustBrush(int32 Direction, const TArray<FVector2D>& InBottomVertexs)
{
	check(InBottomVertexs.Num() > 2);

	int32  BottomFaceVertexCount = InBottomVertexs.Num(); 

	int n = InBottomVertexs.Num() * 2; 
	float Height = 30;
	for (int32 index = 0; index < n; ++index)
	{
		if (index < BottomFaceVertexCount)
		{
			Vertex3f(InBottomVertexs[index].X, InBottomVertexs[index].Y, 0);
		}
		else
		{
			Vertex3f(InBottomVertexs[index % BottomFaceVertexCount].X, InBottomVertexs[index % BottomFaceVertexCount].Y, Height);
		}
	}
	

	//ScalPoly(Vertices);

	//Bottom Face Begin
	PolyBegin(Direction, "Bottom");
	for (int32 BottomFaceIndex = BottomFaceVertexCount-1; BottomFaceIndex > -1; BottomFaceIndex--)
	{
		Polyi(BottomFaceIndex);
	}
	PolyEnd();
	//Bottom Face End

	//Each Face begin
	for (int32 EachFaceIndex = 0; EachFaceIndex < BottomFaceVertexCount; ++EachFaceIndex)
	{
		int32 FirstIndex = EachFaceIndex; // 0
		int32 SecIndex = EachFaceIndex + BottomFaceVertexCount;
		int32 ThirdIndex = (EachFaceIndex + 1) % BottomFaceVertexCount + BottomFaceVertexCount;
		int32 FourIndex = (EachFaceIndex + 1) % BottomFaceVertexCount;

		Poly4i(Direction, FourIndex, ThirdIndex, SecIndex, FirstIndex, "Each");
	}
	//Each Face End

	//Top Face Begin
	PolyBegin(Direction, "Top");
	for (int32 TopFaceIndex = BottomFaceVertexCount; TopFaceIndex < n; ++TopFaceIndex)
	{
		Polyi(TopFaceIndex);
	}
	PolyEnd();
	//Top Face End
}


BottomVertexs[5]

  •   BottomVertexs	Num=5	TArray&lt;FVector2D,FDefaultAllocator&gt;
    
  •   [0]	{X=-404.539948 Y=3105.41455 }	FVector2D
    
  •   [1]	{X=-667.448730 Y=-754.085632 }	FVector2D
    
  •   [2]	{X=4131.35010 Y=-544.531250 }	FVector2D
    
  •   [3]	{X=1116.35742 Y=1687.62085 }	FVector2D
    
  •   [4]	{X=4096.51123 Y=2377.76196 }	FVector2D
    

Error result :
error.png

Correct result :

why?

I’ve been trying to work on something similar, but I can’t even get my project to build. Trying to extend UEditorBrushBuilder gives me a bunch of unresolved external symbol errors. How did you get around that?

Did you add the dependency? UEditorBrushBuilder is part of UnrealEd module.

Add that to you .build.cs



PublicDependencyModuleNames.AddRange(new string] { "UnrealEd" });

OR depending of what you need

PrivateDependencyModuleNames.AddRange(new string] { "UnrealEd" });

/**

  • Base class of UnrealEd brush builders.
  • Tips for writing brush builders:
    • Always validate the user-specified and call BadParameters function
  • if anything is wrong, instead of actually building geometry.
  • If you build an invalid brush due to bad user parameters, you’ll
  • cause an extraordinary amount of pain for the poor user.

*** - When generating polygons with more than 3 vertices, BE SURE all the

  • polygon’s vertices are coplanar! Out-of-plane polygons will cause
  • geometry to be corrupted.**
    */
    UCLASS(abstract, hidecategories=(Object), MinimalAPI)
    class UBrushBuilder
    { … }