DENSITY TRANSITIONS!

This commit is contained in:
unknown 2023-07-24 18:57:30 -04:00
parent c35a599f6b
commit cc5edb452b
2 changed files with 29 additions and 19 deletions

View File

@ -612,21 +612,21 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_copyNeighbors
int DIM = N;
float * target = GET_ARR(env,neighborArray,CENTER_LOC);
float * source;
// if(ARR_EXISTS(chunk_mask,0,1,1)){
// source = GET_ARR(env,neighborArray,CK(0,1,1));
// for(int x=1; x < DIM-1; x++){
// for(int y = 1; y < DIM-1; y++){
// target[IX(0,x,y)] = source[IX(DIM-2,x,y)];
// }
// }
// }
if(ARR_EXISTS(chunk_mask,0,1,1)){
source = GET_ARR(env,neighborArray,CK(0,1,1));
for(int x=1; x < DIM-1; x++){
for(int y = 1; y < DIM-1; y++){
target[IX(0,x,y)] = source[IX(DIM-2,x,y)];
}
}
}
// if(ARR_EXISTS(chunk_mask,2,1,1)){
// source = GET_ARR(env,neighborArray,CK(2,1,1));
// for(int x=1; x < DIM-1; x++){
// for(int y = 1; y < DIM-1; y++){
// target[IX(DIM-1,x,y)] = source[IX(1,x,y)];
// }
// }
// }
if(ARR_EXISTS(chunk_mask,2,1,1)){
source = GET_ARR(env,neighborArray,CK(2,1,1));
for(int x=1; x < DIM-1; x++){
for(int y = 1; y < DIM-1; y++){
target[IX(DIM-1,x,y)] = source[IX(1,x,y)];
}
}
}
}

View File

@ -186,7 +186,9 @@ public class FluidSim {
//
//Density stage
addDensity(simArray, timestep);
swapAllDensityArrays(simArray, timestep);
diffuseDensity(simArray, timestep);
swapAllDensityArrays(simArray, timestep);
advectDensity(simArray, timestep);
// mirrorNeighborDensities(simArray, timestep);
@ -351,6 +353,9 @@ public class FluidSim {
simArray[x][y][z].setBoundsToNeighborsWrapper(1, simArray[x][y][z].uVector);
simArray[x][y][z].setBoundsToNeighborsWrapper(2, simArray[x][y][z].vVector);
simArray[x][y][z].setBoundsToNeighborsWrapper(3, simArray[x][y][z].wVector);
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].uAdditionVector);
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vAdditionVector);
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].wAdditionVector);
}
}
}
@ -442,13 +447,13 @@ public class FluidSim {
simArray[x][y][z].addDensityWrapper(timestep);
//swap x <=> x0
//swap arrays in java side...
simArray[x][y][z].swapDensityArrays();
// simArray[x][y][z].swapDensityArrays();
}
}
}
}
private void swapAllDensityArrays(FluidSim[][][] simArray, float timestep){
private static void swapAllDensityArrays(FluidSim[][][] simArray, float timestep){
for(int x = 0; x < simArray.length; x++){
for(int y = 0; y < simArray[0].length; y++){
for(int z = 0; z < simArray[0][0].length; z++){
@ -499,7 +504,7 @@ public class FluidSim {
for(int y = 0; y < simArray[0].length; y++){
for(int z = 0; z < simArray[0][0].length; z++){
//swap x <=> x0 again
simArray[x][y][z].swapDensityArrays();
// simArray[x][y][z].swapDensityArrays();
//advect density
simArray[x][y][z].advectDensityWrapper(timestep);
}
@ -874,6 +879,10 @@ public class FluidSim {
return density[getNeighborIndex(1,1,1)];
}
public ByteBuffer getDensityAdditionBuffer(){
return densityAddition[getNeighborIndex(1,1,1)];
}
public ByteBuffer getUBuffer(){
return uVector[getNeighborIndex(1,1,1)];
}
@ -900,6 +909,7 @@ public class FluidSim {
public void setNeighbor(int x, int y, int z, FluidSim neighbor){
density[getNeighborIndex(x,y,z)] = neighbor.getDensityBuffer();
densityAddition[getNeighborIndex(x,y,z)] = neighbor.getDensityAdditionBuffer();
uVector[getNeighborIndex(x,y,z)] = neighbor.getUBuffer();
vVector[getNeighborIndex(x,y,z)] = neighbor.getVBuffer();
wVector[getNeighborIndex(x,y,z)] = neighbor.getWBuffer();