From 585cfa0b7b6d600689ffb1af3c6247c7f7b9300b Mon Sep 17 00:00:00 2001 From: makamys Date: Sat, 8 May 2021 23:27:38 +0200 Subject: Make render distance not hardcoded --- src/main/java/makamys/lodmod/renderer/LODChunk.java | 4 ++-- src/main/java/makamys/lodmod/renderer/LODRenderer.java | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/makamys/lodmod/renderer/LODChunk.java b/src/main/java/makamys/lodmod/renderer/LODChunk.java index 63b43e7..ae86103 100644 --- a/src/main/java/makamys/lodmod/renderer/LODChunk.java +++ b/src/main/java/makamys/lodmod/renderer/LODChunk.java @@ -84,9 +84,9 @@ public class LODChunk { public void tick(Entity player) { double distSq = distSq(player); - if(distSq < Math.pow(32 * 16, 2)) { + if(distSq < Math.pow((LODMod.renderer.renderRange / 2) * 16, 2)) { renderer.setLOD(this, 2); - } else if(distSq < Math.pow(64 * 16, 2)) { + } else if(distSq < Math.pow((LODMod.renderer.renderRange) * 16, 2)) { renderer.setLOD(this, 1); } else { renderer.setLOD(this, 0); diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 5454352..4e9c97d 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -77,6 +77,8 @@ public class LODRenderer { private long lastGCTime = -1; private long gcInterval = 60 * 1000; + public int renderRange = 48; + public LODRenderer(){ hasInited = init(); } @@ -113,9 +115,8 @@ public class LODRenderer { int centerX = (int)Math.floor(player.posX / 16.0); int centerZ = (int)Math.floor(player.posZ / 16.0); - int range = 64; - for(int x = -range; x <= range; x++) { - for(int z = -range; z <= range; z++) { + for(int x = -renderRange; x <= renderRange; x++) { + for(int z = -renderRange; z <= renderRange; z++) { int chunkX = centerX + x; int chunkZ = centerZ + z; @@ -145,7 +146,7 @@ public class LODRenderer { } public int getFarPlaneDistanceMultiplier() { - return 4; + return renderRange / 12; } private void handleKeyboard() { -- cgit