macro data injection into voxel gen
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
531781dd54
commit
82bf65d4a2
@ -1878,6 +1878,7 @@ Scaffolding jobs assigned by town to characters
|
|||||||
Fix character position not saving on creating a player's character for the first time
|
Fix character position not saving on creating a player's character for the first time
|
||||||
Server utility to move entities scans to see if it needs to create macro data if moving a player's entity
|
Server utility to move entities scans to see if it needs to create macro data if moving a player's entity
|
||||||
Road macro data generation
|
Road macro data generation
|
||||||
|
Macro data is injected into voxel chunk generators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -151,6 +151,7 @@ public class SceneLoader {
|
|||||||
}
|
}
|
||||||
//hook up macro data if relevant
|
//hook up macro data if relevant
|
||||||
if(macroData != null){
|
if(macroData != null){
|
||||||
|
realm.getServerWorldData().getServerTerrainManager().setMacroData(macroData);
|
||||||
realm.getServerWorldData().getServerBlockManager().setMacroData(macroData);
|
realm.getServerWorldData().getServerBlockManager().setMacroData(macroData);
|
||||||
}
|
}
|
||||||
//load scripts
|
//load scripts
|
||||||
|
|||||||
@ -646,7 +646,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
|||||||
int worldY = ServerWorldData.convertRealToChunkSpace(point.y);
|
int worldY = ServerWorldData.convertRealToChunkSpace(point.y);
|
||||||
int worldZ = ServerWorldData.convertRealToChunkSpace(point.z);
|
int worldZ = ServerWorldData.convertRealToChunkSpace(point.z);
|
||||||
Vector3i worldPos = new Vector3i(worldX,worldY,worldZ);
|
Vector3i worldPos = new Vector3i(worldX,worldY,worldZ);
|
||||||
return tryCreateCellAtPoint(worldPos);
|
return this.tryCreateCellAtPoint(worldPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package electrosphere.server.physics.terrain.generation;
|
|||||||
|
|
||||||
import electrosphere.client.terrain.cache.ChunkData;
|
import electrosphere.client.terrain.cache.ChunkData;
|
||||||
import electrosphere.entity.scene.RealmDescriptor;
|
import electrosphere.entity.scene.RealmDescriptor;
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
||||||
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
||||||
import electrosphere.server.physics.terrain.models.TerrainModel;
|
import electrosphere.server.physics.terrain.models.TerrainModel;
|
||||||
@ -23,7 +24,7 @@ public class DefaultChunkGenerator implements ChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride) {
|
public ServerTerrainChunk generateChunk(MacroData macroData, int worldX, int worldY, int worldZ, int stride) {
|
||||||
//Each chunk also needs custody of the next chunk's first values so that they can perfectly overlap.
|
//Each chunk also needs custody of the next chunk's first values so that they can perfectly overlap.
|
||||||
//Hence, width should actually be chunk dimension + 1
|
//Hence, width should actually be chunk dimension + 1
|
||||||
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
|
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import org.graalvm.polyglot.Value;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.server.datacell.ServerWorldData;
|
import electrosphere.server.datacell.ServerWorldData;
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.generation.heightmap.EmptySkyGen;
|
import electrosphere.server.physics.terrain.generation.heightmap.EmptySkyGen;
|
||||||
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapGenerator;
|
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapGenerator;
|
||||||
import electrosphere.server.physics.terrain.generation.heightmap.HillsGen;
|
import electrosphere.server.physics.terrain.generation.heightmap.HillsGen;
|
||||||
@ -112,7 +113,7 @@ public class JSChunkGenerator implements ChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride) {
|
public ServerTerrainChunk generateChunk(MacroData macroData, int worldX, int worldY, int worldZ, int stride) {
|
||||||
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator.generateChunk");
|
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator.generateChunk");
|
||||||
ServerTerrainChunk rVal = new ServerTerrainChunk(worldX, worldY, worldZ);
|
ServerTerrainChunk rVal = new ServerTerrainChunk(worldX, worldY, worldZ);
|
||||||
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];;
|
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.server.physics.terrain.generation;
|
package electrosphere.server.physics.terrain.generation;
|
||||||
|
|
||||||
import electrosphere.client.terrain.cache.ChunkData;
|
import electrosphere.client.terrain.cache.ChunkData;
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
||||||
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
||||||
import electrosphere.server.physics.terrain.models.TerrainModel;
|
import electrosphere.server.physics.terrain.models.TerrainModel;
|
||||||
@ -25,7 +26,7 @@ public class OverworldChunkGenerator implements ChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride) {
|
public ServerTerrainChunk generateChunk(MacroData macroData, int worldX, int worldY, int worldZ, int stride) {
|
||||||
ServerTerrainChunk returnedChunk;
|
ServerTerrainChunk returnedChunk;
|
||||||
//Each chunk also needs custody of the next chunk's first values so that they can perfectly overlap.
|
//Each chunk also needs custody of the next chunk's first values so that they can perfectly overlap.
|
||||||
//Hence, width should actually be chunk dimension + 1
|
//Hence, width should actually be chunk dimension + 1
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import electrosphere.data.biome.BiomeSurfaceGenerationParams;
|
|||||||
import electrosphere.data.voxel.sampler.SamplerFile;
|
import electrosphere.data.voxel.sampler.SamplerFile;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.server.datacell.ServerWorldData;
|
import electrosphere.server.datacell.ServerWorldData;
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.generation.heightmap.EmptySkyGen;
|
import electrosphere.server.physics.terrain.generation.heightmap.EmptySkyGen;
|
||||||
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapGenerator;
|
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapGenerator;
|
||||||
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapNoiseGen;
|
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapNoiseGen;
|
||||||
@ -128,7 +129,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride) {
|
public ServerTerrainChunk generateChunk(MacroData macroData, int worldX, int worldY, int worldZ, int stride) {
|
||||||
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator.generateChunk");
|
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator.generateChunk");
|
||||||
ServerTerrainChunk rVal = new ServerTerrainChunk(worldX, worldY, worldZ);
|
ServerTerrainChunk rVal = new ServerTerrainChunk(worldX, worldY, worldZ);
|
||||||
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];;
|
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.server.physics.terrain.generation.interfaces;
|
package electrosphere.server.physics.terrain.generation.interfaces;
|
||||||
|
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
||||||
import electrosphere.server.physics.terrain.models.TerrainModel;
|
import electrosphere.server.physics.terrain.models.TerrainModel;
|
||||||
|
|
||||||
@ -10,13 +11,14 @@ public interface ChunkGenerator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a chunk given an x, y, and z
|
* Generates a chunk given an x, y, and z
|
||||||
|
* @param macroData The macro data
|
||||||
* @param worldX The x component
|
* @param worldX The x component
|
||||||
* @param worldY The y component
|
* @param worldY The y component
|
||||||
* @param worldZ The z component
|
* @param worldZ The z component
|
||||||
* @param stride The stride of the data
|
* @param stride The stride of the data
|
||||||
* @return The chunk
|
* @return The chunk
|
||||||
*/
|
*/
|
||||||
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride);
|
public ServerTerrainChunk generateChunk(MacroData macroData, int worldX, int worldY, int worldZ, int stride);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the elevation at a given 2d coordinate
|
* Gets the elevation at a given 2d coordinate
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
|
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
|
||||||
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
||||||
|
|
||||||
@ -38,6 +39,11 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
*/
|
*/
|
||||||
ChunkGenerator chunkGenerator;
|
ChunkGenerator chunkGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The macro data
|
||||||
|
*/
|
||||||
|
MacroData macroData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The world x coordinate
|
* The world x coordinate
|
||||||
*/
|
*/
|
||||||
@ -65,6 +71,7 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the chunk generation job
|
* Creates the chunk generation job
|
||||||
|
* @param macroData The macro data
|
||||||
* @param chunkDiskMap The chunk disk map
|
* @param chunkDiskMap The chunk disk map
|
||||||
* @param chunkCache The chunk cache on the server
|
* @param chunkCache The chunk cache on the server
|
||||||
* @param chunkGenerator The chunk generator
|
* @param chunkGenerator The chunk generator
|
||||||
@ -75,6 +82,7 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
* @param onLoad The work to do once the chunk is available
|
* @param onLoad The work to do once the chunk is available
|
||||||
*/
|
*/
|
||||||
public ChunkGenerationThread(
|
public ChunkGenerationThread(
|
||||||
|
MacroData macroData,
|
||||||
ChunkDiskMap chunkDiskMap,
|
ChunkDiskMap chunkDiskMap,
|
||||||
ServerChunkCache chunkCache,
|
ServerChunkCache chunkCache,
|
||||||
ChunkGenerator chunkGenerator,
|
ChunkGenerator chunkGenerator,
|
||||||
@ -82,6 +90,7 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
int stride,
|
int stride,
|
||||||
Consumer<ServerTerrainChunk> onLoad
|
Consumer<ServerTerrainChunk> onLoad
|
||||||
){
|
){
|
||||||
|
this.macroData = macroData;
|
||||||
this.chunkDiskMap = chunkDiskMap;
|
this.chunkDiskMap = chunkDiskMap;
|
||||||
this.chunkCache = chunkCache;
|
this.chunkCache = chunkCache;
|
||||||
this.chunkGenerator = chunkGenerator;
|
this.chunkGenerator = chunkGenerator;
|
||||||
@ -109,7 +118,7 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
}
|
}
|
||||||
//generate if it does not exist
|
//generate if it does not exist
|
||||||
if(chunk == null){
|
if(chunk == null){
|
||||||
chunk = chunkGenerator.generateChunk(worldX, worldY, worldZ, stride);
|
chunk = chunkGenerator.generateChunk(this.macroData, worldX, worldY, worldZ, stride);
|
||||||
}
|
}
|
||||||
if(chunk != null){
|
if(chunk != null){
|
||||||
chunkCache.add(worldX, worldY, worldZ, stride, chunk);
|
chunkCache.add(worldX, worldY, worldZ, stride, chunk);
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.engine.threads.ThreadCounts;
|
import electrosphere.engine.threads.ThreadCounts;
|
||||||
import electrosphere.entity.scene.RealmDescriptor;
|
import electrosphere.entity.scene.RealmDescriptor;
|
||||||
import electrosphere.server.datacell.ServerWorldData;
|
import electrosphere.server.datacell.ServerWorldData;
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
|
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
|
||||||
import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
|
import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
|
||||||
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
|
||||||
@ -55,10 +56,14 @@ public class ServerTerrainManager {
|
|||||||
*/
|
*/
|
||||||
ServerWorldData parent;
|
ServerWorldData parent;
|
||||||
|
|
||||||
//the seed for terrain generation
|
/**
|
||||||
|
* the seed for terrain generation
|
||||||
|
*/
|
||||||
long seed;
|
long seed;
|
||||||
|
|
||||||
//The model of the terrain this manager is managing
|
/**
|
||||||
|
* The model of the terrain this manager is managing
|
||||||
|
*/
|
||||||
TerrainModel model;
|
TerrainModel model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,13 +72,23 @@ public class ServerTerrainManager {
|
|||||||
@Exclude
|
@Exclude
|
||||||
ServerChunkCache chunkCache;
|
ServerChunkCache chunkCache;
|
||||||
|
|
||||||
//The map of chunk position <-> file on disk containing chunk data
|
/**
|
||||||
|
* The map of chunk position <-> file on disk containing chunk data
|
||||||
|
*/
|
||||||
ChunkDiskMap chunkDiskMap = null;
|
ChunkDiskMap chunkDiskMap = null;
|
||||||
|
|
||||||
//The generation algorithm for this terrain manager
|
/**
|
||||||
|
* The generation algorithm for this terrain manager
|
||||||
|
*/
|
||||||
@Exclude
|
@Exclude
|
||||||
ChunkGenerator chunkGenerator;
|
ChunkGenerator chunkGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The macro data for this world
|
||||||
|
*/
|
||||||
|
@Exclude
|
||||||
|
MacroData macroData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The threadpool for chunk generation
|
* The threadpool for chunk generation
|
||||||
*/
|
*/
|
||||||
@ -289,7 +304,7 @@ public class ServerTerrainManager {
|
|||||||
}
|
}
|
||||||
//generate if it does not exist
|
//generate if it does not exist
|
||||||
if(returnedChunk == null){
|
if(returnedChunk == null){
|
||||||
returnedChunk = chunkGenerator.generateChunk(worldX, worldY, worldZ, ChunkData.NO_STRIDE);
|
returnedChunk = chunkGenerator.generateChunk(this.macroData, worldX, worldY, worldZ, ChunkData.NO_STRIDE);
|
||||||
}
|
}
|
||||||
this.chunkCache.add(worldX, worldY, worldZ, ChunkData.NO_STRIDE, returnedChunk);
|
this.chunkCache.add(worldX, worldY, worldZ, ChunkData.NO_STRIDE, returnedChunk);
|
||||||
}
|
}
|
||||||
@ -336,7 +351,7 @@ public class ServerTerrainManager {
|
|||||||
*/
|
*/
|
||||||
public void getChunkAsync(int worldX, int worldY, int worldZ, int stride, Consumer<ServerTerrainChunk> onLoad){
|
public void getChunkAsync(int worldX, int worldY, int worldZ, int stride, Consumer<ServerTerrainChunk> onLoad){
|
||||||
Globals.profiler.beginAggregateCpuSample("ServerTerrainManager.getChunkAsync");
|
Globals.profiler.beginAggregateCpuSample("ServerTerrainManager.getChunkAsync");
|
||||||
chunkExecutorService.submit(new ChunkGenerationThread(chunkDiskMap, chunkCache, chunkGenerator, worldX, worldY, worldZ, stride, onLoad));
|
chunkExecutorService.submit(new ChunkGenerationThread(this.macroData, chunkDiskMap, chunkCache, chunkGenerator, worldX, worldY, worldZ, stride, onLoad));
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,4 +404,12 @@ public class ServerTerrainManager {
|
|||||||
chunkExecutorService.shutdownNow();
|
chunkExecutorService.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the macro data for the block manager
|
||||||
|
* @param macroData The macro data
|
||||||
|
*/
|
||||||
|
public void setMacroData(MacroData macroData){
|
||||||
|
this.macroData = macroData;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user