voxelImprovements #5
@ -42,6 +42,11 @@ public class ClientTerrainCache {
|
|||||||
*/
|
*/
|
||||||
Map<Long,ChunkData> cacheMapEighthRes = new ConcurrentHashMap<Long,ChunkData>();
|
Map<Long,ChunkData> cacheMapEighthRes = new ConcurrentHashMap<Long,ChunkData>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The map of sixteenth res chunk key -> chunk data
|
||||||
|
*/
|
||||||
|
Map<Long,ChunkData> cacheMapSixteenthRes = new ConcurrentHashMap<Long,ChunkData>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of keys in the cache
|
* The list of keys in the cache
|
||||||
*/
|
*/
|
||||||
@ -178,6 +183,9 @@ public class ClientTerrainCache {
|
|||||||
case 3: {
|
case 3: {
|
||||||
return cacheMapEighthRes;
|
return cacheMapEighthRes;
|
||||||
}
|
}
|
||||||
|
case 4: {
|
||||||
|
return cacheMapEighthRes;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error("Invalid stride probided! " + stride);
|
throw new Error("Invalid stride probided! " + stride);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,12 @@ public class ClientDrawCellManager {
|
|||||||
/**
|
/**
|
||||||
* The distance for eighth resolution
|
* The distance for eighth resolution
|
||||||
*/
|
*/
|
||||||
public static final double EIGHTH_RES_DIST = 28 * ServerTerrainChunk.CHUNK_DIMENSION;
|
public static final double EIGHTH_RES_DIST = 32 * ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The distance for sixteenth resolution
|
||||||
|
*/
|
||||||
|
public static final double SIXTEENTH_RES_DIST = 48 * ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lod value for a full res chunk
|
* Lod value for a full res chunk
|
||||||
@ -70,6 +75,16 @@ public class ClientDrawCellManager {
|
|||||||
*/
|
*/
|
||||||
public static final int EIGHTH_RES_LOD = 3;
|
public static final int EIGHTH_RES_LOD = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lod value for a sixteenth res chunk
|
||||||
|
*/
|
||||||
|
public static final int SIXTEENTH_RES_LOD = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lod value for evaluating all lod levels
|
||||||
|
*/
|
||||||
|
public static final int ALL_RES_LOD = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The octree holding all the chunks to evaluate
|
* The octree holding all the chunks to evaluate
|
||||||
*/
|
*/
|
||||||
@ -153,6 +168,12 @@ public class ClientDrawCellManager {
|
|||||||
if(!updatedLastFrame){
|
if(!updatedLastFrame){
|
||||||
updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, EIGHTH_RES_LOD);
|
updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, EIGHTH_RES_LOD);
|
||||||
}
|
}
|
||||||
|
if(!updatedLastFrame){
|
||||||
|
updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, SIXTEENTH_RES_LOD);
|
||||||
|
}
|
||||||
|
if(!updatedLastFrame){
|
||||||
|
updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerPos, ALL_RES_LOD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
@ -277,17 +298,22 @@ public class ClientDrawCellManager {
|
|||||||
node.canSplit() &&
|
node.canSplit() &&
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
node.getLevel() < this.chunkTree.getMaxLevel() - 3 &&
|
node.getLevel() < this.chunkTree.getMaxLevel() - SIXTEENTH_RES_LOD &&
|
||||||
|
this.getMinDistance(pos, node) <= SIXTEENTH_RES_DIST
|
||||||
|
)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
node.getLevel() < this.chunkTree.getMaxLevel() - EIGHTH_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() < this.chunkTree.getMaxLevel() - 2 &&
|
node.getLevel() < this.chunkTree.getMaxLevel() - QUARTER_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) <= QUARTER_RES_DIST
|
this.getMinDistance(pos, node) <= QUARTER_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() < this.chunkTree.getMaxLevel() - 1 &&
|
node.getLevel() < this.chunkTree.getMaxLevel() - HALF_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) <= HALF_RES_DIST
|
this.getMinDistance(pos, node) <= HALF_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
@ -426,23 +452,28 @@ public class ClientDrawCellManager {
|
|||||||
!node.isLeaf() &&
|
!node.isLeaf() &&
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 1 &&
|
node.getLevel() == this.chunkTree.getMaxLevel() - HALF_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) > FULL_RES_DIST
|
this.getMinDistance(pos, node) > FULL_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 2 &&
|
node.getLevel() == this.chunkTree.getMaxLevel() - QUARTER_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) > HALF_RES_DIST
|
this.getMinDistance(pos, node) > HALF_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 3 &&
|
node.getLevel() == this.chunkTree.getMaxLevel() - EIGHTH_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) > QUARTER_RES_DIST
|
this.getMinDistance(pos, node) > QUARTER_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
|
node.getLevel() == this.chunkTree.getMaxLevel() - SIXTEENTH_RES_LOD &&
|
||||||
this.getMinDistance(pos, node) > EIGHTH_RES_DIST
|
this.getMinDistance(pos, node) > EIGHTH_RES_DIST
|
||||||
)
|
)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
this.getMinDistance(pos, node) > SIXTEENTH_RES_DIST
|
||||||
|
)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -468,22 +499,28 @@ public class ClientDrawCellManager {
|
|||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 1
|
node.getLevel() == this.chunkTree.getMaxLevel() - HALF_RES_LOD
|
||||||
&&
|
&&
|
||||||
this.getMinDistance(pos, node) <= QUARTER_RES_DIST
|
this.getMinDistance(pos, node) <= QUARTER_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 2
|
node.getLevel() == this.chunkTree.getMaxLevel() - QUARTER_RES_LOD
|
||||||
&&
|
&&
|
||||||
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 3
|
node.getLevel() == this.chunkTree.getMaxLevel() - EIGHTH_RES_LOD
|
||||||
&&
|
&&
|
||||||
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
||||||
)
|
)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
node.getLevel() == this.chunkTree.getMaxLevel() - SIXTEENTH_RES_LOD
|
||||||
|
&&
|
||||||
|
this.getMinDistance(pos, node) <= SIXTEENTH_RES_DIST
|
||||||
|
)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -509,22 +546,28 @@ public class ClientDrawCellManager {
|
|||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 1
|
node.getLevel() == this.chunkTree.getMaxLevel() - HALF_RES_LOD
|
||||||
&&
|
&&
|
||||||
this.getMinDistance(pos, node) <= QUARTER_RES_DIST
|
this.getMinDistance(pos, node) <= QUARTER_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 2
|
node.getLevel() == this.chunkTree.getMaxLevel() - QUARTER_RES_LOD
|
||||||
&&
|
&&
|
||||||
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
||||||
)
|
)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
node.getLevel() == this.chunkTree.getMaxLevel() - 3
|
node.getLevel() == this.chunkTree.getMaxLevel() - EIGHTH_RES_LOD
|
||||||
&&
|
&&
|
||||||
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
this.getMinDistance(pos, node) <= EIGHTH_RES_DIST
|
||||||
)
|
)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
node.getLevel() == this.chunkTree.getMaxLevel() - SIXTEENTH_RES_LOD
|
||||||
|
&&
|
||||||
|
this.getMinDistance(pos, node) <= SIXTEENTH_RES_DIST
|
||||||
|
)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,11 @@ public class ClientTerrainManager {
|
|||||||
* Locks the terrain manager (eg if adding message from network)
|
* Locks the terrain manager (eg if adding message from network)
|
||||||
*/
|
*/
|
||||||
static Semaphore lock = new Semaphore(1);
|
static Semaphore lock = new Semaphore(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum concurrent terrain requests
|
||||||
|
*/
|
||||||
|
public static final int MAX_CONCURRENT_REQUESTS = 500;
|
||||||
|
|
||||||
//The interpolation ratio of terrain
|
//The interpolation ratio of terrain
|
||||||
public static final int INTERPOLATION_RATIO = ServerTerrainManager.SERVER_TERRAIN_MANAGER_INTERPOLATION_RATIO;
|
public static final int INTERPOLATION_RATIO = ServerTerrainManager.SERVER_TERRAIN_MANAGER_INTERPOLATION_RATIO;
|
||||||
@ -207,7 +212,7 @@ public class ClientTerrainManager {
|
|||||||
public boolean requestChunk(int worldX, int worldY, int worldZ, int stride){
|
public boolean requestChunk(int worldX, int worldY, int worldZ, int stride){
|
||||||
boolean rVal = false;
|
boolean rVal = false;
|
||||||
lock.acquireUninterruptibly();
|
lock.acquireUninterruptibly();
|
||||||
if(!this.requestedMap.containsKey(this.getRequestKey(worldX, worldY, worldZ, stride))){
|
if(this.requestedMap.size() < MAX_CONCURRENT_REQUESTS && !this.requestedMap.containsKey(this.getRequestKey(worldX, worldY, worldZ, stride))){
|
||||||
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedChunkDataMessage(
|
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedChunkDataMessage(
|
||||||
worldX,
|
worldX,
|
||||||
worldY,
|
worldY,
|
||||||
|
|||||||
@ -46,6 +46,11 @@ public class ServerChunkCache {
|
|||||||
*/
|
*/
|
||||||
Map<Long,ServerTerrainChunk> cacheMapEighthRes = new ConcurrentHashMap<Long,ServerTerrainChunk>();
|
Map<Long,ServerTerrainChunk> cacheMapEighthRes = new ConcurrentHashMap<Long,ServerTerrainChunk>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The map of sixteenth res chunk key -> chunk data
|
||||||
|
*/
|
||||||
|
Map<Long,ServerTerrainChunk> cacheMapSixteenthRes = new ConcurrentHashMap<Long,ServerTerrainChunk>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tracks how recently a chunk has been queries for (used for evicting old chunks from cache)
|
* Tracks how recently a chunk has been queries for (used for evicting old chunks from cache)
|
||||||
*/
|
*/
|
||||||
@ -208,6 +213,9 @@ public class ServerChunkCache {
|
|||||||
case 3: {
|
case 3: {
|
||||||
return cacheMapEighthRes;
|
return cacheMapEighthRes;
|
||||||
}
|
}
|
||||||
|
case 4: {
|
||||||
|
return cacheMapSixteenthRes;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error("Invalid stride probided! " + stride);
|
throw new Error("Invalid stride probided! " + stride);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user