UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DynamicBoneAttribute.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Containers/Array.h"
7
8//
9// Forward declarations
10//
11namespace UE::Geometry { class FDynamicMesh3; }
12
13namespace UE
14{
15namespace Geometry
16{
17
21template<typename ParentType, typename AttribValueType>
23:
24public TDynamicAttributeBase<ParentType>
25{
26protected:
28
30 ParentType* Parent = nullptr;
31
34public:
35
38
40 TDynamicBoneAttributeBase(ParentType* ParentIn, const int InNumBones = 0);
41
43 TDynamicBoneAttributeBase(ParentType* ParentIn, const int InNumBones, const AttribValueType& InitialValue);
44
45 virtual ~TDynamicBoneAttributeBase() = default;
46
48 void Initialize(const int32 InNumBones, const AttribValueType& InitialValue);
49
51 void Resize(const int32 InNumBones);
52
55
57 inline bool IsEmpty() const
58 {
59 return AttribValues.IsEmpty();
60 }
61
63 inline int32 Num() const
64 {
65 return AttribValues.Num();
66 }
67
73
75 {
76 return AttribValues;
77 }
78
84
85 inline const AttribValueType& GetValue(const int32 InBoneID) const
86 {
88 return AttribValues[InBoneID];
89 }
90
92 void Append(const AttribValueType& InValue);
93
95 {
97 }
98public:
99
100 //
101 // TDynamicAttributeBase interface
102 //
103
104 virtual TDynamicAttributeBase<ParentType>* MakeCopy(ParentType* ParentIn) const override;
105
106 virtual TDynamicAttributeBase<ParentType>* MakeNew(ParentType* ParentIn) const override;
107
108 virtual void CompactInPlace(const FCompactMaps& CompactMaps) override
109 {
110 // Compact maps don't affect the bone attribute.
111 }
112
113 virtual void Reparent(ParentType* NewParent) override
114 {
115 Parent = NewParent;
116 }
117
118 virtual bool CopyThroughMapping(const TDynamicAttributeBase<ParentType>* Source, const FMeshIndexMappings& Mapping) override
119 {
120 // Index remapping is not supported by the bone attribute. We need to be careful with the order of the
121 // bones since it affects the indexing of the skin weight attributes.
122 return true;
123 }
124
126 {
127 // Appending bone attributes is a special case that must be handled AttributeSet level,
128 // because it may require also consistently remapping bone weights
129 ensureMsgf(false, TEXT("Directly appending bone attributes is not supported"));
130 return false;
131 }
132
134 {
135 // bone attributes are not attached to mesh vertices/triangles/edges, so there is no work to do in the append-defaulted case
136 }
137
138 virtual bool CopyOut(int RawID, void* Buffer, int BufferSize) const override
139 {
140 return false; // Not supported for bones
141 }
142
143 virtual bool CopyIn(int RawID, void* Buffer, int BufferSize) override
144 {
145 return false; // Not supported for bones
146 }
147
152
153public:
154
155 //
156 // Serialization
157 //
158
159 void Serialize(FArchive& Ar);
160};
161
163template<>
165
170
171} // namespace Geometry
172} // namespace UE
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
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
Definition Archive.h:1208
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_REWRITE bool IsEmpty() const
Definition Array.h:1133
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize(void) const
Definition Array.h:1059
Definition UniquePtr.h:107
Definition CompactMaps.h:20
Definition DynamicMeshAttributeSet.h:84
Definition DynamicAttribute.h:67
Definition DynamicBoneAttribute.h:25
SIZE_T GetByteCount() const
Definition DynamicBoneAttribute.h:94
virtual void Reparent(ParentType *NewParent) override
Definition DynamicBoneAttribute.h:113
TArray< AttribValueType > AttribValues
Definition DynamicBoneAttribute.h:33
virtual bool Append(const TDynamicAttributeBase< ParentType > &Source, const UE::Geometry::FDynamicMesh3::FAppendInfo &Info) override
Definition DynamicBoneAttribute.h:125
virtual TUniquePtr< TDynamicAttributeChangeBase< ParentType > > NewBlankChange() const override
Definition DynamicBoneAttribute.h:148
virtual void AppendDefaulted(const UE::Geometry::FDynamicMesh3::FAppendInfo &Info) override
Definition DynamicBoneAttribute.h:133
const AttribValueType & GetValue(const int32 InBoneID) const
Definition DynamicBoneAttribute.h:85
void Resize(const int32 InNumBones)
Definition DynamicBoneAttribute.cpp:49
ParentType * Parent
Definition DynamicBoneAttribute.h:30
virtual TDynamicAttributeBase< ParentType > * MakeCopy(ParentType *ParentIn) const override
Definition DynamicBoneAttribute.cpp:62
virtual TDynamicAttributeBase< ParentType > * MakeNew(ParentType *ParentIn) const override
Definition DynamicBoneAttribute.cpp:70
void SetValue(const int32 InBoneID, const AttribValueType &InValue)
Definition DynamicBoneAttribute.h:79
virtual void CompactInPlace(const FCompactMaps &CompactMaps) override
Definition DynamicBoneAttribute.h:108
const TArray< AttribValueType > & GetAttribValues() const
Definition DynamicBoneAttribute.h:74
virtual bool CopyOut(int RawID, void *Buffer, int BufferSize) const override
Definition DynamicBoneAttribute.h:138
bool IsEmpty() const
Definition DynamicBoneAttribute.h:57
virtual bool CopyIn(int RawID, void *Buffer, int BufferSize) override
Definition DynamicBoneAttribute.h:143
virtual bool IsSameAs(const TDynamicBoneAttributeBase< ParentType, AttribValueType > &Other) const
Definition DynamicBoneAttribute.cpp:77
virtual bool CopyThroughMapping(const TDynamicAttributeBase< ParentType > *Source, const FMeshIndexMappings &Mapping) override
Definition DynamicBoneAttribute.h:118
int32 Num() const
Definition DynamicBoneAttribute.h:63
Definition ParametricSurfaceData.h:18
Definition AdvancedWidgetsModule.cpp:13
Definition DynamicMesh3.h:309
Definition MeshIndexMappings.h:22