pressure recapture work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
de3e29c99e
commit
c3e319280a
@ -67,5 +67,10 @@
|
||||
*/
|
||||
#define FLUID_PRESSURECELL_PRESSURE_BACKDOWN_FACTOR 0.5f
|
||||
|
||||
/**
|
||||
* Pressure added on recapturing fluid pushed into borders
|
||||
*/
|
||||
#define FLUID_PRESSURECELL_RECAPTURE_PRESSURE 1.0f
|
||||
|
||||
|
||||
#endif
|
||||
@ -1,6 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "fluid/sim/pressurecell/normalization.h"
|
||||
#include "fluid/sim/pressurecell/solver_consts.h"
|
||||
#include "fluid/queue/chunkmask.h"
|
||||
#include "fluid/queue/chunk.h"
|
||||
|
||||
@ -23,6 +24,7 @@ LIBRARY_API void fluid_pressurecell_calculate_expected_intake(Environment * env,
|
||||
chunk->pressureCellData.densitySum = sum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the ratio to normalize the chunk by
|
||||
*/
|
||||
@ -74,8 +76,10 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
float * uArr = chunk->uTempCache;
|
||||
float * vArr = chunk->vTempCache;
|
||||
float * wArr = chunk->wTempCache;
|
||||
float * pressure = chunk->pressureTempCache;
|
||||
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;
|
||||
@ -83,9 +87,10 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
|
||||
//check +x plane
|
||||
if(chunk->d[CK(2,1,1)] == NULL){
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
neighbor = CK(2,1,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(DIM-1,x,y);
|
||||
adjacentIndex = IX(DIM-2,x,y);
|
||||
if(uArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
@ -93,6 +98,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
@ -101,20 +107,21 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,y,0);
|
||||
adjacentIndex = IX(x,y,1);
|
||||
if(dArr[ghostIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[CK(2,1,1)] += dArr[ghostIndex];
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//check -x plane
|
||||
if(chunk->d[CK(0,1,1)] == NULL){
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
neighbor = CK(0,1,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(0,x,y);
|
||||
adjacentIndex = IX(1,x,y);
|
||||
if(uArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
@ -122,6 +129,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
@ -130,21 +138,22 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(0,x,y);
|
||||
adjacentIndex = IX(1,x,y);
|
||||
if(dArr[ghostIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[CK(0,1,1)] += dArr[ghostIndex];
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +y plane
|
||||
if(chunk->d[CK(1,2,1)] == NULL){
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
neighbor = CK(1,2,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,DIM-1,y);
|
||||
adjacentIndex = IX(x,DIM-2,y);
|
||||
if(vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
@ -152,6 +161,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
@ -160,20 +170,21 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,DIM-1,y);
|
||||
adjacentIndex = IX(x,DIM-2,y);
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
if(dArr[ghostIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[CK(1,2,1)] += dArr[ghostIndex];
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//check -y plane
|
||||
if(chunk->d[CK(1,0,1)] == NULL){
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
neighbor = CK(1,0,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,0,y);
|
||||
adjacentIndex = IX(x,1,y);
|
||||
if(vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
@ -181,6 +192,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
@ -189,21 +201,22 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,0,y);
|
||||
adjacentIndex = IX(x,1,y);
|
||||
if(dArr[ghostIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[CK(1,0,1)] += dArr[ghostIndex];
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +z plane
|
||||
if(chunk->d[CK(1,1,2)] == NULL){
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
neighbor = CK(1,1,2);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,y,DIM-1);
|
||||
adjacentIndex = IX(x,y,DIM-2);
|
||||
if(wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
@ -211,6 +224,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
@ -219,20 +233,21 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,y,DIM-1);
|
||||
adjacentIndex = IX(x,y,DIM-2);
|
||||
if(dArr[ghostIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[CK(1,1,2)] += dArr[ghostIndex];
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//check -z plane
|
||||
if(chunk->d[CK(1,1,0)] == NULL){
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
neighbor = CK(1,1,0);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,y,0);
|
||||
adjacentIndex = IX(x,y,1);
|
||||
if(wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
@ -240,6 +255,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
@ -248,15 +264,402 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
for(y = 2; y < DIM-2; y++){
|
||||
ghostIndex = IX(x,y,0);
|
||||
adjacentIndex = IX(x,y,1);
|
||||
if(dArr[ghostIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[CK(1,1,0)] += dArr[ghostIndex];
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//check -x,-y edge
|
||||
neighbor = CK(0,0,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,0,x);
|
||||
adjacentIndex = IX(1,1,x);
|
||||
if(uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,0,x);
|
||||
adjacentIndex = IX(1,1,x);
|
||||
if(uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check -x,+y edge
|
||||
neighbor = CK(0,2,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,DIM-1,x);
|
||||
adjacentIndex = IX(1,DIM-2,x);
|
||||
if(uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,DIM-1,x);
|
||||
adjacentIndex = IX(1,DIM-2,x);
|
||||
if(uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +x,-y edge
|
||||
neighbor = CK(2,0,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(DIM-1,0,x);
|
||||
adjacentIndex = IX(DIM-2,1,x);
|
||||
if(uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(DIM-1,0,x);
|
||||
adjacentIndex = IX(DIM-2,1,x);
|
||||
if(uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +x,+y edge
|
||||
neighbor = CK(2,2,1);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; 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){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; 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){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//check -x,-z edge
|
||||
neighbor = CK(0,1,0);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,x,0);
|
||||
adjacentIndex = IX(1,x,1);
|
||||
if(uArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,x,0);
|
||||
adjacentIndex = IX(1,x,1);
|
||||
if(uArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check -x,+z edge
|
||||
neighbor = CK(0,1,2);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,x,DIM-1);
|
||||
adjacentIndex = IX(1,x,DIM-2);
|
||||
if(uArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(0,x,DIM-1);
|
||||
adjacentIndex = IX(1,x,DIM-2);
|
||||
if(uArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +x,-z edge
|
||||
neighbor = CK(2,1,0);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(DIM-1,x,0);
|
||||
adjacentIndex = IX(DIM-2,x,1);
|
||||
if(uArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(DIM-1,x,0);
|
||||
adjacentIndex = IX(DIM-2,x,1);
|
||||
if(uArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +x,+z edge
|
||||
neighbor = CK(2,1,2);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; 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){
|
||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; 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){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//check -y,-z edge
|
||||
neighbor = CK(1,0,0);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(x,0,0);
|
||||
adjacentIndex = IX(x,1,1);
|
||||
if(vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(x,0,0);
|
||||
adjacentIndex = IX(x,1,1);
|
||||
if(vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check -y,+z edge
|
||||
neighbor = CK(1,0,2);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(x,0,DIM-1);
|
||||
adjacentIndex = IX(x,1,DIM-2);
|
||||
if(vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(x,0,DIM-1);
|
||||
adjacentIndex = IX(x,1,DIM-2);
|
||||
if(vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +y,-z edge
|
||||
neighbor = CK(1,2,0);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(x,DIM-1,0);
|
||||
adjacentIndex = IX(x,DIM-2,1);
|
||||
if(vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; x++){
|
||||
ghostIndex = IX(x,DIM-1,0);
|
||||
adjacentIndex = IX(x,DIM-2,1);
|
||||
if(vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check +y,+z edge
|
||||
neighbor = CK(1,2,2);
|
||||
if(chunk->d[neighbor] == NULL){
|
||||
for(x = 2; x < DIM-2; 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){
|
||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||
dArr[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||
overdraw = dArr[adjacentIndex] - MAX_FLUID_VALUE;
|
||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||
if(overdraw > 0){
|
||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||
dArr[adjacentIndex] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(x = 2; x < DIM-2; 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){
|
||||
chunk->pressureCellData.outgoingDensity[neighbor] += dArr[ghostIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user