Skip to content

Commit 6c06ff8

Browse files
committed
Bugfixes
1 parent 3e8f008 commit 6c06ff8

3 files changed

Lines changed: 32 additions & 28 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void UPCGExEdgeRefinePrimMST::Process(
5656
if (Score >= ScoredQueue->Scores[NeighborIndex]) { continue; }
5757

5858
ScoredQueue->Scores[NeighborIndex] = Score;
59-
Parent[NeighborIndex] = AdjacencyHash;
59+
Parent[NeighborIndex] = PCGEx::H64(CurrentNodeIndex, EdgeIndex);
6060

6161
ScoredQueue->Enqueue(NeighborIndex, Score);
6262
}
@@ -66,6 +66,7 @@ void UPCGExEdgeRefinePrimMST::Process(
6666
{
6767
uint32 NeighborIndex;
6868
uint32 EdgeIndex;
69+
6970
PCGEx::H64(Parent[i], NeighborIndex, EdgeIndex);
7071

7172
if (NeighborIndex == i) { continue; }

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Public/Geometry/PCGExGeoMesh.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ namespace PCGExGeo
149149
const int32* BPtr = IndexedUniquePositions.Find(VB);
150150
const int32* CPtr = IndexedUniquePositions.Find(VC);
151151

152-
const uint32 A = APtr ? *APtr : IndexedUniquePositions.FindOrAdd(VA, Idx++);
153-
const uint32 B = BPtr ? *BPtr : IndexedUniquePositions.FindOrAdd(VB, Idx++);
154-
const uint32 C = CPtr ? *CPtr : IndexedUniquePositions.FindOrAdd(VC, Idx++);
152+
const uint32 A = APtr ? *APtr : IndexedUniquePositions.Add(VA, Idx++);
153+
const uint32 B = BPtr ? *BPtr : IndexedUniquePositions.Add(VB, Idx++);
154+
const uint32 C = CPtr ? *CPtr : IndexedUniquePositions.Add(VC, Idx++);
155155

156156
Edges.Add(PCGEx::H64U(A, B));
157157
Edges.Add(PCGEx::H64U(B, C));
@@ -199,9 +199,9 @@ namespace PCGExGeo
199199
const int32* BPtr = IndexedUniquePositions.Find(VB);
200200
const int32* CPtr = IndexedUniquePositions.Find(VC);
201201

202-
const uint32 A = APtr ? *APtr : IndexedUniquePositions.FindOrAdd(VA, Idx++);
203-
const uint32 B = BPtr ? *BPtr : IndexedUniquePositions.FindOrAdd(VB, Idx++);
204-
const uint32 C = CPtr ? *CPtr : IndexedUniquePositions.FindOrAdd(VC, Idx++);
202+
const uint32 A = APtr ? *APtr : IndexedUniquePositions.Add(VA, Idx++);
203+
const uint32 B = BPtr ? *BPtr : IndexedUniquePositions.Add(VB, Idx++);
204+
const uint32 C = CPtr ? *CPtr : IndexedUniquePositions.Add(VC, Idx++);
205205

206206
const uint64 AB = PCGEx::H64U(A, B);
207207
const uint64 BC = PCGEx::H64U(B, C);
@@ -219,16 +219,18 @@ namespace PCGExGeo
219219
const uint64* AdjacencyBCPtr = EdgeAdjacency.Find(BC);
220220
const uint64* AdjacencyACPtr = EdgeAdjacency.Find(AC);
221221

222-
Triangles[TriangleIndex++] = FIntVector3(A, B, C);
222+
Triangles[TriangleIndex] = FIntVector3(A, B, C);
223223

224-
if (AdjacencyABPtr) { EdgeAdjacency.Add(AB, PCGEx::NH64(TriangleIndex, PCGEx::H64B(*AdjacencyABPtr))); }
224+
if (AdjacencyABPtr) { EdgeAdjacency.Add(AB, PCGEx::NH64(TriangleIndex, PCGEx::NH64B(*AdjacencyABPtr))); }
225225
else { EdgeAdjacency.Add(AB, PCGEx::NH64(-1, TriangleIndex)); }
226226

227-
if (AdjacencyBCPtr) { EdgeAdjacency.Add(BC, PCGEx::NH64(TriangleIndex, PCGEx::H64B(*AdjacencyBCPtr))); }
227+
if (AdjacencyBCPtr) { EdgeAdjacency.Add(BC, PCGEx::NH64(TriangleIndex, PCGEx::NH64B(*AdjacencyBCPtr))); }
228228
else { EdgeAdjacency.Add(BC, PCGEx::NH64(-1, TriangleIndex)); }
229229

230-
if (AdjacencyACPtr) { EdgeAdjacency.Add(AC, PCGEx::NH64(TriangleIndex, PCGEx::H64B(*AdjacencyACPtr))); }
230+
if (AdjacencyACPtr) { EdgeAdjacency.Add(AC, PCGEx::NH64(TriangleIndex, PCGEx::NH64B(*AdjacencyACPtr))); }
231231
else { EdgeAdjacency.Add(AC, PCGEx::NH64(-1, TriangleIndex)); }
232+
233+
TriangleIndex++;
232234
}
233235

234236
int32 ENum = EdgeAdjacency.Num();

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Public/PCGEx.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -323,28 +323,17 @@ namespace PCGEx
323323
static_cast<uint64>(B) << 32 | A;
324324
}
325325

326-
// Unsigned uint64 hash
327-
FORCEINLINE static uint64 H64NOT(const uint64 Hash, const uint32 Not)
328-
{
329-
const uint32 A = static_cast<uint32>(Hash >> 32);
330-
return A == Not ? static_cast<uint32>(Hash) : A;
331-
}
332-
333-
// Unsigned uint64 hash
334-
FORCEINLINE static uint64 NH64NOT(const uint64 Hash, const int32 Not)
335-
{
336-
const int32 A = static_cast<int32>(static_cast<uint32>(Hash >> 32)) - 1;
337-
return A == Not ? static_cast<int32>(static_cast<uint32>(Hash)) - 1 : A;
338-
}
339-
340326
// Signed uint64 hash
341327
FORCEINLINE static uint64 H64(const uint32 A, const uint32 B) { return static_cast<uint64>(A) << 32 | B; }
342-
FORCEINLINE static uint64 NH64(const uint32 A, const uint32 B) { return static_cast<uint64>(A + 1) << 32 | (B + 1); }
328+
FORCEINLINE static uint64 NH64(const int32 A, const int32 B) { return H64(A + 1, B + 1); }
343329

344330
// Expand uint64 hash
345331
FORCEINLINE static uint32 H64A(const uint64 Hash) { return static_cast<uint32>(Hash >> 32); }
346332
FORCEINLINE static uint32 H64B(const uint64 Hash) { return static_cast<uint32>(Hash); }
347333

334+
FORCEINLINE static int32 NH64A(const uint64 Hash) { return static_cast<int32>(H64A(Hash)) - 1; }
335+
FORCEINLINE static int32 NH64B(const uint64 Hash) { return static_cast<int32>(H64B(Hash)) - 1; }
336+
348337
FORCEINLINE static void H64(const uint64 Hash, uint32& A, uint32& B)
349338
{
350339
A = H64A(Hash);
@@ -353,8 +342,20 @@ namespace PCGEx
353342

354343
FORCEINLINE static void NH64(const uint64 Hash, int32& A, int32& B)
355344
{
356-
A = H64A(Hash) - 1;
357-
B = H64B(Hash) - 1;
345+
A = NH64A(Hash);
346+
B = NH64B(Hash);
347+
}
348+
349+
FORCEINLINE static uint64 H64NOT(const uint64 Hash, const uint32 Not)
350+
{
351+
const uint32 A = H64A(Hash);
352+
return A == Not ? H64B(Hash) : A;
353+
}
354+
355+
FORCEINLINE static int32 NH64NOT(const uint64 Hash, const int32 Not)
356+
{
357+
const int32 A = NH64A(Hash);
358+
return A == Not ? NH64B(Hash) : A;
358359
}
359360

360361
FORCEINLINE static uint64 H6416(const uint16 A, const uint16 B, const uint16 C, const uint16 D)

0 commit comments

Comments
 (0)