added the dataPoint to the threadMaputil

This commit is contained in:
Leonardo
2021-09-20 14:01:18 +02:00
parent 25fd29b97e
commit a00698ccab
3 changed files with 18 additions and 42 deletions
@@ -36,7 +36,7 @@ import net.minecraft.util.math.BlockPos;
*/
public class CubicLodTemplate extends AbstractLodTemplate
{
public CubicLodTemplate()
{
@@ -105,12 +105,12 @@ public class CubicLodTemplate extends AbstractLodTemplate
private void addBoundingBoxToBuffer(BufferBuilder buffer, Box box)
{
for(Direction direction : Box.DIRECTIONS)
for (Direction direction : Box.DIRECTIONS)
{
//if(box.isCulled(direction))
// continue;
int adjIndex = 0;
while(box.shouldContinue(direction, adjIndex))
while (box.shouldContinue(direction, adjIndex))
{
for (int vertexIndex = 0; vertexIndex < 4; vertexIndex++)
{
@@ -289,6 +289,7 @@ public class DataPointUtil
boolean allEmpty = true;
boolean allVoid = true;
long singleData;
long[] dataPoint = ThreadMapUtil.verticalDataArray(DetailDistanceUtil.getMaxVerticalData(LodUtil.BLOCK_DETAIL_LEVEL));
Arrays.fill(projection, (short) 0); //probably can remove
short depth;
@@ -318,9 +319,15 @@ public class DataPointUtil
//We check if there is any data that's not empty or void
if (allEmpty)
return new long[]{EMPTY_DATA};
{
dataPoint[0] = EMPTY_DATA;
return dataPoint;
}
if (allVoid)
return new long[]{createVoidDataPoint(genMode)};
{
dataPoint[0] = createVoidDataPoint(genMode);
return dataPoint;
}
//We extract the merged data
int count = 0;
@@ -383,7 +390,6 @@ public class DataPointUtil
}
//As standard the vertical lods are ordered from top to bottom
long[] dataPoint = new long[count];
for (j = count - 1; j >= 0; j--)
{
depth = heightAndDepth[j * 2];
@@ -72,49 +72,19 @@ public class ThreadMapUtil
return threadBuilderVerticalArrayMap.get(Thread.currentThread().getName());
}
public static long[] addVerticalDataArray()
public static long[] verticalDataArray(int count)
{
if (!threadVerticalAddDataMap.containsKey(Thread.currentThread().getName()) || (threadVerticalAddDataMap.get(Thread.currentThread().getName()) == null))
{
threadVerticalAddDataMap.put(Thread.currentThread().getName(), new long[16]);
threadVerticalAddDataMap.put(Thread.currentThread().getName(), new long[count]);
}
for(int i = 0; i < count ; i++)
{
threadVerticalAddDataMap.get(Thread.currentThread().getName())[i] = DataPointUtil.EMPTY_DATA;
}
return threadVerticalAddDataMap.get(Thread.currentThread().getName());
}
public static long[] getVerticalGetDataArray()
{
if (!threadVerticalGetDataMap.containsKey(Thread.currentThread().getName()) || (threadVerticalGetDataMap.get(Thread.currentThread().getName()) == null))
{
threadVerticalGetDataMap.put(Thread.currentThread().getName(), new long[16]);
}
return threadVerticalGetDataMap.get(Thread.currentThread().getName());
}
public static long[] getAdjDataArray()
{
if(!threadAdjData.containsKey(Thread.currentThread().getName()) || (threadAdjData.get(Thread.currentThread().getName()) == null))
{
threadAdjData.put(Thread.currentThread().getName(), new long[NUMBER_OF_DIRECTION]);
}
return threadAdjData.get(Thread.currentThread().getName());
}
public static long[][] getVerticalUpdateArray(){
if(!threadVerticalUpdateMap.containsKey(Thread.currentThread().getName()) || (threadVerticalUpdateMap.get(Thread.currentThread().getName()) == null))
{
threadVerticalUpdateMap.put(Thread.currentThread().getName(), new long[4][]);
}
return threadVerticalUpdateMap.get(Thread.currentThread().getName());
}
public static int[] getVerticalIndexesArray(){
if(!threadVerticalIndexesMap.containsKey(Thread.currentThread().getName()) || (threadVerticalIndexesMap.get(Thread.currentThread().getName()) == null))
{
threadVerticalIndexesMap.put(Thread.currentThread().getName(), new int[4]);
}
return threadVerticalIndexesMap.get(Thread.currentThread().getName());
}
public static short[] getProjectionShort(int size){
if(!projectionShortMap.containsKey(Thread.currentThread().getName()) || (projectionShortMap.get(Thread.currentThread().getName()) == null) || (projectionShortMap.get(Thread.currentThread().getName()).length != size))
{