Fix sorting not working properly

This commit is contained in:
Lukas Rieger (Blue) 2022-10-19 23:02:27 +02:00
parent cc1e2197f0
commit a5c6f5a31f
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -34,7 +34,10 @@
import de.bluecolored.bluemap.core.util.math.MatrixM4f;
import de.bluecolored.bluemap.core.util.math.VectorM3f;
import java.io.*;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
@ -625,10 +628,11 @@ private void sort() {
MergeSort.mergeSortInt(materialIndexSort, 0, size, this::compareMaterialIndex, materialIndexSortSupport);
// move
int s;
for (int i = 0; i < size; i++) {
while (materialIndexSort[i] != i) {
swap(i, materialIndexSort[i]);
}
s = materialIndexSort[i];
while (s < i) s = materialIndexSort[s];
swap(i, s);
}
}
@ -694,9 +698,9 @@ private void swap(int face1, int face2) {
materialIndex[face2] = vi;
//swap material-index-sort (assuming FI_MATERIAL_INDEX = 1)
vi = materialIndexSort[face1];
materialIndexSort[face1] = materialIndexSort[face2];
materialIndexSort[face2] = vi;
//vi = materialIndexSort[face1];
//materialIndexSort[face1] = materialIndexSort[face2];
//materialIndexSort[face2] = vi;
}
private static void calculateSurfaceNormal(