aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling
diff options
context:
space:
mode:
authorYasin <a.piri@hotmail.de>2023-10-09 12:58:02 +0200
committerYasin <a.piri@hotmail.de>2023-10-09 12:58:02 +0200
commitbd3f0329d0e391bd84b5f9e3ff207d9dd9815853 (patch)
tree2fd1d1ef625f57acc2e4916c967d8d2393844798 /src/main/java/me/xmrvizzy/skyblocker/utils/render/culling
parent2315b90da8117f28f66348927afdb621ee4fc815 (diff)
downloadSkyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.tar.gz
Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.tar.bz2
Skyblocker-bd3f0329d0e391bd84b5f9e3ff207d9dd9815853.zip
new pr because fixing merge conflict would take too long
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils/render/culling')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/OcclusionCulling.java47
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/WorldProvider.java28
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/package-info.java4
3 files changed, 0 insertions, 79 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/OcclusionCulling.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/OcclusionCulling.java
deleted file mode 100644
index 5c7f69ad..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/OcclusionCulling.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package me.xmrvizzy.skyblocker.utils.render.culling;
-
-import com.logisticscraft.occlusionculling.OcclusionCullingInstance;
-import com.logisticscraft.occlusionculling.cache.ArrayOcclusionCache;
-import com.logisticscraft.occlusionculling.util.Vec3d;
-import me.xmrvizzy.skyblocker.utils.render.FrustumUtils;
-import net.minecraft.client.MinecraftClient;
-
-public class OcclusionCulling {
- private static final int TRACING_DISTANCE = 128;
- private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
- private static OcclusionCullingInstance instance = null;
-
- // Reused objects to reduce allocation overhead
- private static final Vec3d cameraPos = new Vec3d(0, 0, 0);
- private static final Vec3d min = new Vec3d(0, 0, 0);
- private static final Vec3d max = new Vec3d(0, 0, 0);
-
- /**
- * Initializes the occlusion culling instance
- */
- public static void init() {
- instance = new OcclusionCullingInstance(TRACING_DISTANCE, new WorldProvider(), new ArrayOcclusionCache(TRACING_DISTANCE), 2);
- }
-
- private static void updateCameraPos() {
- var camera = CLIENT.gameRenderer.getCamera().getPos();
- cameraPos.set(camera.x, camera.y, camera.z);
- }
-
- /**
- * This first checks checks if the bounding box is within the camera's FOV, if
- * it is then it checks for whether it's occluded or not.
- *
- * @return A boolean representing whether the bounding box is fully visible or
- * not.
- */
- public static boolean isVisible(double x1, double y1, double z1, double x2, double y2, double z2) {
- if (!FrustumUtils.isVisible(x1, y1, z1, x2, y2, z2)) return false;
-
- updateCameraPos();
- min.set(x1, y1, z1);
- max.set(x2, y2, z2);
-
- return instance.isAABBVisible(min, max, cameraPos);
- }
-}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/WorldProvider.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/WorldProvider.java
deleted file mode 100644
index 09a7bc79..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/WorldProvider.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package me.xmrvizzy.skyblocker.utils.render.culling;
-
-import com.logisticscraft.occlusionculling.DataProvider;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.world.ClientWorld;
-import net.minecraft.util.math.BlockPos;
-
-public class WorldProvider implements DataProvider {
- private final static MinecraftClient CLIENT = MinecraftClient.getInstance();
- private ClientWorld world = null;
-
- @Override
- public boolean prepareChunk(int chunkX, int chunkZ) {
- this.world = CLIENT.world;
- return this.world != null;
- }
-
- @Override
- public boolean isOpaqueFullCube(int x, int y, int z) {
- BlockPos pos = new BlockPos(x, y, z);
- return this.world.getBlockState(pos).isOpaqueFullCube(this.world, pos);
- }
-
- @Override
- public void cleanup() {
- this.world = null;
- }
-}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/package-info.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/package-info.java
deleted file mode 100644
index 97ebac86..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/culling/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Package dedicated to occlusion culling utilities
- */
-package me.xmrvizzy.skyblocker.utils.render.culling; \ No newline at end of file