terrain lod bounding sphere fix
Some checks failed
studiorailgun/Renderer/pipeline/pr-master There was a failure building this commit
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-11-07 14:59:25 -05:00
parent 22e468a6d0
commit 36e261b054
3 changed files with 25 additions and 9 deletions

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;
}