UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SplineMeshSceneProxy.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"
6#include "RenderingThread.h"
7#include "ShaderParameters.h"
8#include "VertexFactory.h"
12#include "StaticMeshResources.h"
14#include "SplineMeshShaderParams.h"
15#include "NaniteSceneProxy.h"
17
19
21// SplineMeshVertexFactory
22
55
57// FSplineMeshVertexFactoryShaderParameters
58
61{
63public:
64 void Bind(const FShaderParameterMap& ParameterMap);
65
67 const class FSceneInterface* Scene,
68 const FSceneView* View,
69 const class FMeshMaterialShader* Shader,
71 ERHIFeatureLevel::Type FeatureLevel,
72 const FVertexFactory* VertexFactory,
74 class FMeshDrawSingleShaderBindings& ShaderBindings,
75 FVertexInputStreamArray& VertexStreams
76 ) const;
77
78private:
80};
81
87
89// SplineMeshSceneProxy
90
95template<typename TDerived>
97{
98public:
105
107
109 {
110 check(SplineIndex == 0); // currently only support one spline type, but could do instanced later
111 SplineParams.TextureCoord = TexCoord;
113 }
114
116 {
117 // Don't replace the texture coord that was assigned to us in SetSplineTextureCoord
118 FUintVector2 TexCoord = SplineParams.TextureCoord;
119 SplineParams = Params;
120 SplineParams.TextureCoord = TexCoord;
122 }
123
124protected:
126 {
127 auto& SceneProxy = Downcast();
128
129 // NOTE: If the payload extension was not initialized, we're probably not using GPU Scene
131 {
132 if (bUpdateGPUScene)
133 {
134 // Request a GPU Scene update for this primitive so it updates its instance data
135 SceneProxy.GetScene().RequestGPUSceneUpdate(
136 *SceneProxy.GetPrimitiveSceneInfo(),
138 );
139 }
140 }
141
143 }
144
145protected:
148
150
153private:
155 virtual TDerived& Downcast() = 0;
156};
157
158#define IMPL_SPLINE_MESH_SCENE_PROXY_COMMON(classname) \
159 friend class TSplineMeshSceneProxyCommon<classname>; \
160 private: \
161 virtual classname& Downcast() override { return *this; }
162
164class FSplineMeshSceneProxy final : public FStaticMeshSceneProxy, public TSplineMeshSceneProxyCommon<FSplineMeshSceneProxy>
165{
167
168public:
170
172 // FPrimitiveSceneProxy interface
173 virtual SIZE_T GetTypeHash() const override;
174 virtual bool GetShadowMeshElement(int32 LODIndex, int32 BatchIndex, uint8 InDepthPriorityGroup, FMeshBatch& OutMeshBatch, bool bDitheredLODTransition) const override;
175 virtual bool GetMeshElement(int32 LODIndex, int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, bool bUseSelectionOutline, bool bAllowPreCulledIndices, FMeshBatch& OutMeshBatch) const override;
177 virtual bool GetCollisionMeshElement(int32 LODIndex, int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, const FMaterialRenderProxy* RenderProxy, FMeshBatch& OutMeshBatch) const override;
178 virtual bool GetRayTracingMeshElement(int32 LODIndex, int32 BatchIndex, int32 SectionIndex, uint8 InDepthPriorityGroup, FMeshBatch& OutMeshBatch) const;
179#if RHI_RAYTRACING
180 virtual bool HasRayTracingRepresentation() const override { return true; }
181 virtual bool IsRayTracingRelevant() const override { return true; }
182 virtual void GetDynamicRayTracingInstances(FRayTracingInstanceCollector& Collector) override;
183#endif // RHI_RAYTRACING
184 virtual void OnTransformChanged(FRHICommandListBase& RHICmdList) override;
185
186private:
187 struct FLODResources
188 {
190 FSplineMeshVertexFactory* VertexFactory;
191
193 VertexFactory(InVertexFactory)
194 {
195 }
196 };
197
198 void SetupMeshBatchForSpline(int32 InLODIndex, FMeshBatch& OutMeshBatch) const;
199 void SetupRayTracingMeshBatchForSpline(int32 InLODIndex, FMeshBatch& OutMeshBatch) const;
200
201private:
202 TArray<FLODResources> LODResources;
203};
204
206class FNaniteSplineMeshSceneProxy final : public Nanite::FSceneProxy, public TSplineMeshSceneProxyCommon<FNaniteSplineMeshSceneProxy>
207{
209
210public:
213
214 // FPrimitiveSceneProxy interface
215 virtual SIZE_T GetTypeHash() const override;
216 virtual void OnTransformChanged(FRHICommandListBase& RHICmdList) override;
217#if RHI_RAYTRACING
218 virtual void GetDynamicRayTracingInstances(FRayTracingInstanceCollector& Collector) override;
219 virtual void SetupFallbackRayTracingMaterials(int32 LODIndex, TArray<FMeshBatch>& OutMaterials) const override;
220#endif
221};
222
225
226
227
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
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
#define LAYOUT_FIELD(T, Name,...)
Definition MemoryLayout.h:471
#define DECLARE_TYPE_LAYOUT(T, Interface)
Definition MemoryLayout.h:557
void BeginUpdateResourceRHI(FRenderResource *Resource, FRenderCommandPipe *RenderCommandPipe)
Definition RenderResource.cpp:302
#define ENQUEUE_RENDER_COMMAND(Type)
Definition RenderingThread.h:1167
ENGINE_API void UpdateSplineMeshParams_RenderThread(FPrimitiveSceneProxy *SceneProxy, const FSplineMeshShaderParams &Params)
Definition SplineMeshSceneProxy.cpp:553
#define IMPL_SPLINE_MESH_SCENE_PROXY_COMMON(classname)
Definition SplineMeshSceneProxy.h:158
EVertexInputStreamType
Definition VertexFactory.h:128
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition LocalVertexFactory.h:51
FDataType Data
Definition LocalVertexFactory.h:188
Definition MaterialRenderProxy.h:102
Definition MeshDrawShaderBindings.h:104
Definition MeshMaterialShader.h:68
Definition SplineMeshSceneProxy.h:207
virtual void OnTransformChanged(FRHICommandListBase &RHICmdList) override
Definition SplineMeshSceneProxy.cpp:501
virtual SIZE_T GetTypeHash() const override
Definition SplineMeshSceneProxy.cpp:495
Definition PrimitiveSceneProxy.h:296
Definition RHICommandList.h:455
Definition RHICommandList.h:4626
Definition SceneInterface.h:106
Definition SceneView.h:1425
Definition ShaderCore.h:323
Definition ShaderParameters.h:56
Definition InstanceDataSceneProxy.h:413
Definition SplineMeshSceneProxy.h:165
virtual bool GetShadowMeshElement(int32 LODIndex, int32 BatchIndex, uint8 InDepthPriorityGroup, FMeshBatch &OutMeshBatch, bool bDitheredLODTransition) const override
Definition SplineMeshSceneProxy.cpp:147
virtual SIZE_T GetTypeHash() const override
Definition SplineMeshSceneProxy.cpp:117
virtual bool GetRayTracingMeshElement(int32 LODIndex, int32 BatchIndex, int32 SectionIndex, uint8 InDepthPriorityGroup, FMeshBatch &OutMeshBatch) const
Definition SplineMeshSceneProxy.cpp:196
virtual bool GetWireframeMeshElement(int32 LODIndex, int32 BatchIndex, const FMaterialRenderProxy *WireframeRenderProxy, uint8 InDepthPriorityGroup, bool bAllowPreCulledIndices, FMeshBatch &OutMeshBatch) const override
Definition SplineMeshSceneProxy.cpp:171
virtual bool GetCollisionMeshElement(int32 LODIndex, int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, const FMaterialRenderProxy *RenderProxy, FMeshBatch &OutMeshBatch) const override
Definition SplineMeshSceneProxy.cpp:184
virtual void OnTransformChanged(FRHICommandListBase &RHICmdList) override
Definition SplineMeshSceneProxy.cpp:405
virtual bool GetMeshElement(int32 LODIndex, int32 BatchIndex, int32 ElementIndex, uint8 InDepthPriorityGroup, bool bUseSelectionOutline, bool bAllowPreCulledIndices, FMeshBatch &OutMeshBatch) const override
Definition SplineMeshSceneProxy.cpp:159
Definition SplineMeshSceneProxy.h:61
void GetElementShaderBindings(const class FSceneInterface *Scene, const FSceneView *View, const class FMeshMaterialShader *Shader, const EVertexInputStreamType InputStreamType, ERHIFeatureLevel::Type FeatureLevel, const FVertexFactory *VertexFactory, const FMeshBatchElement &BatchElement, class FMeshDrawSingleShaderBindings &ShaderBindings, FVertexInputStreamArray &VertexStreams) const
Definition SplineMeshComponent.cpp:130
void Bind(const FShaderParameterMap &ParameterMap)
Definition SplineMeshComponent.cpp:125
Definition StaticMeshSceneProxy.h:34
Definition VertexFactory.h:172
Definition VertexFactory.h:661
Definition NaniteSceneProxy.h:480
Definition SplineMeshSceneProxy.h:97
TSplineMeshSceneProxyCommon()
Definition SplineMeshSceneProxy.h:99
void SetSplineTextureCoord_RenderThread(uint32 SplineIndex, FUintVector2 TexCoord)
Definition SplineMeshSceneProxy.h:108
const FSplineMeshShaderParams & GetSplineMeshParams() const
Definition SplineMeshSceneProxy.h:106
virtual ~TSplineMeshSceneProxyCommon()
Definition SplineMeshSceneProxy.h:104
FSplineMeshShaderParams SplineParams
Definition SplineMeshSceneProxy.h:147
FSplineMeshSceneInstanceDataBuffers SplineMeshInstanceData
Definition SplineMeshSceneProxy.h:149
bool bUpdateRayTracingGeometry
Definition SplineMeshSceneProxy.h:151
FRWBuffer RayTracingDynamicVertexBuffer
Definition SplineMeshSceneProxy.h:152
void RepackSplineMeshParams(bool bUpdateGPUScene=true)
Definition SplineMeshSceneProxy.h:125
void UpdateSplineMeshParams_RenderThread(const FSplineMeshShaderParams &Params)
Definition SplineMeshSceneProxy.h:115
Type
Definition RHIFeatureLevel.h:20
Definition LocalVertexFactory.h:60
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
Definition MeshBatch.h:232
Definition MeshBatch.h:371
Definition RHIUtilities.h:181
Definition ShaderCore.h:544
Definition SplineMeshSceneProxy.h:83
ENGINE_API void Setup(const FSplineMeshShaderParams &InSplineMeshShaderParams)
Definition SplineMeshSceneProxy.cpp:414
ENGINE_API bool Update(const FSplineMeshShaderParams &InSplineMeshShaderParams)
Definition SplineMeshSceneProxy.cpp:421
Definition SplineMeshSceneProxyDesc.h:10
Definition SplineMeshSceneProxy.h:25
static void ModifyCompilationEnvironment(const FVertexFactoryShaderPermutationParameters &Parameters, FShaderCompilerEnvironment &OutEnvironment)
Definition SplineMeshSceneProxy.cpp:35
FSplineMeshVertexFactory(ERHIFeatureLevel::Type InFeatureLevel)
Definition SplineMeshSceneProxy.h:28
static bool ShouldCompilePermutation(const FVertexFactoryShaderPermutationParameters &Parameters)
Definition SplineMeshSceneProxy.cpp:28
DECLARE_VERTEX_FACTORY_TYPE(FSplineMeshVertexFactory)
static void GetPSOPrecacheVertexFetchElements(EVertexInputStreamType VertexInputStreamType, FVertexDeclarationElementList &Elements)
Definition SplineMeshSceneProxy.cpp:47
void Copy(const FSplineMeshVertexFactory &Other)
Definition SplineMeshSceneProxy.h:43
Definition StaticMeshSceneProxyDesc.h:13
Definition MeshMaterialShader.h:44
Definition NaniteSceneProxy.h:66