UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Components.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "MeshUVChannelInfo.h"
10#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
11#include "NaniteDefinitions.h"
12#endif
13
14/*=============================================================================
15 Components.h: Forward declarations of object components of actors
16=============================================================================*/
17
19
20
21// Constants.
23
36
69
82
94
96{
105
106 inline void Empty(int32 Slack = 0, int32 NumTexCoords = 0, int32 NumBoneInfluences = 0)
107 {
108 Position.Empty(Slack);
109 TangentX.Empty(Slack);
110 TangentY.Empty(Slack);
111 TangentZ.Empty(Slack);
112 Color.Empty(Slack);
113
114 BoneIndices.SetNum(NumBoneInfluences);
115 BoneWeights.SetNum(NumBoneInfluences);
116 for (int32 Influence = 0; Influence < NumBoneInfluences; ++Influence)
117 {
120 }
121
122 UVs.SetNum(NumTexCoords);
123 for (int32 TexCoord = 0; TexCoord < NumTexCoords; ++TexCoord)
124 {
125 UVs[TexCoord].Empty(Slack);
126 }
127 }
128};
129
131{
132 if (VertexView.Color.Num() > 0)
133 {
134 // Don't trust any input. We only have color if it isn't all white.
135 uint32 Channel = 255;
136
137 for (const FColor& Color : VertexView.Color)
138 {
139 Channel &= Color.R;
140 Channel &= Color.G;
141 Channel &= Color.B;
142 Channel &= Color.A;
143
144 if (Channel != 255)
145 {
146 break;
147 }
148 }
149
150 if (Channel == 255)
151 {
152 VertexView.Color = {};
153 }
154 }
155}
156
158{
159 if (VertexView.Color.Num() > 0)
160 {
161 // Don't trust any input. We only have color if it isn't all white.
162 uint32 Channel = 255;
163
164 for (const FColor& Color : VertexView.Color)
165 {
166 Channel &= Color.R;
167 Channel &= Color.G;
168 Channel &= Color.B;
169 Channel &= Color.A;
170
171 if (Channel != 255)
172 {
173 break;
174 }
175 }
176
177 if (Channel == 255)
178 {
179 VertexView.Color = {};
180 }
181 }
182}
183
204
224
227{
229 {
230 View.Position = MakeStridedView(InVertexData.Position);
231 View.TangentX = MakeStridedView(InVertexData.TangentX);
232 View.TangentY = MakeStridedView(InVertexData.TangentY);
233 View.TangentZ = MakeStridedView(InVertexData.TangentZ);
234 View.Color = MakeStridedView(InVertexData.Color);
235
236 View.BoneIndices.Reserve(InVertexData.BoneIndices.Num());
237 for (int32 Influence = 0; Influence < InVertexData.BoneIndices.Num(); ++Influence)
238 {
239 if (InVertexData.BoneIndices[Influence].Num() > 0)
240 {
241 View.BoneIndices.Add(MakeStridedView(sizeof(uint16), &InVertexData.BoneIndices[Influence][0], InVertexData.BoneIndices[Influence].Num()));
242 }
243 else
244 {
245 View.BoneIndices.Add({});
246 }
247 }
248
249 View.BoneWeights.Reserve(InVertexData.BoneWeights.Num());
250 for (int32 Influence = 0; Influence < InVertexData.BoneWeights.Num(); ++Influence)
251 {
252 if (InVertexData.BoneWeights[Influence].Num() > 0)
253 {
254 View.BoneWeights.Add(MakeStridedView(sizeof(uint16), &InVertexData.BoneWeights[Influence][0], InVertexData.BoneWeights[Influence].Num()));
255 }
256 else
257 {
258 View.BoneWeights.Add({});
259 }
260 }
261
262 View.UVs.Reserve(InVertexData.UVs.Num());
263 for (int32 UVCoord = 0; UVCoord < InVertexData.UVs.Num(); ++UVCoord)
264 {
265 if (InVertexData.UVs[UVCoord].Num() > 0)
266 {
267 View.UVs.Add(MakeStridedView(sizeof(FVector2f), &InVertexData.UVs[UVCoord][0], InVertexData.UVs[UVCoord].Num()));
268 }
269 else
270 {
271 View.UVs.Add({});
272 }
273 }
274
276 }
277 return View;
278}
279
281{
283 {
284 View.Position = MakeStridedView(InVertexData.Position);
285 View.TangentX = MakeStridedView(InVertexData.TangentX);
286 View.TangentY = MakeStridedView(InVertexData.TangentY);
287 View.TangentZ = MakeStridedView(InVertexData.TangentZ);
288 View.Color = MakeStridedView(InVertexData.Color);
289
290 View.BoneIndices.Reserve(InVertexData.BoneIndices.Num());
291 for (int32 Influence = 0; Influence < InVertexData.BoneIndices.Num(); ++Influence)
292 {
293 if (InVertexData.BoneIndices[Influence].Num() > 0)
294 {
295 View.BoneIndices.Add(MakeStridedView(sizeof(uint16), &InVertexData.BoneIndices[Influence][0], InVertexData.BoneIndices[Influence].Num()));
296 }
297 else
298 {
299 View.BoneIndices.Add({});
300 }
301 }
302
303 View.BoneWeights.Reserve(InVertexData.BoneWeights.Num());
304 for (int32 Influence = 0; Influence < InVertexData.BoneWeights.Num(); ++Influence)
305 {
306 if (InVertexData.BoneWeights[Influence].Num() > 0)
307 {
308 View.BoneWeights.Add(MakeStridedView(sizeof(uint16), &InVertexData.BoneWeights[Influence][0], InVertexData.BoneWeights[Influence].Num()));
309 }
310 else
311 {
312 View.BoneWeights.Add({});
313 }
314 }
315
316 View.UVs.Reserve(InVertexData.UVs.Num());
317 for (int32 UVCoord = 0; UVCoord < InVertexData.UVs.Num(); ++UVCoord)
318 {
319 if (InVertexData.UVs[UVCoord].Num() > 0)
320 {
321 View.UVs.Add(MakeStridedView(sizeof(FVector2f), &InVertexData.UVs[UVCoord][0], InVertexData.UVs[UVCoord].Num()));
322 }
323 else
324 {
325 View.UVs.Add({});
326 }
327 }
328
330 }
331 return View;
332}
333
334
336{
338
340 Vertex.TangentX = View.TangentX[Index];
341 Vertex.TangentY = View.TangentZ[Index];
342 Vertex.TangentZ = View.TangentY[Index];
343
344 for (int32 UVCoord = 0; UVCoord < View.UVs.Num(); ++UVCoord)
345 {
346 Vertex.UVs[UVCoord] = View.UVs[UVCoord][Index];
347 }
348
349 for (int32 UVCoord = View.UVs.Num(); UVCoord < MAX_STATIC_TEXCOORDS; ++UVCoord)
350 {
352 }
353
354 if (View.Color.Num() > 0)
355 {
356 Vertex.Color = View.Color[Index];
357 }
358 else
359 {
360 Vertex.Color = FColor::White;
361 }
362
363 return Vertex;
364}
365
367{
369 Output.Position = InVertexData.Position[Index];
370 Output.TangentX = InVertexData.TangentX[Index];
371 Output.TangentY = InVertexData.TangentY[Index];
372 Output.TangentZ = InVertexData.TangentZ[Index];
373 Output.Color = InVertexData.Color.Num() ? InVertexData.Color[Index] : FColor::White;
374
375 for (int32 UVCoord = 0; UVCoord < InVertexData.UVs.Num(); ++UVCoord)
376 {
378 }
379
381 {
383 }
384
385 return Output;
386}
FConstMeshBuildVertexView MakeConstMeshBuildVertexView(const TConstArrayView< FStaticMeshBuildVertex > &InVertices)
Definition Components.h:205
FStaticMeshBuildVertex MakeStaticMeshVertex(const FMeshBuildVertexView &View, int32 Index)
Definition Components.h:335
FMeshBuildVertexView MakeMeshBuildVertexView(TArray< FStaticMeshBuildVertex > &InVertices)
Definition Components.h:185
@ MAX_STATIC_TEXCOORDS
Definition Components.h:22
void RemoveInvalidVertexColor(FMeshBuildVertexView &VertexView)
Definition Components.h:130
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
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
@ Vertex
Definition MetalRHIPrivate.h:223
TStridedView< ElementType > MakeStridedView(int32 BytesBetweenElements, ElementType *FirstElement, int32 Count)
Definition StridedView.h:177
TConstStridedView< ElementType > MakeConstStridedView(int32 BytesBetweenElements, const ElementType *FirstElement, int32 Count)
Definition StridedView.h:183
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 RHIResources.h:3304
Definition Array.h:670
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition ContainerAllocationPolicies.h:1276
Definition ContainerAllocationPolicies.h:894
Definition StridedView.h:44
UE_FORCEINLINE_HINT SizeType Num() const
Definition StridedView.h:93
U16 Index
Definition radfft.cpp:71
Definition Color.h:486
static CORE_API const FColor White
Definition Color.h:749
Definition Components.h:72
TStridedView< const FVector3f > TangentX
Definition Components.h:74
TStridedView< const FVector3f > TangentY
Definition Components.h:75
TStridedView< const FColor > Color
Definition Components.h:80
TStridedView< const FVector3f > TangentZ
Definition Components.h:76
TArray< TStridedView< const FVector2f >, TInlineAllocator< 1 > > UVs
Definition Components.h:79
TArray< TStridedView< const uint16 > > BoneIndices
Definition Components.h:77
TArray< TStridedView< const uint16 > > BoneWeights
Definition Components.h:78
TStridedView< const FVector3f > Position
Definition Components.h:73
Definition Components.h:96
void Empty(int32 Slack=0, int32 NumTexCoords=0, int32 NumBoneInfluences=0)
Definition Components.h:106
TArray< TArray< FVector2f >, TInlineAllocator< 1 > > UVs
Definition Components.h:103
TArray< FColor > Color
Definition Components.h:104
TArray< FVector3f > Position
Definition Components.h:97
TArray< FVector3f > TangentX
Definition Components.h:98
TArray< FVector3f > TangentZ
Definition Components.h:100
TArray< FVector3f > TangentY
Definition Components.h:99
TArray< TArray< uint16 > > BoneIndices
Definition Components.h:101
TArray< TArray< uint16 > > BoneWeights
Definition Components.h:102
Definition Components.h:84
TStridedView< FColor > Color
Definition Components.h:92
TArray< TStridedView< uint16 > > BoneIndices
Definition Components.h:89
TStridedView< FVector3f > TangentY
Definition Components.h:87
TArray< TStridedView< FVector2f >, TInlineAllocator< 1 > > UVs
Definition Components.h:91
TStridedView< FVector3f > Position
Definition Components.h:85
TStridedView< FVector3f > TangentZ
Definition Components.h:88
TArray< TStridedView< uint16 > > BoneWeights
Definition Components.h:90
TStridedView< FVector3f > TangentX
Definition Components.h:86
Definition Components.h:26
FColor Color
Definition Components.h:34
FVector3f Position
Definition Components.h:27
FVector3f TangentZ
Definition Components.h:31
FVector3f TangentX
Definition Components.h:29
FVector2f UVs[MAX_STATIC_TEXCOORDS]
Definition Components.h:33
FVector3f TangentY
Definition Components.h:30
Definition Components.h:38
int8 LightMapCoordinateIndex
Definition Components.h:65
uint32 ColorIndexMask
Definition Components.h:64
TArray< FVertexStreamComponent, TFixedAllocator< MAX_STATIC_TEXCOORDS/2 > > TextureCoordinates
Definition Components.h:46
FVertexStreamComponent ColorComponent
Definition Components.h:52
uint8 LODLightmapDataIndex
Definition Components.h:67
FRHIShaderResourceView * TextureCoordinatesSRV
Definition Components.h:59
FVertexStreamComponent TangentBasisComponents[2]
Definition Components.h:43
uint8 NumTexCoords
Definition Components.h:66
FVertexStreamComponent LightMapCoordinateComponent
Definition Components.h:49
FRHIShaderResourceView * TangentsSRV
Definition Components.h:56
FRHIShaderResourceView * PositionComponentSRV
Definition Components.h:54
FVertexStreamComponent PositionComponent
Definition Components.h:40
FRHIShaderResourceView * ColorComponentsSRV
Definition Components.h:62
Definition VertexStreamComponent.h:22
static CORE_API const TVector2< float > ZeroVector
Definition Vector2D.h:63