@@ -13,6 +13,10 @@ class FRuntimeMeshSceneProxy : public FPrimitiveSceneProxy
1313private:
1414 TUniformBufferRef<FPrimitiveUniformShaderParameters> MeshUniformBuffer;
1515
16+ // Temporarily holds all section creation data until this proxy is passsed to the RT.
17+ // After this data is applied this array is cleared.
18+ TArray<FRuntimeMeshSectionCreateDataInterface*> SectionCreationData;
19+
1620public:
1721
1822 FRuntimeMeshSceneProxy (URuntimeMeshComponent* Component)
@@ -37,29 +41,8 @@ class FRuntimeMeshSceneProxy : public FPrimitiveSceneProxy
3741
3842 // Get the section creation data
3943 auto * SectionData = SourceSection->GetSectionCreationData (Material);
40-
41-
42- auto Proxy = SectionData->NewProxy ;
43-
44- if (!IsInRenderingThread ())
45- {
46- // Enqueue update on RT
47- ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER (
48- FRuntimeMeshCreateSectionInternalCommand,
49- FRuntimeMeshSectionProxyInterface*, Proxy, Proxy,
50- FRuntimeMeshSectionCreateDataInterface*, SectionData, SectionData,
51- {
52- Proxy->FinishCreate_RenderThread (SectionData);
53- }
54- );
55- }
56- else
57- {
58- Proxy->FinishCreate_RenderThread (SectionData);
59- }
60-
61- // Save ref to new section
62- Sections[SectionIdx] = Proxy;
44+ SectionData->SetTargetSection (SectionIdx);
45+ SectionCreationData.Add (SectionData);
6346
6447 }
6548 }
@@ -76,6 +59,18 @@ class FRuntimeMeshSceneProxy : public FPrimitiveSceneProxy
7659 }
7760 }
7861
62+ void CreateRenderThreadResources () override
63+ {
64+ FPrimitiveSceneProxy::CreateRenderThreadResources ();
65+
66+ for (auto Section : SectionCreationData)
67+ {
68+ CreateSection_RenderThread (Section);
69+ }
70+ // The individual items are deleted by CreateSection_RenderThread so just clear the array.
71+ SectionCreationData.Empty ();
72+ }
73+
7974 /* * Called on render thread to create a new dynamic section. (Static sections are handled differently) */
8075 void CreateSection_RenderThread (FRuntimeMeshSectionCreateDataInterface* SectionData)
8176 {
0 commit comments