From 3a34dc28ceca4b965fa89edbba2b5c794c600246 Mon Sep 17 00:00:00 2001 From: austin Date: Tue, 29 Apr 2025 13:50:30 -0400 Subject: [PATCH] cleanup work --- .vscode/launch.json | 8 -- docs/src/progress/renderertodo.md | 2 + .../java/electrosphere/engine/Globals.java | 3 - src/main/java/electrosphere/engine/Main.java | 97 ++++--------------- .../electrosphere/engine/cli/CLIParser.java | 3 - .../electrosphere/server/macro/MacroData.java | 9 +- .../server/macro/structure/Structure.java | 18 +++- 7 files changed, 44 insertions(+), 96 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5d82726e..4f5b55cf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -54,14 +54,6 @@ "projectName": "Renderer", "args": "--headless" }, - { - "type": "java", - "name": "Launch Simulation Only", - "request": "launch", - "mainClass": "electrosphere.engine.Main", - "projectName": "Renderer", - "args": "--simulate" - }, { "name": "C/C++: gcc.exe build and debug active file", "type": "cppdbg", diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 8e4d565a..9899731b 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1585,6 +1585,8 @@ BlockFab metadata Structure editing tab in editor view Reduce physics generation calls on GriddedDataCellManager Fab selection doesn't overflow anymore +Cleaning up parts of Main class +Spawn test structure in macro data on creation diff --git a/src/main/java/electrosphere/engine/Globals.java b/src/main/java/electrosphere/engine/Globals.java index 086f907b..ce49412b 100644 --- a/src/main/java/electrosphere/engine/Globals.java +++ b/src/main/java/electrosphere/engine/Globals.java @@ -332,9 +332,6 @@ public class Globals { //macro simulation public static MacroSimulation macroSimulation; public static MacroData macroData; - - //flag to only run a simulation without full client - public static boolean RUN_SIMULATION_ONLY = false; //micro simulation public static MicroSimulation microSimulation; diff --git a/src/main/java/electrosphere/engine/Main.java b/src/main/java/electrosphere/engine/Main.java index 365fb20a..a7b23b33 100644 --- a/src/main/java/electrosphere/engine/Main.java +++ b/src/main/java/electrosphere/engine/Main.java @@ -20,8 +20,6 @@ import electrosphere.engine.time.Timekeeper; import electrosphere.logger.LoggerInterface; import electrosphere.renderer.RenderingEngine; import electrosphere.server.MainServerFunctions; -import electrosphere.server.macro.MacroData; -import electrosphere.server.simulation.MacroSimulation; /** @@ -50,7 +48,9 @@ public class Main { - + /** + * Tracks whether the application is running or not + */ public static boolean running = true; /** @@ -58,14 +58,25 @@ public class Main { */ static boolean initOde = false; - //target amount of time per frame + /** + * target amount of time per frame + */ public static float targetFrameRate = 60.0f; + /** + * Target period per frame + */ static float targetFramePeriod = 1.0f/targetFrameRate; - //framestep variable + /** + * Framestep tracking variable + */ static int framestep = 2; - + + /** + * The initial method of the application + * @param args CLI args + */ public static void main(String args[]){ // @@ -74,9 +85,9 @@ public class Main { // // - startUp(args); + Main.startUp(args); - mainLoop(); + Main.mainLoop(); } @@ -84,7 +95,7 @@ public class Main { * Starts up the engine */ public static void startUp(){ - startUp(new String[]{ + Main.startUp(new String[]{ "Renderer" }); } @@ -115,49 +126,7 @@ public class Main { OdeHelper.initODE(); initOde = true; } - - //world gen testing - //gen terrain - if(Globals.RUN_SIMULATION_ONLY){ - //gen world - Globals.macroData = MacroData.generateWorld(0); - Globals.macroData.describeWorld(); - boolean run = true; - Globals.macroSimulation = new MacroSimulation(); - while(run){ - Globals.macroSimulation.simulate(); - try { - TimeUnit.MILLISECONDS.sleep(1000); - } catch (InterruptedException ex) { - ex.printStackTrace(); - } - } - } -// if(1==1){ -// Globals.audioEngine = new AudioEngine(); -// Globals.audioEngine.init(); -// Globals.assetManager.addAudioPathToQueue("/Audio/MenuStartup.ogg"); -// Globals.assetManager.loadAssetsInQueue(); -// Globals.audioEngine.setGain(0.1f); -// AudioSource startupSound = AudioUtils.playAudioAtLocation("/Audio/MenuStartup.ogg", new Vector3f(3,0,0)); -// if(startupSound != null){ -// while(startupSound.isPlaying()){ -// try { -// TimeUnit.MILLISECONDS.sleep(10); -// } catch (InterruptedException ex) { -// ex.printStackTrace(); -// } -// } -// } -// System.exit(0); -// } - - - - //debug: create terrain/world viewer - // TerrainViewer.runViewer(); - //create the drawing context if(Globals.RUN_CLIENT && !Globals.HEADLESS){ //create opengl context @@ -180,31 +149,6 @@ public class Main { } })); - //uncomment to test loading a model into engine - // if(1==1){ - // //Models/creatures/person2/person2_1.glb - // ///Models/creatures/viewmodel.glb - // Globals.assetManager.addModelPathToQueue("/Models/creatures/person2/person2_1.glb"); - // Globals.assetManager.loadAssetsInQueue(); - // electrosphere.renderer.model.Model model = Globals.assetManager.fetchModel("/Models/creatures/person2/person2_1.glb"); - // // for(electrosphere.renderer.anim.Animation anim : model.getAnimations()){ - // // if(anim.name.equals("Armature|Idle1")){ - // // System.out.println(anim.duration); - // // for(electrosphere.renderer.anim.AnimChannel channel : anim.channels){ - // // if(channel.getNodeID().equals("Torso")){ - // // channel.fullDescribeChannel(); - // // } - // // // System.out.println("CHannel: " + channel.getNodeID()); - // // } - // // break; - // // } - // // } - // model.describeHighLevel(); - // // model.animations.get(0).fullDescribeAnimation(); - // // model.describeHighLevel(); - // System.exit(0); - // } - //create the audio context Globals.audioEngine = new AudioEngine(); if(Globals.RUN_CLIENT && !Globals.HEADLESS && Globals.RUN_AUDIO){ @@ -235,7 +179,6 @@ public class Main { LoggerInterface.loggerStartup.INFO("Recapture screen"); Globals.controlHandler.setRecapture(true); } - // RenderUtils.recaptureScreen(); } /** diff --git a/src/main/java/electrosphere/engine/cli/CLIParser.java b/src/main/java/electrosphere/engine/cli/CLIParser.java index 3a6f4c6c..de704831 100644 --- a/src/main/java/electrosphere/engine/cli/CLIParser.java +++ b/src/main/java/electrosphere/engine/cli/CLIParser.java @@ -19,9 +19,6 @@ public class CLIParser { Globals.RUN_SERVER = true; Globals.HEADLESS = true; } break; - case "--simulate": { - Globals.RUN_SIMULATION_ONLY = true; - } break; case "--maxLogs": { LoggerInterface.setInitLogLevel(LogLevel.LOOP_DEBUG); } break; diff --git a/src/main/java/electrosphere/server/macro/MacroData.java b/src/main/java/electrosphere/server/macro/MacroData.java index 9d4c7563..0765ad1f 100644 --- a/src/main/java/electrosphere/server/macro/MacroData.java +++ b/src/main/java/electrosphere/server/macro/MacroData.java @@ -109,10 +109,11 @@ public class MacroData { rVal.characters.add(testChar); //add a test character - // Structure struct = Structure. - // testChar.setPos(new Vector3d(ServerWorldData.convertChunkToRealSpace(new Vector3i(32774, 1, 32770)))); - // Race.setRace(testChar, Race.create("human", "human")); - // rVal.characters.add(testChar); + Structure struct = Structure.createStructure( + Globals.gameConfigCurrent.getStructureData().getType("test1"), + new Vector3d(ServerWorldData.convertChunkToRealSpace(new Vector3i(32774, 1, 32770))) + ); + rVal.structures.add(struct); //spawn initial characters in each race //find initial positions to place characters at per race diff --git a/src/main/java/electrosphere/server/macro/structure/Structure.java b/src/main/java/electrosphere/server/macro/structure/Structure.java index 588b06ba..8882ea94 100644 --- a/src/main/java/electrosphere/server/macro/structure/Structure.java +++ b/src/main/java/electrosphere/server/macro/structure/Structure.java @@ -7,6 +7,7 @@ import java.util.List; import org.joml.AABBd; import org.joml.Vector3d; +import electrosphere.game.data.struct.StructureData; import electrosphere.server.macro.character.CharacterData; import electrosphere.server.macro.character.CharacterDataStrings; import electrosphere.server.macro.spatial.MacroAreaObject; @@ -50,9 +51,24 @@ public class Structure extends CharacterData implements MacroAreaObject { * Constructor * @param dataType The data type of the structure */ - public Structure(){ + private Structure(){ super(CharacterDataStrings.STRUCTURE); } + + /** + * Creates a structure + * @param data The data + * @param position The position + * @return The structure + */ + public static Structure createStructure(StructureData data, Vector3d position){ + Structure rVal = new Structure(); + rVal.fabPath = data.getFabPath(); + rVal.type = data.getId(); + rVal.position = position; + rVal.aabb = new AABBd(new Vector3d(0,0,0), data.getDimensions()); + return rVal; + } /** * Puts some data in the structure