diff --git a/src/main/java/com/seibel/lod/util/DataPointUtil.java b/src/main/java/com/seibel/lod/util/DataPointUtil.java index e80eb3bc7..d88b2f899 100644 --- a/src/main/java/com/seibel/lod/util/DataPointUtil.java +++ b/src/main/java/com/seibel/lod/util/DataPointUtil.java @@ -283,7 +283,7 @@ public class DataPointUtil { int size = dataToMerge.length / inputVerticalData; short[] projection = ThreadMapUtil.getProjectionShort((WORLD_HEIGHT) / 16 + 1); - short[][] heightAndDepth = ThreadMapUtil.getHeightAndDepth(inputVerticalData + 1); + short[] heightAndDepth = ThreadMapUtil.getHeightAndDepth(inputVerticalData * 2); long[] singleDataToMerge = ThreadMapUtil.getSingleAddDataToMerge(size); int genMode = DistanceGenerationMode.SERVER.complexity; boolean allEmpty = true; @@ -348,15 +348,15 @@ public class DataPointUtil while (i < projection.length && ~(projection[i]) == 0) i++; //check for big solid blocks if (i == projection.length) //solid to WORLD_HEIGHT { - heightAndDepth[count][0] = depth; - heightAndDepth[count][1] = WORLD_HEIGHT - 1; + heightAndDepth[count * 2] = depth; + heightAndDepth[count * 2 + 1] = WORLD_HEIGHT - 1; break; } while ((((projection[i] >>> ii) & 1) == 1)) ii++; } height = (short)(i * 16 + ii - 1); - heightAndDepth[count][0] = depth; - heightAndDepth[count][1] = height; + heightAndDepth[count * 2] = depth; + heightAndDepth[count * 2 + 1] = height; count++; } @@ -367,16 +367,16 @@ public class DataPointUtil ii = WORLD_HEIGHT; for (i = 0; i < count - 1; i++) { - if (heightAndDepth[i + 1][0] - heightAndDepth[i][1] < ii) + if (heightAndDepth[(i + 1) * 2] - heightAndDepth[i * 2 + 1] < ii) { - ii = heightAndDepth[i + 1][0] - heightAndDepth[i][1]; + ii = heightAndDepth[(i + 1) * 2] - heightAndDepth[i * 2 + 1]; j = i; } } - heightAndDepth[j][1] = heightAndDepth[j + 1][1]; + heightAndDepth[j * 2 + 1] = heightAndDepth[(j + 1) * 2 + 1]; for (i = j + 1; i < count - 1; i++){ - heightAndDepth[i][0] = heightAndDepth[i + 1][0]; - heightAndDepth[i][1] = heightAndDepth[i + 1][1]; + heightAndDepth[i * 2] = heightAndDepth[(i + 1) * 2]; + heightAndDepth[i * 2 + 1] = heightAndDepth[(i + 1) * 2 + 1]; } //System.arraycopy(heightAndDepth,j + 1, heightAndDepth, j,count - j - 1); count--; diff --git a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java index d94c5527e..5273f814c 100644 --- a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java +++ b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java @@ -21,7 +21,7 @@ public class ThreadMapUtil public static final ConcurrentMap threadAdjData = new ConcurrentHashMap<>(); public static final ConcurrentMap projectionShortMap = new ConcurrentHashMap<>(); - public static final ConcurrentMap heightAndDepthMap = new ConcurrentHashMap<>(); + public static final ConcurrentMap heightAndDepthMap = new ConcurrentHashMap<>(); public static final ConcurrentMap singleDataToMergeMap = new ConcurrentHashMap<>(); @@ -123,10 +123,10 @@ public class ThreadMapUtil return projectionShortMap.get(Thread.currentThread().getName()); } - public static short[][] getHeightAndDepth(int size){ + public static short[] getHeightAndDepth(int size){ if(!heightAndDepthMap.containsKey(Thread.currentThread().getName()) || (heightAndDepthMap.get(Thread.currentThread().getName()) == null) || (heightAndDepthMap.get(Thread.currentThread().getName()).length != size)) { - heightAndDepthMap.put(Thread.currentThread().getName(), new short[size][2]); + heightAndDepthMap.put(Thread.currentThread().getName(), new short[size]); } return heightAndDepthMap.get(Thread.currentThread().getName()); }