identify negative density bug
This commit is contained in:
parent
10c7a6c0c0
commit
4fa843b967
@ -46,6 +46,15 @@ LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * c
|
||||
} else {
|
||||
if(expected > 0.001f){
|
||||
printf("We've managed to completely delete all density! (expected: %f) \n", expected);
|
||||
sum = 0;
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
for(z = 1; z < DIM-1; z++){
|
||||
sum = sum + chunk->dTempCache[IX(x,y,z)];
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("dTempCache sum: %lf \n", sum);
|
||||
}
|
||||
chunk->pressureCellData.normalizationRatio = 1.0f;
|
||||
}
|
||||
@ -77,20 +86,25 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
int ghostIndex, adjacentIndex;
|
||||
float overdraw, estimatedLoss, invertedForce;
|
||||
int neighbor;
|
||||
|
||||
//clear neighbor outgoing values
|
||||
for(int i = 0; i < 9; i++){
|
||||
chunk->pressureCellData.outgoingDensity[i] = 0;
|
||||
chunk->pressureCellData.outgoingPressure[i] = 0;
|
||||
}
|
||||
|
||||
//clear dtemp
|
||||
for(x = 0; x < DIM; x++){
|
||||
for(y = 0; y < DIM; y++){
|
||||
for(z = 0; z < DIM; z++){
|
||||
dTemp[IX(x,y,z)] = dArr[IX(x,y,z)];
|
||||
dTemp[IX(x,y,z)] = fmax(MIN_FLUID_VALUE,dArr[IX(x,y,z)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//check +x plane
|
||||
neighbor = CK(2,1,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
@ -98,15 +112,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
ghostIndex = IX(DIM-1,x,y);
|
||||
adjacentIndex = IX(DIM-2,x,y);
|
||||
if(uArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
if(uArr[adjacentIndex] > 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = 1.0f - fabs(uArr[adjacentIndex]);
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,6 +138,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//check -x plane
|
||||
neighbor = CK(0,1,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
@ -129,15 +146,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
ghostIndex = IX(0,x,y);
|
||||
adjacentIndex = IX(1,x,y);
|
||||
if(uArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
if(uArr[adjacentIndex] < 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = 1.0f - fabs(uArr[adjacentIndex]);
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,15 +180,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
ghostIndex = IX(x,DIM-1,y);
|
||||
adjacentIndex = IX(x,DIM-2,y);
|
||||
if(vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
if(vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = 1.0f - fabs(vArr[adjacentIndex]);
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,6 +206,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//check -y plane
|
||||
neighbor = CK(1,0,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
@ -192,15 +214,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
ghostIndex = IX(x,0,y);
|
||||
adjacentIndex = IX(x,1,y);
|
||||
if(vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
if(vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = 1.0f - fabs(vArr[adjacentIndex]);
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,15 +248,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
ghostIndex = IX(x,y,DIM-1);
|
||||
adjacentIndex = IX(x,y,DIM-2);
|
||||
if(wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
if(wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = 1.0f - fabs(wArr[adjacentIndex]);
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -248,6 +274,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//check -z plane
|
||||
neighbor = CK(1,1,0);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
@ -255,15 +282,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
ghostIndex = IX(x,y,0);
|
||||
adjacentIndex = IX(x,y,1);
|
||||
if(wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
if(wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = 1.0f - fabs(wArr[adjacentIndex]);
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,15 +335,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(0,0,x);
|
||||
adjacentIndex = IX(1,1,x);
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -334,15 +365,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(0,DIM-1,x);
|
||||
adjacentIndex = IX(1,DIM-2,x);
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -362,15 +395,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(DIM-1,0,x);
|
||||
adjacentIndex = IX(DIM-2,1,x);
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -390,15 +425,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(DIM-1,DIM-1,x);
|
||||
adjacentIndex = IX(DIM-2,DIM-2,x);
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -424,15 +461,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(0,x,0);
|
||||
adjacentIndex = IX(1,x,1);
|
||||
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,15 +491,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(0,x,DIM-1);
|
||||
adjacentIndex = IX(1,x,DIM-2);
|
||||
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -480,15 +521,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(DIM-1,x,0);
|
||||
adjacentIndex = IX(DIM-2,x,1);
|
||||
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -508,15 +551,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(DIM-1,x,DIM-1);
|
||||
adjacentIndex = IX(DIM-2,x,DIM-2);
|
||||
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -540,15 +585,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(x,0,0);
|
||||
adjacentIndex = IX(x,1,1);
|
||||
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -568,15 +615,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(x,0,DIM-1);
|
||||
adjacentIndex = IX(x,1,DIM-2);
|
||||
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -596,15 +645,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(x,DIM-1,0);
|
||||
adjacentIndex = IX(x,DIM-2,1);
|
||||
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -624,15 +675,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
ghostIndex = IX(x,DIM-1,DIM-1);
|
||||
adjacentIndex = IX(x,DIM-2,DIM-2);
|
||||
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -685,15 +738,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(0,0,0);
|
||||
adjacentIndex = IX(1,1,1);
|
||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -711,15 +766,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(0,DIM-1,0);
|
||||
adjacentIndex = IX(1,DIM-2,1);
|
||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -736,15 +793,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(DIM-1,0,0);
|
||||
adjacentIndex = IX(DIM-2,1,1);
|
||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -762,15 +821,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(DIM-1,DIM-1,0);
|
||||
adjacentIndex = IX(DIM-2,DIM-2,1);
|
||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -792,15 +853,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(0,0,DIM-1);
|
||||
adjacentIndex = IX(1,1,DIM-2);
|
||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -818,15 +881,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(0,DIM-1,DIM-1);
|
||||
adjacentIndex = IX(1,DIM-2,DIM-2);
|
||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -843,15 +908,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(DIM-1,0,DIM-1);
|
||||
adjacentIndex = IX(DIM-2,1,DIM-2);
|
||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -869,15 +936,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
ghostIndex = IX(DIM-1,DIM-1,DIM-1);
|
||||
adjacentIndex = IX(DIM-2,DIM-2,DIM-2);
|
||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
if(invertedForce > MIN_FLUID_VALUE){
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user