fluid chunk sleeping
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
172110a6d0
commit
c473805510
@ -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
|
||||
|
||||
@ -25,6 +25,7 @@ typedef struct {
|
||||
jfieldID chunkmaskJId;
|
||||
jfieldID updatedId;
|
||||
jfieldID totalDensityId;
|
||||
jfieldID asleepId;
|
||||
} ServerFluidChunkLookupTable;
|
||||
|
||||
/**
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user