fluid chunk sleeping
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-01 17:03:43 -05:00
parent 172110a6d0
commit c473805510
5 changed files with 31 additions and 2 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Sun Dec 01 16:31:44 EST 2024
buildNumber=477
#Sun Dec 01 16:56:17 EST 2024
buildNumber=480

View File

@ -25,6 +25,7 @@ typedef struct {
jfieldID chunkmaskJId;
jfieldID updatedId;
jfieldID totalDensityId;
jfieldID asleepId;
} ServerFluidChunkLookupTable;
/**

View File

@ -113,6 +113,7 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate
environment->lookupTable.serverFluidChunkTable.chunkmaskJId = (*env)->GetFieldID(env,fluidSimStorageClass,"chunkMask","I");
environment->lookupTable.serverFluidChunkTable.totalDensityId = (*env)->GetFieldID(env,fluidSimStorageClass,"totalDensity","F");
environment->lookupTable.serverFluidChunkTable.updatedId = (*env)->GetFieldID(env,fluidSimStorageClass,"updated","Z");
environment->lookupTable.serverFluidChunkTable.asleepId = (*env)->GetFieldID(env,fluidSimStorageClass,"asleep","Z");
}
/**
@ -137,6 +138,7 @@ int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment){
jfieldID v0JId = environment->lookupTable.serverFluidChunkTable.v0JId;
jfieldID w0JId = environment->lookupTable.serverFluidChunkTable.w0JId;
jfieldID chunkmaskJId = environment->lookupTable.serverFluidChunkTable.chunkmaskJId;
jfieldID asleepId = environment->lookupTable.serverFluidChunkTable.asleepId;
//the number of chunks
numChunks = (*env)->CallIntMethod(env,chunkList,jListSize);
@ -161,6 +163,7 @@ int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment){
//skip this chunk if the center array is not allocated (must not have been removed yet?)
if(
(*env)->GetBooleanField(env,chunkJRaw,asleepId) == JNI_TRUE ||
getBuffArr(dJId) == NULL ||
(*env)->GetObjectArrayElement(env,getBuffArr(dJId),CENTER_LOC) == NULL ||
(*env)->GetDirectBufferAddress(env,(*env)->GetObjectArrayElement(env,getBuffArr(dJId),CENTER_LOC)) == NULL

View File

@ -46,6 +46,10 @@ void updateMetadata(JNIEnv * env, int numChunks, Chunk ** passedInChunks, Enviro
(*env)->SetBooleanField(env,jObj,updatedId,JNI_TRUE);
(*env)->SetFloatField(env,jObj,totalDensityId,sum);
if(sum <= 0){
//sleep the chunk if it has no density
(*env)->SetBooleanField(env,jObj,environment->lookupTable.serverFluidChunkTable.asleepId,JNI_TRUE);
}
}
}

View File

@ -137,6 +137,11 @@ public class ServerFluidChunk {
*/
public boolean updated = false;
/**
* Tracks whether this chunk is asleep or not
*/
public boolean asleep = false;
/**
* The total density of the chunk
*/
@ -467,6 +472,22 @@ public class ServerFluidChunk {
public boolean isAllocated(){
return this.bWeights[CENTER_BUFF] != null;
}
/**
* Gets whether this chunk is asleep or not
* @return true if it is asleep, false otherwise
*/
public boolean isAsleep() {
return asleep;
}
/**
* Sets whether this chunk is asleep or not
* @return true if it is asleep, false otherwise
*/
public void setAsleep(boolean asleep) {
this.asleep = asleep;
}
/**
* Allocates the central arrays for this chunk