diff --git a/src/main/c/includes/fluid/env/environment.h b/src/main/c/includes/fluid/env/environment.h index ac7cf457..53d0fe7b 100644 --- a/src/main/c/includes/fluid/env/environment.h +++ b/src/main/c/includes/fluid/env/environment.h @@ -43,6 +43,10 @@ typedef struct { jfieldID massCountId; jfieldID pressureTotalId; jfieldID velocityMagTotalId; + jfieldID pressureOutgoingId; + jfieldID pressureIncomingId; + jfieldID densityOutgoingId; + jfieldID densityIncomingId; } ServerFluidChunkLookupTable; /** diff --git a/src/main/c/includes/fluid/queue/chunk.h b/src/main/c/includes/fluid/queue/chunk.h index 66df2ff7..72489dd8 100644 --- a/src/main/c/includes/fluid/queue/chunk.h +++ b/src/main/c/includes/fluid/queue/chunk.h @@ -190,6 +190,26 @@ typedef struct { */ int projectionIterations; + /** + * The amount of pressure outgoing to other chunks this frame + */ + float outgoingPressure[27]; + + /** + * The amount of pressure incoming to other chunks this frame + */ + float incomingPressure[27]; + + /** + * The amount of density outgoing to other chunks this frame + */ + float outgoingDensity[27]; + + /** + * The amount of density incoming to other chunks this frame + */ + float incomingDensity[27]; + /** * The data for pressure cell work in particular */ diff --git a/src/main/c/src/fluid/queue/javainterface.c b/src/main/c/src/fluid/queue/javainterface.c index 12725d87..9d4826d4 100644 --- a/src/main/c/src/fluid/queue/javainterface.c +++ b/src/main/c/src/fluid/queue/javainterface.c @@ -145,6 +145,10 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate environment->lookupTable.serverFluidChunkTable.massCountId = (*env)->GetStaticFieldID(env,fluidSimStorageClass,"massCount","F"); environment->lookupTable.serverFluidChunkTable.pressureTotalId = (*env)->GetFieldID(env,fluidSimStorageClass,"totalPressure","F"); environment->lookupTable.serverFluidChunkTable.velocityMagTotalId = (*env)->GetFieldID(env,fluidSimStorageClass,"totalVelocityMag","F"); + environment->lookupTable.serverFluidChunkTable.pressureOutgoingId = (*env)->GetFieldID(env,fluidSimStorageClass,"pressureOutgoing","[F"); + environment->lookupTable.serverFluidChunkTable.pressureIncomingId = (*env)->GetFieldID(env,fluidSimStorageClass,"pressureIncoming","[F"); + environment->lookupTable.serverFluidChunkTable.densityOutgoingId = (*env)->GetFieldID(env,fluidSimStorageClass,"densityOutgoing","[F"); + environment->lookupTable.serverFluidChunkTable.densityIncomingId = (*env)->GetFieldID(env,fluidSimStorageClass,"densityIncoming","[F"); } /** @@ -260,6 +264,10 @@ int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment){ newChunk->bounds[j] = getArray(env,bounds,j); newChunk->pressureCache[j] = getArray(env,pressureCache,j); newChunk->divergenceCache[j] = getArray(env,divergenceCache,j); + newChunk->outgoingPressure[j] = (*env)->GetFloatArrayElements(env,(*env)->GetObjectField(env,chunkJRaw,environment->lookupTable.serverFluidChunkTable.pressureOutgoingId),JNI_FALSE)[j]; + newChunk->incomingPressure[j] = (*env)->GetFloatArrayElements(env,(*env)->GetObjectField(env,chunkJRaw,environment->lookupTable.serverFluidChunkTable.pressureIncomingId),JNI_FALSE)[j]; + newChunk->outgoingDensity[j] = (*env)->GetFloatArrayElements(env,(*env)->GetObjectField(env,chunkJRaw,environment->lookupTable.serverFluidChunkTable.densityOutgoingId),JNI_FALSE)[j]; + newChunk->incomingDensity[j] = (*env)->GetFloatArrayElements(env,(*env)->GetObjectField(env,chunkJRaw,environment->lookupTable.serverFluidChunkTable.densityIncomingId),JNI_FALSE)[j]; } else { newChunk->d[j] = NULL; newChunk->d0[j] = NULL; @@ -272,6 +280,10 @@ int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment){ newChunk->bounds[j] = NULL; newChunk->pressureCache[j] = NULL; newChunk->divergenceCache[j] = NULL; + newChunk->outgoingPressure[j] = 0; + newChunk->incomingPressure[j] = 0; + newChunk->outgoingDensity[j] = 0; + newChunk->incomingDensity[j] = 0; } } } diff --git a/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java b/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java index 1b8260a5..c447c0cd 100644 --- a/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java +++ b/src/main/java/electrosphere/server/fluid/manager/ServerFluidChunk.java @@ -221,6 +221,26 @@ public class ServerFluidChunk { */ public static float massCount = 0; + /** + * The amount of pressure outgoing to other chunks + */ + public float[] pressureOutgoing = new float[ARRAY_CT]; + + /** + * The amount of pressure incoming from other chunks + */ + public float[] pressureIncoming = new float[ARRAY_CT]; + + /** + * The amount of density outgoing to other chunks + */ + public float[] densityOutgoing = new float[ARRAY_CT]; + + /** + * The amount of density incoming from other chunks + */ + public float[] densityIncoming = new float[ARRAY_CT]; + /** * Allocates the central arrays for this chunk */