// Copyright Epic Games, Inc. All Rights Reserved. /*============================================================================= StaticMeshImportUtils.h: Static mesh import functions. =============================================================================*/ #pragma once #include "CoreMinimal.h" #include "Engine/EngineTypes.h" #include "Engine/MeshMerging.h" #include "Engine/StaticMesh.h" #include "PerPlatformProperties.h" struct FMeshDescription; class UStaticMeshSocket; class UAssetImportData; class UThumbnailInfo; class UModel; class UBodySetup; namespace UnFbx { struct FBXImportOptions; } // LOD data to copy over struct FExistingLODMeshData { FMeshBuildSettings ExistingBuildSettings; FMeshReductionSettings ExistingReductionSettings; TUniquePtr ExistingMeshDescription; TArray ExistingMaterials; FPerPlatformFloat ExistingScreenSize; FString ExistingSourceImportFilename; }; struct FExistingStaticMeshData { TArray ExistingMaterials; FMeshSectionInfoMap ExistingSectionInfoMap; TArray ExistingLODData; TArray ExistingSockets; bool ExistingCustomizedCollision; bool bAutoComputeLODScreenSize; int32 ExistingLightMapResolution; int32 ExistingLightMapCoordinateIndex; TWeakObjectPtr ExistingImportData; TWeakObjectPtr ExistingThumbnailInfo; UModel* ExistingCollisionModel; UBodySetup* ExistingBodySetup; // A mapping of vertex positions to their color in the existing static mesh TMap ExistingVertexColorData; float LpvBiasMultiplier; float BouncedSVGIBiasMultiplier; bool bHasNavigationData; FName LODGroup; FPerPlatformInt MinLOD; int32 ImportVersion; bool UseMaterialNameSlotWorkflow; // The last import material data (fbx original data before user changes) TArray LastImportMaterialOriginalNameData; TArray> LastImportMeshLodSectionMaterialData; bool ExistingGenerateMeshDistanceField; int32 ExistingLODForCollision; float ExistingDistanceFieldSelfShadowBias; bool ExistingSupportUniformlyDistributedSampling; bool ExistingAllowCpuAccess; FVector ExistingPositiveBoundsExtension; FVector ExistingNegativeBoundsExtension; UStaticMesh::FOnMeshChanged ExistingOnMeshChanged; UStaticMesh* ExistingComplexCollisionMesh = nullptr; TMap ExistingUMetaDataTagValues; }; namespace StaticMeshImportUtils { UNREALED_API bool DecomposeUCXMesh(const TArray& CollisionVertices, const TArray& CollisionFaceIdx, UBodySetup* BodySetup); /** * Function for adding a box collision primitive to the supplied collision geometry based on the mesh of the box. * * We keep a list of triangle normals found so far. For each normal direction, * we should have 2 distances from the origin (2 parallel box faces). If the * mesh is a box, we should have 3 distinct normal directions, and 2 distances * found for each. The difference between these distances should be the box * dimensions. The 3 directions give us the key axes, and therefore the * box transformation matrix. This shouldn't rely on any vertex-ordering on * the triangles (normals are compared +ve & -ve). It also shouldn't matter * about how many triangles make up each side (but it will take longer). * We get the centre of the box from the centre of its AABB. */ UNREALED_API bool AddBoxGeomFromTris(const TArray& Tris, FKAggregateGeom* AggGeom, const TCHAR* ObjName); /** * Function for adding a sphere collision primitive to the supplied collision geometry based on a set of Verts. * * Simply put an AABB around mesh and use that to generate center and radius. * It checks that the AABB is square, and that all vertices are either at the * center, or within 5% of the radius distance away. */ UNREALED_API bool AddSphereGeomFromVerts(const TArray& Verts, FKAggregateGeom* AggGeom, const TCHAR* ObjName); UNREALED_API bool AddCapsuleGeomFromVerts(const TArray& Verts, FKAggregateGeom* AggGeom, const TCHAR* ObjName); /** Utility for adding one convex hull from the given verts */ UNREALED_API bool AddConvexGeomFromVertices(const TArray& Verts, FKAggregateGeom* AggGeom, const TCHAR* ObjName); UNREALED_API TSharedPtr SaveExistingStaticMeshData(UStaticMesh* ExistingMesh, UnFbx::FBXImportOptions* ImportOptions, int32 LodIndex); /* This function is call before building the mesh when we do a re-import*/ UNREALED_API void RestoreExistingMeshSettings(const FExistingStaticMeshData* ExistingMesh, UStaticMesh* NewMesh, int32 LODIndex); UNREALED_API void UpdateSomeLodsImportMeshData(UStaticMesh* NewMesh, TArray* ReimportLodList); UNREALED_API void RestoreExistingMeshData(const TSharedPtr& ExistingMeshDataPtr, UStaticMesh* NewMesh, int32 LodLevel, bool bCanShowDialog, bool bForceConflictingMaterialReset); } // namespace StaticMeshImportUtils