DENSITY TRANSITIONS!
This commit is contained in:
parent
c35a599f6b
commit
cc5edb452b
@ -612,21 +612,21 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_copyNeighbors
|
|||||||
int DIM = N;
|
int DIM = N;
|
||||||
float * target = GET_ARR(env,neighborArray,CENTER_LOC);
|
float * target = GET_ARR(env,neighborArray,CENTER_LOC);
|
||||||
float * source;
|
float * source;
|
||||||
// if(ARR_EXISTS(chunk_mask,0,1,1)){
|
if(ARR_EXISTS(chunk_mask,0,1,1)){
|
||||||
// source = GET_ARR(env,neighborArray,CK(0,1,1));
|
source = GET_ARR(env,neighborArray,CK(0,1,1));
|
||||||
// for(int x=1; x < DIM-1; x++){
|
for(int x=1; x < DIM-1; x++){
|
||||||
// for(int y = 1; y < DIM-1; y++){
|
for(int y = 1; y < DIM-1; y++){
|
||||||
// target[IX(0,x,y)] = source[IX(DIM-2,x,y)];
|
target[IX(0,x,y)] = source[IX(DIM-2,x,y)];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if(ARR_EXISTS(chunk_mask,2,1,1)){
|
if(ARR_EXISTS(chunk_mask,2,1,1)){
|
||||||
// source = GET_ARR(env,neighborArray,CK(2,1,1));
|
source = GET_ARR(env,neighborArray,CK(2,1,1));
|
||||||
// for(int x=1; x < DIM-1; x++){
|
for(int x=1; x < DIM-1; x++){
|
||||||
// for(int y = 1; y < DIM-1; y++){
|
for(int y = 1; y < DIM-1; y++){
|
||||||
// target[IX(DIM-1,x,y)] = source[IX(1,x,y)];
|
target[IX(DIM-1,x,y)] = source[IX(1,x,y)];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +186,9 @@ public class FluidSim {
|
|||||||
//
|
//
|
||||||
//Density stage
|
//Density stage
|
||||||
addDensity(simArray, timestep);
|
addDensity(simArray, timestep);
|
||||||
|
swapAllDensityArrays(simArray, timestep);
|
||||||
diffuseDensity(simArray, timestep);
|
diffuseDensity(simArray, timestep);
|
||||||
|
swapAllDensityArrays(simArray, timestep);
|
||||||
advectDensity(simArray, timestep);
|
advectDensity(simArray, timestep);
|
||||||
// mirrorNeighborDensities(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(1, simArray[x][y][z].uVector);
|
||||||
simArray[x][y][z].setBoundsToNeighborsWrapper(2, simArray[x][y][z].vVector);
|
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].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);
|
simArray[x][y][z].addDensityWrapper(timestep);
|
||||||
//swap x <=> x0
|
//swap x <=> x0
|
||||||
//swap arrays in java side...
|
//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 x = 0; x < simArray.length; x++){
|
||||||
for(int y = 0; y < simArray[0].length; y++){
|
for(int y = 0; y < simArray[0].length; y++){
|
||||||
for(int z = 0; z < simArray[0][0].length; z++){
|
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 y = 0; y < simArray[0].length; y++){
|
||||||
for(int z = 0; z < simArray[0][0].length; z++){
|
for(int z = 0; z < simArray[0][0].length; z++){
|
||||||
//swap x <=> x0 again
|
//swap x <=> x0 again
|
||||||
simArray[x][y][z].swapDensityArrays();
|
// simArray[x][y][z].swapDensityArrays();
|
||||||
//advect density
|
//advect density
|
||||||
simArray[x][y][z].advectDensityWrapper(timestep);
|
simArray[x][y][z].advectDensityWrapper(timestep);
|
||||||
}
|
}
|
||||||
@ -874,6 +879,10 @@ public class FluidSim {
|
|||||||
return density[getNeighborIndex(1,1,1)];
|
return density[getNeighborIndex(1,1,1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ByteBuffer getDensityAdditionBuffer(){
|
||||||
|
return densityAddition[getNeighborIndex(1,1,1)];
|
||||||
|
}
|
||||||
|
|
||||||
public ByteBuffer getUBuffer(){
|
public ByteBuffer getUBuffer(){
|
||||||
return uVector[getNeighborIndex(1,1,1)];
|
return uVector[getNeighborIndex(1,1,1)];
|
||||||
}
|
}
|
||||||
@ -900,6 +909,7 @@ public class FluidSim {
|
|||||||
|
|
||||||
public void setNeighbor(int x, int y, int z, FluidSim neighbor){
|
public void setNeighbor(int x, int y, int z, FluidSim neighbor){
|
||||||
density[getNeighborIndex(x,y,z)] = neighbor.getDensityBuffer();
|
density[getNeighborIndex(x,y,z)] = neighbor.getDensityBuffer();
|
||||||
|
densityAddition[getNeighborIndex(x,y,z)] = neighbor.getDensityAdditionBuffer();
|
||||||
uVector[getNeighborIndex(x,y,z)] = neighbor.getUBuffer();
|
uVector[getNeighborIndex(x,y,z)] = neighbor.getUBuffer();
|
||||||
vVector[getNeighborIndex(x,y,z)] = neighbor.getVBuffer();
|
vVector[getNeighborIndex(x,y,z)] = neighbor.getVBuffer();
|
||||||
wVector[getNeighborIndex(x,y,z)] = neighbor.getWBuffer();
|
wVector[getNeighborIndex(x,y,z)] = neighbor.getWBuffer();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user