incoming/outgoing field caching on fluid chunks
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-12-19 19:06:29 -05:00
parent f248d68a5b
commit b5cd111e34
4 changed files with 56 additions and 0 deletions

View File

@ -43,6 +43,10 @@ typedef struct {
jfieldID massCountId;
jfieldID pressureTotalId;
jfieldID velocityMagTotalId;
jfieldID pressureOutgoingId;
jfieldID pressureIncomingId;
jfieldID densityOutgoingId;
jfieldID densityIncomingId;
} ServerFluidChunkLookupTable;
/**

View File

@ -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
*/

View File

@ -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;
}
}
}

View File

@ -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
*/