UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CollectionUVFacade.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7
8// Note: Prefer namespace GeometryCollection::UV for new code
10{
11 enum
12 {
14 };
15}
16
18{
19 // Names of each UV layer attribute. In a valid collection with UVs, the first layer must be present, and the other layers are optional
21 // The UV layers are always contained in the vertices group in a geometry collection
23
27
29
48
49 template<typename ManagedArrayType, int32 MaxArraySize>
64
67
73 {
74 FUVLayers Layers;
76 {
78 if (!Layer)
79 {
80 break;
81 }
82 Layers.Attributes.Add(Layer);
83 }
84 return Layers;
85 }
91 {
92 FConstUVLayers Layers;
94 {
96 if (!Layer)
97 {
98 break;
99 }
100 Layers.Attributes.Add(Layer);
101 }
102 return Layers;
103 }
104
105 // Set all UVs in the array for the given vertex, stopping early if there are not enough matching UV layers in the collection
107 {
108 for (int32 LayerIdx = 0; LayerIdx < UVs.Num(); ++LayerIdx)
109 {
111 if (!ensure(Layer != nullptr))
112 {
113 break;
114 }
115 (*Layer)[VertexIdx] = UVs[LayerIdx];
116 }
117 }
118
123}
124
126{
128 {
129 public:
132 FCollectionUVFacade(const FManagedArrayCollection& InCollection) : Collection(nullptr), ConstCollection(&InCollection)
133 {}
134
139 inline bool IsValid() const
140 {
141 return GeometryCollection::UV::HasValidUVs(*ConstCollection);
142 }
143
148 {
150 }
151
152 inline bool SetNumUVLayers(int32 UVLayers)
153 {
154 return GeometryCollection::UV::SetNumUVLayers(*Collection, UVLayers);
155 }
156
157 inline int32 GetNumUVLayers() const
158 {
159 return GeometryCollection::UV::GetNumUVLayers(*ConstCollection);
160 }
161
163 {
164 return GeometryCollection::UV::GetUVLayer(*ConstCollection, UVLayer);
165 }
171 {
172 return GeometryCollection::UV::FindUVLayer(*ConstCollection, UVLayer);
173 }
183 {
185 }
186 inline void SetUV(int32 VertexIdx, int32 LayerIdx, const FVector2f& UV)
187 {
189 }
198
199 // Set all UVs in the array for the given vertex, stopping early if there are not enough matching UV layers in the collection
204
205 private:
206 FManagedArrayCollection* Collection;
207 const FManagedArrayCollection* ConstCollection;
208 };
209
210}
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define ensure( InExpression)
Definition AssertionMacros.h:464
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
EManagedArrayType ManagedArrayType()
Definition NameTypes.h:617
Definition CollectionUVFacade.h:128
GeometryCollection::UV::FUVLayers FindActiveUVLayers()
Definition CollectionUVFacade.h:190
bool SetNumUVLayers(int32 UVLayers)
Definition CollectionUVFacade.h:152
void SetUVs(int32 VertexIdx, TArrayView< const FVector2f > UVs)
Definition CollectionUVFacade.h:200
const FVector2f & GetUV(int32 VertexIdx, int32 LayerIdx) const
Definition CollectionUVFacade.h:182
TManagedArray< FVector2f > * FindUVLayer(int32 UVLayer)
Definition CollectionUVFacade.h:174
GeometryCollection::UV::FConstUVLayers FindActiveUVLayers() const
Definition CollectionUVFacade.h:194
void SetUV(int32 VertexIdx, int32 LayerIdx, const FVector2f &UV)
Definition CollectionUVFacade.h:186
const TManagedArray< FVector2f > & GetUVLayer(int32 UVLayer) const
Definition CollectionUVFacade.h:162
TManagedArray< FVector2f > & ModifyUVLayer(int32 UVLayer)
Definition CollectionUVFacade.h:166
bool IsValid() const
Definition CollectionUVFacade.h:139
FVector2f & ModifyUV(int32 VertexIdx, int32 LayerIdx)
Definition CollectionUVFacade.h:178
int32 GetNumUVLayers() const
Definition CollectionUVFacade.h:157
FCollectionUVFacade(const FManagedArrayCollection &InCollection)
Definition CollectionUVFacade.h:132
void DefineSchema()
Definition CollectionUVFacade.h:147
const TManagedArray< FVector2f > * FindUVLayer(int32 UVLayer) const
Definition CollectionUVFacade.h:170
FCollectionUVFacade(FManagedArrayCollection &InCollection)
Definition CollectionUVFacade.h:130
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition ManagedArray.h:1099
Definition CollectionUVFacade.h:10
@ MAX_NUM_UV_CHANNELS
Definition CollectionUVFacade.h:13
Definition CollectionBoundsFacade.cpp:13
Definition CollectionUVFacade.cpp:9
TManagedArray< FVector2f > & ModifyUVLayer(FManagedArrayCollection &Collection, int32 UVLayer)
Definition CollectionUVFacade.h:43
const FName VerticesGroupName
Definition CollectionUVFacade.cpp:21
void SetUVs(FManagedArrayCollection &Collection, int32 VertexIdx, TArrayView< const FVector2f > UVs)
Definition CollectionUVFacade.h:106
const TManagedArray< FVector2f > & GetUVLayer(const FManagedArrayCollection &Collection, int32 UVLayer)
Definition CollectionUVFacade.h:38
const TManagedArray< FVector2f > * FindUVLayer(const FManagedArrayCollection &Collection, int32 UVLayer)
Definition CollectionUVFacade.h:30
FUVLayers FindActiveUVLayers(FManagedArrayCollection &Collection)
Definition CollectionUVFacade.h:72
void DefineUVSchema(FManagedArrayCollection &Collection)
Definition CollectionUVFacade.cpp:28
const FName UVLayerNames[GeometryCollectionUV::MAX_NUM_UV_CHANNELS]
Definition CollectionUVFacade.cpp:10
bool HasValidUVs(const FManagedArrayCollection &Collection)
Definition CollectionUVFacade.cpp:23
bool SetNumUVLayers(FManagedArrayCollection &Collection, int32 NumLayers)
Definition CollectionUVFacade.cpp:34
void MatchUVLayerCount(FManagedArrayCollection &ToCollection, const FManagedArrayCollection &FromCollection)
Definition CollectionUVFacade.h:119
int32 GetNumUVLayers(const FManagedArrayCollection &Collection)
Definition CollectionUVFacade.cpp:54
Definition ManagedArrayCollection.h:56
Definition CollectionUVFacade.h:51
TArray< ManagedArrayType *, TFixedAllocator< MaxArraySize > > Attributes
Definition CollectionUVFacade.h:52
ManagedArrayType & operator[](int32 Idx) const
Definition CollectionUVFacade.h:54
int32 Num() const
Definition CollectionUVFacade.h:59