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 org.joml.Vector3i;
|
||||||
|
|
||||||
|
import electrosphere.server.fluid.manager.ServerFluidChunk;
|
||||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,7 +11,7 @@ import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
|||||||
public class FluidChunkData {
|
public class FluidChunkData {
|
||||||
|
|
||||||
//The size of a chunk in virtual data
|
//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
|
//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;
|
public static final int CHUNK_DATA_GENERATOR_SIZE = ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE;
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public class ClientFluidManager {
|
|||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case SENDFLUIDDATA: {
|
case SENDFLUIDDATA: {
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(message.getchunkData());
|
ByteBuffer buffer = ByteBuffer.wrap(message.getchunkData());
|
||||||
FluidChunkData data = parseFluidDataBuffer(buffer);
|
FluidChunkData data = this.parseFluidDataBuffer(buffer);
|
||||||
fluidCache.addChunkDataToCache(
|
fluidCache.addChunkDataToCache(
|
||||||
message.getworldX(), message.getworldY(), message.getworldZ(),
|
message.getworldX(), message.getworldY(), message.getworldZ(),
|
||||||
data
|
data
|
||||||
@ -72,7 +72,7 @@ public class ClientFluidManager {
|
|||||||
} break;
|
} break;
|
||||||
case UPDATEFLUIDDATA: {
|
case UPDATEFLUIDDATA: {
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(message.getchunkData());
|
ByteBuffer buffer = ByteBuffer.wrap(message.getchunkData());
|
||||||
FluidChunkData data = parseFluidDataBuffer(buffer);
|
FluidChunkData data = this.parseFluidDataBuffer(buffer);
|
||||||
fluidCache.addChunkDataToCache(
|
fluidCache.addChunkDataToCache(
|
||||||
message.getworldX(), message.getworldY(), message.getworldZ(),
|
message.getworldX(), message.getworldY(), message.getworldZ(),
|
||||||
data
|
data
|
||||||
|
|||||||
@ -396,41 +396,36 @@ public class TerrainProtocol implements ServerProtocolTemplate<TerrainMessage> {
|
|||||||
* @return the buffer
|
* @return the buffer
|
||||||
*/
|
*/
|
||||||
public static ByteBuffer constructFluidByteBuffer(ServerFluidChunk chunk){
|
public static ByteBuffer constructFluidByteBuffer(ServerFluidChunk chunk){
|
||||||
//The length along each access of the chunk data. Typically, should be at least 17.
|
ByteBuffer buffer = ByteBuffer.allocate(ServerFluidChunk.BUFFER_SIZE*(4+4+4+4));
|
||||||
//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));
|
|
||||||
FloatBuffer floatView = buffer.asFloatBuffer();
|
FloatBuffer floatView = buffer.asFloatBuffer();
|
||||||
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||||
floatView.put(chunk.getWeight(x, y, z));
|
floatView.put(chunk.getWeight(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||||
floatView.put(chunk.getVelocityX(x, y, z));
|
floatView.put(chunk.getVelocityX(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||||
floatView.put(chunk.getVelocityY(x, y, z));
|
floatView.put(chunk.getVelocityY(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
for(int x = 0; x < ServerFluidChunk.BUFFER_DIM; x++){
|
||||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
for(int y = 0; y < ServerFluidChunk.BUFFER_DIM; y++){
|
||||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
for(int z = 0; z < ServerFluidChunk.BUFFER_DIM; z++){
|
||||||
floatView.put(chunk.getVelocityZ(x, y, z));
|
floatView.put(chunk.getVelocityZ(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,7 +104,7 @@ public class FluidDiskMap {
|
|||||||
if(rawData != null){
|
if(rawData != null){
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(rawData);
|
ByteBuffer buffer = ByteBuffer.wrap(rawData);
|
||||||
FloatBuffer floatView = buffer.asFloatBuffer();
|
FloatBuffer floatView = buffer.asFloatBuffer();
|
||||||
int DIM = ServerTerrainChunk.CHUNK_DIMENSION;
|
int DIM = ServerFluidChunk.BUFFER_DIM;
|
||||||
rVal = new ServerFluidChunk(worldX, worldY, worldZ);
|
rVal = new ServerFluidChunk(worldX, worldY, worldZ);
|
||||||
for(int x = 0; x < DIM; x++){
|
for(int x = 0; x < DIM; x++){
|
||||||
for(int y = 0; y < DIM; y++){
|
for(int y = 0; y < DIM; y++){
|
||||||
|
|||||||
@ -27,10 +27,15 @@ public class ServerFluidChunk {
|
|||||||
*/
|
*/
|
||||||
static final int CENTER_BUFF = 13;
|
static final int CENTER_BUFF = 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dimension of a fluid buffer
|
||||||
|
*/
|
||||||
|
public static final int BUFFER_DIM = 18;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Size of a fluid buffer
|
* 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