macro data injection into voxel gen
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-18 16:10:44 -04:00
parent 531781dd54
commit 82bf65d4a2
10 changed files with 53 additions and 13 deletions

View File

@ -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
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
Macro data is injected into voxel chunk generators

View File

@ -151,6 +151,7 @@ public class SceneLoader {
}
//hook up macro data if relevant
if(macroData != null){
realm.getServerWorldData().getServerTerrainManager().setMacroData(macroData);
realm.getServerWorldData().getServerBlockManager().setMacroData(macroData);
}
//load scripts

View File

@ -646,7 +646,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
int worldY = ServerWorldData.convertRealToChunkSpace(point.y);
int worldZ = ServerWorldData.convertRealToChunkSpace(point.z);
Vector3i worldPos = new Vector3i(worldX,worldY,worldZ);
return tryCreateCellAtPoint(worldPos);
return this.tryCreateCellAtPoint(worldPos);
}
/**

View File

@ -2,6 +2,7 @@ package electrosphere.server.physics.terrain.generation;
import electrosphere.client.terrain.cache.ChunkData;
import electrosphere.entity.scene.RealmDescriptor;
import electrosphere.server.macro.MacroData;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
import electrosphere.server.physics.terrain.models.TerrainModel;
@ -23,7 +24,7 @@ public class DefaultChunkGenerator implements ChunkGenerator {
}
@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.
//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];

View File

@ -11,6 +11,7 @@ import org.graalvm.polyglot.Value;
import electrosphere.engine.Globals;
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.HeightmapGenerator;
import electrosphere.server.physics.terrain.generation.heightmap.HillsGen;
@ -112,7 +113,7 @@ public class JSChunkGenerator implements ChunkGenerator {
}
@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");
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];;

View File

@ -1,6 +1,7 @@
package electrosphere.server.physics.terrain.generation;
import electrosphere.client.terrain.cache.ChunkData;
import electrosphere.server.macro.MacroData;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
import electrosphere.server.physics.terrain.models.TerrainModel;
@ -25,7 +26,7 @@ public class OverworldChunkGenerator implements ChunkGenerator {
}
@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;
//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

View File

@ -9,6 +9,7 @@ import electrosphere.data.biome.BiomeSurfaceGenerationParams;
import electrosphere.data.voxel.sampler.SamplerFile;
import electrosphere.engine.Globals;
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.HeightmapGenerator;
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapNoiseGen;
@ -128,7 +129,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator {
}
@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");
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];;

View File

@ -1,5 +1,6 @@
package electrosphere.server.physics.terrain.generation.interfaces;
import electrosphere.server.macro.MacroData;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
import electrosphere.server.physics.terrain.models.TerrainModel;
@ -10,13 +11,14 @@ public interface ChunkGenerator {
/**
* Generates a chunk given an x, y, and z
* @param macroData The macro data
* @param worldX The x component
* @param worldY The y component
* @param worldZ The z component
* @param stride The stride of the data
* @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

View File

@ -5,6 +5,7 @@ import java.util.function.Consumer;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.server.macro.MacroData;
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
@ -38,6 +39,11 @@ public class ChunkGenerationThread implements Runnable {
*/
ChunkGenerator chunkGenerator;
/**
* The macro data
*/
MacroData macroData;
/**
* The world x coordinate
*/
@ -65,6 +71,7 @@ public class ChunkGenerationThread implements Runnable {
/**
* Creates the chunk generation job
* @param macroData The macro data
* @param chunkDiskMap The chunk disk map
* @param chunkCache The chunk cache on the server
* @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
*/
public ChunkGenerationThread(
MacroData macroData,
ChunkDiskMap chunkDiskMap,
ServerChunkCache chunkCache,
ChunkGenerator chunkGenerator,
@ -82,6 +90,7 @@ public class ChunkGenerationThread implements Runnable {
int stride,
Consumer<ServerTerrainChunk> onLoad
){
this.macroData = macroData;
this.chunkDiskMap = chunkDiskMap;
this.chunkCache = chunkCache;
this.chunkGenerator = chunkGenerator;
@ -109,7 +118,7 @@ public class ChunkGenerationThread implements Runnable {
}
//generate if it does not exist
if(chunk == null){
chunk = chunkGenerator.generateChunk(worldX, worldY, worldZ, stride);
chunk = chunkGenerator.generateChunk(this.macroData, worldX, worldY, worldZ, stride);
}
if(chunk != null){
chunkCache.add(worldX, worldY, worldZ, stride, chunk);

View File

@ -5,6 +5,7 @@ import electrosphere.engine.Globals;
import electrosphere.engine.threads.ThreadCounts;
import electrosphere.entity.scene.RealmDescriptor;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.MacroData;
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
@ -55,10 +56,14 @@ public class ServerTerrainManager {
*/
ServerWorldData parent;
//the seed for terrain generation
/**
* the seed for terrain generation
*/
long seed;
//The model of the terrain this manager is managing
/**
* The model of the terrain this manager is managing
*/
TerrainModel model;
/**
@ -67,13 +72,23 @@ public class ServerTerrainManager {
@Exclude
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;
//The generation algorithm for this terrain manager
/**
* The generation algorithm for this terrain manager
*/
@Exclude
ChunkGenerator chunkGenerator;
/**
* The macro data for this world
*/
@Exclude
MacroData macroData;
/**
* The threadpool for chunk generation
*/
@ -289,7 +304,7 @@ public class ServerTerrainManager {
}
//generate if it does not exist
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);
}
@ -336,7 +351,7 @@ public class ServerTerrainManager {
*/
public void getChunkAsync(int worldX, int worldY, int worldZ, int stride, Consumer<ServerTerrainChunk> onLoad){
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();
}
@ -389,4 +404,12 @@ public class ServerTerrainManager {
chunkExecutorService.shutdownNow();
}
/**
* Sets the macro data for the block manager
* @param macroData The macro data
*/
public void setMacroData(MacroData macroData){
this.macroData = macroData;
}
}