diff --git a/assets/Config/settings.json b/assets/Config/settings.json index 730eba93..284fa0a4 100644 --- a/assets/Config/settings.json +++ b/assets/Config/settings.json @@ -13,6 +13,7 @@ "graphicsPerformanceEnableVSync" : false, "graphicsPerformanceDrawShadows" : true, "graphicsPerformanceOIT" : true, + "graphicsPerformanceEnableFoliageManager" : false, "graphicsViewRange" : 20000.0, "renderResolutionX": 1920, diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index c91408e2..a5f4b786 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -971,6 +971,8 @@ Script engine synchronization utility Convert ScriptEngine to service ScriptEngine full re-initialization signal Add surface width to test generator +User setting to toggle foliage manager +Fix client terrain cache lookup bug # TODO diff --git a/src/main/java/electrosphere/client/foliagemanager/ClientFoliageManager.java b/src/main/java/electrosphere/client/foliagemanager/ClientFoliageManager.java index b9f96785..8202a4de 100644 --- a/src/main/java/electrosphere/client/foliagemanager/ClientFoliageManager.java +++ b/src/main/java/electrosphere/client/foliagemanager/ClientFoliageManager.java @@ -56,7 +56,7 @@ public class ClientFoliageManager { */ public void update(){ Globals.profiler.beginCpuSample("ClientFoliageManager.update"); - if(ready && this.dependenciesAreReady()){ + if(ready && Globals.userSettings.getGraphicsPerformanceEnableFoliageManager() && this.dependenciesAreReady()){ this.flipUpdateCache(); for(int x = -chunkRadius; x < chunkRadius+1; x++){ for(int y = -chunkRadius; y < chunkRadius+1; y++){ diff --git a/src/main/java/electrosphere/client/terrain/cache/ClientTerrainCache.java b/src/main/java/electrosphere/client/terrain/cache/ClientTerrainCache.java index bc817d90..fe8c97fe 100644 --- a/src/main/java/electrosphere/client/terrain/cache/ClientTerrainCache.java +++ b/src/main/java/electrosphere/client/terrain/cache/ClientTerrainCache.java @@ -187,7 +187,7 @@ public class ClientTerrainCache { return cacheMapEighthRes; } case 4: { - return cacheMapEighthRes; + return cacheMapSixteenthRes; } default: { throw new Error("Invalid stride probided! " + stride); diff --git a/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java b/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java index 3ac46e7e..1ec394b2 100644 --- a/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java +++ b/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java @@ -173,11 +173,16 @@ public class ClientDrawCellManager { //update all full res cells FloatingChunkTreeNode rootNode = this.chunkTree.getRoot(); Globals.profiler.beginCpuSample("ClientDrawCellManager.update - full res cells"); - updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, HALF_RES_LOD); + updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, FULL_RES_LOD); Globals.profiler.endCpuSample(); if(!updatedLastFrame && !this.initialized){ this.initialized = true; } + if(!updatedLastFrame){ + Globals.profiler.beginCpuSample("ClientDrawCellManager.update - half res cells"); + updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, HALF_RES_LOD); + Globals.profiler.endCpuSample(); + } if(!updatedLastFrame){ Globals.profiler.beginCpuSample("ClientDrawCellManager.update - half res cells"); updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, QUARTER_RES_LOD); @@ -193,11 +198,11 @@ public class ClientDrawCellManager { updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, SIXTEENTH_RES_LOD); Globals.profiler.endCpuSample(); } - if(!updatedLastFrame){ - Globals.profiler.beginCpuSample("ClientDrawCellManager.update - all res cells"); - updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, ALL_RES_LOD); - Globals.profiler.endCpuSample(); - } + // if(!updatedLastFrame){ + // Globals.profiler.beginCpuSample("ClientDrawCellManager.update - all res cells"); + // updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, evaluationMap, ALL_RES_LOD); + // Globals.profiler.endCpuSample(); + // } } Globals.profiler.endCpuSample(); } @@ -528,7 +533,7 @@ public class ClientDrawCellManager { node.isLeaf() && node.getData() != null && !node.getData().hasRequested() && - (this.chunkTree.getMaxLevel() - node.getLevel()) < minLeafLod && + (this.chunkTree.getMaxLevel() - node.getLevel()) <= minLeafLod && ( ( node.getLevel() == this.chunkTree.getMaxLevel() @@ -575,7 +580,7 @@ public class ClientDrawCellManager { node.isLeaf() && node.getData() != null && !node.getData().hasGenerated() && - (this.chunkTree.getMaxLevel() - node.getLevel()) < minLeafLod && + (this.chunkTree.getMaxLevel() - node.getLevel()) <= minLeafLod && ( ( node.getLevel() == this.chunkTree.getMaxLevel() diff --git a/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java b/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java index a8e35170..2efa7702 100644 --- a/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java +++ b/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java @@ -152,6 +152,12 @@ public class ClientTerrainManager { message.getworldX(), message.getworldY(), message.getworldZ(), data ); + if(message.getworldX() == 16 && message.getworldY() == 0 && message.getworldZ() == 32){ + System.out.println("Received! " + message.getchunkResolution()); + for(int i = 0; i < 10; i++){ + System.out.println(values[1][i][3]); + } + } //remove from request map this.requestedMap.remove(this.getRequestKey(message.getworldX(), message.getworldY(), message.getworldZ(), message.getchunkResolution())); } break; diff --git a/src/main/java/electrosphere/game/config/UserSettings.java b/src/main/java/electrosphere/game/config/UserSettings.java index d761ca5b..14f4fd71 100644 --- a/src/main/java/electrosphere/game/config/UserSettings.java +++ b/src/main/java/electrosphere/game/config/UserSettings.java @@ -35,6 +35,12 @@ public class UserSettings { boolean graphicsPerformanceEnableVSync; boolean graphicsPerformanceDrawShadows; boolean graphicsPerformanceOIT; + + /** + * Controls whether the foliage manager runs or not + */ + boolean graphicsPerformanceEnableFoliageManager; + //resolution int renderResolutionX; int renderResolutionY; @@ -164,6 +170,21 @@ public class UserSettings { } + /** + * Checks if the foliage manager is enabled or not + * @return true if enabled, false otherwise + */ + public boolean getGraphicsPerformanceEnableFoliageManager() { + return graphicsPerformanceEnableFoliageManager; + } + + /** + * Sets if the foliage manager is enabled or not + * @param graphicsPerformanceEnableFoliageManager true if enabled, false otherwise + */ + public void setGraphicsPerformanceEnableFoliageManager(boolean graphicsPerformanceEnableFoliageManager) { + this.graphicsPerformanceEnableFoliageManager = graphicsPerformanceEnableFoliageManager; + } @@ -171,8 +192,11 @@ public class UserSettings { - - + + /** + * Generates a default settings file + * @return The settings file + */ static UserSettings getDefault(){ UserSettings rVal = new UserSettings(); @@ -196,6 +220,7 @@ public class UserSettings { rVal.graphicsPerformanceDrawShadows = true; rVal.graphicsPerformanceEnableVSync = true; rVal.graphicsPerformanceOIT = true; + rVal.graphicsPerformanceEnableFoliageManager = true; rVal.renderResolutionX = 1920; rVal.renderResolutionY = 1080; @@ -205,7 +230,9 @@ public class UserSettings { return rVal; } - + /** + * Loads the user's settings + */ public static void loadUserSettings(){ if(Globals.userSettings == null){ LoggerInterface.loggerStartup.INFO("Load user settings"); diff --git a/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java b/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java index aef44752..009c0630 100644 --- a/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java +++ b/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java @@ -94,6 +94,9 @@ public class TestGenerationChunkGenerator implements ChunkGenerator { float[][][] weights = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];; int[][][] values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION]; + if(worldX == 16 && worldY == 0 && worldZ == 32){ + System.out.println(worldX + " " + worldY + " " + worldZ); + } try { //actual generation algo