UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StaticMeshSceneProxy.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 StaticMesh.h: Static mesh class definition.
5=============================================================================*/
6
7#pragma once
8
10#include "PrimitiveSceneProxy.h"
11#include "RayTracingInstance.h"
12#include "SceneManagement.h"
13#include "RayTracingGeometry.h"
14
23enum class EPSOPrecachePriority : uint8;
24
26
29
34{
35public:
36 ENGINE_API SIZE_T GetTypeHash() const override;
37
40
43
45
47 virtual int32 GetNumMeshBatches() const
48 {
49 return 1;
50 }
51
53 ENGINE_API virtual bool GetShadowMeshElement(int32 LODIndex, int32 BatchIndex, uint8 InDepthPriorityGroup, FMeshBatch& OutMeshBatch, bool bDitheredLODTransition) const;
54
56 ENGINE_API virtual bool GetMeshElement(
57 int32 LODIndex,
58 int32 BatchIndex,
59 int32 SectionIndex,
61 bool bUseSelectionOutline,
64
66 ENGINE_API virtual bool GetRayTracingMeshElement(int32 LODIndex, int32 BatchIndex, int32 SectionIndex, uint8 InDepthPriorityGroup, FMeshBatch& OutMeshBatch) const;
67
68 ENGINE_API virtual void CreateRenderThreadResources(FRHICommandListBase& RHICmdList) override;
69
70 ENGINE_API virtual void DestroyRenderThreadResources() override;
71
74
77 int32 LODIndex,
78 int32 BatchIndex,
79 int32 ElementIndex,
83
85
86 virtual uint8 GetCurrentFirstLODIdx_RenderThread() const final override
87 {
89 }
90
95
96 ENGINE_API virtual int32 GetLightMapCoordinateIndex() const override;
97
99
101
102 virtual bool CanApplyStreamableRenderAssetScaleFactor() const override { return true; }
103
104protected:
105 UE_DEPRECATED(5.6, "Provide FStaticMeshSection, IndexBuffer and AdditionalIndexBuffers instead of LODIndex, etc.")
107 int32 LODIndex,
108 int32 ElementIndex,
109 bool bWireframe,
112 const FVertexFactory* VertexFactory,
114
117 const FStaticMeshSection& Section,
119 const FAdditionalStaticMeshIndexBuffers* AdditionalIndexBuffers,
120 const FVertexFactory* VertexFactory,
121 bool bWireframe,
124
126 ENGINE_API void SetMeshElementScreenSize(int32 LODIndex, bool bDitheredLODTransition, FMeshBatch& OutMeshBatch) const;
127
130
133
134 ENGINE_API bool IsCollisionView(const FEngineShowFlags& EngineShowFlags, bool& bDrawSimpleCollision, bool& bDrawComplexCollision) const;
135
138
140
141public:
142 // FPrimitiveSceneProxy interface.
143#if WITH_EDITOR
146#endif
148 ENGINE_API virtual int32 GetLOD(const FSceneView* View) const override;
149 ENGINE_API virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View) const override;
150 ENGINE_API virtual bool CanBeOccluded() const override;
151 virtual bool AllowInstanceCullingOcclusionQueries() const override { return true; }
152 ENGINE_API virtual bool IsUsingDistanceCullFade() const override;
153 ENGINE_API virtual void GetLightRelevance(const FLightSceneProxy* LightSceneProxy, bool& bDynamic, bool& bRelevant, bool& bLightMapped, bool& bShadowMapped) const override;
155 ENGINE_API virtual bool HasDistanceFieldRepresentation() const override;
156 ENGINE_API virtual bool StaticMeshHasPendingStreaming() const override;
157 ENGINE_API virtual bool HasDynamicIndirectShadowCasterRepresentation() const override;
158 virtual uint32 GetMemoryFootprint( void ) const override { return( sizeof( *this ) + GetAllocatedSize() ); }
159 SIZE_T GetAllocatedSize( void ) const { return( FPrimitiveSceneProxy::GetAllocatedSize() + LODs.GetAllocatedSize() ); }
160
161 ENGINE_API virtual void GetMeshDescription(int32 LODIndex, TArray<FMeshBatch>& OutMeshElements) const override;
162
163 ENGINE_API virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;
164
165 ENGINE_API virtual const FCardRepresentationData* GetMeshCardRepresentation() const override;
166
167 virtual bool IsCullingReversedByComponent() const override { return bReverseCulling; }
168
169 virtual FUintVector2 GetMeshPaintTextureDescriptor() const override { return MeshPaintTextureDescriptor; }
170
171#if RHI_RAYTRACING
175 ENGINE_API virtual bool HasRayTracingRepresentation() const override;
176 virtual bool IsRayTracingRelevant() const override { return true; }
177 virtual bool IsRayTracingStaticRelevant() const override
178 {
179 const bool bAllowStaticLighting = IsStaticLightingAllowed();
180 const bool bIsStaticInstance = !bDynamicRayTracingInstances && !bDynamicRayTracingGeometry;
181 return bIsStaticInstance && !HasViewDependentDPG() && !(bAllowStaticLighting && HasStaticLighting() && !HasValidSettingsForStaticLighting());
182 }
184#endif // RHI_RAYTRACING
185
186 ENGINE_API virtual void GetLCIs(FLCIArray& LCIs) override;
187
188#if WITH_EDITORONLY_DATA
189 ENGINE_API virtual bool GetPrimitiveDistance(int32 LODIndex, int32 SectionIndex, const FVector& ViewOrigin, float& PrimitiveDistance) const override;
190 ENGINE_API virtual bool GetMeshUVDensities(int32 LODIndex, int32 SectionIndex, FVector4& WorldUVDensities) const override;
191 ENGINE_API virtual bool GetMaterialTextureScales(int32 LODIndex, int32 SectionIndex, const FMaterialRenderProxy* MaterialRenderProxy, FVector4f* OneOverScales, FIntVector4* UVChannelIndices) const override;
192#endif
193
194#if STATICMESH_ENABLE_DEBUG_RENDERING
195 virtual int32 GetLightMapResolution() const override { return LightMapResolution; }
196#endif
197
198protected:
201 {
202 public:
203
206 {
209
210 #if WITH_EDITOR
212 bool bSelected = false;
213
215 HHitProxy* HitProxy = nullptr;
216 #endif
217
218 // The material index from the component. Used by the texture streaming accuracy viewmodes.
220
223 };
224
227
230
232
235
236 bool UsesMeshModifyingMaterials() const { return bUsesMeshModifyingMaterials; }
237
238 // FLightCacheInterface.
240
241 private:
242 TArray<FGuid> IrrelevantLights;
243
245 bool bUsesMeshModifyingMaterials;
246 };
247
250 {
251 public:
252
254 {
256 };
257
259
260 // TODO: Support OverrideColorVertexBuffer (needs to be generated similar to what is done for regular LODs)
261
263 };
264
266
269
272
276
277#if RHI_RAYTRACING
280
283
284 bool bSupportRayTracing : 1;
285 bool bHasRayTracingRepresentation : 1;
287 bool bDynamicRayTracingGeometry : 1;
289
293
295#endif
300
303
305
308
311
314
317
318#if WITH_EDITORONLY_DATA
320 float StreamingDistanceMultiplier;
325
330
333#endif
334
335private:
336
337 const UStaticMesh* StaticMesh;
338
339 FTextureResource* MeshPaintTextureResource = nullptr;
340 FUintVector2 MeshPaintTextureDescriptor = FUintVector2(0, 0);
341
342#if STATICMESH_ENABLE_DEBUG_RENDERING
343 UObject* Owner;
349 ECollisionTraceFlag CollisionTraceFlag;
351 FCollisionResponseContainer CollisionResponse;
353 int32 LODForCollision;
358
359protected:
362#endif
363
364public:
365
371 ENGINE_API float GetScreenSize(int32 LODIndex) const;
372
376 ENGINE_API FLODMask GetLODMask(const FSceneView* View) const;
377
378private:
379 ENGINE_API void AddSpeedTreeWind();
380 ENGINE_API void RemoveSpeedTreeWind();
381};
ECollisionTraceFlag
Definition BodySetupEnums.h:11
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
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
UE::Math::TIntVector2< uint32 > FUintVector2
Definition MathFwd.h:103
EPSOPrecachePriority
Definition PipelineStateCache.h:33
ERayTracingPrimitiveFlags
Definition PrimitiveSceneProxy.h:236
bool IsStaticLightingAllowed()
Definition RenderUtils.h:602
bool ShouldStaticMeshEvaluateWPOInRayTracing(FVector ViewCenter, const FBoxSphereBounds &Bounds)
Definition StaticMeshSceneProxy.cpp:207
ENGINE_API EPSOPrecachePriority GetStaticMeshComponentBoostPSOPrecachePriority()
Definition StaticMeshSceneProxy.cpp:96
void GetStaticMeshRayTracingWPOConfig(bool &bOutHasRayTracingRepresentation, bool &bOutDynamicRayTracingGeometry)
Definition StaticMeshSceneProxy.cpp:201
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MeshCardBuild.h:142
Definition ColorVertexBuffer.h:16
Definition DistanceFieldAtlas.h:241
Definition SceneManagement.h:820
Definition SceneManagement.h:333
Definition LightSceneProxy.h:43
Definition MaterialRenderProxy.h:102
Definition MeshElementCollector.h:26
Definition PrimitiveSceneProxy.h:296
TArray< class FLightCacheInterface *, TInlineAllocator< 8 > > FLCIArray
Definition PrimitiveSceneProxy.h:1132
virtual ENGINE_API HHitProxy * CreateHitProxies(UPrimitiveComponent *Component, TArray< TRefCountPtr< HHitProxy > > &OutHitProxies)
Definition PrimitiveSceneProxy.cpp:661
SIZE_T GetAllocatedSize(void) const
Definition PrimitiveSceneProxy.h:684
virtual int32 GetLightMapResolution() const
Definition PrimitiveSceneProxy.h:1169
bool HasStaticLighting() const
Definition PrimitiveSceneProxy.h:807
bool HasViewDependentDPG() const
Definition PrimitiveSceneProxy.h:806
bool HasValidSettingsForStaticLighting() const
Definition PrimitiveSceneProxy.h:872
Definition RHICommandList.h:455
Definition RawIndexBuffer.h:130
Definition SceneView.h:2212
Definition SceneView.h:1425
Definition StaticMeshResources.h:774
Definition StaticMeshSceneProxy.h:201
TArray< FSectionInfo, TInlineAllocator< 1 > > Sections
Definition StaticMeshSceneProxy.h:226
virtual ENGINE_API FLightInteraction GetInteraction(const FLightSceneProxy *LightSceneProxy) const override
Definition StaticMeshSceneProxy.cpp:2723
TUniformBufferRef< FLocalVertexFactoryUniformShaderParameters > OverrideColorVFUniformBuffer
Definition StaticMeshSceneProxy.h:231
bool UsesMeshModifyingMaterials() const
Definition StaticMeshSceneProxy.h:236
FColorVertexBuffer * OverrideColorVertexBuffer
Definition StaticMeshSceneProxy.h:229
Definition StaticMeshSceneProxy.h:250
TArray< FSectionInfo, TInlineAllocator< 1 > > Sections
Definition StaticMeshSceneProxy.h:258
Definition StaticMeshSceneProxy.h:34
virtual bool CanApplyStreamableRenderAssetScaleFactor() const override
Definition StaticMeshSceneProxy.h:102
int32 ForcedLodModel
Definition StaticMeshSceneProxy.h:299
uint32 MeshPaintTextureCoordinateIndex
Definition StaticMeshSceneProxy.h:310
ENGINE_API bool ShouldRenderBackFaces() const
Definition StaticMeshSceneProxy.cpp:1298
TArray< FRayTracingLODInfo > RayTracingLODInfos
Definition StaticMeshSceneProxy.h:268
virtual uint32 GetMemoryFootprint(void) const override
Definition StaticMeshSceneProxy.h:158
virtual ENGINE_API bool IsUsingDistanceCullFade() const override
Definition StaticMeshSceneProxy.cpp:2366
virtual ENGINE_API bool GetShadowMeshElement(int32 LODIndex, int32 BatchIndex, uint8 InDepthPriorityGroup, FMeshBatch &OutMeshBatch, bool bDitheredLODTransition) const
Definition StaticMeshSceneProxy.cpp:676
SIZE_T GetAllocatedSize(void) const
Definition StaticMeshSceneProxy.h:159
ENGINE_API uint32 SetMeshElementGeometrySource(int32 LODIndex, int32 ElementIndex, bool bWireframe, bool bUseInversedIndices, bool bAllowPreCulledIndices, const FVertexFactory *VertexFactory, FMeshBatch &OutMeshElement) const
Definition StaticMeshSceneProxy.cpp:1258
ENGINE_API void SetMeshElementScreenSize(int32 LODIndex, bool bDitheredLODTransition, FMeshBatch &OutMeshBatch) const
Definition StaticMeshSceneProxy.cpp:1274
ENGINE_API uint8 GetCurrentFirstLODIdx_Internal() const
Definition StaticMeshSceneProxy.cpp:1634
virtual ENGINE_API void GetDynamicMeshElements(const TArray< const FSceneView * > &Views, const FSceneViewFamily &ViewFamily, uint32 VisibilityMap, FMeshElementCollector &Collector) const override
Definition StaticMeshSceneProxy.cpp:1669
virtual ENGINE_API void GetDistanceFieldAtlasData(const FDistanceFieldVolumeData *&OutDistanceFieldData, float &SelfShadowBias) const override
Definition StaticMeshSceneProxy.cpp:2498
TArray< FLODInfo > LODs
Definition StaticMeshSceneProxy.h:267
virtual ENGINE_API void DestroyRenderThreadResources() override
Definition StaticMeshSceneProxy.cpp:988
virtual bool AllowInstanceCullingOcclusionQueries() const override
Definition StaticMeshSceneProxy.h:151
virtual FUintVector2 GetMeshPaintTextureDescriptor() const override
Definition StaticMeshSceneProxy.h:169
virtual ENGINE_API bool HasDistanceFieldRepresentation() const override
Definition StaticMeshSceneProxy.cpp:2504
TArray< TObjectPtr< UMaterialInterface > > MaterialSlotsOverlayMaterial
Definition StaticMeshSceneProxy.h:275
virtual ENGINE_API FPrimitiveViewRelevance GetViewRelevance(const FSceneView *View) const override
Definition StaticMeshSceneProxy.cpp:2372
virtual ENGINE_API bool GetCollisionMeshElement(int32 LODIndex, int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, const FMaterialRenderProxy *RenderProxy, FMeshBatch &OutMeshBatch) const
Definition StaticMeshSceneProxy.cpp:1042
FMaterialRelevance MaterialRelevance
Definition StaticMeshSceneProxy.h:313
virtual ENGINE_API void GetLCIs(FLCIArray &LCIs) override
Definition StaticMeshSceneProxy.cpp:2352
virtual ENGINE_API bool GetWireframeMeshElement(int32 LODIndex, int32 BatchIndex, const FMaterialRenderProxy *WireframeRenderProxy, uint8 InDepthPriorityGroup, bool bAllowPreCulledIndices, FMeshBatch &OutMeshBatch) const
Definition StaticMeshSceneProxy.cpp:1002
float OverlayMaterialMaxDrawDistance
Definition StaticMeshSceneProxy.h:274
virtual ENGINE_API void SetEvaluateWorldPositionOffsetInRayTracing(FRHICommandListBase &RHICmdList, bool bEvaluate)
Definition StaticMeshSceneProxy.cpp:491
ENGINE_API FLODMask GetLODMask(const FSceneView *View) const
Definition StaticMeshSceneProxy.cpp:2813
virtual FDesiredLODLevel GetDesiredLODLevel_RenderThread(const FSceneView *View) const final override
Definition StaticMeshSceneProxy.h:91
virtual ENGINE_API bool GetMeshElement(int32 LODIndex, int32 BatchIndex, int32 SectionIndex, uint8 InDepthPriorityGroup, bool bUseSelectionOutline, bool bAllowPreCulledIndices, FMeshBatch &OutMeshBatch) const
Definition StaticMeshSceneProxy.cpp:733
virtual ENGINE_API void DrawStaticElements(FStaticPrimitiveDrawInterface *PDI) override
Definition StaticMeshSceneProxy.cpp:1382
ENGINE_API float GetScreenSize(int32 LODIndex) const
Definition StaticMeshSceneProxy.cpp:2772
const FCardRepresentationData * CardRepresentationData
Definition StaticMeshSceneProxy.h:271
ENGINE_API bool IsReversedCullingNeeded(bool bUseReversedIndices) const
Definition StaticMeshSceneProxy.cpp:1304
virtual ENGINE_API int32 GetLightMapCoordinateIndex() const override
Definition StaticMeshSceneProxy.cpp:533
virtual ENGINE_API bool StaticMeshHasPendingStreaming() const override
Definition StaticMeshSceneProxy.cpp:2509
virtual ENGINE_API bool CanBeOccluded() const override
Definition StaticMeshSceneProxy.cpp:2361
virtual ENGINE_API void GetLightRelevance(const FLightSceneProxy *LightSceneProxy, bool &bDynamic, bool &bRelevant, bool &bLightMapped, bool &bShadowMapped) const override
Definition StaticMeshSceneProxy.cpp:2453
FStaticMeshRenderData * RenderData
Definition StaticMeshSceneProxy.h:265
virtual ENGINE_API bool GetRayTracingMeshElement(int32 LODIndex, int32 BatchIndex, int32 SectionIndex, uint8 InDepthPriorityGroup, FMeshBatch &OutMeshBatch) const
Definition StaticMeshSceneProxy.cpp:846
uint32 bReverseCulling
Definition StaticMeshSceneProxy.h:307
virtual ENGINE_API bool HasDynamicIndirectShadowCasterRepresentation() const override
Definition StaticMeshSceneProxy.cpp:2514
virtual ENGINE_API const FCardRepresentationData * GetMeshCardRepresentation() const override
Definition StaticMeshSceneProxy.cpp:2008
virtual uint8 GetCurrentFirstLODIdx_RenderThread() const final override
Definition StaticMeshSceneProxy.h:86
virtual ENGINE_API void GetMeshDescription(int32 LODIndex, TArray< FMeshBatch > &OutMeshElements) const override
Definition StaticMeshSceneProxy.cpp:1648
ENGINE_API bool IsCollisionView(const FEngineShowFlags &EngineShowFlags, bool &bDrawSimpleCollision, bool &bDrawComplexCollision) const
Definition StaticMeshSceneProxy.cpp:1609
uint32 bCastShadow
Definition StaticMeshSceneProxy.h:304
virtual ENGINE_API ~FStaticMeshSceneProxy()
Definition StaticMeshSceneProxy.cpp:607
virtual ENGINE_API int32 GetLOD(const FSceneView *View) const override
Definition StaticMeshSceneProxy.cpp:2782
ENGINE_API SIZE_T GetTypeHash() const override
Definition StaticMeshSceneProxy.cpp:670
const FDistanceFieldVolumeData * DistanceFieldData
Definition StaticMeshSceneProxy.h:270
virtual bool IsCullingReversedByComponent() const override
Definition StaticMeshSceneProxy.h:167
virtual ENGINE_API void CreateRenderThreadResources(FRHICommandListBase &RHICmdList) override
Definition StaticMeshSceneProxy.cpp:966
virtual ENGINE_API void GetStreamableRenderAssetInfo(const FBoxSphereBounds &InPrimitiveBounds, TArray< FStreamingRenderAssetPrimitiveInfo > &OutStreamableRenderAssets) const override
Definition StaticMeshSceneProxy.cpp:545
virtual ENGINE_API bool GetInstanceWorldPositionOffsetDisableDistance(float &OutWPODisableDistance) const override
Definition StaticMeshSceneProxy.cpp:539
float WPODisableDistance
Definition StaticMeshSceneProxy.h:316
virtual int32 GetNumMeshBatches() const
Definition StaticMeshSceneProxy.h:47
UMaterialInterface * OverlayMaterial
Definition StaticMeshSceneProxy.h:273
int32 ClampedMinLOD
Definition StaticMeshSceneProxy.h:302
virtual ENGINE_API void OnEvaluateWorldPositionOffsetChanged_RenderThread() override
Definition StaticMeshSceneProxy.cpp:1639
Definition SceneManagement.h:1293
Definition TextureResource.h:103
Definition VertexFactory.h:661
Definition HitProxies.h:135
Definition ComponentInterfaces.h:59
Definition RefCounting.h:454
Definition ShaderParameterMacros.h:136
Definition BodySetup.h:128
Definition MaterialInterface.h:296
Definition Object.h:95
Definition StaticMesh.h:593
int32 FGeometryGroupHandle
Definition SceneManagement.h:74
Definition StaticMeshResources.h:394
Definition EngineTypes.h:1339
Definition PrimitiveSceneProxy.h:67
static FDesiredLODLevel CreateFirst(uint8 LOD)
Definition PrimitiveSceneProxy.h:82
Definition ShowFlags.h:56
Definition SceneManagement.h:1831
Definition MaterialRelevance.h:13
Definition MeshBatch.h:371
Definition PrimitiveViewRelevance.h:14
Definition RayTracingInstance.h:17
Definition StaticMeshSceneProxyDesc.h:13
Definition StaticMeshSceneProxy.h:206
UMaterialInterface * OverlayMaterial
Definition StaticMeshSceneProxy.h:222
UMaterialInterface * Material
Definition StaticMeshSceneProxy.h:208
int32 MaterialIndex
Definition StaticMeshSceneProxy.h:219
Definition StaticMeshSceneProxy.h:254
UMaterialInterface * Material
Definition StaticMeshSceneProxy.h:255
Definition StaticMeshResources.h:202
Definition StaticMeshResources.h:643
Definition BoxSphereBounds.h:25