From 1c73c2d5eab04c5f09d3402ae1427b70157149af Mon Sep 17 00:00:00 2001 From: austin Date: Sat, 7 Dec 2024 16:29:40 -0500 Subject: [PATCH] reintroduce sleep --- docs/src/progress/renderertodo.md | 1 + src/main/c/src/fluid/queue/metadatacalc.c | 60 +++++++++++------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index a95200d4..aaaf8a99 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1270,6 +1270,7 @@ Frame tracking on native side Fix memory leak in client fluid data chunks Work on cellular sim determinism More cellular determinism verification +reintroduce sleeping code # TODO diff --git a/src/main/c/src/fluid/queue/metadatacalc.c b/src/main/c/src/fluid/queue/metadatacalc.c index 4a9f4f72..27fbe72d 100644 --- a/src/main/c/src/fluid/queue/metadatacalc.c +++ b/src/main/c/src/fluid/queue/metadatacalc.c @@ -43,49 +43,49 @@ void updateMetadata(JNIEnv * env, int numChunks, Chunk ** passedInChunks, Enviro } //get whether the chunk is currently homogenous or not int homogenous = sum <= 0 ? JNI_TRUE : JNI_FALSE; - // (*env)->SetBooleanField(env,jObj,environment->lookupTable.serverFluidChunkTable.homogenousId,homogenous); - (*env)->SetBooleanField(env,jObj,environment->lookupTable.serverFluidChunkTable.homogenousId,JNI_FALSE); + (*env)->SetBooleanField(env,jObj,environment->lookupTable.serverFluidChunkTable.homogenousId,homogenous); + // (*env)->SetBooleanField(env,jObj,environment->lookupTable.serverFluidChunkTable.homogenousId,JNI_FALSE); //update total density (*env)->SetFloatField(env,jObj,totalDensityId,sum); //check if any neighbor is non-homogenous - // jobject neighborArr = (*env)->GetObjectField(env,jObj,environment->lookupTable.serverFluidChunkTable.neighborsId); - // int nonHomogenousNeighbor = JNI_FALSE; - // for(int j = 0; j < NEIGHBOR_ARRAY_COUNT; j++){ - // if(j == CENTER_LOC){ - // continue; - // } - // jobject neighborObj = (*env)->GetObjectArrayElement(env,neighborArr,j); - // if(neighborObj != NULL){ - // int neighborHomogenous = (*env)->GetBooleanField(env,neighborObj,environment->lookupTable.serverFluidChunkTable.homogenousId); - // if(neighborHomogenous == JNI_FALSE){ - // nonHomogenousNeighbor = JNI_TRUE; - // break; - // } - // } - // } + jobject neighborArr = (*env)->GetObjectField(env,jObj,environment->lookupTable.serverFluidChunkTable.neighborsId); + int nonHomogenousNeighbor = JNI_FALSE; + for(int j = 0; j < NEIGHBOR_ARRAY_COUNT; j++){ + if(j == CENTER_LOC){ + continue; + } + jobject neighborObj = (*env)->GetObjectArrayElement(env,neighborArr,j); + if(neighborObj != NULL){ + int neighborHomogenous = (*env)->GetBooleanField(env,neighborObj,environment->lookupTable.serverFluidChunkTable.homogenousId); + if(neighborHomogenous == JNI_FALSE){ + nonHomogenousNeighbor = JNI_TRUE; + break; + } + } + } //figure out if this chunk should sleep or not int shouldSleep = JNI_TRUE; - // if(nonHomogenousNeighbor == JNI_TRUE || homogenous == JNI_FALSE){ + if(nonHomogenousNeighbor == JNI_TRUE || homogenous == JNI_FALSE){ shouldSleep = JNI_FALSE; - // } + } (*env)->SetBooleanField(env,jObj,environment->lookupTable.serverFluidChunkTable.asleepId,shouldSleep); //if this cell is awake AND non-homogenous, make sure all neighbors are awake - // if(shouldSleep == JNI_FALSE && homogenous == JNI_FALSE){ + if(shouldSleep == JNI_FALSE && homogenous == JNI_FALSE){ (*env)->SetBooleanField(env,jObj,updatedId,JNI_TRUE); - // for(int j = 0; j < NEIGHBOR_ARRAY_COUNT; j++){ - // if(j == CENTER_LOC){ - // continue; - // } - // jobject neighborObj = (*env)->GetObjectArrayElement(env,neighborArr,j); - // if(neighborObj != NULL){ - // (*env)->SetBooleanField(env,neighborObj,environment->lookupTable.serverFluidChunkTable.asleepId,JNI_FALSE); - // } - // } - // } + for(int j = 0; j < NEIGHBOR_ARRAY_COUNT; j++){ + if(j == CENTER_LOC){ + continue; + } + jobject neighborObj = (*env)->GetObjectArrayElement(env,neighborArr,j); + if(neighborObj != NULL){ + (*env)->SetBooleanField(env,neighborObj,environment->lookupTable.serverFluidChunkTable.asleepId,JNI_FALSE); + } + } + } } //alert java side to updated static values