UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BaseDynamicMeshComponent.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"
12#include "DynamicMesh/DynamicMesh3.h" // todo replace with predeclaration (lots of fallout)
13#include "UDynamicMesh.h"
14
15#include "BaseDynamicMeshComponent.generated.h"
16
17// predecl
18struct FMeshDescription;
20class FMeshChange;
23
29{
30 None = 0,
31 Positions = 1,
32 VertexColors = 1<<1,
33 VertexNormals = 1<<2,
34 VertexUVs = 1<<3,
36
38};
40
41
42
46UENUM(BlueprintType)
48{
54 ExternallyProvided UMETA(DisplayName = "From Dynamic Mesh"),
56 Default = 255
57};
58
59
63UENUM(BlueprintType)
75
76
80UENUM(BlueprintType)
82{
84 DynamicDraw = 0,
86 StaticDraw = 1
87};
88
89
93UENUM(BlueprintType)
94enum class UE_DEPRECATED(5.0, "Dynamic Mesh distance field support has been deprecated") EDynamicMeshComponentDistanceFieldMode : uint8
95{
99 AsyncCPUDistanceField = 1 UMETA(DisplayName = "Async CPU Distance Field")
100};
101
108UENUM(BlueprintType)
110{
112 NoTransform = 0,
116 SRGBToLinear UMETA(DisplayName = "SRGB To Linear")
117};
118
119
123UCLASS(Abstract, hidecategories = (LOD), ClassGroup = Rendering, MinimalAPI)
130{
132
133
134 //===============================================================================================================
135 // UBaseDynamicMeshComponent API. Subclasses must implement these functions
136 //
137public:
142 {
144 }
145
151 {
153 return nullptr;
154 }
155
159 virtual const FDynamicMesh3* GetMesh() const
160 {
162 return nullptr;
163 }
164
169 {
171 }
172
176 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
177 virtual UDynamicMesh* GetDynamicMesh()
178 {
180 return nullptr;
181 }
182
187 virtual void NotifyMeshUpdated()
188 {
190 }
191
195 virtual void ApplyChange(const FMeshVertexChange* Change, bool bRevert) override
196 {
198 }
199
203 virtual void ApplyChange(const FMeshChange* Change, bool bRevert) override
204 {
206 }
207
211 virtual void ApplyChange(const FMeshReplacementChange* Change, bool bRevert) override
212 {
214 }
215
219 virtual void ApplyTransform(const FTransform3d& Transform, bool bInvert)
220 {
222 }
223
224
225protected:
226
231 {
233 return nullptr;
234 }
235
240 {
242 }
243
244
245
246 //===============================================================================================================
247 // Built-in Wireframe-on-Shaded Rendering support. The wireframe looks terrible but this is a convenient
248 // way to enable/disable it.
249 //
250public:
254 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "Wireframe Overlay") )
255 bool bExplicitShowWireframe = false;
256
260 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
261 virtual void SetEnableWireframeRenderPass(bool bEnable) { bExplicitShowWireframe = bEnable; }
262
266 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
267 virtual bool GetEnableWireframeRenderPass() const { return bExplicitShowWireframe; }
268
272 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "Wireframe Color"))
273 FLinearColor WireframeColor = FLinearColor(0, 0.5f, 1.f);
274
275
276 //===============================================================================================================
277 // Built-in Color Rendering Support. When enabled, Color mode will override any assigned Materials.
278 // VertexColor mode displays vertex colors, Polygroup mode displays mesh polygroups via vertex colors,
279 // and Constant mode uses ConstantColor as the vertex color. The class-wide DefaultVertexColorMaterial
280 // is used as the material that displays the vertex colors, and cannot be overridden per-instance
281 // (the OverrideRenderMaterial can be used to do that)
282public:
283 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "Color Override") )
285
289 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
291
295 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
296 virtual EDynamicMeshComponentColorOverrideMode GetColorOverrideMode() const { return ColorMode; }
297
301 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "Constant Color", EditCondition = "ColorMode==EDynamicMeshComponentColorOverrideMode::Constant"))
303
307 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
308 GEOMETRYFRAMEWORK_API virtual void SetConstantOverrideColor(FColor NewColor);
309
313 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
314 virtual FColor GetConstantOverrideColor() const { return ConstantColor; }
315
323 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "Vertex Color Space"))
325
329 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
330 GEOMETRYFRAMEWORK_API virtual void SetVertexColorSpaceTransformMode(EDynamicMeshVertexColorTransformMode NewMode);
331
335 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
336 virtual EDynamicMeshVertexColorTransformMode GetVertexColorSpaceTransformMode() const { return ColorSpaceMode; }
337
338
339 //===============================================================================================================
340 // Two-Sided rendering support. When enabled, triangles will be rendered whether they are facing the camera or not
341public:
342 GEOMETRYFRAMEWORK_API virtual void SetTwoSided(bool bEnable);
343 virtual bool GetTwoSided() const { return bTwoSided; }
344
345protected:
346 UPROPERTY(EditAnywhere, Category = "Dynamic Mesh Component|Rendering");
347 bool bTwoSided = false;
348
349 //===============================================================================================================
350 // Flat shading support. When enabled, per-triangle normals are computed automatically and used in place
351 // of the mesh normals. Mesh tangents are not affected.
352public:
356 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "Flat Shading") )
357 bool bEnableFlatShading = false;
358
362 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
363 GEOMETRYFRAMEWORK_API virtual void SetEnableFlatShading(bool bEnable);
364
368 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component|Rendering")
369 virtual bool GetFlatShadingEnabled() const { return bEnableFlatShading; }
370
371
372
373 //===============================================================================================================
374 // API for changing Rendering settings. Although some of these settings are available publicly
375 // on the Component (in some cases as public members), generally changing them requires more complex
376 // Rendering invalidation.
377 //
378public:
379
380 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
381 GEOMETRYFRAMEWORK_API virtual void SetShadowsEnabled(bool bEnabled);
382
383 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
384 virtual bool GetShadowsEnabled() const { return CastShadow; }
385
386 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
387 GEOMETRYFRAMEWORK_API virtual void SetViewModeOverridesEnabled(bool bEnabled);
388
389 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
390 virtual bool GetViewModeOverridesEnabled() const { return bEnableViewModeOverrides; }
391
392public:
398 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering", meta = (DisplayName = "View Mode Overrides") )
400
401
402 //===============================================================================================================
403 // Override rendering material support. If an Override material is set, then it
404 // will be used during drawing of all mesh buffers except Secondary buffers.
405 //
406public:
410 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
411 GEOMETRYFRAMEWORK_API virtual void SetOverrideRenderMaterial(UMaterialInterface* Material);
412
416 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
417 GEOMETRYFRAMEWORK_API virtual void ClearOverrideRenderMaterial();
418
422 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
423 virtual bool HasOverrideRenderMaterial(int k) const
424 {
425 return OverrideRenderMaterial != nullptr;
426 }
427
431 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
432 virtual UMaterialInterface* GetOverrideRenderMaterial(int MaterialIndex) const
433 {
434 return OverrideRenderMaterial;
435 }
436
437protected:
438 UPROPERTY()
439 TObjectPtr<UMaterialInterface> OverrideRenderMaterial = nullptr;
440
441
442
443
444
445 //===============================================================================================================
446 // Secondary Render Buffers support. This requires implementation in subclasses. It allows
447 // a subset of the mesh triangles to be moved to a separate set of render buffers, which
448 // can then have a separate material (eg to highlight faces), or be shown/hidden independently.
449 //
450public:
454 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
455 GEOMETRYFRAMEWORK_API virtual void SetSecondaryRenderMaterial(UMaterialInterface* Material);
456
460 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
461 GEOMETRYFRAMEWORK_API virtual void ClearSecondaryRenderMaterial();
462
466 virtual bool HasSecondaryRenderMaterial() const
467 {
468 return SecondaryRenderMaterial != nullptr;
469 }
470
474 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
475 virtual UMaterialInterface* GetSecondaryRenderMaterial() const
476 {
477 return SecondaryRenderMaterial;
478 }
479
483 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
484 GEOMETRYFRAMEWORK_API virtual void SetSecondaryBuffersVisibility(bool bSetVisible);
485
489 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
490 GEOMETRYFRAMEWORK_API virtual bool GetSecondaryBuffersVisibility() const;
491
493 UPROPERTY()
494 TObjectPtr<UMaterialInterface> SecondaryRenderMaterial = nullptr;
495
496 bool bDrawSecondaryBuffers = true;
497
498
499 //===============================================================================================================
500 // Wireframe Material Override Support : Allow to override default wireframe material
501 //
502public:
506 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
507 GEOMETRYFRAMEWORK_API virtual void SetOverrideWireframeRenderMaterial(UMaterialInterface* Material);
508
512 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
513 GEOMETRYFRAMEWORK_API virtual void ClearOverrideWireframeRenderMaterial();
514
518 virtual bool HasOverrideWireframeRenderMaterial() const
519 {
520 return WireframeMaterialOverride != nullptr;
521 }
522
526 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
527 virtual UMaterialInterface* GetOverrideWireframeRenderMaterial() const
528 {
529 return WireframeMaterialOverride;
530 }
531
532protected:
534 TObjectPtr<UMaterialInterface> WireframeMaterialOverride = nullptr;
535
536
537 //===============================================================================================================
538 // Wireframe Material Secondary Override Support : Allow to override default secondary wireframe material
539 //
540public:
544 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
545 GEOMETRYFRAMEWORK_API virtual void SetOverrideSecondaryWireframeRenderMaterial(UMaterialInterface* Material);
546
550 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
551 GEOMETRYFRAMEWORK_API virtual void ClearOverrideSecondaryWireframeRenderMaterial();
552
556 virtual bool HasOverrideSecondaryWireframeRenderMaterial() const
557 {
558 return SecondaryWireframeMaterialOverride != nullptr;
559 }
560
564 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
565 virtual UMaterialInterface* GetOverrideSecondaryWireframeRenderMaterial() const
566 {
567 return SecondaryWireframeMaterialOverride;
568 }
569
570protected:
572 TObjectPtr<UMaterialInterface> SecondaryWireframeMaterialOverride = nullptr;
573
574
575 //===============================================================================================================
576 // Raytracing support. Must be enabled for various rendering effects.
577 // However, note that in actual "dynamic" contexts (ie where the mesh is changing every frame),
578 // enabling Raytracing support has additional renderthread performance costs and does
579 // not currently support partial updates in the SceneProxy.
580public:
581
586 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dynamic Mesh Component|Rendering")
588
593 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
594 GEOMETRYFRAMEWORK_API virtual void SetEnableRaytracing(bool bSetEnabled);
595
599 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
600 GEOMETRYFRAMEWORK_API virtual bool GetEnableRaytracing() const;
601
603 GEOMETRYFRAMEWORK_API virtual void OnRenderingStateChanged(bool bForceImmedateRebuild);
604
605
606
607
612 UPROPERTY(EditAnywhere, BlueprintReadWrite,
613 BlueprintSetter=SetMeshDrawPath, BlueprintGetter=GetMeshDrawPath,
614 Category = "Dynamic Mesh Component|Rendering")
616
617 // Whether the fast update paths will be used for the mesh.
618 // If false, fast update methods can still be called, but will fall back to recreating the render proxy
619 virtual bool AllowFastUpdate()
620 {
621 // note: fast update is not compatible with static draw path
623 }
624
625public:
626
630 UFUNCTION(BlueprintCallable, Category = "Dynamic Mesh Component")
632
636 UFUNCTION(BlueprintPure, Category = "Dynamic Mesh Component")
637 GEOMETRYFRAMEWORK_API virtual EDynamicMeshDrawPath GetMeshDrawPath() const;
638
642 UE_DEPRECATED(5.6, "Dynamic Mesh distance field support has been deprecated")
643 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "Dynamic Mesh distance field support has been deprecated"))
645
646public:
650 UE_DEPRECATED(5.6, "Dynamic Mesh distance field support has been deprecated")
651 UFUNCTION(Category = "Dynamic Mesh Component", meta = (DeprecatedFunction, DeprecationMessage = "Dynamic Mesh distance field support has been deprecated"))
653
657 UE_DEPRECATED(5.6, "Dynamic Mesh distance field support has been deprecated")
658 UFUNCTION(Category = "Dynamic Mesh Component", meta = (DeprecatedFunction, DeprecationMessage = "Dynamic Mesh distance field support has been deprecated"))
659 virtual EDynamicMeshComponentDistanceFieldMode GetDistanceFieldMode() const { return EDynamicMeshComponentDistanceFieldMode::NoDistanceField; }
661
662protected:
663 // this will be called if a change to distance field mode is detected
664 UE_DEPRECATED(5.6, "Dynamic Mesh distance field support has been deprecated")
665 GEOMETRYFRAMEWORK_API virtual void OnNewDistanceFieldMode() {}
666
667
668
669 //===============================================================================================================
670 // Standard Component interfaces
671 //
672public:
673
674 // UMeshComponent Interface.
675 GEOMETRYFRAMEWORK_API virtual int32 GetNumMaterials() const override;
676 GEOMETRYFRAMEWORK_API virtual UMaterialInterface* GetMaterial(int32 ElementIndex) const override;
677 UE_DEPRECATED(5.7, "Please use GetMaterialRelevance with EShaderPlatform argument and not ERHIFeatureLevel::Type")
682
683 GEOMETRYFRAMEWORK_API virtual void SetNumMaterials(int32 NumMaterials);
684
685 //~ Dynamic Mesh component just has an array of materials without managing slot names, but some methods expect
686 //~ to access materials via slot name, so we still implement the UPrimitiveComponent interface to do so
687 // @return an array of slot names generated from the current materials
688 GEOMETRYFRAMEWORK_API virtual TArray<FName> GetMaterialSlotNames() const override;
689 // @return true if the dynamic mesh has a material with this slot name
690 GEOMETRYFRAMEWORK_API virtual bool IsMaterialSlotNameValid(FName MaterialSlotName) const override;
691 // @return a material on this component with this slot name, or null not found
692 GEOMETRYFRAMEWORK_API virtual UMaterialInterface* GetMaterialByName(FName MaterialSlotName) const override;
693
694 //~ UObject Interface.
695#if WITH_EDITOR
696 GEOMETRYFRAMEWORK_API void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
697#endif
698
699 UPROPERTY()
701
702
703
704
705
706 //===============================================================================================================
707 // Class-wide Default Materials used for Wireframe and VertexColor display mode.
708 // These are configured for the Editor when the module loads, defaulting to built-in Engine wireframe and
709 // vertex color materials.
710 // Note that the ModelingComponents module in the MeshModelingToolset plugin (usually enabled in the UE Editor)
711 // will set a new VertexColor material from that plugins Content.
712 // Client code can further configure these materials as necessary using the static functions below.
713public:
717 static GEOMETRYFRAMEWORK_API void SetDefaultWireframeMaterial(UMaterialInterface* Material);
718
722 static GEOMETRYFRAMEWORK_API void SetDefaultVertexColorMaterial(UMaterialInterface* Material);
723
725 static GEOMETRYFRAMEWORK_API void InitializeDefaultMaterials();
726 friend class FGeometryFrameworkModule; // FGeometryFrameworkModule needs to call the above function
727
728 static GEOMETRYFRAMEWORK_API UMaterialInterface* GetDefaultWireframeMaterial_RenderThread();
729 static GEOMETRYFRAMEWORK_API UMaterialInterface* GetDefaultVertexColorMaterial_RenderThread();
730 friend class FBaseDynamicMeshSceneProxy; // FBaseDynamicMeshSceneProxy needs to call these functions...
731
732private:
733 // these Materials are used by the render thread. Once the engine is running they should not be modified without
734 // using SetDefaultWireframeMaterial/SetDefaultVertexColorMaterial
735 static GEOMETRYFRAMEWORK_API UMaterialInterface* DefaultWireframeMaterial;
736 static GEOMETRYFRAMEWORK_API UMaterialInterface* DefaultVertexColorMaterial;
737};
#define unimplemented()
Definition AssertionMacros.h:321
EDynamicMeshComponentColorOverrideMode
Definition BaseDynamicMeshComponent.h:65
EDynamicMeshVertexColorTransformMode
Definition BaseDynamicMeshComponent.h:110
EDynamicMeshComponentTangentsMode
Definition BaseDynamicMeshComponent.h:48
EDynamicMeshDrawPath
Definition BaseDynamicMeshComponent.h:82
EMeshRenderAttributeFlags
Definition BaseDynamicMeshComponent.h:29
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#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
EShaderPlatform
Definition RHIShaderPlatform.h:11
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition BaseDynamicMeshSceneProxy.h:39
virtual GEOMETRYFRAMEWORK_API int32 GetNumMaterials() const
Definition BaseDynamicMeshSceneProxy.cpp:115
virtual GEOMETRYFRAMEWORK_API UMaterialInterface * GetMaterial(int32 k) const
Definition BaseDynamicMeshSceneProxy.cpp:120
bool bTwoSided
Definition BaseDynamicMeshSceneProxy.h:61
bool bEnableRaytracing
Definition BaseDynamicMeshSceneProxy.h:64
bool bEnableViewModeOverrides
Definition BaseDynamicMeshSceneProxy.h:67
Definition GeometryFrameworkModule.h:9
Definition MeshChange.h:32
Definition MeshReplacementChange.h:27
Definition MeshVertexChange.h:22
Definition NameTypes.h:617
Definition MeshChange.h:78
Definition MeshReplacementChange.h:68
Definition MeshVertexChange.h:130
Definition InteractiveToolObjects.h:51
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition BaseDynamicMeshComponent.h:130
virtual FDynamicMesh3 * GetMesh()
Definition BaseDynamicMeshComponent.h:150
virtual void NotifyMaterialSetUpdated()
Definition BaseDynamicMeshComponent.h:239
virtual void ApplyTransform(const FTransform3d &Transform, bool bInvert)
Definition BaseDynamicMeshComponent.h:219
virtual FBaseDynamicMeshSceneProxy * GetBaseSceneProxy()
Definition BaseDynamicMeshComponent.h:230
virtual void SetMesh(UE::Geometry::FDynamicMesh3 &&MoveMesh)
Definition BaseDynamicMeshComponent.h:141
virtual void ApplyChange(const FMeshReplacementChange *Change, bool bRevert) override
Definition BaseDynamicMeshComponent.h:211
virtual const FDynamicMesh3 * GetMesh() const
Definition BaseDynamicMeshComponent.h:159
virtual void ApplyChange(const FMeshChange *Change, bool bRevert) override
Definition BaseDynamicMeshComponent.h:203
UPROPERTY(EditAnywhere, Category="Dynamic Mesh Component|Rendering")
virtual void NotifyMeshUpdated()
Definition BaseDynamicMeshComponent.h:187
virtual bool GetTwoSided() const
Definition BaseDynamicMeshComponent.h:343
virtual void ProcessMesh(TFunctionRef< void(const UE::Geometry::FDynamicMesh3 &)> ProcessFunc) const
Definition BaseDynamicMeshComponent.h:168
virtual void ApplyChange(const FMeshVertexChange *Change, bool bRevert) override
Definition BaseDynamicMeshComponent.h:195
Definition UDynamicMesh.h:123
Definition DynamicMesh3.h:108
Definition MaterialInterface.h:296
Definition MeshComponent.h:25
Definition SceneComponent.h:24
@ false
Definition radaudio_common.h:23
Definition Color.h:486
Definition Color.h:48
Definition MaterialRelevance.h:13
Definition MeshDescription.h:94
Definition UnrealType.h:6865
Definition ObjectPtr.h:488