UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SkinWeightsAttributesRef.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "MeshDescription.h"
6#include "BoneWeights.h"
7
8
9namespace Internal
10{
12 {
14
16
18 {
19 return InContainer.Num();
20 }
21
26
27 template<typename Predicate>
29 {
30 auto ProxyPredicate = [InPredicate](const int32 InV) -> bool
31 {
33 };
34 return InContainer.IndexOfByPredicate(ProxyPredicate);
35 }
36 };
37
39 {
41
43
45 {
46 InContainer.SetNumUninitialized(InNum);
47 }
48
50 {
51 return InContainer.Num();
52 }
53
58
60 {
61 InContainer.GetData()[InIndex] = InBoneWeight.ToInt32();
62 }
63
65 {
66 InContainer.Add(InBoneWeight.ToInt32());
67 }
68
70 {
71 InContainer.RemoveAt(InIndex, 1);
72 }
73
74 template<typename Predicate>
75 static void Sort(ContainerType& InContainer, Predicate InPredicate)
76 {
77 auto ProxyPredicate = [InPredicate](const int32 InA, const int32 InB) -> bool
78 {
80 };
81 InContainer.SortByPredicate(ProxyPredicate);
82 }
83
84 template<typename Predicate>
86 {
87 auto ProxyPredicate = [InPredicate](const int32 InV) -> bool
88 {
90 };
91 return InContainer.IndexOfByPredicate(ProxyPredicate);
92 }
93 };
94
95
96 template<typename AdaptorType, typename StorageType>
98 public UE::AnimationCore::TBoneWeights<AdaptorType>
99 {
101 public:
103 Super(Container),
104 Container(InContainer)
105 {}
106
107 // For compatibility with range-based for loops.
109 {
110 public:
112 {
113 ++Index;
114 return *this;
115 }
116
118 {
119 return Weights != InOther.Weights || Index != InOther.Index;
120 }
121
123 {
124 return Weights->Get(Index);
125 }
126
127 protected:
128 friend class TVertexBoneWeightsBase<AdaptorType, StorageType>;
129
130 const_iterator() = delete;
131
139
142 };
143
144 const_iterator begin() const { return const_iterator(this, 0); }
145 const_iterator end() const { return const_iterator(this, this->Num()); }
146
147 private:
149 };
150
151} // namespace Internal
152
155
156
157// Merge these two.
159{
160public:
165 {
166 AttributesRef = InAttributesRef.AttributesRef;
167 return *this;
168 }
169
176
177 bool IsValid() const
178 {
179 return AttributesRef.IsValid();
180 }
181
183 {
184 return FVertexBoneWeights(AttributesRef.Get(InVertexIndex));
185 }
186
188 {
189 // FBoneWeights guarantees ordering and normalization, so we just copy the raw data.
190 TArrayAttribute<int32> Weights = AttributesRef.Get(InVertexIndex);
191
192 Weights.SetNumUninitialized(InWeights.Num());
193 for (int32 Index = 0; Index < InWeights.Num(); Index++)
194 {
195 Weights[Index] = InWeights[Index].ToInt32();
196 }
197 }
198
199 void Set(
203 )
204 {
205 // Proxy through FVertexBoneWeights so we get proper sorting and normalization of the weights.
206 FVertexBoneWeights BoneWeights(AttributesRef.Get(InVertexIndex));
207
208 BoneWeights.SetBoneWeights(InWeights, InSettings);
209 }
210
211protected:
213
217
218private:
221};
222
223
225{
226public:
231 {
232 AttributesConstRef = InAttributesRef.AttributesConstRef;
233 return *this;
234 }
235
237 {
238 AttributesConstRef = MoveTemp(InAttributesRef.AttributesConstRef);
240 return *this;
241 }
242
243 // Converting constructors from the non-const variant
245 AttributesConstRef(InAttribs.AttributesRef)
246 {}
247
249 {
250 AttributesConstRef = InAttribs.AttributesRef;
251 return *this;
252 }
253
254 bool IsValid() const
255 {
256 return AttributesConstRef.IsValid();
257 }
258
260 {
261 return FVertexBoneWeightsConst(AttributesConstRef.Get(InVertexIndex));
262 }
263
264protected:
267
271
275
276private:
278};
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
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
Internal::TVertexBoneWeightsBase< Internal::FAttributesRefAdapter, int32 > FVertexBoneWeights
Definition SkinWeightsAttributesRef.h:153
Internal::TVertexBoneWeightsBase< Internal::FAttributesRefAdapterConst, const int32 > FVertexBoneWeightsConst
Definition SkinWeightsAttributesRef.h:154
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition SkeletalMeshAttributes.h:47
Definition SkeletalMeshAttributes.h:221
Definition SkinWeightsAttributesRef.h:225
FSkinWeightsVertexAttributesConstRef(const FSkinWeightsVertexAttributesRef &InAttribs)
Definition SkinWeightsAttributesRef.h:244
FSkinWeightsVertexAttributesConstRef(TVertexAttributesRef< TArrayAttribute< int32 > > InAttributesConstRef)
Definition SkinWeightsAttributesRef.h:268
FSkinWeightsVertexAttributesConstRef & operator=(FSkinWeightsVertexAttributesConstRef &&InAttributesRef) noexcept
Definition SkinWeightsAttributesRef.h:236
FSkinWeightsVertexAttributesConstRef & operator=(const FSkinWeightsVertexAttributesRef &InAttribs)
Definition SkinWeightsAttributesRef.h:248
FVertexBoneWeightsConst Get(FVertexID InVertexIndex) const
Definition SkinWeightsAttributesRef.h:259
FSkinWeightsVertexAttributesConstRef(TVertexAttributesRef< TArrayAttribute< const int32 > > InAttributesConstRef)
Definition SkinWeightsAttributesRef.h:272
bool IsValid() const
Definition SkinWeightsAttributesRef.h:254
FSkinWeightsVertexAttributesConstRef(const FSkinWeightsVertexAttributesConstRef &)=default
FSkinWeightsVertexAttributesConstRef(FSkinWeightsVertexAttributesConstRef &&) noexcept=default
Definition SkinWeightsAttributesRef.h:159
bool IsValid() const
Definition SkinWeightsAttributesRef.h:177
void Set(const FVertexID InVertexIndex, const UE::AnimationCore::FBoneWeights &InWeights)
Definition SkinWeightsAttributesRef.h:187
FSkinWeightsVertexAttributesRef(TVertexAttributesRef< TArrayAttribute< int32 > > InAttributesRef)
Definition SkinWeightsAttributesRef.h:214
FVertexBoneWeights Get(const FVertexID InVertexIndex) const
Definition SkinWeightsAttributesRef.h:182
FSkinWeightsVertexAttributesRef(const FSkinWeightsVertexAttributesRef &)=default
FSkinWeightsVertexAttributesRef(FSkinWeightsVertexAttributesRef &&) noexcept=default
FSkinWeightsVertexAttributesRef & operator=(FSkinWeightsVertexAttributesRef &&InAttributesRef) noexcept
Definition SkinWeightsAttributesRef.h:170
void Set(const FVertexID InVertexIndex, TArrayView< const UE::AnimationCore::FBoneWeight > InWeights, const UE::AnimationCore::FBoneWeightsSettings &InSettings={})
Definition SkinWeightsAttributesRef.h:199
Definition SkinWeightsAttributesRef.h:109
const_iterator(const TVertexBoneWeightsBase< AdaptorType, StorageType > *InWeights, int32 InIndex)
Definition SkinWeightsAttributesRef.h:132
const TVertexBoneWeightsBase< AdaptorType, StorageType > * Weights
Definition SkinWeightsAttributesRef.h:140
int32 Index
Definition SkinWeightsAttributesRef.h:141
bool operator!=(const const_iterator &InOther) const
Definition SkinWeightsAttributesRef.h:117
const_iterator & operator++()
Definition SkinWeightsAttributesRef.h:111
UE::AnimationCore::FBoneWeight operator*() const
Definition SkinWeightsAttributesRef.h:122
Definition SkinWeightsAttributesRef.h:99
const_iterator begin() const
Definition SkinWeightsAttributesRef.h:144
const_iterator end() const
Definition SkinWeightsAttributesRef.h:145
TVertexBoneWeightsBase(const TArrayAttribute< StorageType > InContainer)
Definition SkinWeightsAttributesRef.h:102
Definition AttributeArrayContainer.h:393
void SetNumUninitialized(int32 Num)
Definition AttributeArrayContainer.h:491
Definition ArrayView.h:139
Definition MeshAttributeArray.h:836
Definition BoneWeights.h:48
static FBoneWeight FromInt32(int32 InBoneWeight)
Definition BoneWeights.h:197
Definition BoneWeights.h:229
A simple container for per-vertex influence of bones and their weights.
Definition BoneWeights.h:526
Definition BoneWeights.h:390
int32 Num() const
Definition BoneWeights.h:459
Definition ByteSwap.h:14
U16 Index
Definition radfft.cpp:71
Definition MeshTypes.h:90
Definition SkinWeightsAttributesRef.h:12
static int32 Num(const ContainerType &InContainer)
Definition SkinWeightsAttributesRef.h:17
static int32 IndexOf(const ContainerType &InContainer, Predicate InPredicate)
Definition SkinWeightsAttributesRef.h:28
static FBoneWeight Get(const ContainerType &InContainer, int32 InIndex)
Definition SkinWeightsAttributesRef.h:22
Definition SkinWeightsAttributesRef.h:39
static int32 IndexOf(const ContainerType &InContainer, Predicate InPredicate)
Definition SkinWeightsAttributesRef.h:85
static FBoneWeight Get(const ContainerType &InContainer, int32 InIndex)
Definition SkinWeightsAttributesRef.h:54
static int32 Num(const ContainerType &InContainer)
Definition SkinWeightsAttributesRef.h:49
static void Add(ContainerType &InContainer, FBoneWeight InBoneWeight)
Definition SkinWeightsAttributesRef.h:64
static void Sort(ContainerType &InContainer, Predicate InPredicate)
Definition SkinWeightsAttributesRef.h:75
static void SetNum(ContainerType &InContainer, int32 InNum)
Definition SkinWeightsAttributesRef.h:44
static void Set(ContainerType &InContainer, int32 InIndex, FBoneWeight InBoneWeight)
Definition SkinWeightsAttributesRef.h:59
static void Remove(ContainerType &InContainer, int32 InIndex)
Definition SkinWeightsAttributesRef.h:69