MCPcopy Create free account
hub / github.com/PCGEx/PCGExtendedToolkit / Compile

Method Compile

Source/PCGExtendedToolkit/Private/Graph/PCGExGraph.cpp:312–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)\
365MACRO(IsEdgeUnion, bool, false, IsUnion()) \
366MACRO(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)

Callers 1

ExecuteTaskMethod · 0.45

Calls 15

InitArrayFunction · 0.85
MakeNoneDistancesFunction · 0.85
IsValidNameFunction · 0.85
checkFunction · 0.85
ReorderArrayFunction · 0.85
NodeGUIDFunction · 0.85
MarkClusterEdgesFunction · 0.85
MarkClusterVtxFunction · 0.85
NumMethod · 0.80
SetNumMethod · 0.80
AddSourcesMethod · 0.80
PrepareMergeMethod · 0.80

Tested by

no test coverage detected