roads block content generation
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-20 13:01:24 -04:00
parent 27330797e9
commit f8e919f599
3 changed files with 41 additions and 1 deletions

View File

@ -1917,7 +1917,8 @@ Town layout tries to connect intersection nodes with roads
Macro area objects don't store start/end bounds separate from aabb anymore Macro area objects don't store start/end bounds separate from aabb anymore
Unify functions to fetch/generate chunks on server Unify functions to fetch/generate chunks on server
Macro data blocks terrain and block generation until it is ready Macro data blocks terrain and block generation until it is ready
Content generation blocks for macro data generation
Roads block content generation

View File

@ -2,6 +2,7 @@ package electrosphere.server.entity;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import org.joml.Vector3i; import org.joml.Vector3i;
@ -11,6 +12,7 @@ import electrosphere.entity.state.server.ServerCharacterData;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.ServerDataCell; import electrosphere.server.datacell.ServerDataCell;
import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.entity.serialization.ContentSerialization; import electrosphere.server.entity.serialization.ContentSerialization;
import electrosphere.server.macro.MacroData; import electrosphere.server.macro.MacroData;
import electrosphere.server.saves.SaveUtils; import electrosphere.server.saves.SaveUtils;
@ -18,6 +20,7 @@ import electrosphere.util.FileUtils;
import electrosphere.util.math.HashUtils; import electrosphere.util.math.HashUtils;
import electrosphere.server.macro.character.Character; import electrosphere.server.macro.character.Character;
import electrosphere.server.macro.race.Race; import electrosphere.server.macro.race.Race;
import electrosphere.server.macro.spatial.MacroLODObject;
import electrosphere.server.macro.spatial.MacroObject; import electrosphere.server.macro.spatial.MacroObject;
/** /**
@ -25,6 +28,11 @@ import electrosphere.server.macro.spatial.MacroObject;
*/ */
public class ServerContentManager { public class ServerContentManager {
/**
* Maximum amount of time to wait
*/
public static final int MAX_TIME_TO_WAIT = 100;
/** /**
* controls whether the manager should generate content on loading a new scene * controls whether the manager should generate content on loading a new scene
*/ */
@ -62,6 +70,36 @@ public class ServerContentManager {
*/ */
public void generateContentForDataCell(Realm realm, Vector3i worldPos, ServerDataCell cell, Long cellKey){ public void generateContentForDataCell(Realm realm, Vector3i worldPos, ServerDataCell cell, Long cellKey){
Globals.profiler.beginCpuSample("ServerContentManager.generateContentForDataCell"); Globals.profiler.beginCpuSample("ServerContentManager.generateContentForDataCell");
//
//Block for macro data generation if relevant
//
List<MacroObject> objects = null;
if(macroData != null){
objects = macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldPos.x, worldPos.y, worldPos.z));
}
//if any of this macro data isn't ready, return a null chunk
long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count();
int waitCount = 0;
while(notFullResCount > 0 && waitCount < MAX_TIME_TO_WAIT){
try {
TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count();
waitCount++;
}
if(notFullResCount > 0){
throw new Error("Failed to generate content " + notFullResCount + " " + waitCount);
}
//
//Actual generation/loading
//
String fullPath = "/content/" + cellKey + ".dat"; String fullPath = "/content/" + cellKey + ".dat";
if(generateContent){ //in other words, if not arena mode if(generateContent){ //in other words, if not arena mode
if(FileUtils.checkSavePathExists(Globals.serverState.currentSave.getName(), fullPath)){ if(FileUtils.checkSavePathExists(Globals.serverState.currentSave.getName(), fullPath)){

View File

@ -344,6 +344,7 @@ public class MacroData {
public List<MacroAreaObject> getContentBlockers(){ public List<MacroAreaObject> getContentBlockers(){
List<MacroAreaObject> blockers = new LinkedList<MacroAreaObject>(); List<MacroAreaObject> blockers = new LinkedList<MacroAreaObject>();
blockers.addAll(this.structures); blockers.addAll(this.structures);
blockers.addAll(this.roads);
return blockers; return blockers;
} }