diff --git a/.vscode/launch.json b/.vscode/launch.json index dc095bc6..812ba153 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,14 +9,14 @@ "name": "Launch Current File", "request": "launch", "mainClass": "${file}", - "vmArgs": "-Xmx4G -Xms1024m -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\"" + "vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\"" }, { "type": "java", "name": "Launch Main", "request": "launch", "mainClass": "electrosphere.engine.Main", - "vmArgs": "-Xmx4G -Xms1024m -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\"", + "vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\"", "projectName": "Renderer" }, { @@ -24,7 +24,7 @@ "name": "Launch Main (Debug Memory)", "request": "launch", "mainClass": "electrosphere.engine.Main", - "vmArgs": "-Xmx4G -Xms1024m -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\" -javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log", + "vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\" -javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log", "projectName": "Renderer" }, { @@ -35,7 +35,7 @@ "env": { "ALSOFT_LOGLEVEL": 4, }, - "vmArgs": "-Xmx4G -Xms1024m -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\"", + "vmArgs": "-Xmx4G -Xms1024m -Djava.library.path=./shared-folder -XX:+UseZGC -XX:SoftMaxHeapSize=3G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"./tmp/heap.dump\"", "projectName": "Renderer" }, { diff --git a/buildNumber.properties b/buildNumber.properties index 1c8a8bfe..4698f3cf 100644 --- a/buildNumber.properties +++ b/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Sat Nov 30 16:32:02 EST 2024 -buildNumber=419 +#Sat Nov 30 18:07:55 EST 2024 +buildNumber=427 diff --git a/src/fluid/src/javainterface.c b/src/fluid/src/javainterface.c index a9658e4f..3ea4d660 100644 --- a/src/fluid/src/javainterface.c +++ b/src/fluid/src/javainterface.c @@ -36,7 +36,7 @@ Chunk ** javaChunkView = NULL; int numChunks = 0; -JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate( +JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAcceleratedSimulator_simulate( JNIEnv * env, jclass fluidSimClass, jobject chunkList, @@ -72,7 +72,7 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate */ void readInChunks(JNIEnv * env, jobject chunkList){ jclass listClass = (*env)->FindClass(env,"java/util/List"); - jclass fluidSimClass = (*env)->FindClass(env,"electrosphere/server/fluid/manager/FluidSim"); + jclass fluidSimClass = (*env)->FindClass(env,"electrosphere/server/fluid/manager/ServerFluidChunk"); //JNIEnv *env, jclass clazz, const char *name, const char *sig jmethodID jListSize = (*env)->GetMethodID(env, listClass, "size", "()I"); jmethodID jListGet = (*env)->GetMethodID(env, listClass, "get", "(I)Ljava/lang/Object;"); diff --git a/src/launcher/src/main.c b/src/launcher/src/main.c index 1cc41190..c158faad 100644 --- a/src/launcher/src/main.c +++ b/src/launcher/src/main.c @@ -38,7 +38,7 @@ int main(){ logVar("jarPath: ",jarPath); printf("%s\n",jarPath); fflush(stdout); - int execVal = execlp(javaPath,"java","-jar",jarPath, (char *)NULL); + int execVal = execlp(javaPath,"java","-jar","-Djava.library.path=./shared-folder",jarPath, (char *)NULL); printf("Exec code: %d\n",execVal); perror("execlp"); fflush(stdout); diff --git a/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java b/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java index 61782ef3..85ae6671 100644 --- a/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java +++ b/src/main/java/electrosphere/server/fluid/manager/ServerFluidManager.java @@ -6,7 +6,7 @@ import electrosphere.game.server.world.ServerWorldData; import electrosphere.server.fluid.diskmap.FluidDiskMap; import electrosphere.server.fluid.generation.FluidGenerator; import electrosphere.server.fluid.models.FluidModel; -import electrosphere.server.fluid.simulator.FluidCellularAutomataSimulator; +import electrosphere.server.fluid.simulator.FluidAcceleratedSimulator; import electrosphere.server.fluid.simulator.ServerFluidSimulator; import electrosphere.server.terrain.manager.ServerTerrainManager; import electrosphere.util.FileUtils; @@ -100,7 +100,7 @@ public class ServerFluidManager { this.serverTerrainManager = serverTerrainManager; this.seed = seed; this.chunkGenerator = chunkGenerator; - this.serverFluidSimulator = new FluidCellularAutomataSimulator(); + this.serverFluidSimulator = new FluidAcceleratedSimulator(); } ServerFluidManager(){ @@ -166,50 +166,6 @@ public class ServerFluidManager { chunkDiskMap.init(saveName); } - public float[][] getFluidAtChunk(int x, int y){ - return model.getElevationForChunk(x, y); - } - - public double getHeightAtPosition(double x, double y, double z){ - return y; - } - - public float getDiscreteValue(int x, int y){ - if(model != null){ - return model.getElevation()[x][y]; - } else { - return 0; - } - } - - public int getDynamicInterpolationRatio(){ - //THIS FIRES IF THERE IS A MAIN GAME WORLD RUNNING - if(model != null){ - return model.getDynamicInterpolationRatio(); - } else { - //THIS FIRES IF THERE IS AN ARENA WORLD RUNNING - return 0; - } - } - - public float getRandomDampener(){ - //THIS FIRES IF THERE IS A MAIN GAME WORLD RUNNING - if(model != null){ - return model.getRandomDampener(); - } else { - //THIS FIRES IF THERE IS AN ARENA WORLD RUNNING - return 0.0f; - } - } - - /** - * Gets the fluid model backing this fluid manager - * @return The fluid model - */ - public FluidModel getModel() { - return model; - } - /** * Gets the key for a given world position * @param worldX The x component diff --git a/src/main/java/electrosphere/server/fluid/simulator/FluidAcceleratedSimulator.java b/src/main/java/electrosphere/server/fluid/simulator/FluidAcceleratedSimulator.java index 24217f9d..c2ce85fd 100644 --- a/src/main/java/electrosphere/server/fluid/simulator/FluidAcceleratedSimulator.java +++ b/src/main/java/electrosphere/server/fluid/simulator/FluidAcceleratedSimulator.java @@ -3,6 +3,7 @@ package electrosphere.server.fluid.simulator; import java.io.File; import java.util.List; +import electrosphere.logger.LoggerInterface; import electrosphere.server.fluid.manager.ServerFluidChunk; /** @@ -10,6 +11,16 @@ import electrosphere.server.fluid.manager.ServerFluidChunk; */ public class FluidAcceleratedSimulator implements ServerFluidSimulator { + /** + * The library path property's name + */ + static final String LIBRARY_PATH_PROP_NAME = "java.library.path"; + + /** + * Directory to serach for the library in + */ + static final String LIB_DIR = "./shared-folder"; + /** * Timestep to simulate by */ @@ -19,12 +30,25 @@ public class FluidAcceleratedSimulator implements ServerFluidSimulator { * Load fluid sim library */ static { - String osName = System.getProperty("os.name").toLowerCase(); - if(osName.contains("win")){ - System.load(new File("./shared-folder/libfluidsim.dll").toPath().toAbsolutePath().toString()); - } else { - System.load(new File("./shared-folder/libfluidsim.so").toPath().toAbsolutePath().toString()); + String libraryPath = System.getProperty(LIBRARY_PATH_PROP_NAME); + if(!libraryPath.contains(LIB_DIR)){ + LoggerInterface.loggerEngine.ERROR(new Error("Failed to load fluid library! The path does not contain the library folder! " + libraryPath)); } + String osName = System.getProperty("os.name").toLowerCase(); + String libPath = LIB_DIR; + if(osName.contains("win")){ + libPath = libPath + "/libfluidsim.dll"; + } else { + libPath = libPath + "/libfluidsim.so"; + } + String absolutePath = new File(libPath).toPath().toAbsolutePath().toString(); + System.load(absolutePath); + } + + /** + * Starts up the simulator + */ + public FluidAcceleratedSimulator(){ } @Override