2019-12-27 09:26:59 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-10-01 20:41:42 -04:00
# pragma once
# include "CoreMinimal.h"
# include "Components/MeshComponent.h"
2019-10-31 17:12:21 -04:00
# include "InteractiveToolObjects.h"
2019-10-01 20:41:42 -04:00
# include "Changes/MeshVertexChange.h"
# include "Changes/MeshChange.h"
2019-12-19 18:07:47 -05:00
# include "Changes/MeshReplacementChange.h"
2020-04-23 18:02:05 -04:00
# include "MeshConversionOptions.h"
2021-06-13 00:36:02 -04:00
# include "DynamicMesh/DynamicMesh3.h" // todo replace with predeclaration (lots of fallout)
2021-06-10 18:37:57 -04:00
# include "UDynamicMesh.h"
2019-10-01 20:41:42 -04:00
# include "BaseDynamicMeshComponent.generated.h"
// predecl
2020-04-23 18:02:05 -04:00
struct FMeshDescription ;
2019-10-01 20:41:42 -04:00
class FMeshVertexChange ;
class FMeshChange ;
2021-06-17 19:18:41 -04:00
class FBaseDynamicMeshSceneProxy ;
2021-03-09 19:33:56 -04:00
using UE : : Geometry : : FDynamicMesh3 ;
2019-10-01 20:41:42 -04:00
2020-04-18 18:42:59 -04:00
/**
* EMeshRenderAttributeFlags is used to identify different mesh rendering attributes , for things
* like fast - update functions
*/
enum class EMeshRenderAttributeFlags : uint8
{
None = 0 ,
2021-01-24 16:05:21 -04:00
Positions = 1 ,
VertexColors = 1 < < 1 ,
VertexNormals = 1 < < 2 ,
VertexUVs = 1 < < 3 ,
SecondaryIndexBuffers = 1 < < 4 ,
2020-04-18 18:42:59 -04:00
2021-01-24 16:05:21 -04:00
AllVertexAttribs = Positions | VertexColors | VertexNormals | VertexUVs
2020-04-18 18:42:59 -04:00
} ;
ENUM_CLASS_FLAGS ( EMeshRenderAttributeFlags ) ;
2019-10-01 20:41:42 -04:00
/**
* Tangent calculation modes
*/
UENUM ( )
2021-06-11 22:42:32 -04:00
enum class EDynamicMeshComponentTangentsMode : uint8
2019-10-01 20:41:42 -04:00
{
/** Tangents are not used/available, proceed accordingly (eg generate arbitrary orthogonal basis) */
NoTangents ,
2021-06-11 22:42:32 -04:00
/** Tangents will be automatically calculated on demand. Note that mesh changes due to tangents calculation will *not* be broadcast via MeshChange events! */
2019-10-01 20:41:42 -04:00
AutoCalculated ,
2021-06-11 22:42:32 -04:00
/** Tangents are externally provided via the FDynamicMesh3 AttributeSet */
2023-07-18 10:07:19 -04:00
ExternallyProvided UMETA ( DisplayName = " From Dynamic Mesh " ) ,
/** Tangents mode will be set to the most commonly-useful default -- currently "From Dynamic Mesh" */
Default = 255
2019-10-01 20:41:42 -04:00
} ;
2022-06-15 16:49:13 -04:00
/**
* Color Override Modes
*/
UENUM ( )
enum class EDynamicMeshComponentColorOverrideMode : uint8
{
/** No Color Override enabled */
None ,
/** Vertex Colors are displayed */
VertexColors ,
/** Polygroup Colors are displayed */
Polygroups ,
/** Constant Color is displayed */
Constant
} ;
2023-05-17 11:12:48 -04:00
/**
* Color Transform to apply to Vertex Colors when converting from internal DynamicMesh
* Color attributes ( eg Color Overlay stored in FVector4f ) to RHI Render Buffers ( FColor ) .
*
* Note that UStaticMesh assumes the Source Mesh colors are Linear and always converts to SRGB .
*/
UENUM ( )
enum class EDynamicMeshVertexColorTransformMode : uint8
{
/** Do not apply any color-space transform to Vertex Colors */
NoTransform ,
/** Assume Vertex Colors are in Linear space and transform to SRGB */
LinearToSRGB ,
/** Assume Vertex Colors are in SRGB space and convert to Linear */
SRGBToLinear
} ;
2022-06-15 16:49:13 -04:00
2019-10-01 20:41:42 -04:00
/**
2021-06-10 18:37:57 -04:00
* UBaseDynamicMeshComponent is a base interface for a UMeshComponent based on a UDynamicMesh .
2019-10-01 20:41:42 -04:00
*/
2023-06-17 18:13:06 -04:00
UCLASS ( Abstract , hidecategories = ( LOD ) , ClassGroup = Rendering , MinimalAPI )
class UBaseDynamicMeshComponent :
2021-06-10 18:37:57 -04:00
public UMeshComponent ,
public IToolFrameworkComponent ,
public IMeshVertexCommandChangeTarget ,
public IMeshCommandChangeTarget ,
public IMeshReplacementCommandChangeTarget
2019-10-01 20:41:42 -04:00
{
GENERATED_UCLASS_BODY ( )
2021-06-10 18:37:57 -04:00
//===============================================================================================================
// UBaseDynamicMeshComponent API. Subclasses must implement these functions
//
public :
2020-04-23 18:02:05 -04:00
/**
2021-06-11 22:42:32 -04:00
* initialize the internal mesh from a DynamicMesh
2020-04-23 18:02:05 -04:00
*/
2021-06-11 22:42:32 -04:00
virtual void SetMesh ( UE : : Geometry : : FDynamicMesh3 & & MoveMesh )
2020-04-23 18:02:05 -04:00
{
unimplemented ( ) ;
}
/**
* @ return pointer to internal mesh
2021-06-10 18:37:57 -04:00
* @ warning avoid usage of this function , access via GetDynamicMesh ( ) instead
2020-04-23 18:02:05 -04:00
*/
virtual FDynamicMesh3 * GetMesh ( )
{
unimplemented ( ) ;
return nullptr ;
}
/**
* @ return pointer to internal mesh
*/
virtual const FDynamicMesh3 * GetMesh ( ) const
{
unimplemented ( ) ;
return nullptr ;
}
2021-06-11 22:42:32 -04:00
/**
* Allow external code to read the internal mesh .
*/
virtual void ProcessMesh ( TFunctionRef < void ( const UE : : Geometry : : FDynamicMesh3 & ) > ProcessFunc ) const
{
unimplemented ( ) ;
}
2021-06-10 18:37:57 -04:00
/**
* @ return the child UDynamicMesh
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
virtual UDynamicMesh * GetDynamicMesh ( )
{
unimplemented ( ) ;
return nullptr ;
}
2019-10-01 20:41:42 -04:00
/**
* Call this if you update the mesh via GetMesh ( )
* @ todo should provide a function that calls a lambda to modify the mesh , and only return const mesh pointer
*/
virtual void NotifyMeshUpdated ( )
{
unimplemented ( ) ;
}
/**
* Apply a vertex deformation change to the internal mesh ( implements IMeshVertexCommandChangeTarget )
*/
virtual void ApplyChange ( const FMeshVertexChange * Change , bool bRevert ) override
{
unimplemented ( ) ;
}
/**
* Apply a general mesh change to the internal mesh ( implements IMeshCommandChangeTarget )
*/
virtual void ApplyChange ( const FMeshChange * Change , bool bRevert ) override
{
unimplemented ( ) ;
}
2019-12-19 18:07:47 -05:00
/**
* Apply a full mesh replacement change to the internal mesh ( implements IMeshReplacementCommandChangeTarget )
*/
virtual void ApplyChange ( const FMeshReplacementChange * Change , bool bRevert ) override
{
unimplemented ( ) ;
}
2021-06-10 18:37:57 -04:00
/**
* Apply a transform to the mesh
*/
2022-01-29 14:37:53 -05:00
virtual void ApplyTransform ( const FTransform3d & Transform , bool bInvert )
2020-04-23 18:02:05 -04:00
{
unimplemented ( ) ;
}
2019-12-19 18:07:47 -05:00
protected :
2021-06-17 19:18:41 -04:00
/**
* Subclass must implement this to return scene proxy if available , or nullptr
*/
virtual FBaseDynamicMeshSceneProxy * GetBaseSceneProxy ( )
{
unimplemented ( ) ;
return nullptr ;
}
2019-12-19 18:07:47 -05:00
/**
* Subclass must implement this to notify allocated proxies of updated materials
*/
virtual void NotifyMaterialSetUpdated ( )
{
unimplemented ( ) ;
}
2021-06-10 18:37:57 -04:00
//===============================================================================================================
// Built-in Wireframe-on-Shaded Rendering support. The wireframe looks terrible but this is a convenient
// way to enable/disable it.
//
2019-12-19 18:07:47 -05:00
public :
2021-06-10 18:37:57 -04:00
/**
2021-11-25 17:01:03 -05:00
* If true , render the Wireframe on top of the Shaded Mesh
2021-06-10 18:37:57 -04:00
*/
2021-10-01 16:01:41 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " Wireframe Overlay " ) )
2021-06-10 18:37:57 -04:00
bool bExplicitShowWireframe = false ;
2019-12-19 18:07:47 -05:00
2020-04-18 18:42:59 -04:00
/**
* Configure whether wireframe rendering is enabled or not
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
virtual void SetEnableWireframeRenderPass ( bool bEnable ) { bExplicitShowWireframe = bEnable ; }
2020-04-18 18:42:59 -04:00
2019-12-19 18:07:47 -05:00
/**
2021-06-10 18:37:57 -04:00
* @ return true if wireframe rendering pass is enabled
2019-12-19 18:07:47 -05:00
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
virtual bool GetEnableWireframeRenderPass ( ) const { return bExplicitShowWireframe ; }
2019-12-19 18:07:47 -05:00
2022-06-15 16:49:13 -04:00
/**
* Constant Color used when Override Color Mode is set to Constant
*/
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " Wireframe Color " ) )
FLinearColor WireframeColor = FLinearColor ( 0 , 0.5f , 1.f ) ;
//===============================================================================================================
// Built-in Color Rendering Support. When enabled, Color mode will override any assigned Materials.
// VertexColor mode displays vertex colors, Polygroup mode displays mesh polygroups via vertex colors,
// and Constant mode uses ConstantColor as the vertex color. The class-wide DefaultVertexColorMaterial
// is used as the material that displays the vertex colors, and cannot be overridden per-instance
// (the OverrideRenderMaterial can be used to do that)
public :
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " Color Override " ) )
EDynamicMeshComponentColorOverrideMode ColorMode = EDynamicMeshComponentColorOverrideMode : : None ;
/**
* Configure the active Color Override
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetColorOverrideMode ( EDynamicMeshComponentColorOverrideMode NewMode ) ;
2022-06-15 16:49:13 -04:00
/**
* @ return active Color Override mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
virtual EDynamicMeshComponentColorOverrideMode GetColorOverrideMode ( ) const { return ColorMode ; }
/**
* Constant Color used when Override Color Mode is set to Constant
*/
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " Constant Color " , EditCondition = " ColorMode==EDynamicMeshComponentColorOverrideMode::Constant " ) )
FColor ConstantColor = FColor : : White ;
/**
* Configure the Color used with Constant Color Override Mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetConstantOverrideColor ( FColor NewColor ) ;
2022-06-15 16:49:13 -04:00
/**
* @ return active Color used for Constant Color Override Mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
virtual FColor GetConstantOverrideColor ( ) const { return ConstantColor ; }
2023-05-17 11:12:48 -04:00
/**
* Color Space Transform that will be applied to the colors stored in the DynamicMesh Attribute Color Overlay when
* constructing render buffers .
* Default is " No Transform " , ie color R / G / B / A will be independently converted from 32 - bit float to 8 - bit by direct mapping .
* LinearToSRGB mode will apply SRGB conversion , ie assumes colors in the Mesh are in Linear space . This will produce the same behavior as UStaticMesh .
* SRGBToLinear mode will invert SRGB conversion , ie assumes colors in the Mesh are in SRGB space .
*/
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " Vertex Color Space " ) )
EDynamicMeshVertexColorTransformMode ColorSpaceMode = EDynamicMeshVertexColorTransformMode : : NoTransform ;
/**
* Configure the active Color Space Transform Mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetVertexColorSpaceTransformMode ( EDynamicMeshVertexColorTransformMode NewMode ) ;
2023-05-17 11:12:48 -04:00
/**
* @ return active Color Override mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
virtual EDynamicMeshVertexColorTransformMode GetVertexColorSpaceTransformMode ( ) const { return ColorSpaceMode ; }
2022-06-15 16:49:13 -04:00
//===============================================================================================================
// Flat shading support. When enabled, per-triangle normals are computed automatically and used in place
// of the mesh normals. Mesh tangents are not affected.
public :
/**
* Enable use of per - triangle facet normals in place of mesh normals
*/
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " Flat Shading " ) )
bool bEnableFlatShading = false ;
/**
* Configure the Color used with Constant Color Override Mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetEnableFlatShading ( bool bEnable ) ;
2022-06-15 16:49:13 -04:00
/**
* @ return active Color used for Constant Color Override Mode
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component|Rendering " )
virtual bool GetFlatShadingEnabled ( ) const { return bEnableFlatShading ; }
2019-12-19 18:07:47 -05:00
2021-06-10 18:37:57 -04:00
2021-06-17 19:18:41 -04:00
//===============================================================================================================
// API for changing Rendering settings. Although some of these settings are available publicly
// on the Component (in some cases as public members), generally changing them requires more complex
// Rendering invalidation.
//
public :
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetShadowsEnabled ( bool bEnabled ) ;
2021-06-17 19:18:41 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
virtual bool GetShadowsEnabled ( ) const { return CastShadow ; }
2021-11-25 17:01:03 -05:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetViewModeOverridesEnabled ( bool bEnabled ) ;
2021-11-25 17:01:03 -05:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
virtual bool GetViewModeOverridesEnabled ( ) const { return bEnableViewModeOverrides ; }
public :
/**
* This flag controls whether Editor View Mode Overrides are enabled for this mesh . For example , this controls hidden - line removal on the wireframe
* in Wireframe View Mode , and whether the normal map will be disabled in Lighting - Only View Mode , as well as various other things .
* Use SetViewModeOverridesEnabled ( ) to control this setting in Blueprints / C + + .
*/
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " , meta = ( DisplayName = " View Mode Overrides " ) )
bool bEnableViewModeOverrides = true ;
2021-06-10 18:37:57 -04:00
//===============================================================================================================
// Override rendering material support. If an Override material is set, then it
// will be used during drawing of all mesh buffers except Secondary buffers.
2019-12-19 18:07:47 -05:00
//
2021-06-10 18:37:57 -04:00
public :
2019-12-19 18:07:47 -05:00
/**
* Set an active override render material . This should replace all materials during rendering .
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetOverrideRenderMaterial ( UMaterialInterface * Material ) ;
2019-12-19 18:07:47 -05:00
/**
* Clear any active override render material
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void ClearOverrideRenderMaterial ( ) ;
2019-12-19 18:07:47 -05:00
/**
* @ return true if an override render material is currently enabled for the given MaterialIndex
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2019-12-19 18:07:47 -05:00
virtual bool HasOverrideRenderMaterial ( int k ) const
{
return OverrideRenderMaterial ! = nullptr ;
}
/**
* @ return active override render material for the given MaterialIndex
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2019-12-19 18:07:47 -05:00
virtual UMaterialInterface * GetOverrideRenderMaterial ( int MaterialIndex ) const
{
return OverrideRenderMaterial ;
}
2021-06-10 18:37:57 -04:00
protected :
UPROPERTY ( )
TObjectPtr < UMaterialInterface > OverrideRenderMaterial = nullptr ;
2019-12-19 18:07:47 -05:00
2021-06-10 18:37:57 -04:00
//===============================================================================================================
// Secondary Render Buffers support. This requires implementation in subclasses. It allows
// a subset of the mesh triangles to be moved to a separate set of render buffers, which
// can then have a separate material (eg to highlight faces), or be shown/hidden independently.
//
2019-12-19 18:07:47 -05:00
public :
/**
2021-06-10 18:37:57 -04:00
* Set an active secondary render material .
2019-12-19 18:07:47 -05:00
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetSecondaryRenderMaterial ( UMaterialInterface * Material ) ;
2019-12-19 18:07:47 -05:00
/**
2021-06-10 18:37:57 -04:00
* Clear any active secondary render material
2019-12-19 18:07:47 -05:00
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void ClearSecondaryRenderMaterial ( ) ;
2019-12-19 18:07:47 -05:00
/**
2021-06-10 18:37:57 -04:00
* @ return true if a secondary render material is set
2019-12-19 18:07:47 -05:00
*/
virtual bool HasSecondaryRenderMaterial ( ) const
{
return SecondaryRenderMaterial ! = nullptr ;
}
/**
2021-06-10 18:37:57 -04:00
* @ return active secondary render material
2019-12-19 18:07:47 -05:00
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2019-12-19 18:07:47 -05:00
virtual UMaterialInterface * GetSecondaryRenderMaterial ( ) const
{
return SecondaryRenderMaterial ;
}
2020-01-27 20:11:15 -05:00
/**
* Show / Hide the secondary triangle buffers . Does not invalidate SceneProxy .
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetSecondaryBuffersVisibility ( bool bSetVisible ) ;
2020-01-27 20:11:15 -05:00
/**
* @ return true if secondary buffers are currently set to be visible
*/
2021-06-10 18:37:57 -04:00
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual bool GetSecondaryBuffersVisibility ( ) const ;
2020-01-27 20:11:15 -05:00
2019-12-19 18:07:47 -05:00
protected :
2021-01-21 17:02:07 -04:00
UPROPERTY ( )
2021-06-10 18:37:57 -04:00
TObjectPtr < UMaterialInterface > SecondaryRenderMaterial = nullptr ;
2019-12-19 18:07:47 -05:00
2020-01-27 20:11:15 -05:00
bool bDrawSecondaryBuffers = true ;
2019-11-19 17:08:48 -05:00
2021-06-10 18:37:57 -04:00
2021-10-01 16:01:41 -04:00
//===============================================================================================================
// Raytracing support. Must be enabled for various rendering effects.
// However, note that in actual "dynamic" contexts (ie where the mesh is changing every frame),
// enabling Raytracing support has additional renderthread performance costs and does
// not currently support partial updates in the SceneProxy.
public :
2021-11-25 17:01:03 -05:00
/**
* Enable / disable Raytracing support on this Mesh , if Raytracing is currently enabled in the Project Settings .
* Use SetEnableRaytracing ( ) to configure this flag in Blueprints / C + + .
*/
2021-10-01 16:01:41 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = " Dynamic Mesh Component|Rendering " )
2021-10-07 22:25:54 -04:00
bool bEnableRaytracing = true ;
2021-10-01 16:01:41 -04:00
/**
* Enable / Disable raytracing support . This is an expensive call as it flushes
* the rendering queue and forces an immediate rebuild of the SceneProxy .
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetEnableRaytracing ( bool bSetEnabled ) ;
2021-10-01 16:01:41 -04:00
/**
* @ return true if raytracing support is currently enabled
*/
UFUNCTION ( BlueprintCallable , Category = " Dynamic Mesh Component " )
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual bool GetEnableRaytracing ( ) const ;
2021-10-01 16:01:41 -04:00
protected :
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void OnRenderingStateChanged ( bool bForceImmedateRebuild ) ;
2021-10-01 16:01:41 -04:00
2021-06-10 18:37:57 -04:00
//===============================================================================================================
// Standard Component interfaces
//
2019-12-19 18:07:47 -05:00
public :
2021-06-10 18:37:57 -04:00
// UMeshComponent Interface.
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual int32 GetNumMaterials ( ) const override ;
GEOMETRYFRAMEWORK_API virtual UMaterialInterface * GetMaterial ( int32 ElementIndex ) const override ;
GEOMETRYFRAMEWORK_API virtual FMaterialRelevance GetMaterialRelevance ( ERHIFeatureLevel : : Type InFeatureLevel ) const override ;
GEOMETRYFRAMEWORK_API virtual void SetMaterial ( int32 ElementIndex , UMaterialInterface * Material ) override ;
GEOMETRYFRAMEWORK_API virtual void GetUsedMaterials ( TArray < UMaterialInterface * > & OutMaterials , bool bGetDebugMaterials = false ) const override ;
2019-12-19 18:07:47 -05:00
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API virtual void SetNumMaterials ( int32 NumMaterials ) ;
2021-09-15 21:24:22 -04:00
2021-10-01 16:01:41 -04:00
//~ UObject Interface.
# if WITH_EDITOR
2023-06-17 18:13:06 -04:00
GEOMETRYFRAMEWORK_API void PostEditChangeProperty ( FPropertyChangedEvent & PropertyChangedEvent ) override ;
2021-10-01 16:01:41 -04:00
# endif
2021-06-10 18:37:57 -04:00
UPROPERTY ( )
TArray < TObjectPtr < UMaterialInterface > > BaseMaterials ;
2022-06-15 16:49:13 -04:00
//===============================================================================================================
// Class-wide Default Materials used for Wireframe and VertexColor display mode.
// These are configured for the Editor when the module loads, defaulting to built-in Engine wireframe and
// vertex color materials.
// Note that the ModelingComponents module in the MeshModelingToolset plugin (usually enabled in the UE Editor)
// will set a new VertexColor material from that plugins Content.
// Client code can further configure these materials as necessary using the static functions below.
public :
/**
* Set the wireframe material used for all BaseDynamicMeshComponent - derived Components
*/
2023-06-17 18:13:06 -04:00
static GEOMETRYFRAMEWORK_API void SetDefaultWireframeMaterial ( UMaterialInterface * Material ) ;
2022-06-15 16:49:13 -04:00
/**
* Set the vertex color material used for all BaseDynamicMeshComponent - derived Components
*/
2023-06-17 18:13:06 -04:00
static GEOMETRYFRAMEWORK_API void SetDefaultVertexColorMaterial ( UMaterialInterface * Material ) ;
2022-06-15 16:49:13 -04:00
protected :
2023-06-17 18:13:06 -04:00
static GEOMETRYFRAMEWORK_API void InitializeDefaultMaterials ( ) ;
2022-06-15 16:49:13 -04:00
friend class FGeometryFrameworkModule ; // FGeometryFrameworkModule needs to call the above function
2023-06-17 18:13:06 -04:00
static GEOMETRYFRAMEWORK_API UMaterialInterface * GetDefaultWireframeMaterial_RenderThread ( ) ;
static GEOMETRYFRAMEWORK_API UMaterialInterface * GetDefaultVertexColorMaterial_RenderThread ( ) ;
2022-06-15 16:49:13 -04:00
friend class FBaseDynamicMeshSceneProxy ; // FBaseDynamicMeshSceneProxy needs to call these functions...
private :
// these Materials are used by the render thread. Once the engine is running they should not be modified without
// using SetDefaultWireframeMaterial/SetDefaultVertexColorMaterial
2023-06-17 18:13:06 -04:00
static GEOMETRYFRAMEWORK_API UMaterialInterface * DefaultWireframeMaterial ;
static GEOMETRYFRAMEWORK_API UMaterialInterface * DefaultVertexColorMaterial ;
2019-10-01 20:41:42 -04:00
} ;