From 1888ac7adcae66034f5b3bfe0f93f0f75c3f58fa Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sat, 18 Sep 2021 17:09:13 +0200 Subject: [PATCH 1/2] Fixed the culling coordinate --- .../seibel/lod/builders/lodTemplates/Box.java | 29 +++++++++---------- .../lodTemplates/CubicLodTemplate.java | 4 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java b/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java index 018078606..a42435b10 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java @@ -7,10 +7,12 @@ import com.seibel.lod.util.DataPointUtil; import com.seibel.lod.wrappers.MinecraftWrapper; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; import org.lwjgl.system.CallbackI; import java.util.HashMap; import java.util.Map; +import java.util.Vector; public class Box { @@ -186,17 +188,19 @@ public class Box } } - public void setUpCulling(BlockPos playerPos, int cullingDistance) + public void setUpCulling(int cullingDistance) { + BlockPos playerPos = MinecraftWrapper.INSTANCE.getPlayer().blockPosition(); for (Direction direction : DIRECTIONS) { - if(direction == Direction.UP || direction == Direction.DOWN) - culling.get(direction)[0] = false; - else if(direction == Direction.EAST || direction == Direction.SOUTH) - culling.get(direction)[0] = playerPos.get(direction.getAxis()) < getFacePos(direction) + 32; - else - culling.get(direction)[0] = playerPos.get(direction.getAxis()) > getFacePos(direction) - 32; - culling.get(direction)[0] = false; + if(direction == Direction.DOWN) + culling.get(direction)[0] = playerPos.get(direction.getAxis()) > getFacePos(direction) + cullingDistance; + else if(direction == Direction.UP) + culling.get(direction)[0] = playerPos.get(direction.getAxis()) < getFacePos(direction) - cullingDistance; + else if(direction == Direction.WEST || direction == Direction.NORTH) + culling.get(direction)[0] = -playerPos.get(direction.getAxis()) > getFacePos(direction) + cullingDistance; + else if(direction == Direction.WEST || direction == Direction.NORTH) + culling.get(direction)[0] = -playerPos.get(direction.getAxis()) < getFacePos(direction) - cullingDistance; } } @@ -213,11 +217,9 @@ public class Box int maxY = getMaxY(); for (Direction direction : ADJ_DIRECTIONS) { - if(isCulled(direction)){ + /*if(isCulled(direction)){ continue; - } - - //Reset the ordered array + }*/ long[] dataPoint = adjData.get(direction); if (dataPoint == null || DataPointUtil.isItVoid(dataPoint[0])) @@ -377,9 +379,6 @@ public class Box public boolean shouldContinue(Direction direction, int adjIndex) { - if(isCulled(direction)){ - return false; - } if (direction == Direction.UP || direction == Direction.DOWN) { if (adjIndex == 0) diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java index d42c53981..387c903d3 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java @@ -100,7 +100,7 @@ public class CubicLodTemplate extends AbstractLodTemplate box.setColor(color); box.set(width, height - depth, width); box.move((int) (xOffset + x), (int) (depth + yOffset), (int) (zOffset + z)); - box.setUpCulling(bufferCenterBlockPos, 32); + box.setUpCulling(32); box.setAdjData(adjData); } @@ -108,6 +108,8 @@ public class CubicLodTemplate extends AbstractLodTemplate { for(Direction direction : Box.DIRECTIONS) { + if(box.isCulled(direction)) + continue; int adjIndex = 0; while(box.shouldContinue(direction, adjIndex)) { From dadda4bdc9894a99061eb94f8ef84b12fb2d03bc Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sat, 18 Sep 2021 17:32:34 +0200 Subject: [PATCH 2/2] Disabled the culling until it's fixed --- .../seibel/lod/builders/lodTemplates/Box.java | 30 +++++++++---------- .../lodTemplates/CubicLodTemplate.java | 4 +-- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java b/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java index a42435b10..dccf512b7 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/Box.java @@ -101,13 +101,11 @@ public class Box public int color; public Map adjHeightAndDepth; public Map culling; - public long[] order; - public Box() { box = new int[2][3]; - order = new long[32]; + //order = new long[32]; colorMap = new HashMap() {{ put(Direction.UP, new int[1]); @@ -165,11 +163,6 @@ public class Box } } - for (int i = 0; i < order.length; i++) - { - order[i] = 0; - } - for (Direction direction : DIRECTIONS) { colorMap.get(direction)[0] = 0; @@ -190,16 +183,20 @@ public class Box public void setUpCulling(int cullingDistance) { - BlockPos playerPos = MinecraftWrapper.INSTANCE.getPlayer().blockPosition(); + Vector3d playerPos = MinecraftWrapper.INSTANCE.getPlayer().position(); for (Direction direction : DIRECTIONS) { if(direction == Direction.DOWN) culling.get(direction)[0] = playerPos.get(direction.getAxis()) > getFacePos(direction) + cullingDistance; else if(direction == Direction.UP) culling.get(direction)[0] = playerPos.get(direction.getAxis()) < getFacePos(direction) - cullingDistance; - else if(direction == Direction.WEST || direction == Direction.NORTH) + else if(direction == Direction.WEST) culling.get(direction)[0] = -playerPos.get(direction.getAxis()) > getFacePos(direction) + cullingDistance; - else if(direction == Direction.WEST || direction == Direction.NORTH) + else if(direction == Direction.NORTH) + culling.get(direction)[0] = -playerPos.get(direction.getAxis()) > getFacePos(direction) + cullingDistance; + else if(direction == Direction.EAST) + culling.get(direction)[0] = -playerPos.get(direction.getAxis()) < getFacePos(direction) - cullingDistance; + else if(direction == Direction.SOUTH) culling.get(direction)[0] = -playerPos.get(direction.getAxis()) < getFacePos(direction) - cullingDistance; } } @@ -217,9 +214,9 @@ public class Box int maxY = getMaxY(); for (Direction direction : ADJ_DIRECTIONS) { - /*if(isCulled(direction)){ - continue; - }*/ + //if(isCulled(direction)){ + // continue; + //} long[] dataPoint = adjData.get(direction); if (dataPoint == null || DataPointUtil.isItVoid(dataPoint[0])) @@ -233,6 +230,7 @@ public class Box //We order the adj list /**TODO remove this if the order is maintained naturally*/ + /* order[0] = 0; for (int i = 0; i < dataPoint.length; i++) { @@ -242,7 +240,7 @@ public class Box j = j - 1; } order[j + 1] = dataPoint[i]; - } + }*/ int i; int faceToDraw = 0; @@ -250,7 +248,7 @@ public class Box boolean toFinish = false; for (i = dataPoint.length - 1; i >= 0; i--) { - long singleDataPoint = order[i]; + long singleDataPoint = dataPoint[i]; height = DataPointUtil.getHeight(singleDataPoint); depth = DataPointUtil.getDepth(singleDataPoint); diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java index 387c903d3..f12173b92 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java @@ -108,8 +108,8 @@ public class CubicLodTemplate extends AbstractLodTemplate { for(Direction direction : Box.DIRECTIONS) { - if(box.isCulled(direction)) - continue; + //if(box.isCulled(direction)) + // continue; int adjIndex = 0; while(box.shouldContinue(direction, adjIndex)) {