| 310 | } |
| 311 | |
| 312 | void FSubGraph::Compile( |
| 313 | const TWeakPtr<PCGExMT::FAsyncMultiHandle>& InParentHandle, |
| 314 | const TSharedPtr<PCGExMT::FTaskManager>& AsyncManager, |
| 315 | const TSharedPtr<FGraphBuilder>& InBuilder) |
| 316 | { |
| 317 | TRACE_CPUPROFILER_EVENT_SCOPE(FWriteSubGraphEdges::ExecuteTask); |
| 318 | |
| 319 | const TSharedPtr<FGraph> ParentGraph = WeakParentGraph.Pin(); |
| 320 | |
| 321 | WeakBuilder = InBuilder; |
| 322 | WeakAsyncManager = AsyncManager; |
| 323 | |
| 324 | TArray<int32> EdgeDump = Edges.Array(); |
| 325 | const int32 NumEdges = EdgeDump.Num(); |
| 326 | |
| 327 | PCGEx::InitArray(FlattenedEdges, NumEdges); |
| 328 | |
| 329 | TArray<FPCGPoint>& MutablePoints = EdgesDataFacade->Source->GetOut()->GetMutablePoints(); |
| 330 | MutablePoints.SetNum(NumEdges); |
| 331 | |
| 332 | if (EdgesDataFacade->Source->GetIn()) |
| 333 | { |
| 334 | TRACE_CPUPROFILER_EVENT_SCOPE(FWriteSubGraphEdges::GatherPreExistingPoints); |
| 335 | |
| 336 | // Copy any existing point properties first |
| 337 | UPCGMetadata* Metadata = EdgesDataFacade->Source->GetOut()->Metadata; |
| 338 | const TArray<FPCGPoint>& InPoints = EdgesDataFacade->Source->GetIn()->GetPoints(); |
| 339 | for (int i = 0; i < NumEdges; i++) |
| 340 | { |
| 341 | const FEdge& OE = ParentGraph->Edges[EdgeDump[i]]; |
| 342 | FlattenedEdges[i] = FEdge(i, ParentGraph->Nodes[OE.Start].PointIndex, ParentGraph->Nodes[OE.End].PointIndex, i, OE.Index); // Use flat edge IOIndex to store original edge index |
| 343 | if (InPoints.IsValidIndex(OE.PointIndex)) { MutablePoints[i] = InPoints[OE.PointIndex]; } |
| 344 | Metadata->InitializeOnSet(MutablePoints[i].MetadataEntry); |
| 345 | } |
| 346 | } |
| 347 | else |
| 348 | { |
| 349 | TRACE_CPUPROFILER_EVENT_SCOPE(FWriteSubGraphEdges::CreatePoints); |
| 350 | |
| 351 | UPCGMetadata* Metadata = EdgesDataFacade->Source->GetOut()->Metadata; |
| 352 | |
| 353 | for (int i = 0; i < NumEdges; i++) |
| 354 | { |
| 355 | const FEdge& E = ParentGraph->Edges[EdgeDump[i]]; |
| 356 | FlattenedEdges[i] = FEdge(i, ParentGraph->Nodes[E.Start].PointIndex, ParentGraph->Nodes[E.End].PointIndex, i, E.Index); |
| 357 | Metadata->InitializeOnSet(MutablePoints[i].MetadataEntry); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | MetadataDetails = InBuilder->GetMetadataDetails(); |
| 362 | const bool bHasUnionMetadata = (MetadataDetails && InBuilder && !ParentGraph->EdgeMetadata.IsEmpty()); |
| 363 | |
| 364 | #define PCGEX_FOREACH_EDGE_METADATA(MACRO)\ |
| 365 | MACRO(IsEdgeUnion, bool, false, IsUnion()) \ |
| 366 | MACRO(EdgeUnionSize, int32, 0, UnionSize) |
| 367 | |
| 368 | #define PCGEX_EDGE_METADATA_DECL(_NAME, _TYPE, _DEFAULT, _ACCESSOR) if(bHasUnionMetadata && MetadataDetails->bWrite##_NAME){ _NAME##Buffer = EdgesDataFacade->GetWritable<_TYPE>(MetadataDetails->_NAME##AttributeName, _DEFAULT, true, PCGExData::EBufferInit::New); } |
| 369 | PCGEX_FOREACH_EDGE_METADATA(PCGEX_EDGE_METADATA_DECL) |
no test coverage detected