diff --git a/03-UnrealEngine/Rendering/RenderingPipeline/Materials&MeshDraw/UE5.5 MeshDraw&SceneProxy探索.md b/03-UnrealEngine/Rendering/RenderingPipeline/Materials&MeshDraw/UE5.5 MeshDraw&SceneProxy探索.md index e449457..ca6d000 100644 --- a/03-UnrealEngine/Rendering/RenderingPipeline/Materials&MeshDraw/UE5.5 MeshDraw&SceneProxy探索.md +++ b/03-UnrealEngine/Rendering/RenderingPipeline/Materials&MeshDraw/UE5.5 MeshDraw&SceneProxy探索.md @@ -7,85 +7,14 @@ rating: ⭐ --- # 前言 探索思路: -- [ ] SceneProxy收集机制的改变。 -- [ ] GetDynamicMeshElements的调用方式。 -- [ ] 在SendRenderDynamicData_Concurrent中添加(模仿USkeletalMeshComponent::SendRenderDynamicData_Concurrent()与FDebugSkelMeshSceneProxy) - -# GetDynamicMeshElements -看得出主要在FDynamicMeshElementContext::GatherDynamicMeshElementsForPrimitive()中调用Primitive->Proxy->GetDynamicMeshElements()。 +# 问题解决方法 +添加相关性overrider,将bDynamicRelevance设置成true。 ```c++ -UE::Tasks::FTask FDynamicMeshElementContext::LaunchAsyncTask(FDynamicPrimitiveIndexQueue* PrimitiveIndexQueue, UE::Tasks::ETaskPriority TaskPriority) -{ - return Pipe.Launch(UE_SOURCE_LOCATION, [this, PrimitiveIndexQueue] - { - FOptionalTaskTagScope Scope(ETaskTag::EParallelRenderingThread); - FDynamicPrimitiveIndex PrimitiveIndex; - - while (PrimitiveIndexQueue->Pop(PrimitiveIndex)) - { - GatherDynamicMeshElementsForPrimitive(Primitives[PrimitiveIndex.Index], PrimitiveIndex.ViewMask); - } - -#if WITH_EDITOR - while (PrimitiveIndexQueue->PopEditor(PrimitiveIndex)) - { - GatherDynamicMeshElementsForEditorPrimitive(Primitives[PrimitiveIndex.Index], PrimitiveIndex.ViewMask); - } -#endif - }, TaskPriority); +FPrimitiveViewRelevance FOutlineSkeletalMeshSceneProxy::GetViewRelevance(const FSceneView* View) const +{ + FPrimitiveViewRelevance Result = FSkeletalMeshSceneProxy::GetViewRelevance(View); + Result.bDynamicRelevance = true; + return Result; } - -void FDynamicMeshElementContext::GatherDynamicMeshElementsForPrimitive(FPrimitiveSceneInfo* Primitive, uint8 ViewMask) -{ - SCOPED_NAMED_EVENT(DynamicPrimitive, FColor::Magenta); - - TArray> MeshBatchCountBefore; - MeshBatchCountBefore.SetNumUninitialized(Views.Num()); - for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++) - { - MeshBatchCountBefore[ViewIndex] = MeshCollector.GetMeshBatchCount(ViewIndex); - } - - MeshCollector.SetPrimitive(Primitive->Proxy, Primitive->DefaultDynamicHitProxyId); - - // If Custom Render Passes aren't in use, there will be only one group, which is the common case. - if (ViewFamilyGroups.Num() == 1 || Primitive->Proxy->SinglePassGDME()) - { - Primitive->Proxy->GetDynamicMeshElements(FirstViewFamily.AllViews, FirstViewFamily, ViewMask, MeshCollector); - } - else - { - for (FViewFamilyGroup& Group : ViewFamilyGroups) - { - if (uint8 MaskedViewMask = ViewMask & Group.ViewSubsetMask) - { - Primitive->Proxy->GetDynamicMeshElements(FirstViewFamily.AllViews, *Group.Family, MaskedViewMask, MeshCollector); - } - } - } - - for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++) - { - FViewInfo& View = *Views[ViewIndex]; - - if (ViewMask & (1 << ViewIndex)) - { - FDynamicPrimitive& DynamicPrimitive = DynamicPrimitives.Emplace_GetRef(); - DynamicPrimitive.PrimitiveIndex = Primitive->GetIndex(); - DynamicPrimitive.ViewIndex = ViewIndex; - DynamicPrimitive.StartElementIndex = MeshBatchCountBefore[ViewIndex]; - DynamicPrimitive.EndElementIndex = MeshCollector.GetMeshBatchCount(ViewIndex); - } - } -} -``` - -# SendRenderDynamicData_Concurrent - -## FDebugSkelMeshSceneProxy::GetDynamicMeshElements - - -# 其他? - -MeshBuilderSurface.GetMesh(GetLocalToWorld(), MatProxySurface, SDPG_Foreground, false, false, ViewIndex, Collector); \ No newline at end of file +``` \ No newline at end of file