update fluid chunk dims
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
96107d4356
commit
40ae429417
@ -2,6 +2,7 @@ package electrosphere.client.fluid.cache;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.server.fluid.manager.ServerFluidChunk;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
|
||||
/**
|
||||
@ -10,7 +11,7 @@ import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
public class FluidChunkData {
|
||||
|
||||
//The size of a chunk in virtual data
|
||||
public static final int CHUNK_SIZE = ServerTerrainChunk.CHUNK_DIMENSION;
|
||||
public static final int CHUNK_SIZE = ServerFluidChunk.BUFFER_DIM;
|
||||
//The size of the data passed into marching cubes/transvoxel algorithm to get a fully connected and seamless chunk
|
||||
public static final int CHUNK_DATA_GENERATOR_SIZE = ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE;
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public class ClientFluidManager {
|
||||
switch(message.getMessageSubtype()){
|
||||
case SENDFLUIDDATA: {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(message.getchunkData());
|
||||
FluidChunkData data = parseFluidDataBuffer(buffer);
|
||||
FluidChunkData data = this.parseFluidDataBuffer(buffer);
|
||||
fluidCache.addChunkDataToCache(
|
||||
message.getworldX(), message.getworldY(), message.getworldZ(),
|
||||
data
|
||||
@ -72,7 +72,7 @@ public class ClientFluidManager {
|
||||
} break;
|
||||
case UPDATEFLUIDDATA: {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(message.getchunkData());
|
||||
FluidChunkData data = parseFluidDataBuffer(buffer);
|
||||
FluidChunkData data = this.parseFluidDataBuffer(buffer);
|
||||
fluidCache.addChunkDataToCache(
|
||||
message.getworldX(), message.getworldY(), message.getworldZ(),
|
||||
data
|
||||
|
||||
@ -396,41 +396,36 @@ public class TerrainProtocol implements ServerProtocolTemplate<TerrainMessage> {
|
||||
* @return the buffer
|
||||
*/
|
||||
public static ByteBuffer constructFluidByteBuffer(ServerFluidChunk chunk){
|
||||
//The length along each access of the chunk data. Typically, should be at least 17.
|
||||
//Because CHUNK_SIZE is 16, 17 adds the necessary extra value. Each chunk needs the value of the immediately following position to generate
|
||||
//chunk data that connects seamlessly to the next chunk.
|
||||
int dataLength = chunk.getWeights().limit();
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocate(dataLength*(4+4+4+4));
|
||||
ByteBuffer buffer = ByteBuffer.allocate(ServerFluidChunk.BUFFER_SIZE*(4+4+4+4));
|
||||
FloatBuffer floatView = buffer.asFloatBuffer();
|
||||
|
||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||
floatView.put(chunk.getWeight(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||
floatView.put(chunk.getVelocityX(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||
floatView.put(chunk.getVelocityY(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||
floatView.put(chunk.getVelocityZ(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class FluidDiskMap {
|
||||
if(rawData != null){
|
||||
ByteBuffer buffer = ByteBuffer.wrap(rawData);
|
||||
FloatBuffer floatView = buffer.asFloatBuffer();
|
||||
int DIM = ServerTerrainChunk.CHUNK_DIMENSION;
|
||||
int DIM = ServerFluidChunk.BUFFER_DIM;
|
||||
rVal = new ServerFluidChunk(worldX, worldY, worldZ);
|
||||
for(int x = 0; x < DIM; x++){
|
||||
for(int y = 0; y < DIM; y++){
|
||||
|
||||
@ -27,10 +27,15 @@ public class ServerFluidChunk {
|
||||
*/
|
||||
static final int CENTER_BUFF = 13;
|
||||
|
||||
/**
|
||||
* Dimension of a fluid buffer
|
||||
*/
|
||||
public static final int BUFFER_DIM = 18;
|
||||
|
||||
/**
|
||||
* Size of a fluid buffer
|
||||
*/
|
||||
static final int BUFFER_SIZE = ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION;
|
||||
public static final int BUFFER_SIZE = ServerFluidChunk.BUFFER_DIM * ServerFluidChunk.BUFFER_DIM * ServerFluidChunk.BUFFER_DIM;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user