Skip to content

Commit a5c6f5a

Browse files
committed
Fix sorting not working properly
1 parent cc1e219 commit a5c6f5a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/HiresTileModel.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
import de.bluecolored.bluemap.core.util.math.MatrixM4f;
3535
import de.bluecolored.bluemap.core.util.math.VectorM3f;
3636

37-
import java.io.*;
37+
import java.io.BufferedWriter;
38+
import java.io.IOException;
39+
import java.io.OutputStream;
40+
import java.io.OutputStreamWriter;
3841
import java.nio.charset.StandardCharsets;
3942
import java.util.UUID;
4043

@@ -625,10 +628,11 @@ private void sort() {
625628
MergeSort.mergeSortInt(materialIndexSort, 0, size, this::compareMaterialIndex, materialIndexSortSupport);
626629

627630
// move
631+
int s;
628632
for (int i = 0; i < size; i++) {
629-
while (materialIndexSort[i] != i) {
630-
swap(i, materialIndexSort[i]);
631-
}
633+
s = materialIndexSort[i];
634+
while (s < i) s = materialIndexSort[s];
635+
swap(i, s);
632636
}
633637
}
634638

@@ -694,9 +698,9 @@ private void swap(int face1, int face2) {
694698
materialIndex[face2] = vi;
695699

696700
//swap material-index-sort (assuming FI_MATERIAL_INDEX = 1)
697-
vi = materialIndexSort[face1];
698-
materialIndexSort[face1] = materialIndexSort[face2];
699-
materialIndexSort[face2] = vi;
701+
//vi = materialIndexSort[face1];
702+
//materialIndexSort[face1] = materialIndexSort[face2];
703+
//materialIndexSort[face2] = vi;
700704
}
701705

702706
private static void calculateSurfaceNormal(

0 commit comments

Comments
 (0)