UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SkeletalMeshLODImporterData.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4#include "MeshDescription.h"
5
6#if WITH_EDITOR
7
9#include "BoneIndices.h"
11#include "Components.h"
12#include "Math/GenericOctree.h"
14#include "Templates/DontCopy.h"
15
17struct FMeshDescription;
19
20
22{
24 SkeletalMeshBuildRefactor,
25
26 // -----<new versions can be added above this line>-------------------------------------------------
29};
30
32{
34 SkeletalMeshBuildRefactor,
35
36 // -----<new versions can be added above this line>-------------------------------------------------
39};
40
41
43{
48 struct FMeshInfo
49 {
50 FName Name; // The name of the mesh.
51 int32 NumVertices = 0; // The number of imported (dcc) vertices that are part of this mesh. This is a value of 8 for a cube. So NOT the number of render vertices.
52 int32 StartImportedVertex = 0; // The first index of imported (dcc) vertices in the mesh. So this NOT an index into the render vertex buffer. In range of 0..7 for a cube.
53 };
54
55 struct FMeshWedge
56 {
57 uint32 iVertex; // Vertex index.
59 FColor Color; // Vertex color.
60 friend FArchive &operator<<(FArchive& Ar, FMeshWedge& T)
61 {
62 Ar << T.iVertex;
63 for (int32 UVIdx = 0; UVIdx < MAX_TEXCOORDS; ++UVIdx)
64 {
65 Ar << T.UVs[UVIdx];
66 }
67 Ar << T.Color;
68 return Ar;
69 }
70 };
71
72 struct FMeshFace
73 {
74 // Textured Vertex indices.
75 uint32 iWedge[3];
76 // Source Material (= texture plus unique flags) index.
78
79 FVector3f TangentX[3];
80 FVector3f TangentY[3];
81 FVector3f TangentZ[3];
82
83 // 32-bit flag for smoothing groups.
85 };
86
87 // A bone: an orientation, and a position, all relative to their parent.
88 struct FJointPos
89 {
90 ::FTransform3f Transform; // LWC_TODO: UE::Geometry namespace issues
91
92 // For collision testing / debug drawing...
93 float Length;
94 float XSize;
95 float YSize;
96 float ZSize;
97
99 {
100 Ar << F.Transform;
101 return Ar;
102 }
103 };
104
105 // Textured triangle.
106 struct FTriangle
107 {
108 // Point to three vertices in the vertex list.
110 // Materials can be anything.
112 // Second material from exporter (unused)
114 // 32-bit flag for smoothing groups.
116
117 FVector3f TangentX[3];
118 FVector3f TangentY[3];
119 FVector3f TangentZ[3];
120
121
122 friend FArchive &operator<<(FArchive& Ar, FTriangle& F)
123 {
125
127 {
129 Ar << TempMatIndex;
130 F.MatIndex = TempMatIndex;
131 }
132 else
133 {
134 Ar << F.MatIndex;
135 }
136 Ar << F.AuxMatIndex;
137 Ar << F.SmoothingGroups;
138
139 Ar << F.WedgeIndex[0];
140 Ar << F.WedgeIndex[1];
141 Ar << F.WedgeIndex[2];
142
143 Ar << F.TangentX[0];
144 Ar << F.TangentX[1];
145 Ar << F.TangentX[2];
146
147 Ar << F.TangentY[0];
148 Ar << F.TangentY[1];
149 Ar << F.TangentY[2];
150
151 Ar << F.TangentZ[0];
152 Ar << F.TangentZ[1];
153 Ar << F.TangentZ[2];
154 return Ar;
155 }
156 };
157
158 struct FVertInfluence
159 {
160 float Weight;
161 uint32 VertIndex;
162 FBoneIndexType BoneIndex;
164 {
165 Ar << F.Weight << F.VertIndex << F.BoneIndex;
166 return Ar;
167 }
168 };
169
170 // Raw data material.
171 struct FMaterial
172 {
176 FString MaterialImportName;
177
178 friend FArchive &operator<<(FArchive& Ar, FMaterial& F)
179 {
180 Ar << F.MaterialImportName;
181 return Ar;
182 }
183 };
184
185
186 // Raw data bone.
187 struct FBone
188 {
189 FString Name; //
190 //@ todo FBX - Flags unused?
191 uint32 Flags; // reserved / 0x02 = bone where skin is to be attached...
192 int32 NumChildren; // children // only needed in animation ?
193 int32 ParentIndex; // 0/NULL if this is the root bone.
194 FJointPos BonePos; // reference position
195
196 friend FArchive &operator<<(FArchive& Ar, FBone& F)
197 {
198 Ar << F.Name;
199 Ar << F.Flags;
200 Ar << F.NumChildren;
201 Ar << F.ParentIndex;
202 Ar << F.BonePos;
203 return Ar;
204 }
205 };
206
207
208 // Raw data bone influence.
209 struct FRawBoneInfluence // just weight, vertex, and Bone, sorted later....
210 {
211 float Weight;
213 int32 BoneIndex;
214
216 {
217 Ar << F.Weight;
218 Ar << F.VertexIndex;
219 Ar << F.BoneIndex;
220 return Ar;
221 }
222 };
223
224 // Vertex with texturing info, akin to Hoppe's 'Wedge' concept - import only.
225 struct FVertex
226 {
227 uint32 VertexIndex; // Index to a vertex.
228 FVector2f UVs[MAX_TEXCOORDS]; // Scaled to BYTES, rather...-> Done in digestion phase, on-disk size doesn't matter here.
229 FColor Color; // Vertex colors
230 uint8 MatIndex; // At runtime, this one will be implied by the face that's pointing to us.
231 uint8 Reserved; // Top secret.
232
233 FVertex()
234 {
235 FMemory::Memzero(this, sizeof(FVertex));
236 }
237
238 bool operator==(const FVertex& Other) const
239 {
240 bool Equal = true;
241
242 Equal &= (VertexIndex == Other.VertexIndex);
243 Equal &= (MatIndex == Other.MatIndex);
244 Equal &= (Color == Other.Color);
245 Equal &= (Reserved == Other.Reserved);
246
247 bool bUVsEqual = true;
248 for (uint32 UVIdx = 0; UVIdx < MAX_TEXCOORDS; ++UVIdx)
249 {
251 {
252 bUVsEqual = false;
253 break;
254 }
255 }
256
257 Equal &= bUVsEqual;
258
259 return Equal;
260 }
261
262 friend uint32 GetTypeHash(const FVertex& Vertex)
263 {
264 return FCrc::MemCrc_DEPRECATED(&Vertex, sizeof(FVertex));
265 }
266
267 friend FArchive &operator<<(FArchive& Ar, FVertex& F)
268 {
269 Ar << F.VertexIndex;
270 Ar << F.Color;
271 Ar << F.MatIndex;
272 Ar << F.Reserved;
273
274 for (uint32 UVIdx = 0; UVIdx < MAX_TEXCOORDS; ++UVIdx)
275 {
276 Ar << F.UVs[UVIdx];
277 }
278
279 return Ar;
280 }
281 };
282
283
284 // Points: regular FVectors (for now..)
285 struct FPoint
286 {
287 FVector3f Point; // Change into packed integer later IF necessary, for 3x size reduction...
288
289 friend FArchive &operator<<(FArchive& Ar, FPoint& F)
290 {
291 Ar << F.Point;
292 return Ar;
293 }
294 };
295
296 struct FVertexAttribute
297 {
298 FVertexAttribute() = default;
301 {}
302 FVertexAttribute(const FVertexAttribute&) = default;
303 FVertexAttribute(FVertexAttribute&&) = default;
304
306 int32 ComponentCount;
307
308 friend FArchive &operator<<(FArchive& Ar, FVertexAttribute& A)
309 {
310 Ar << A.AttributeValues;
311 Ar << A.ComponentCount;
312
313 return Ar;
314 }
315 };
316}
317
318template <> struct TIsPODType<SkeletalMeshImportData::FMeshWedge> { enum { Value = true }; };
319template <> struct TIsPODType<SkeletalMeshImportData::FMeshFace> { enum { Value = true }; };
320template <> struct TIsPODType<SkeletalMeshImportData::FJointPos> { enum { Value = true }; };
321template <> struct TIsPODType<SkeletalMeshImportData::FTriangle> { enum { Value = true }; };
322template <> struct TIsPODType<SkeletalMeshImportData::FVertInfluence> { enum { Value = true }; };
323
328{
329public:
331 TArray <FVector3f> Points;
337 TArray <int32> PointToRawMap; // Mapping from current point index to the original import point index
338 uint32 NumTexCoords; // The number of texture coordinate sets
339 uint32 MaxMaterialIndex; // The max material index found on a triangle
340 bool bHasVertexColors; // If true there are vertex colors in the imported file
341 bool bHasNormals; // If true there are normals in the imported file
342 bool bHasTangents; // If true there are tangents in the imported file
343
344 // Morph targets imported(i.e. FBX) data. The name is the morph target name
348
349 // Alternate influence imported(i.e. FBX) data. The name is the alternate skinning profile name
352
355
357
359 : NumTexCoords(0)
364 {
365
366 }
367
368 /*
369 * Copy only unnecessary array data from the structure to build the morph target (this will save a lot of memory)
370 */
372
373 /*
374 * Remove all unnecessary array data from the structure (this will save a lot of memory)
375 * We only need Points, Influences and RefBonesBinary arrays
376 */
378
393
394 static ENGINE_API FString FixupBoneName(FString InBoneName);
395
399 void Empty()
400 {
401 Materials.Empty();
402 Points.Empty();
403 Wedges.Empty();
404 Faces.Empty();
405 RefBonesBinary.Empty();
406 Influences.Empty();
407 PointToRawMap.Empty();
408 MeshInfos.Empty();
409 }
410
413
414 //Fit another rig data on this one
415 ENGINE_API bool ApplyRigToGeo(FSkeletalMeshImportData& Other);
416
417 /*
418 * Use the faces corner normals to create the face smooth groups data
419 */
421
422 /*
423 * Add morph target data from UMorphTarget in case there was none on the mesh itself.
424 */
426
427 /*
428 * Add alternate skin profile from FImportedSkinWeightProfileData
429 */
431
432
438
445
446private:
453 ) const;
454
457
459};
460
465{
468
469 //The custom version when this was load
471 FPackageFileVersion UEVersion;
474
477
478 /*
479 * Caching those value since this is a slow operation to load the bulk data to retrieve the original geometry information
480 */
482
483public:
486
487 /*Static function helper to serialize an array of reduction data. */
489
491 ENGINE_API void Serialize(class FArchive& Ar, class UObject* Owner);
492
495
498
501
502 FByteBulkData& GetBulkData() { return BulkData; }
503
506
508 inline bool IsEmpty() const { return BulkData.GetBulkDataSize() == 0; }
509};
510
512{
515
516 /*
517 * Caching those value since this is a slow operation to load the bulk data to retrieve the original geometry information
518 */
520
522
525};
526
528{
529 Ar << InlineReductionCacheData.CacheLODVertexCount;
530 Ar << InlineReductionCacheData.CacheLODTriCount;
531 return Ar;
532}
533
538{
539#if WITH_EDITOR
542#endif
546 FGuid Guid;
548 bool bGuidIsHash;
549
550 //The custom version when this was load
552 FPackageFileVersion UEVersion;
555
556public:
557 /*
558 * The last geo imported version, we use this flag to know if we have some data or not.
559 * This flag must be updated every time we import a new geometry
560 */
562
563 /*
564 * The last skinning imported version, we use this flag to know if we have some data or not.
565 * This flag must be updated every time we import the skinning
566 */
568
571
572 /*Static function helper to serialize an array of Raw source data. */
574
576 ENGINE_API void Serialize(class FArchive& Ar, class UObject* Owner);
577
579 ENGINE_API void SaveRawMesh(FSkeletalMeshImportData& InMesh);
580
582 ENGINE_API void LoadRawMesh(FSkeletalMeshImportData& OutMesh);
583
585 ENGINE_API FString GetIdString() const;
586
588 ENGINE_API void UseHashAsGuid(class UObject* Owner);
589
590 ENGINE_API FByteBulkData& GetBulkData();
591
592 ENGINE_API const FByteBulkData& GetBulkData() const;
593
595 void EmptyBulkData()
596 {
597 //Clear all the data
598 BulkData.RemoveBulkData();
599 Guid.Invalidate();
600 bGuidIsHash = false;
603 GeoImportVersion = ESkeletalMeshGeoImportVersions::Before_Versionning;
604 SkinningImportVersion = ESkeletalMeshSkinningImportVersions::Before_Versionning;
605 }
606
608 inline bool IsEmpty() const { return BulkData.GetBulkDataSize() == 0; }
609
611 bool IsBuildDataAvailable() const
612 {
613 return GeoImportVersion >= ESkeletalMeshGeoImportVersions::SkeletalMeshBuildRefactor &&
614 SkinningImportVersion >= ESkeletalMeshSkinningImportVersions::SkeletalMeshBuildRefactor;
615 }
616
617private:
619};
620
621namespace FWedgePositionHelper
622{
623 inline bool PointsEqual(const FVector3f& V1, const FVector3f& V2, float ComparisonThreshold)
624 {
625 if (FMath::Abs(V1.X - V2.X) > ComparisonThreshold
626 || FMath::Abs(V1.Y - V2.Y) > ComparisonThreshold
627 || FMath::Abs(V1.Z - V2.Z) > ComparisonThreshold)
628 {
629 return false;
630 }
631 return true;
632 }
633
635 struct FIndexAndZ
636 {
637 float Z;
638 int32 Index;
639
641 FIndexAndZ() {}
642
645 {
646 Z = 0.30f * V.X + 0.33f * V.Y + 0.37f * V.Z;
647 Index = InIndex;
648 }
649 };
650
652 struct FCompareIndexAndZ
653 {
654 inline bool operator()(FIndexAndZ const& A, FIndexAndZ const& B) const { return A.Z < B.Z; }
655 };
656}
657
658struct FWedgeInfo
659{
662};
663
666{
667 enum { MaxElementsPerLeaf = 16 };
668 enum { MinInclusiveElementsPerNode = 7 };
669 enum { MaxNodeDepth = 12 };
670
671 typedef TInlineAllocator<MaxElementsPerLeaf> ElementAllocator;
672
681 inline static FBoxCenterAndExtent GetBoundingBox(const FWedgeInfo& Element)
682 {
684 }
685
694 inline static bool AreElementsEqual(const FWedgeInfo& A, const FWedgeInfo& B)
695 {
696 return (A.Position == B.Position && A.WedgeIndex == B.WedgeIndex);
697 }
698
700 inline static void SetElementId(const FWedgeInfo& Element, FOctreeElementId2 Id)
701 {
702 }
703};
705
707{
708public:
711 {}
712 /*
713 * Find the nearest wedge indexes to SearchPosition.
714 *
715 * SearchPosition: The reference vertex position use to search the wedges
716 * OutNearestWedges: The nearest wedge indexes to SearchPosition
717 */
719private:
721};
722
723struct FWedgePosition
724{
726 {
727 WedgePosOctree = nullptr;
728 }
729
731 {
732 if (WedgePosOctree != nullptr)
733 {
734 delete WedgePosOctree;
735 WedgePosOctree = nullptr;
736 }
737 }
738
739 const TWedgeInfoPosOctree *GetOctree() const
740 {
741 return WedgePosOctree;
742 }
743
744 /*
745 * Find all wedges index that match exactly the vertex position. OutResult will be empty if there is no match
746 *
747 * Position: The reference vertex position use to search the wedges
748 * RefPoints: The array of position that was use when calling FillWedgePosition
749 * RefWedges: The array of wedges that was use when calling FillWedgePosition
750 * OutResults: The wedge indexes that fit the Position parameter
751 * ComparisonThreshold: The threshold use to exactly match the Position. Not use when bExactMatch is false
752 */
754
755 // Fill the data:
756 // Create the SortedPosition use to find exact match (position)
757 // Create the wedge position octree to find the closest position, we use this when there is no exact match
758 // The targetPositions is use to to max out the octree bounding box to both the source and target geometry
759 static void FillWedgePosition(
763 const TArray<FVector3f>& TargetPositions,
764 float ComparisonThreshold);
765
766private:
769 TArray<FVector3f> Points;
771};
772
773
774
775#endif // WITH_EDITOR
uint16 FBoneIndexType
Definition BoneIndices.h:7
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
bool PointsEqual(const FVector3f &V1, const FVector3f &V2, bool bUseEpsilonCompare=true)
Definition MeshBuild.h:40
@ MAX_TEXCOORDS
Definition MeshUVChannelInfo.h:8
@ Vertex
Definition MetalRHIPrivate.h:223
#define MAX_uint32
Definition NumericLimits.h:21
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
virtual CORE_API void UsingCustomVersion(const struct FGuid &Guid)
Definition Archive.cpp:590
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
CORE_API int32 CustomVer(const struct FGuid &Key) const
Definition Archive.cpp:602
Definition GenericOctree.h:42
COREUOBJECT_API void RemoveBulkData()
Definition BulkData.cpp:1049
Definition CustomVersion.h:111
Definition MaterialShared.h:2058
Definition NameTypes.h:617
Definition GenericOctreePublic.h:15
Definition RawMesh.Build.cs:6
Definition Array.h:670
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition UnrealString.h.inl:34
Definition GenericOctree.h:378
Definition SharedPointer.h:153
Definition ContainerAllocationPolicies.h:894
Definition Object.h:95
Definition SkeletalMesh.h:440
uint32 GetTypeHash(const FKey &Key)
Definition BlackboardKey.h:35
@ VersionPlusOne
Definition PropertyBag.cpp:48
@ LatestVersion
Definition PropertyBag.cpp:49
const FName ParentIndex("ParentIndex")
Definition SkeletalMeshAttributes.h:33
const FName VertexIndex("VertexIndex")
Definition MeshAttributes.h:28
Definition SkinWeightProfile.h:21
bool operator==(const FCachedAssetKey &A, const FCachedAssetKey &B)
Definition AssetDataMap.h:501
@ Element
Definition Visu.h:18
@ V2
Definition NNEModelData.cpp:18
@ V1
Definition NNEModelData.cpp:17
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition Color.h:486
Definition MeshUtilitiesCommon.h:53
static CORE_API uint32 MemCrc_DEPRECATED(const void *Data, int32 Length, uint32 CRC=0)
Definition Crc.cpp:592
@ SkeletalMeshSourceDataSupport16bitOfMaterialNumber
Definition EditorObjectVersion.h:93
CORE_API static const FGuid GUID
Definition EditorObjectVersion.h:100
Definition Guid.h:109
Definition MeshUtilitiesCommon.h:36
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
Definition MeshDescription.h:94
Definition MorphTarget.h:165
Definition ObjectVersion.h:762
Definition EngineTypes.h:2862
Definition BlendSpaceHelpers.h:88
Definition BlendSpaceHelpers.h:20
Definition DontCopy.h:13
Definition IsPODType.h:12
@ Value
Definition IsPODType.h:13
Definition WeakObjectPtrTemplates.h:25
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
T X
Definition Vector.h:62