structure voxel foundation
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-20 14:51:14 -04:00
parent fd74af2e88
commit a4d2f7d72a
4 changed files with 27 additions and 1 deletions

View File

@ -1921,6 +1921,7 @@ Content generation blocks for macro data generation
Roads block content generation
Properly layout roads along town points in TownLayout
Town generates a structure -- scaffolding for doing it across roads
Structures create foundations in terrain voxels

View File

@ -98,7 +98,8 @@ public class TownLayout {
aabb.setMin(pos);
aabb.setMax(new Vector3d(pos).add(structureData.getDimensions()));
if(!macroData.intersectsStruct(aabb)){
VirtualStructure.createStructure(macroData, structureData, pos);
VirtualStructure struct = VirtualStructure.createStructure(macroData, structureData, pos);
town.addStructure(struct);
}
//right-facing road

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.joml.AABBd;
import org.joml.Vector3d;
import electrosphere.client.terrain.cache.ChunkData;
@ -14,6 +15,7 @@ import electrosphere.engine.Globals;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.civilization.road.Road;
import electrosphere.server.macro.spatial.MacroObject;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.server.physics.terrain.generation.heightmap.EmptySkyGen;
import electrosphere.server.physics.terrain.generation.heightmap.HeightmapGenerator;
@ -282,6 +284,19 @@ public class ProceduralChunkGenerator implements ChunkGenerator {
}
}
}
} else if(object instanceof VirtualStructure){
VirtualStructure struct = (VirtualStructure)object;
AABBd aabb = struct.getAABB();
//create a foundation underneath the structure
if(realX >= aabb.minX && realX <= aabb.maxX && realZ >= aabb.minZ && realZ <= aabb.maxZ){
//check if within foundation range
double vertDist = aabb.minY - realY;
if(vertDist > 0 && vertDist < 2){
voxel.type = 1;
voxel.weight = 1;
rVal = true;
}
}
} else if(object instanceof Town){
} else {
throw new Error("Unsupported object type " + object);

View File

@ -3,6 +3,7 @@ package electrosphere.server.physics.terrain.manager;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
@ -10,6 +11,8 @@ import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.macro.MacroData;
import electrosphere.server.macro.spatial.MacroLODObject;
import electrosphere.server.macro.spatial.MacroObject;
import electrosphere.server.macro.structure.VirtualStructure;
import electrosphere.server.macro.town.Town;
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
@ -163,6 +166,12 @@ public class ChunkGenerationThread implements Runnable {
if(notFullResCount > 0){
return null;
}
List<MacroObject> towns = objects.stream().filter((MacroObject obj) -> obj instanceof Town).collect(Collectors.toList());
for(MacroObject currObj : towns){
Town town = (Town)currObj;
List<VirtualStructure> structs = town.getStructures(macroData);
objects.addAll(structs);
}
if(chunkCache.containsChunk(worldX, worldY, worldZ, stride)){
rVal = chunkCache.get(worldX, worldY, worldZ, stride);