voxelImprovements #5

Merged
railgun merged 21 commits from voxelImprovements into master 2024-11-07 15:08:54 -05:00
3 changed files with 25 additions and 9 deletions
Showing only changes of commit 36e261b054 - Show all commits

View File

@ -20,6 +20,11 @@ public class TerrainChunkData {
//texture ratio vector
List<Float> textureRatioVectors; //HOW MUCH of each texture in the atlas to sample
/**
* The LOD of the model
*/
int lod;
/**
* Creates an object to hold data required to generate a chunk
* @param vertices
@ -27,14 +32,16 @@ public class TerrainChunkData {
* @param faceElements
* @param uvs
* @param textureSamplers
* @param lod The LOD of the model
*/
public TerrainChunkData(List<Float> vertices, List<Float> normals, List<Integer> faceElements, List<Float> uvs, List<Float> textureSamplers, List<Float> textureRatioVectors){
public TerrainChunkData(List<Float> vertices, List<Float> normals, List<Integer> faceElements, List<Float> uvs, List<Float> textureSamplers, List<Float> textureRatioVectors, int lod){
this.vertices = vertices;
this.normals = normals;
this.faceElements = faceElements;
this.uvs = uvs;
this.textureSamplers = textureSamplers;
this.textureRatioVectors = textureRatioVectors;
this.lod = lod;
}
/**
@ -85,4 +92,12 @@ public class TerrainChunkData {
return textureRatioVectors;
}
/**
* Gets the LOD of the model
* @return The LOD
*/
public int getLOD(){
return lod;
}
}

View File

@ -763,7 +763,7 @@ public class TerrainChunkModelGeneration {
}
//List<Float> vertices, List<Float> normals, List<Integer> faceElements, List<Float> uvs
TerrainChunkData rVal = new TerrainChunkData(vertsFlat, normalsFlat, elementsFlat, UVs, textureSamplers, textureRatioData);
TerrainChunkData rVal = new TerrainChunkData(vertsFlat, normalsFlat, elementsFlat, UVs, textureSamplers, textureRatioData, 0);
return rVal;
}
@ -892,14 +892,15 @@ public class TerrainChunkModelGeneration {
//bounding sphere logic
int distance = ServerTerrainChunk.CHUNK_DIMENSION / 2 * (int)Math.pow(2,data.getLOD());
mesh.updateBoundingSphere(
ServerTerrainChunk.CHUNK_DIMENSION,
ServerTerrainChunk.CHUNK_DIMENSION,
ServerTerrainChunk.CHUNK_DIMENSION,
distance,
distance,
distance,
(float)Math.sqrt(
ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION +
ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION +
ServerTerrainChunk.CHUNK_DIMENSION * ServerTerrainChunk.CHUNK_DIMENSION
distance * distance +
distance * distance +
distance * distance
));

View File

@ -1694,7 +1694,7 @@ public class TransvoxelModelGeneration {
}
//List<Float> vertices, List<Float> normals, List<Integer> faceElements, List<Float> uvs
TerrainChunkData rVal = new TerrainChunkData(vertsFlat, normalsFlat, elementsFlat, UVs, textureSamplers, textureRatioData);
TerrainChunkData rVal = new TerrainChunkData(vertsFlat, normalsFlat, elementsFlat, UVs, textureSamplers, textureRatioData, chunkData.levelOfDetail);
return rVal;
}