properly linking library
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-11-30 18:10:41 -05:00
parent 888cc254f3
commit 5caed003d1
6 changed files with 40 additions and 60 deletions

8
.vscode/launch.json vendored
View File

@ -9,14 +9,14 @@
"name": "Launch Current File", "name": "Launch Current File",
"request": "launch", "request": "launch",
"mainClass": "${file}", "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", "type": "java",
"name": "Launch Main", "name": "Launch Main",
"request": "launch", "request": "launch",
"mainClass": "electrosphere.engine.Main", "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" "projectName": "Renderer"
}, },
{ {
@ -24,7 +24,7 @@
"name": "Launch Main (Debug Memory)", "name": "Launch Main (Debug Memory)",
"request": "launch", "request": "launch",
"mainClass": "electrosphere.engine.Main", "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" "projectName": "Renderer"
}, },
{ {
@ -35,7 +35,7 @@
"env": { "env": {
"ALSOFT_LOGLEVEL": 4, "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" "projectName": "Renderer"
}, },
{ {

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Sat Nov 30 16:32:02 EST 2024 #Sat Nov 30 18:07:55 EST 2024
buildNumber=419 buildNumber=427

View File

@ -36,7 +36,7 @@ Chunk ** javaChunkView = NULL;
int numChunks = 0; int numChunks = 0;
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate( JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAcceleratedSimulator_simulate(
JNIEnv * env, JNIEnv * env,
jclass fluidSimClass, jclass fluidSimClass,
jobject chunkList, jobject chunkList,
@ -72,7 +72,7 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate
*/ */
void readInChunks(JNIEnv * env, jobject chunkList){ void readInChunks(JNIEnv * env, jobject chunkList){
jclass listClass = (*env)->FindClass(env,"java/util/List"); 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 //JNIEnv *env, jclass clazz, const char *name, const char *sig
jmethodID jListSize = (*env)->GetMethodID(env, listClass, "size", "()I"); jmethodID jListSize = (*env)->GetMethodID(env, listClass, "size", "()I");
jmethodID jListGet = (*env)->GetMethodID(env, listClass, "get", "(I)Ljava/lang/Object;"); jmethodID jListGet = (*env)->GetMethodID(env, listClass, "get", "(I)Ljava/lang/Object;");

View File

@ -38,7 +38,7 @@ int main(){
logVar("jarPath: ",jarPath); logVar("jarPath: ",jarPath);
printf("%s\n",jarPath); printf("%s\n",jarPath);
fflush(stdout); 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); printf("Exec code: %d\n",execVal);
perror("execlp"); perror("execlp");
fflush(stdout); fflush(stdout);

View File

@ -6,7 +6,7 @@ import electrosphere.game.server.world.ServerWorldData;
import electrosphere.server.fluid.diskmap.FluidDiskMap; import electrosphere.server.fluid.diskmap.FluidDiskMap;
import electrosphere.server.fluid.generation.FluidGenerator; import electrosphere.server.fluid.generation.FluidGenerator;
import electrosphere.server.fluid.models.FluidModel; 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.fluid.simulator.ServerFluidSimulator;
import electrosphere.server.terrain.manager.ServerTerrainManager; import electrosphere.server.terrain.manager.ServerTerrainManager;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
@ -100,7 +100,7 @@ public class ServerFluidManager {
this.serverTerrainManager = serverTerrainManager; this.serverTerrainManager = serverTerrainManager;
this.seed = seed; this.seed = seed;
this.chunkGenerator = chunkGenerator; this.chunkGenerator = chunkGenerator;
this.serverFluidSimulator = new FluidCellularAutomataSimulator(); this.serverFluidSimulator = new FluidAcceleratedSimulator();
} }
ServerFluidManager(){ ServerFluidManager(){
@ -166,50 +166,6 @@ public class ServerFluidManager {
chunkDiskMap.init(saveName); 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 * Gets the key for a given world position
* @param worldX The x component * @param worldX The x component

View File

@ -3,6 +3,7 @@ package electrosphere.server.fluid.simulator;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import electrosphere.logger.LoggerInterface;
import electrosphere.server.fluid.manager.ServerFluidChunk; import electrosphere.server.fluid.manager.ServerFluidChunk;
/** /**
@ -10,6 +11,16 @@ import electrosphere.server.fluid.manager.ServerFluidChunk;
*/ */
public class FluidAcceleratedSimulator implements ServerFluidSimulator { 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 * Timestep to simulate by
*/ */
@ -19,12 +30,25 @@ public class FluidAcceleratedSimulator implements ServerFluidSimulator {
* Load fluid sim library * Load fluid sim library
*/ */
static { static {
String osName = System.getProperty("os.name").toLowerCase(); String libraryPath = System.getProperty(LIBRARY_PATH_PROP_NAME);
if(osName.contains("win")){ if(!libraryPath.contains(LIB_DIR)){
System.load(new File("./shared-folder/libfluidsim.dll").toPath().toAbsolutePath().toString()); LoggerInterface.loggerEngine.ERROR(new Error("Failed to load fluid library! The path does not contain the library folder! " + libraryPath));
} else {
System.load(new File("./shared-folder/libfluidsim.so").toPath().toAbsolutePath().toString());
} }
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 @Override