generation testing menu with regenerate button
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
604380b31e
commit
987165649f
@ -3,7 +3,7 @@
|
||||
have a heightmap generated by tectonic sim
|
||||
is interpolated to 2000x2000
|
||||
saved as a byte per pixel
|
||||
this map is used to determine what type of noise to sample from (ie mountain noise vs ocean noise vs plains noise)
|
||||
~~~~~this map is used to determine what type of noise to sample from (ie mountain noise vs ocean noise vs plains noise)~~~~~
|
||||
generate a separate map for biomes that is also 2000x2000
|
||||
this is stored as shorts, where value is the id of the biome
|
||||
"civilization" gradient map generated with simplex noise (1byte resolution)
|
||||
|
||||
@ -475,6 +475,22 @@ public class DrawCellManager {
|
||||
updateable.add(getCellKey(chunkX, chunkY, chunkZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Evicts all chunks
|
||||
*/
|
||||
public void evictAll(){
|
||||
//destroy models
|
||||
for(String key : drawable){
|
||||
keyCellMap.get(key).destroy();
|
||||
}
|
||||
keyCellMap.clear();
|
||||
hasNotRequested.clear();
|
||||
requested.clear();
|
||||
drawable.clear();
|
||||
undrawable.clear();
|
||||
updateable.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the radius within which full-detail models are drawn
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
package electrosphere.client.ui.menu.debug;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindow;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
|
||||
import electrosphere.server.datacell.GriddedDataCellManager;
|
||||
import imgui.ImGui;
|
||||
|
||||
/**
|
||||
* Menu for altering parameters of the test terrain generator
|
||||
*/
|
||||
public class ImGuiTestGen {
|
||||
|
||||
//window for viewing information about the ai state
|
||||
protected static ImGuiWindow testGenWindow;
|
||||
|
||||
/**
|
||||
* Creates the windows in this file
|
||||
*/
|
||||
protected static void createTestGenWindows(){
|
||||
createTestGenDebugWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Client scene entity view
|
||||
*/
|
||||
protected static void createTestGenDebugWindow(){
|
||||
testGenWindow = new ImGuiWindow("Test Terrain Generation");
|
||||
testGenWindow.setCallback(new ImGuiWindowCallback() {
|
||||
@Override
|
||||
public void exec() {
|
||||
//ui framework text
|
||||
ImGui.text("Test Terrain Generation");
|
||||
|
||||
//regenerate the test area
|
||||
if(ImGui.button("Regenerate")){
|
||||
GriddedDataCellManager gridManager = (GriddedDataCellManager)Globals.realmManager.first().getDataCellManager();
|
||||
gridManager.evictAll();
|
||||
Globals.drawCellManager.evictAll();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
testGenWindow.setOpen(false);
|
||||
Globals.renderingEngine.getImGuiPipeline().addImGuiWindow(testGenWindow);
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,6 +11,7 @@ import electrosphere.renderer.ui.imgui.ImGuiWindow;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
|
||||
import electrosphere.server.fluid.manager.ServerFluidManager;
|
||||
import electrosphere.server.terrain.generation.TestGenerationChunkGenerator;
|
||||
import imgui.ImGui;
|
||||
|
||||
/**
|
||||
@ -49,6 +50,7 @@ public class ImGuiWindowMacros {
|
||||
ImGuiAudio.createAudioDebugMenu();
|
||||
ImGuiLogger.createLoggersWindows();
|
||||
ImGuiRenderer.createRendererWindows();
|
||||
ImGuiTestGen.createTestGenWindows();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,6 +173,16 @@ public class ImGuiWindowMacros {
|
||||
if(ImGui.button("UI")){
|
||||
ImGuiUIFramework.uiFrameworkWindow.setOpen(true);
|
||||
}
|
||||
//test gen window (only drawn if realm is a test generation realm)
|
||||
if(
|
||||
Globals.realmManager != null &&
|
||||
Globals.realmManager.first() != null &&
|
||||
Globals.realmManager.first().getServerWorldData() != null &&
|
||||
Globals.realmManager.first().getServerWorldData().getServerTerrainManager().getChunkGenerator() instanceof TestGenerationChunkGenerator &&
|
||||
ImGui.button("Test Terrain Gen")
|
||||
){
|
||||
ImGuiTestGen.testGenWindow.setOpen(true);
|
||||
}
|
||||
//close button
|
||||
if(ImGui.button("Close")){
|
||||
mainDebugWindow.setOpen(false);
|
||||
|
||||
@ -315,6 +315,37 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evicts all loaded chunks.
|
||||
* <p>
|
||||
* Note: Does not save to disk.
|
||||
* </p>
|
||||
*/
|
||||
public void evictAll(){
|
||||
//TODO: improve to make have less performance impact
|
||||
for(ServerDataCell cell : loadedCells){
|
||||
loadedCellsLock.acquireUninterruptibly();
|
||||
int frameCount = cellPlayerlessFrameMap.get(cell) + 1;
|
||||
cellPlayerlessFrameMap.put(cell,frameCount);
|
||||
toCleanQueue.add(cell);
|
||||
loadedCellsLock.release();
|
||||
}
|
||||
for(ServerDataCell cell : toCleanQueue){
|
||||
parent.deregisterCell(cell);
|
||||
loadedCells.remove(cell);
|
||||
Vector3i worldPos = getCellWorldPosition(cell);
|
||||
String key = getServerDataCellKey(worldPos);
|
||||
groundDataCells.remove(key);
|
||||
//offload all entities in cell to chunk file
|
||||
serverContentManager.saveContentToDisk(key, cell.getScene().getEntityList());
|
||||
//clear all entities in cell
|
||||
for(Entity entity : cell.getScene().getEntityList()){
|
||||
ClientEntityUtils.destroyEntity(entity);
|
||||
}
|
||||
}
|
||||
toCleanQueue.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data cell at a given real point in this realm
|
||||
* @param point The real point
|
||||
|
||||
@ -199,6 +199,9 @@ public class RealmManager {
|
||||
* @return The first realm in the manager
|
||||
*/
|
||||
public Realm first(){
|
||||
if(realms.size() == 0){
|
||||
return null;
|
||||
}
|
||||
return realms.iterator().next();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user