UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UDynamicMesh.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"
7
11
12#include "UDynamicMesh.generated.h"
13
14
15
21UCLASS(Abstract, MinimalAPI)
23{
25public:
27 virtual void Generate(FDynamicMesh3& MeshInOut) { };
28};
29
30
31
32
33
37UENUM(BlueprintType)
48
49UENUM(BlueprintType)
51{
52 Unknown = 0,
53 MeshTopology = 1 << 0,
54
55 VertexPositions = 1 << 1,
56 NormalsTangents = 1 << 2,
57 VertexColors = 1 << 3,
58 UVs = 1 << 4,
59 TriangleGroups = 1 << 5
60};
62
63
67USTRUCT(BlueprintType)
69{
71
72 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "DynamicMeshChangeInfo")
74
75 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "DynamicMeshChangeInfo")
77
78 // for changes that are an FChange, indicates whether this is an 'Apply' or 'Revert' of the FChange
79 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "DynamicMeshChangeInfo")
80 bool bIsRevertChange = false;
81
82 // return the single valid FChange, or null
83 const FMeshRegionChangeBase* GetChange() const
84 {
85 if (MeshChange)
86 {
87 ensure(!ReplaceChange && !VertexChange); // not valid to have multiple non-null FChanges
88 return MeshChange;
89 }
90 else if (ReplaceChange)
91 {
92 ensure(!VertexChange); // not valid to have multiple non-null FChanges
93 return ReplaceChange;
94 }
95 else
96 {
97 return VertexChange;
98 }
99 }
100
101 //
102 // internals
103 //
104 const FMeshChange* MeshChange = nullptr;
105 const FMeshReplacementChange* ReplaceChange = nullptr;
106 const FMeshVertexChange* VertexChange = nullptr;
107};
108
109// These delegates are used by UDynamicMesh
112
113
114
118UCLASS(BlueprintType, MinimalAPI)
123{
125public:
126
131 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh", meta = (Keywords = "Clear Empty Delete"))
132 GEOMETRYFRAMEWORK_API UPARAM(DisplayName = "Target") UDynamicMesh* Reset();
133
138 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh")
140
141 //
142 // Native access/modification functions
143 //
144
148 GEOMETRYFRAMEWORK_API virtual void InitializeMesh();
149
153 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh")
154 GEOMETRYFRAMEWORK_API bool IsEmpty() const;
155
159 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh")
160 GEOMETRYFRAMEWORK_API UPARAM(DisplayName = "Triangle Count") int32 GetTriangleCount() const;
161
162
167 const UE::Geometry::FDynamicMesh3& GetMeshRef() const { return *Mesh; }
172 const UE::Geometry::FDynamicMesh3* GetMeshPtr() const { return Mesh.Get(); }
173
184
185
188
191
196
204 bool bDeferChangeEvents = false);
205
210
211
212 //
213 // Change support
214 //
215
216
217 // IMeshVertexCommandChangeTarget implementation, allows a FVertexChange to be applied to the mesh
218 GEOMETRYFRAMEWORK_API void ApplyChange(const FMeshVertexChange* Change, bool bRevert);
219
220 // IMeshCommandChangeTarget implementation, allows a FMeshChange to be applied to the mesh
221 GEOMETRYFRAMEWORK_API void ApplyChange(const FMeshChange* Change, bool bRevert);
222
223 // IMeshReplacementCommandChangeTarget implementation, allows a FMeshReplacementChange to be applied to the mesh
224 GEOMETRYFRAMEWORK_API void ApplyChange(const FMeshReplacementChange* Change, bool bRevert);
225
226
227 //
228 // Event support
229 //
230protected:
235
236public:
238 FOnDynamicMeshChanged& OnPreMeshChanged() { return PreMeshChangedEvent; }
240 FOnDynamicMeshChanged& OnMeshChanged() { return MeshChangedEvent; }
241
242public:
244 UPROPERTY(BlueprintAssignable, meta = (DisplayName = "MeshModified"))
245 FOnDynamicMeshModifiedBP MeshModifiedBPEvent;
246
247
248 //
249 // Realtime Update support.
250 // This is intended to be used in situations where the internal mesh is being
251 // modified directly, ie instead of via EditMesh(), and we would like to
252 // notify listeners of these changes. Generally EditMesh() is preferred but in certain
253 // cases (eg like 3D sculpting) it is too complex to refactor all the mesh updates
254 // into EditMesh() calls (eg some are done async/etc). So, code that does those
255 // kinds of modifications can call PostRealtimeUpdate() to let any interested
256 // parties know that the mesh is actively changing.
257 //
258public:
260
264 FOnMeshRealtimeUpdate& OnMeshRealtimeUpdate() { return MeshRealtimeUpdateEvent; }
265
269 GEOMETRYFRAMEWORK_API virtual void PostRealtimeUpdate();
270
271protected:
273
274
275
276protected:
282
286 GEOMETRYFRAMEWORK_API void InitializeNewMesh();
287
292
293
294public:
295 // serialize Mesh to an Archive
296 GEOMETRYFRAMEWORK_API virtual void Serialize(FArchive& Archive) override;
297
298 // serialize Mesh to/from T3D
299 GEOMETRYFRAMEWORK_API virtual void ExportCustomProperties(FOutputDevice& Out, uint32 Indent) override;
300 GEOMETRYFRAMEWORK_API virtual void ImportCustomProperties(const TCHAR* SourceText, FFeedbackContext* Warn) override;
301
302
303
304 //
305 // (Preliminary) Procedural Generator support. If a Generator is configured, then each
306 // time this mesh is Reset(), it will call MeshGenerator->Generate(). The idea is that
307 // generator will be set to something that emits a new mesh based on external data,
308 // for example a procedural primitive Actor/Component could configure a Generator that
309 // generates the primitive mesh based on Actor settings.
310 //
311
312protected:
313
318 UPROPERTY(Instanced)
320
321public:
322
326 UPROPERTY(EditAnywhere, Category = "Dynamic Mesh")
327 bool bEnableMeshGenerator = false;
328
333
337 GEOMETRYFRAMEWORK_API virtual void ClearMeshGenerator();
338
342 GEOMETRYFRAMEWORK_API virtual void Regenerate();
343
344};
345
346
347
348
349
350
386UCLASS(BlueprintType, Transient, MinimalAPI)
388{
390public:
392 UFUNCTION(BlueprintCallable, Category="Dynamic Mesh")
393 GEOMETRYFRAMEWORK_API UDynamicMesh* RequestMesh();
394
396 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh")
397 GEOMETRYFRAMEWORK_API void ReturnMesh(UDynamicMesh* Mesh);
398
400 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh")
401 GEOMETRYFRAMEWORK_API void ReturnAllMeshes();
402
404 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh")
405 GEOMETRYFRAMEWORK_API void FreeAllMeshes();
406
407protected:
409 UPROPERTY()
411
413 UPROPERTY()
414 TArray<TObjectPtr<UDynamicMesh>> AllCreatedMeshes;
415
416private:
417 // Typically the mesh pool is used from the game thread, but
418 // in case it is not, we protect pool access w/ this critical section
419 mutable FCriticalSection PoolAccessCs;
420};
#define ensure( InExpression)
Definition AssertionMacros.h:464
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
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
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:58
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:53
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UPARAM(...)
Definition ObjectMacros.h:748
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EDynamicMeshAttributeChangeFlags
Definition UDynamicMesh.h:51
EDynamicMeshChangeType
Definition UDynamicMesh.h:39
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition FeedbackContext.h:30
Definition MeshChange.h:32
Definition MeshRegionChange.h:11
Definition MeshReplacementChange.h:27
Definition MeshVertexChange.h:22
Definition OutputDevice.h:133
Definition MeshChange.h:78
Definition MeshReplacementChange.h:68
Definition MeshVertexChange.h:130
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition UniquePtr.h:107
Definition UDynamicMesh.h:23
virtual void Generate(FDynamicMesh3 &MeshInOut)
Definition UDynamicMesh.h:27
Definition UDynamicMesh.h:388
Definition UDynamicMesh.h:123
FOnMeshRealtimeUpdate MeshRealtimeUpdateEvent
Definition UDynamicMesh.h:272
FOnDynamicMeshChanged MeshChangedEvent
Definition UDynamicMesh.h:234
FOnDynamicMeshChanged & OnPreMeshChanged()
Definition UDynamicMesh.h:238
const UE::Geometry::FDynamicMesh3 * GetMeshPtr() const
Definition UDynamicMesh.h:172
FOnDynamicMeshChanged PreMeshChangedEvent
Definition UDynamicMesh.h:232
FOnDynamicMeshChanged & OnMeshChanged()
Definition UDynamicMesh.h:240
UE::Geometry::FDynamicMesh3 * GetMeshPtr()
Definition UDynamicMesh.h:183
UE::Geometry::FDynamicMesh3 & GetMeshRef()
Definition UDynamicMesh.h:178
TUniquePtr< UE::Geometry::FDynamicMesh3 > Mesh
Definition UDynamicMesh.h:281
Definition DynamicMesh3.h:108
Definition Object.h:95
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition UDynamicMesh.h:69
Definition ObjectPtr.h:488