91 lines
2.9 KiB
Markdown
Raw Normal View History

2024-11-14 12:59:18 +08:00
---
title: Untitled
date: 2024-11-14 12:19:36
excerpt:
tags:
rating: ⭐
---
# 前言
探索思路:
- [ ] SceneProxy收集机制的改变。
- [ ] GetDynamicMeshElements的调用方式。
- [ ] 在SendRenderDynamicData_Concurrent中添加模仿USkeletalMeshComponent::SendRenderDynamicData_Concurrent()与FDebugSkelMeshSceneProxy
# GetDynamicMeshElements
看得出主要在FDynamicMeshElementContext::GatherDynamicMeshElementsForPrimitive()中调用Primitive->Proxy->GetDynamicMeshElements()。
```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);
}
void FDynamicMeshElementContext::GatherDynamicMeshElementsForPrimitive(FPrimitiveSceneInfo* Primitive, uint8 ViewMask)
{
SCOPED_NAMED_EVENT(DynamicPrimitive, FColor::Magenta);
TArray<int32, TInlineAllocator<4>> 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);