Compare commits
No commits in common. "22e468a6d0d38a840d1cfce1433c28039fea6be1" and "96b65dba465e4c92e65148569ab87513d4d437a5" have entirely different histories.
22e468a6d0
...
96b65dba46
@ -4,7 +4,6 @@ import java.lang.management.ManagementFactory;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.joml.Matrix4d;
|
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
@ -258,7 +257,7 @@ public class Globals {
|
|||||||
|
|
||||||
//matrices for drawing models
|
//matrices for drawing models
|
||||||
public static Matrix4f viewMatrix = new Matrix4f();
|
public static Matrix4f viewMatrix = new Matrix4f();
|
||||||
public static Matrix4d projectionMatrix;
|
public static Matrix4f projectionMatrix;
|
||||||
public static Matrix4f lightDepthMatrix = new Matrix4f();
|
public static Matrix4f lightDepthMatrix = new Matrix4f();
|
||||||
|
|
||||||
//locations for shadow map specific variables
|
//locations for shadow map specific variables
|
||||||
|
|||||||
@ -245,7 +245,7 @@ public class ClientLoading {
|
|||||||
EntityCreationUtils.makeEntityDrawable(skybox, "Models/environment/skyboxSphere.fbx");
|
EntityCreationUtils.makeEntityDrawable(skybox, "Models/environment/skyboxSphere.fbx");
|
||||||
DrawableUtils.disableCulling(skybox);
|
DrawableUtils.disableCulling(skybox);
|
||||||
EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f));
|
EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f));
|
||||||
EntityUtils.getScale(skybox).mul(600000.0f);
|
EntityUtils.getScale(skybox).mul(200000.0f);
|
||||||
Globals.assetManager.queueOverrideMeshShader("Models/environment/skyboxSphere.fbx", "Sphere", "Shaders/entities/skysphere/skysphere.vs", "Shaders/entities/skysphere/skysphere.fs");
|
Globals.assetManager.queueOverrideMeshShader("Models/environment/skyboxSphere.fbx", "Sphere", "Shaders/entities/skysphere/skysphere.vs", "Shaders/entities/skysphere/skysphere.fs");
|
||||||
|
|
||||||
//cloud ring pseudo skybox
|
//cloud ring pseudo skybox
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package electrosphere.renderer;
|
package electrosphere.renderer;
|
||||||
|
|
||||||
import org.joml.FrustumIntersection;
|
import org.joml.FrustumIntersection;
|
||||||
import org.joml.Matrix4d;
|
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
import electrosphere.renderer.actor.instance.InstanceData;
|
import electrosphere.renderer.actor.instance.InstanceData;
|
||||||
@ -167,7 +166,7 @@ public class RenderPipelineState {
|
|||||||
* @param projectionMatrix the projection matrix
|
* @param projectionMatrix the projection matrix
|
||||||
* @param viewMatrix the view matrix
|
* @param viewMatrix the view matrix
|
||||||
*/
|
*/
|
||||||
public void updateFrustumIntersection(Matrix4d projectionMatrix, Matrix4f viewMatrix){
|
public void updateFrustumIntersection(Matrix4f projectionMatrix, Matrix4f viewMatrix){
|
||||||
Matrix4f projectionViewMatrix = new Matrix4f();
|
Matrix4f projectionViewMatrix = new Matrix4f();
|
||||||
projectionViewMatrix.set(projectionMatrix);
|
projectionViewMatrix.set(projectionMatrix);
|
||||||
projectionViewMatrix.mul(viewMatrix);
|
projectionViewMatrix.mul(viewMatrix);
|
||||||
|
|||||||
@ -453,7 +453,7 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
// Projection and View matrix creation
|
// Projection and View matrix creation
|
||||||
//
|
//
|
||||||
Globals.projectionMatrix = new Matrix4d();
|
Globals.projectionMatrix = new Matrix4f();
|
||||||
Globals.viewMatrix = new Matrix4f();
|
Globals.viewMatrix = new Matrix4f();
|
||||||
verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
||||||
//set local aspect ratio and global aspect ratio at the same time
|
//set local aspect ratio and global aspect ratio at the same time
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -71,52 +72,72 @@ public class TestGenerationChunkGenerator implements ChunkGenerator {
|
|||||||
int[][][] values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
int[][][] values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//actual generation algo
|
if(worldX == 0 || worldZ == 0){
|
||||||
|
//generate flat ground for the player to spawn on
|
||||||
//biome of the current chunk
|
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||||
BiomeData surfaceBiome = this.terrainModel.getSurfaceBiome(worldX, worldY, worldZ);
|
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||||
|
Arrays.fill(weights[x][y],-1f);
|
||||||
BiomeSurfaceGenerationParams surfaceParams = surfaceBiome.getSurfaceGenerationParams();
|
|
||||||
HeightmapGenerator heightmapGen = this.tagGeneratorMap.get(surfaceParams.getSurfaceGenTag());
|
|
||||||
if(heightmapGen == null){
|
|
||||||
throw new Error("Undefined heightmap generator in biome! " + surfaceBiome.getId() + " " + surfaceBiome.getDisplayName() + " " + surfaceParams.getSurfaceGenTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
//stride value
|
|
||||||
int strideValue = (int)Math.pow(2,stride);
|
|
||||||
|
|
||||||
//presolve heightfield
|
|
||||||
float[][] heightfield = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
|
||||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
|
||||||
int finalWorldX = worldX + ((x * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
|
||||||
int finalWorldZ = worldZ + ((z * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
|
||||||
int finalChunkX = (x * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
|
||||||
int finalChunkZ = (z * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
|
||||||
heightfield[x][z] = heightmapGen.getHeight(
|
|
||||||
this.terrainModel.getSeed(),
|
|
||||||
this.serverWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX),
|
|
||||||
this.serverWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
|
||||||
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator - Generate slice");
|
|
||||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
|
||||||
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
|
||||||
int finalWorldX = worldX + ((x * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
|
||||||
int finalWorldY = worldY + ((y * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
|
||||||
int finalWorldZ = worldZ + ((z * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
|
||||||
int finalChunkX = (x * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
|
||||||
int finalChunkY = (y * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
|
||||||
int finalChunkZ = (z * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
|
||||||
GeneratedVoxel voxel = this.getVoxel(finalWorldX, finalWorldY, finalWorldZ, finalChunkX, finalChunkY, finalChunkZ, heightfield[x][z], this.terrainModel, surfaceBiome);
|
|
||||||
weights[x][y][z] = voxel.weight;
|
|
||||||
values[x][y][z] = voxel.type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Globals.profiler.endCpuSample();
|
if(worldY == 0){
|
||||||
|
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||||
|
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||||
|
values[x][0][z] = 1;
|
||||||
|
weights[x][0][z] = 0.1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//actual generation algo
|
||||||
|
|
||||||
|
//biome of the current chunk
|
||||||
|
BiomeData surfaceBiome = this.terrainModel.getSurfaceBiome(worldX, worldY, worldZ);
|
||||||
|
|
||||||
|
BiomeSurfaceGenerationParams surfaceParams = surfaceBiome.getSurfaceGenerationParams();
|
||||||
|
HeightmapGenerator heightmapGen = this.tagGeneratorMap.get(surfaceParams.getSurfaceGenTag());
|
||||||
|
if(heightmapGen == null){
|
||||||
|
throw new Error("Undefined heightmap generator in biome! " + surfaceBiome.getId() + " " + surfaceBiome.getDisplayName() + " " + surfaceParams.getSurfaceGenTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
//stride value
|
||||||
|
int strideValue = (int)Math.pow(2,stride);
|
||||||
|
|
||||||
|
//presolve heightfield
|
||||||
|
float[][] heightfield = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
||||||
|
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||||
|
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||||
|
int finalWorldX = worldX + ((x * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
||||||
|
int finalWorldZ = worldZ + ((z * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
||||||
|
int finalChunkX = (x * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
int finalChunkZ = (z * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
heightfield[x][z] = heightmapGen.getHeight(
|
||||||
|
this.terrainModel.getSeed(),
|
||||||
|
this.serverWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX),
|
||||||
|
this.serverWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||||
|
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator - Generate slice");
|
||||||
|
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||||
|
for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){
|
||||||
|
int finalWorldX = worldX + ((x * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
||||||
|
int finalWorldY = worldY + ((y * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
||||||
|
int finalWorldZ = worldZ + ((z * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION);
|
||||||
|
int finalChunkX = (x * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
int finalChunkY = (y * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
int finalChunkZ = (z * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION;
|
||||||
|
GeneratedVoxel voxel = this.getVoxel(finalWorldX, finalWorldY, finalWorldZ, finalChunkX, finalChunkY, finalChunkZ, heightfield[x][z], this.terrainModel, surfaceBiome);
|
||||||
|
weights[x][y][z] = voxel.weight;
|
||||||
|
values[x][y][z] = voxel.type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception ex){
|
} catch(Exception ex){
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
try {
|
try {
|
||||||
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.threadManager.shouldKeepRunning()){
|
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.threadManager.shouldKeepRunning()){
|
||||||
if(chunkCache.containsChunk(worldX, worldY, worldZ, stride)){
|
if(chunkCache.containsChunk(worldX,worldY,worldZ,stride)){
|
||||||
chunk = chunkCache.get(worldX, worldY, worldZ, stride);
|
chunk = chunkCache.get(worldX, worldY, worldZ, stride);
|
||||||
} else {
|
} else {
|
||||||
//pull from disk if it exists
|
//pull from disk if it exists
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user