Skip to content

Commit 3e8f008

Browse files
committed
Bump to 0.15
1 parent 648ffd4 commit 3e8f008

35 files changed

Lines changed: 511 additions & 429 deletions
-101 KB
Binary file not shown.
0 Bytes
Binary file not shown.

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Data/PCGExPointIO.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ namespace PCGExData
356356
*/
357357
void FPointIOCollection::OutputTo(FPCGContext* Context)
358358
{
359+
Sort();
359360
for (FPointIO* Pair : Pairs) { Pair->OutputTo(Context); }
360361
}
361362

@@ -367,6 +368,7 @@ namespace PCGExData
367368
*/
368369
void FPointIOCollection::OutputTo(FPCGContext* Context, const int32 MinPointCount, const int32 MaxPointCount)
369370
{
371+
Sort();
370372
for (FPointIO* Pair : Pairs) { Pair->OutputTo(Context, MinPointCount, MaxPointCount); }
371373
}
372374

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Edges/PCGExBridgeEdgeClusters.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool FPCGExBridgeEdgeClustersElement::ExecuteInternal(
113113
EdgeIO->CreateInKeys();
114114
Context->GetAsyncManager()->Start<PCGExClusterTask::FBuildCluster>(
115115
-1, Context->CurrentIO,
116-
NewCluster, EdgeIO, &Context->NodeIndicesMap, &Context->EdgeNumReader->Values);
116+
NewCluster, EdgeIO, &Context->EndpointsLookup, &Context->EdgeNumReader->Values);
117117
}
118118

119119
Context->SetAsyncState(PCGExGraph::State_BuildingClusters);
@@ -330,8 +330,7 @@ bool FPCGExCreateBridgeTask::ExecuteTask()
330330
UPCGMetadata* EdgeMetadata = Context->ConsolidatedEdges->GetOut()->Metadata;
331331
UPCGMetadata* PointMetadata = Context->CurrentIO->GetOut()->Metadata;
332332

333-
FPCGMetadataAttribute<int64>* StartIndexAtt = static_cast<FPCGMetadataAttribute<int64>*>(EdgeMetadata->GetMutableAttribute(PCGExGraph::Tag_EdgeStart));
334-
FPCGMetadataAttribute<int64>* EndIndexAtt = static_cast<FPCGMetadataAttribute<int64>*>(EdgeMetadata->GetMutableAttribute(PCGExGraph::Tag_EdgeEnd));
333+
FPCGMetadataAttribute<int64>* EndpointAtt = static_cast<FPCGMetadataAttribute<int64>*>(EdgeMetadata->GetMutableAttribute(PCGExGraph::Tag_EdgeEndpoints));
335334
const FPCGMetadataAttribute<int64>* EdgeIndexAtt = static_cast<FPCGMetadataAttribute<int64>*>(PointMetadata->GetMutableAttribute(PCGExGraph::Tag_EdgeIndex));
336335

337336
FPCGPoint& EdgePoint = PointIO->GetOut()->GetMutablePoints()[TaskIndex];
@@ -343,8 +342,7 @@ bool FPCGExCreateBridgeTask::ExecuteTask()
343342

344343
Context->BumpEdgeNum(StartPoint, EndPoint);
345344

346-
StartIndexAtt->SetValue(EdgePoint.MetadataEntry, EdgeIndexAtt->GetValueFromItemKey(StartPoint.MetadataEntry));
347-
EndIndexAtt->SetValue(EdgePoint.MetadataEntry, EdgeIndexAtt->GetValueFromItemKey(EndPoint.MetadataEntry));
345+
EndpointAtt->SetValue(EdgePoint.MetadataEntry, EdgeIndexAtt->GetValueFromItemKey(EndPoint.MetadataEntry));
348346

349347
return true;
350348
}

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Edges/PCGExDrawEdges.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ bool FPCGExDrawEdgesElement::ExecuteInternal(
8686
{
8787
while (Context->AdvanceEdges(true))
8888
{
89-
if (!Context->CurrentCluster) { continue; }
89+
if (!Context->CurrentCluster)
90+
{
91+
PCGE_LOG(Warning, GraphAndLog, FTEXT("A cluster is corrupted."));
92+
continue;
93+
}
9094

9195
double L = Context->CurrentLerp / Context->MaxLerp;
9296
FColor Col = Settings->bLerpColor ?
@@ -96,8 +100,8 @@ bool FPCGExDrawEdgesElement::ExecuteInternal(
96100
for (const PCGExGraph::FIndexedEdge& Edge : Context->CurrentCluster->Edges)
97101
{
98102
if (!Edge.bValid) { continue; }
99-
FVector Start = Context->CurrentCluster->GetNodeFromPointIndex(Edge.Start).Position;
100-
FVector End = Context->CurrentCluster->GetNodeFromPointIndex(Edge.End).Position;
103+
FVector Start = Context->CurrentCluster->Nodes[*Context->CurrentCluster->NodeIndexLookup.Find(Edge.Start)].Position;
104+
FVector End = Context->CurrentCluster->Nodes[*Context->CurrentCluster->NodeIndexLookup.Find(Edge.End)].Position;
101105
DrawDebugLine(Context->World, Start, End, Col, true, -1, Settings->DepthPriority, Settings->Thickness);
102106
}
103107

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Edges/PCGExPruneEdgesByLength.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ bool FPCGExPruneEdgesByLengthElement::ExecuteInternal(FPCGContext* InContext) co
7777
double MaxEdgeLength = TNumericLimits<double>::Min();
7878
double SumEdgeLength = 0;
7979

80-
BuildIndexedEdges(*Context->CurrentEdges, Context->NodeIndicesMap, Context->IndexedEdges);
80+
BuildIndexedEdges(*Context->CurrentEdges, Context->EndpointsLookup, Context->IndexedEdges);
8181

8282
const TArray<FPCGPoint>& InNodePoints = Context->CurrentIO->GetIn()->GetPoints();
8383

@@ -138,17 +138,19 @@ bool FPCGExPruneEdgesByLengthElement::ExecuteInternal(FPCGContext* InContext) co
138138
Context->ReferenceMin = FMath::Min(RMin, RMax);
139139
Context->ReferenceMax = FMath::Max(RMin, RMax);
140140

141+
Context->GraphBuilder = new PCGExGraph::FGraphBuilder(*Context->CurrentIO, &Context->GraphBuilderSettings, 6, Context->MainEdges);
141142
Context->SetState(PCGExGraph::State_ProcessingEdges);
142143
}
143144

144145
if (Context->IsState(PCGExGraph::State_ProcessingEdges))
145146
{
146-
Context->GraphBuilder = new PCGExGraph::FGraphBuilder(*Context->CurrentIO, &Context->GraphBuilderSettings, 6, Context->MainEdges);
147-
148-
for (PCGExGraph::FIndexedEdge& Edge : Context->IndexedEdges)
147+
auto ProcessEdge = [&](const int32 EdgeIndex)
149148
{
149+
PCGExGraph::FIndexedEdge& Edge = Context->IndexedEdges[EdgeIndex];
150150
Edge.bValid = FMath::IsWithin(Context->EdgeLength[Edge.EdgeIndex], Context->ReferenceMin, Context->ReferenceMax);
151-
}
151+
};
152+
153+
if (!Context->Process(ProcessEdge, Context->IndexedEdges.Num())) { return false; }
152154

153155
Context->GraphBuilder->Graph->InsertEdges(Context->IndexedEdges);
154156
Context->GraphBuilder->Compile(Context);

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Edges/Refining/PCGExEdgeRefinePrimMST.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void UPCGExEdgeRefinePrimMST::Process(
2222

2323
PCGExSearch::TScoredQueue* ScoredQueue = new PCGExSearch::TScoredQueue(NumNodes, 0, 0);
2424

25-
TArray<int32> Parent;
25+
TArray<uint64> Parent;
2626
Parent.SetNum(NumNodes);
2727

2828
for (int i = 0; i < NumNodes; i++)
@@ -40,29 +40,36 @@ void UPCGExEdgeRefinePrimMST::Process(
4040
const PCGExCluster::FNode& Current = InCluster->Nodes[CurrentNodeIndex];
4141
Visited.Add(CurrentNodeIndex);
4242

43-
for (const int32 AdjacentIndex : Current.AdjacentNodes)
43+
for (const uint64 AdjacencyHash : Current.Adjacency)
4444
{
45-
if (Visited.Contains(AdjacentIndex)) { continue; } // Exit early
45+
uint32 NeighborIndex;
46+
uint32 EdgeIndex;
47+
PCGEx::H64(AdjacencyHash, NeighborIndex, EdgeIndex);
4648

47-
const PCGExCluster::FNode& AdjacentNode = InCluster->Nodes[AdjacentIndex];
48-
const PCGExGraph::FIndexedEdge& Edge = InCluster->GetEdgeFromNodeIndices(CurrentNodeIndex, AdjacentIndex);
49+
if (Visited.Contains(NeighborIndex)) { continue; } // Exit early
50+
51+
const PCGExCluster::FNode& AdjacentNode = InCluster->Nodes[NeighborIndex];
52+
const PCGExGraph::FIndexedEdge& Edge = InCluster->Edges[EdgeIndex];
4953

5054
const double Score = InHeuristics->GetEdgeScore(Current, AdjacentNode, Edge, *NoNode, *NoNode);
5155

52-
if (Score >= ScoredQueue->Scores[AdjacentIndex]) { continue; }
56+
if (Score >= ScoredQueue->Scores[NeighborIndex]) { continue; }
5357

54-
ScoredQueue->Scores[AdjacentIndex] = Score;
55-
Parent[AdjacentIndex] = CurrentNodeIndex;
58+
ScoredQueue->Scores[NeighborIndex] = Score;
59+
Parent[NeighborIndex] = AdjacencyHash;
5660

57-
ScoredQueue->Enqueue(AdjacentIndex, Score);
61+
ScoredQueue->Enqueue(NeighborIndex, Score);
5862
}
5963
}
6064

61-
PCGExGraph::FIndexedEdge InsertedEdge;
6265
for (int32 i = 0; i < NumNodes; i++)
6366
{
64-
if (Parent[i] == i) { continue; }
65-
InGraph->InsertEdge(InCluster->GetEdgeFromNodeIndices(Parent[i], i));
67+
uint32 NeighborIndex;
68+
uint32 EdgeIndex;
69+
PCGEx::H64(Parent[i], NeighborIndex, EdgeIndex);
70+
71+
if (NeighborIndex == i) { continue; }
72+
InGraph->InsertEdge(InCluster->Edges[EdgeIndex]);
6673
}
6774

6875
Visited.Empty();

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Edges/Relaxing/PCGExForceDirectedRelaxing.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ void UPCGExForceDirectedRelaxing::ProcessVertex(const PCGExCluster::FNode& Verte
1111
const FVector Position = (*ReadBuffer)[Vertex.PointIndex];
1212
FVector Force = FVector::Zero();
1313

14-
for (const int32 VtxIndex : Vertex.AdjacentNodes)
14+
for (const uint64 AdjacencyHash : Vertex.Adjacency)
1515
{
16+
const uint32 VtxIndex = PCGEx::H64A(AdjacencyHash);
1617
const PCGExCluster::FNode& OtherVtx = CurrentCluster->Nodes[VtxIndex];
1718
const FVector OtherPosition = (*ReadBuffer)[OtherVtx.PointIndex];
1819
CalculateAttractiveForce(Force, Position, OtherPosition);

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Edges/Relaxing/PCGExLaplacianRelaxing.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ void UPCGExLaplacianRelaxing::ProcessVertex(const PCGExCluster::FNode& Vertex)
1111
const FVector Position = (*ReadBuffer)[Vertex.PointIndex];
1212
FVector Force = FVector::Zero();
1313

14-
for (const int32 VtxIndex : Vertex.AdjacentNodes)
14+
for (const uint64 AdjacencyHash : Vertex.Adjacency)
1515
{
16+
const uint32 VtxIndex = PCGEx::H64A(AdjacencyHash);
1617
const PCGExCluster::FNode& OtherVtx = CurrentCluster->Nodes[VtxIndex];
1718
Force += (*ReadBuffer)[OtherVtx.PointIndex] - (*ReadBuffer)[Vertex.PointIndex];
1819
}
1920

20-
(*WriteBuffer)[Vertex.PointIndex] = Position + Force / static_cast<double>(Vertex.AdjacentNodes.Num());
21+
(*WriteBuffer)[Vertex.PointIndex] = Position + Force / static_cast<double>(Vertex.Adjacency.Num());
2122
}

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Graph/Filters/PCGExAdjacencyFilter.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ namespace PCGExNodeAdjacency
105105
for (int i = 0; i < NumNodes; i++)
106106
{
107107
const PCGExCluster::FNode& Node = CapturedCluster->Nodes[i];
108-
CachedMeasure[i] = LocalMeasure->Values[Node.PointIndex] * Node.AdjacentNodes.Num();
108+
CachedMeasure[i] = LocalMeasure->Values[Node.PointIndex] * Node.Adjacency.Num();
109109
}
110110
}
111111
}
@@ -120,7 +120,7 @@ namespace PCGExNodeAdjacency
120120
for (int i = 0; i < NumNodes; i++)
121121
{
122122
const PCGExCluster::FNode& Node = CapturedCluster->Nodes[i];
123-
CachedMeasure[i] = TypedFilterFactory->ConstantMeasure * Node.AdjacentNodes.Num();
123+
CachedMeasure[i] = TypedFilterFactory->ConstantMeasure * Node.Adjacency.Num();
124124
}
125125
}
126126
}
@@ -137,8 +137,9 @@ namespace PCGExNodeAdjacency
137137

138138
if (TypedFilterFactory->Mode == EPCGExAdjacencyTestMode::All)
139139
{
140-
for (const int32 OtherNodeIndex : Node.AdjacentNodes)
140+
for (const uint64 AdjacencyHash : Node.Adjacency)
141141
{
142+
const uint32 OtherNodeIndex = PCGEx::H64A(AdjacencyHash);
142143
B = OperandA->Values[CapturedCluster->Nodes[OtherNodeIndex].PointIndex];
143144
if (!PCGExCompare::Compare(TypedFilterFactory->Comparison, A, B, TypedFilterFactory->Tolerance)) { return false; }
144145
}
@@ -150,19 +151,20 @@ namespace PCGExNodeAdjacency
150151

151152
if (TypedFilterFactory->SubsetMode == EPCGExAdjacencySubsetMode::AtLeast && bUseAbsoluteMeasure)
152153
{
153-
if (Node.AdjacentNodes.Num() < MeasureReference) { return false; } // Early exit, not enough neighbors.
154+
if (Node.Adjacency.Num() < MeasureReference) { return false; } // Early exit, not enough neighbors.
154155
}
155156

156157
if (TypedFilterFactory->Consolidation == EPCGExAdjacencyGatherMode::Individual)
157158
{
158159
double LocalSuccessCount = 0;
159-
for (const int32 OtherNodeIndex : Node.AdjacentNodes)
160+
for (const uint64 AdjacencyHash : Node.Adjacency)
160161
{
162+
const uint32 OtherNodeIndex = PCGEx::H64A(AdjacencyHash);
161163
B = OperandA->Values[CapturedCluster->Nodes[OtherNodeIndex].PointIndex];
162164
if (PCGExCompare::Compare(TypedFilterFactory->Comparison, A, B, TypedFilterFactory->Tolerance)) { LocalSuccessCount++; }
163165
}
164166

165-
if (!bUseAbsoluteMeasure) { LocalSuccessCount /= static_cast<double>(Node.AdjacentNodes.Num()); }
167+
if (!bUseAbsoluteMeasure) { LocalSuccessCount /= static_cast<double>(Node.Adjacency.Num()); }
166168

167169
switch (TypedFilterFactory->SubsetMode)
168170
{
@@ -179,19 +181,19 @@ namespace PCGExNodeAdjacency
179181
switch (TypedFilterFactory->Consolidation)
180182
{
181183
case EPCGExAdjacencyGatherMode::Average:
182-
for (const int32 OtherNodeIndex : Node.AdjacentNodes) { B += OperandB->Values[CapturedCluster->Nodes[OtherNodeIndex].PointIndex]; }
183-
B /= static_cast<double>(Node.AdjacentNodes.Num());
184+
for (const uint64 AdjacencyHash : Node.Adjacency) { B += OperandB->Values[CapturedCluster->Nodes[PCGEx::H64A(AdjacencyHash)].PointIndex]; }
185+
B /= static_cast<double>(Node.Adjacency.Num());
184186
break;
185187
case EPCGExAdjacencyGatherMode::Min:
186188
B = TNumericLimits<double>::Max();
187-
for (const int32 OtherNodeIndex : Node.AdjacentNodes) { B = FMath::Min(B, OperandB->Values[CapturedCluster->Nodes[OtherNodeIndex].PointIndex]); }
189+
for (const uint64 AdjacencyHash : Node.Adjacency) { B = FMath::Min(B, OperandB->Values[CapturedCluster->Nodes[PCGEx::H64A(AdjacencyHash)].PointIndex]); }
188190
break;
189191
case EPCGExAdjacencyGatherMode::Max:
190192
B = TNumericLimits<double>::Min();
191-
for (const int32 OtherNodeIndex : Node.AdjacentNodes) { B = FMath::Max(B, OperandB->Values[CapturedCluster->Nodes[OtherNodeIndex].PointIndex]); }
193+
for (const uint64 AdjacencyHash : Node.Adjacency) { B = FMath::Max(B, OperandB->Values[CapturedCluster->Nodes[PCGEx::H64A(AdjacencyHash)].PointIndex]); }
192194
break;
193195
case EPCGExAdjacencyGatherMode::Sum:
194-
for (const int32 OtherNodeIndex : Node.AdjacentNodes) { B += OperandB->Values[CapturedCluster->Nodes[OtherNodeIndex].PointIndex]; }
196+
for (const uint64 AdjacencyHash : Node.Adjacency) { B += OperandB->Values[CapturedCluster->Nodes[PCGEx::H64A(AdjacencyHash)].PointIndex]; }
195197
break;
196198
default: ;
197199
}

0 commit comments

Comments
 (0)