UDynamicMesh* TargetMesh Error Code : LNK2019

MyMeshPrimitiveFunctions.h

// Copyright 2020-2021 CesiumGS, Inc. and Contributors

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GeometryScript/GeometryScriptTypes.h"
#include "GeometryScript/MeshPrimitiveFunctions.h"
#include "UDynamicMesh.h"
#include "MyMeshPrimitiveFunctions.generated.h"

/**
 * 
 */
UCLASS(meta = (ScriptName = "GeometryScript_Primitives"))
class MYCESIUM_API UMyMeshPrimitiveFunctions : public UGeometryScriptLibrary_MeshPrimitiveFunctions
{
	GENERATED_BODY()
public:

	static UPARAM(DisplayName = "Target Mesh") UDynamicMesh*
		AppendBox(
			UDynamicMesh* TargetMesh,
			FGeometryScriptPrimitiveOptions PrimitiveOptions,
			FTransform Transform,
			float DimensionX = 100,
			float DimensionY = 100,
			float DimensionZ = 100,
			int32 StepsX = 0,
			int32 StepsY = 0,
			int32 StepsZ = 0,
			EGeometryScriptPrimitiveOriginMode Origin = EGeometryScriptPrimitiveOriginMode::Base,
			UGeometryScriptDebug* Debug = nullptr);

};

MyMeshPrimitiveFunctions.h

// Copyright 2020-2021 CesiumGS, Inc. and Contributors


#include "MyMeshPrimitiveFunctions.h"

#include "DynamicMesh/DynamicMesh3.h"
#include "DynamicMesh/MeshNormals.h"
#include "DynamicMesh/MeshTransforms.h"
#include "DynamicMeshEditor.h"
#include "UDynamicMesh.h"

#include "Generators/GridBoxMeshGenerator.h"
#include "Generators/SphereGenerator.h"
#include "Generators/BoxSphereGenerator.h"
#include "Generators/CapsuleGenerator.h"
#include "Generators/RectangleMeshGenerator.h"
#include "Generators/DiscMeshGenerator.h"
#include "Generators/SweepGenerator.h"
#include "Generators/FlatTriangulationMeshGenerator.h"
#include "Generators/RevolveGenerator.h"
#include "Generators/StairGenerator.h"
#include "ConstrainedDelaunay2.h"
#include "Arrangement2d.h"

using namespace UE::Geometry;

static void AppendPrimitive(
	UDynamicMesh* TargetMesh,
	FMeshShapeGenerator* Generator,
	FTransform Transform,
	FGeometryScriptPrimitiveOptions PrimitiveOptions,
	FVector3d PreTranslate = FVector3d::Zero())
{
	auto ApplyOptionsToMesh = [&Transform, &PrimitiveOptions, PreTranslate](FDynamicMesh3& Mesh)
	{
		if (PreTranslate.SquaredLength() > 0)
		{
			MeshTransforms::Translate(Mesh, PreTranslate);
		}

		MeshTransforms::ApplyTransform(Mesh, (FTransformSRT3d)Transform);
		if (PrimitiveOptions.PolygroupMode == EGeometryScriptPrimitivePolygroupMode::SingleGroup)
		{
			for (int32 tid : Mesh.TriangleIndicesItr())
			{
				Mesh.SetTriangleGroup(tid, 0);
			}
		}
		if (PrimitiveOptions.bFlipOrientation)
		{
			Mesh.ReverseOrientation(true);
			if (Mesh.HasAttributes())
			{
				FDynamicMeshNormalOverlay* Normals = Mesh.Attributes()->PrimaryNormals();
				for (int elemid : Normals->ElementIndicesItr())
				{
					Normals->SetElement(elemid, -Normals->GetElement(elemid));
				}
			}
		}
	};

	TargetMesh->IsEmpty(); //// Error LNK2019

}

UDynamicMesh* UMyMeshPrimitiveFunctions::AppendBox(
	UDynamicMesh* TargetMesh,
	FGeometryScriptPrimitiveOptions PrimitiveOptions,
	FTransform Transform,
	float DimensionX,
	float DimensionY,
	float DimensionZ,
	int32 StepsX,
	int32 StepsY,
	int32 StepsZ,
	EGeometryScriptPrimitiveOriginMode Origin,
	UGeometryScriptDebug* Debug)
{
	UE::Geometry::FAxisAlignedBox3d ConvertBox(
		FVector3d(-DimensionX / 2, -DimensionY / 2, 0),
		FVector3d(DimensionX / 2, DimensionY / 2, DimensionZ));
	FGridBoxMeshGenerator GridBoxGenerator;
	GridBoxGenerator.Box = UE::Geometry::FOrientedBox3d(ConvertBox);
	GridBoxGenerator.EdgeVertices = FIndex3i(FMath::Max(0, StepsX), FMath::Max(0, StepsY), FMath::Max(0, StepsZ));
	GridBoxGenerator.bPolygroupPerQuad = (PrimitiveOptions.PolygroupMode == EGeometryScriptPrimitivePolygroupMode::PerQuad);
	GridBoxGenerator.Generate();

	FVector3d OriginShift = (Origin == EGeometryScriptPrimitiveOriginMode::Center) ? FVector3d(0, 0, -DimensionZ / 2) : FVector3d::Zero();
	AppendPrimitive(TargetMesh, &GridBoxGenerator, Transform, PrimitiveOptions, OriginShift);

	return TargetMesh;
}

	PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine","UnrealEd", "InputCore","WebBrowser","WebBrowserTexture","UMG", "ProceduralMeshComponent", "GeometryScriptingCore", "GeometryFramework" });
4 Likes