package electrosphere.client.fluid.cache;

import org.joml.Vector3i;

import electrosphere.server.terrain.manager.ServerTerrainChunk;

/**
 * A container of data about a chunk of fluid
 */
public class FluidChunkData {

    //The size of a chunk in virtual data
    public static final int CHUNK_SIZE = ServerTerrainChunk.CHUNK_DIMENSION;
    //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;
    
    //How much of that fluid type is in this voxel
    float[][][] voxelWeight;

    //The velocities
    float[][][] velocityX;
    float[][][] velocityY;
    float[][][] velocityZ;


    /**
     * Gets the voxel weight array in this container
     * @return The voxel weight array
     */
    public float[][][] getVoxelWeight(){
        return voxelWeight;
    }

    /**
     * Sets the voxel weight array in this container
     * @param voxelWeight The voxel weight array
     */
    public void setVoxelWeight(float[][][] voxelWeight){
        //update data
        this.voxelWeight = voxelWeight;
    }

    /**
     * Gets the weight of a voxel at a poisiton
     * @param localPosition The local position
     * @return The weight of the specified voxel
     */
    public float getWeight(Vector3i localPosition){
        return voxelWeight[localPosition.x][localPosition.y][localPosition.z];
    }

    /**
     * Gets the weight of a voxel at a poisiton
     * @return The weight of the specified voxel
     */
    public float getWeight(int x, int y, int z){
        return voxelWeight[x][y][z];
    }

    /**
     * Gets a key for the modifiedSinceLastGeneration set based on a voxel position
     * @param position The voxel position
     * @return The key
     */
    private String getVoxelPositionKey(Vector3i position){
        return position.x + "_" + position.y + "_" + position.z;
    }


}
