Setup work for chunk sharing
This commit is contained in:
parent
efbf3169f9
commit
c35a599f6b
@ -6,7 +6,7 @@
|
||||
#include "includes/utilities.h"
|
||||
#include "includes/chunkmask.h"
|
||||
|
||||
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray jrd, float * d0, float * u, float * v, float * w, float dt);
|
||||
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray jrd, jobjectArray d0, float * u, float * v, float * w, float dt);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
@ -19,12 +19,12 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addDensity
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jobjectArray jrx,
|
||||
jobject x0,
|
||||
jobjectArray x0,
|
||||
jfloat dt){
|
||||
int i;
|
||||
int size=N*N*N;
|
||||
float * x = GET_ARR(env,jrx,CENTER_LOC);
|
||||
float * s = (*env)->GetDirectBufferAddress(env,x0);
|
||||
float * s = GET_ARR(env,x0,CENTER_LOC);
|
||||
for(i=0; i<size; i++){
|
||||
x[i] += dt*s[i];
|
||||
}
|
||||
@ -41,7 +41,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jobjectArray jrx,
|
||||
jobject jrx0,
|
||||
jobjectArray jrx0,
|
||||
jobjectArray jru,
|
||||
jobjectArray jrv,
|
||||
jobjectArray jrw,
|
||||
@ -52,7 +52,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
float c=1+6*a;
|
||||
int i, j, k, l, m;
|
||||
float * x = GET_ARR(env,jrx,CENTER_LOC);
|
||||
float * x0 = (*env)->GetDirectBufferAddress(env,jrx0);
|
||||
float * x0 = GET_ARR(env,jrx0,CENTER_LOC);
|
||||
|
||||
__m256 aScalar = _mm256_set1_ps(a);
|
||||
__m256 cScalar = _mm256_set1_ps(c);
|
||||
@ -95,18 +95,17 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectDensity
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jobjectArray jrx,
|
||||
jobject jrx0,
|
||||
jobjectArray jrx0,
|
||||
jobjectArray jru,
|
||||
jobjectArray jrv,
|
||||
jobjectArray jrw,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float * x0 = (*env)->GetDirectBufferAddress(env,jrx0);
|
||||
advectDensity(env,chunk_mask,N,3,jrx,x0,GET_ARR(env,jru,CENTER_LOC),GET_ARR(env,jrv,CENTER_LOC),GET_ARR(env,jrw,CENTER_LOC),dt);
|
||||
advectDensity(env,chunk_mask,N,3,jrx,jrx0,GET_ARR(env,jru,CENTER_LOC),GET_ARR(env,jrv,CENTER_LOC),GET_ARR(env,jrw,CENTER_LOC),dt);
|
||||
}
|
||||
|
||||
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray jrd, float * d0, float * u, float * v, float * w, float dt){
|
||||
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray jrd, jobjectArray d0, float * u, float * v, float * w, float dt){
|
||||
int i, j, k, i0, j0, k0, i1, j1, k1;
|
||||
int m,n,o;
|
||||
float x, y, z, s0, t0, s1, t1, u1, u0, dtx,dty,dtz;
|
||||
@ -115,12 +114,14 @@ void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, jobjectArray
|
||||
|
||||
float * d = GET_ARR(env,jrd,CENTER_LOC);
|
||||
|
||||
float * sampleArr = d0;
|
||||
float * x0 = GET_ARR(env,d0,CENTER_LOC);
|
||||
|
||||
float * sampleArr = x0;
|
||||
|
||||
for(k=1; k<N-1; k++){
|
||||
for(j=1; j<N-1; j++){
|
||||
for(i=1; i<N-1; i++){
|
||||
sampleArr = d0;
|
||||
sampleArr = x0;
|
||||
//calculate location to pull from
|
||||
x = i-dtx*u[IX(i,j,k)];
|
||||
y = j-dty*v[IX(i,j,k)];
|
||||
|
||||
@ -84,26 +84,26 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectVectors
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: addDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;F)V
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;F)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addDensity
|
||||
(JNIEnv *, jobject, jint, jint, jobjectArray, jobject, jfloat);
|
||||
(JNIEnv *, jobject, jint, jint, jobjectArray, jobjectArray, jfloat);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: solveDiffuseDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
(JNIEnv *, jobject, jint, jint, jobjectArray, jobject, jobjectArray, jobjectArray, jobjectArray, jfloat, jfloat, jfloat);
|
||||
(JNIEnv *, jobject, jint, jint, jobjectArray, jobjectArray, jobjectArray, jobjectArray, jobjectArray, jfloat, jfloat, jfloat);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: advectDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectDensity
|
||||
(JNIEnv *, jobject, jint, jint, jobjectArray, jobject, jobjectArray, jobjectArray, jobjectArray, jfloat, jfloat, jfloat);
|
||||
(JNIEnv *, jobject, jint, jint, jobjectArray, jobjectArray, jobjectArray, jobjectArray, jobjectArray, jfloat, jfloat, jfloat);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
@ -113,6 +113,14 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectDensity
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_setBoundsToNeighbors
|
||||
(JNIEnv *, jobject, jint, jint, jint, jobjectArray);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: copyNeighbors
|
||||
* Signature: (III[Ljava/nio/ByteBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_copyNeighbors
|
||||
(JNIEnv *, jobject, jint, jint, jint, jobjectArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -598,3 +598,35 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_setBoundsToNeighbors
|
||||
target[IX(DIM-1,0,DIM-1)] = (float)((target[IX(DIM-1,0,DIM-2)]+target[IX(DIM-2,0,DIM-1)]+target[IX(DIM-1,1,DIM-1)])/3.0);
|
||||
target[IX(DIM-1,DIM-1,DIM-1)] = (float)((target[IX(DIM-1,DIM-1,DIM-2)]+target[IX(DIM-1,DIM-2,DIM-1)]+target[IX(DIM-1,DIM-1,DIM-2)])/3.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This exclusively copies neighbors to make sure zeroing out stuff doesn't break sim
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_copyNeighbors
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jint vector_dir,
|
||||
jobjectArray neighborArray){
|
||||
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,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)];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class FluidSim {
|
||||
//Buffers that contain density for current frame
|
||||
ByteBuffer[] density = new ByteBuffer[27];
|
||||
//Buffers that contain new density to add to the simulation
|
||||
ByteBuffer densityAddition;
|
||||
ByteBuffer[] densityAddition = new ByteBuffer[27];
|
||||
//Buffers that contain u vector directions
|
||||
ByteBuffer[] uVector = new ByteBuffer[27];
|
||||
//Buffers that contain v vector directions
|
||||
@ -82,7 +82,7 @@ public class FluidSim {
|
||||
public void setup(Vector3i offset){
|
||||
//allocate buffers for this chunk
|
||||
density[13] = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
densityAddition = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
densityAddition[13] = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
uVector[13] = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
vVector[13] = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
wVector[13] = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
@ -91,7 +91,7 @@ public class FluidSim {
|
||||
wAdditionVector[13] = ByteBuffer.allocateDirect(DIM * DIM * DIM * 4);
|
||||
//order endian-ness
|
||||
density[13].order(ByteOrder.LITTLE_ENDIAN);
|
||||
densityAddition.order(ByteOrder.LITTLE_ENDIAN);
|
||||
densityAddition[13].order(ByteOrder.LITTLE_ENDIAN);
|
||||
uVector[13].order(ByteOrder.LITTLE_ENDIAN);
|
||||
vVector[13].order(ByteOrder.LITTLE_ENDIAN);
|
||||
wVector[13].order(ByteOrder.LITTLE_ENDIAN);
|
||||
@ -112,17 +112,17 @@ public class FluidSim {
|
||||
for(int k = 0; k < DIM; k++){
|
||||
if(offset.x == 1){
|
||||
if(
|
||||
Math.abs(5 - i) < 4 &&
|
||||
Math.abs(16 - i) < 4 &&
|
||||
Math.abs(j) < 4 &&
|
||||
Math.abs(5 - k) < 4 &&
|
||||
Math.abs(16 - k) < 4 &&
|
||||
i < 17 && i > 0 &&
|
||||
j < 17 && j > 0 &&
|
||||
k < 17 && k > 0
|
||||
){
|
||||
xf.put(1);
|
||||
uf.put(1);
|
||||
vf.put(-1f);
|
||||
wf.put(rand.nextFloat() * 0.1f);
|
||||
uf.put(-50);
|
||||
vf.put(0);
|
||||
wf.put(0);
|
||||
} else {
|
||||
xf.put(0);
|
||||
uf.put(0);
|
||||
@ -131,16 +131,16 @@ public class FluidSim {
|
||||
}
|
||||
} else {
|
||||
if(
|
||||
Math.abs(8 - i) < 4 &&
|
||||
Math.abs(0 - i) < 4 &&
|
||||
Math.abs(j) < 4 &&
|
||||
Math.abs(16 - k) < 4 &&
|
||||
Math.abs(0 - k) < 4 &&
|
||||
i < 17 && i > 0 &&
|
||||
j < 17 && j > 0 &&
|
||||
k < 17 && k > 0
|
||||
){
|
||||
xf.put(1);
|
||||
uf.put(1);
|
||||
vf.put(-1f);
|
||||
uf.put(50);
|
||||
vf.put(0);
|
||||
wf.put(rand.nextFloat() * 0.1f);
|
||||
} else {
|
||||
xf.put(0);
|
||||
@ -206,27 +206,6 @@ public class FluidSim {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a frame of the fluid simulation
|
||||
*/
|
||||
private void simulate(int step, float timestep){
|
||||
simulate(
|
||||
DIM,
|
||||
0,
|
||||
density,
|
||||
densityAddition,
|
||||
uVector,
|
||||
vVector,
|
||||
wVector,
|
||||
uAdditionVector,
|
||||
vAdditionVector,
|
||||
wAdditionVector,
|
||||
DIFFUSION_CONSTANT,
|
||||
VISCOSITY_CONSTANT,
|
||||
timestep
|
||||
);
|
||||
}
|
||||
|
||||
private static void solveChunkMask(FluidSim[][][] simArray){
|
||||
for(int x = 0; x < simArray.length; x++){
|
||||
for(int y = 0; y < simArray[0].length; y++){
|
||||
@ -256,6 +235,20 @@ public class FluidSim {
|
||||
}
|
||||
|
||||
private static void solveVectorDiffusion(FluidSim[][][] simArray, float timestep){
|
||||
//samples u,v,w,u0,v0,w0
|
||||
//sets u,v,w
|
||||
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++){
|
||||
simArray[x][y][z].copyNeighborsWrapper(1, simArray[x][y][z].uVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(3, simArray[x][y][z].wVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(1, simArray[x][y][z].uAdditionVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vAdditionVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(3, simArray[x][y][z].wAdditionVector);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int l = 0; l < LINEARSOLVERTIMES; l++){
|
||||
for(int x = 0; x < simArray.length; x++){
|
||||
for(int y = 0; y < simArray[0].length; y++){
|
||||
@ -281,6 +274,19 @@ public class FluidSim {
|
||||
}
|
||||
|
||||
private static void solveProjection(FluidSim[][][] simArray, float timestep){
|
||||
//samples u,v,w
|
||||
//sets u0,v0
|
||||
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++){
|
||||
simArray[x][y][z].copyNeighborsWrapper(1, simArray[x][y][z].uVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(3, simArray[x][y][z].wVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(1, simArray[x][y][z].uAdditionVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vAdditionVector);
|
||||
}
|
||||
}
|
||||
}
|
||||
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++){
|
||||
@ -300,6 +306,9 @@ public class FluidSim {
|
||||
}
|
||||
}
|
||||
}
|
||||
//samples u0, v0
|
||||
//sets u0
|
||||
//these should have just been mirrored in the above
|
||||
//
|
||||
//Perform main projection solver
|
||||
for(int l = 0; l < LINEARSOLVERTIMES; l++){
|
||||
@ -322,6 +331,8 @@ public class FluidSim {
|
||||
}
|
||||
}
|
||||
}
|
||||
//samples u,v,w,u0
|
||||
//sets u,v,w
|
||||
//Finalize projection
|
||||
for(int x = 0; x < simArray.length; x++){
|
||||
for(int y = 0; y < simArray[0].length; y++){
|
||||
@ -363,6 +374,18 @@ public class FluidSim {
|
||||
}
|
||||
}
|
||||
}
|
||||
//then need to mirror each array as relevant
|
||||
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++){
|
||||
simArray[x][y][z].copyNeighborsWrapper(1, simArray[x][y][z].uVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(3, simArray[x][y][z].wVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(1, simArray[x][y][z].uAdditionVector);
|
||||
simArray[x][y][z].copyNeighborsWrapper(2, simArray[x][y][z].vAdditionVector);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void swapVectorFields(){
|
||||
@ -387,6 +410,7 @@ public class FluidSim {
|
||||
}
|
||||
|
||||
private static void advectVectorsAcrossBoundaries(FluidSim[][][] simArray, float timestep){
|
||||
//samples u,v,w,u0,v0,w0
|
||||
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++){
|
||||
@ -424,10 +448,28 @@ public class FluidSim {
|
||||
}
|
||||
}
|
||||
|
||||
private 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++){
|
||||
simArray[x][y][z].swapDensityArrays();
|
||||
}
|
||||
}
|
||||
}
|
||||
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++){
|
||||
simArray[x][y][z].copyNeighborsWrapper(0, simArray[x][y][z].density);
|
||||
simArray[x][y][z].copyNeighborsWrapper(0, simArray[x][y][z].densityAddition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void swapDensityArrays(){
|
||||
ByteBuffer tmp = density[13];
|
||||
density[13] = densityAddition;
|
||||
densityAddition = tmp;
|
||||
density[13] = densityAddition[13];
|
||||
densityAddition[13] = tmp;
|
||||
}
|
||||
|
||||
private static void diffuseDensity(FluidSim[][][] simArray, float timestep){
|
||||
@ -605,7 +647,7 @@ public class FluidSim {
|
||||
private void addDensityWrapper(float timestep){
|
||||
addDensity(DIM, chunkMask, density, densityAddition, timestep);
|
||||
}
|
||||
private native void addDensity(int DIM_X, int chunkMask, ByteBuffer[] x, ByteBuffer x0, float timestep);
|
||||
private native void addDensity(int DIM_X, int chunkMask, ByteBuffer[] x, ByteBuffer[] x0, float timestep);
|
||||
|
||||
/**
|
||||
* Solve density diffusion
|
||||
@ -613,7 +655,7 @@ public class FluidSim {
|
||||
private void solveDiffuseDensityWrapper(float timestep){
|
||||
solveDiffuseDensity(DIM, chunkMask, density, densityAddition, uVector, vVector, wVector, DIFFUSION_CONSTANT, VISCOSITY_CONSTANT, timestep);
|
||||
}
|
||||
private native void solveDiffuseDensity(int DIM_X, int chunkMask, ByteBuffer[] x, ByteBuffer x0, ByteBuffer[] u, ByteBuffer v[], ByteBuffer w[], float DIFFUSION_CONSTANT, float VISCOSITY_CONSTANT, float timestep);
|
||||
private native void solveDiffuseDensity(int DIM_X, int chunkMask, ByteBuffer[] x, ByteBuffer[] x0, ByteBuffer[] u, ByteBuffer v[], ByteBuffer w[], float DIFFUSION_CONSTANT, float VISCOSITY_CONSTANT, float timestep);
|
||||
|
||||
/**
|
||||
* Solve density diffusion
|
||||
@ -621,7 +663,7 @@ public class FluidSim {
|
||||
private void advectDensityWrapper(float timestep){
|
||||
advectDensity(DIM, chunkMask, density, densityAddition, uVector, vVector, wVector, DIFFUSION_CONSTANT, VISCOSITY_CONSTANT, timestep);
|
||||
}
|
||||
private native void advectDensity(int DIM_X, int chunkMask, ByteBuffer[] x, ByteBuffer x0, ByteBuffer[] u, ByteBuffer v[], ByteBuffer w[], float DIFFUSION_CONSTANT, float VISCOSITY_CONSTANT, float timestep);
|
||||
private native void advectDensity(int DIM_X, int chunkMask, ByteBuffer[] x, ByteBuffer[] x0, ByteBuffer[] u, ByteBuffer v[], ByteBuffer w[], float DIFFUSION_CONSTANT, float VISCOSITY_CONSTANT, float timestep);
|
||||
|
||||
|
||||
/**
|
||||
@ -632,6 +674,15 @@ public class FluidSim {
|
||||
}
|
||||
private native void setBoundsToNeighbors(int DIM_X, int chunkMask, int vectorDir, ByteBuffer[] neighborMap);
|
||||
|
||||
/**
|
||||
* Sets the bounds of the neighbormap to neighbor values if available, otherwise doesn't mess with them.
|
||||
* This is to make sure zeroing out doesn't mess up the sim
|
||||
*/
|
||||
private void copyNeighborsWrapper(int vectorDir, ByteBuffer[] neighborMap){
|
||||
copyNeighbors(DIM, chunkMask, vectorDir, neighborMap);
|
||||
}
|
||||
private native void copyNeighbors(int DIM_X, int chunkMask, int vectorDir, ByteBuffer[] neighborMap);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -723,8 +774,8 @@ public class FluidSim {
|
||||
* Writes data from the java-side arrays into buffers that get passed into c-side
|
||||
*/
|
||||
private void writeNewStateIntoBuffers(){
|
||||
if(densityAddition.position() > 0){
|
||||
densityAddition.position(0);
|
||||
if(densityAddition[13].position() > 0){
|
||||
densityAddition[13].position(0);
|
||||
}
|
||||
if(uAdditionVector[13].position() > 0){
|
||||
uAdditionVector[13].position(0);
|
||||
@ -735,7 +786,7 @@ public class FluidSim {
|
||||
if(wAdditionVector[13].position() > 0){
|
||||
wAdditionVector[13].position(0);
|
||||
}
|
||||
FloatBuffer x0FloatView = densityAddition.asFloatBuffer();
|
||||
FloatBuffer x0FloatView = densityAddition[13].asFloatBuffer();
|
||||
FloatBuffer u0FloatView = uAdditionVector[13].asFloatBuffer();
|
||||
FloatBuffer v0FloatView = vAdditionVector[13].asFloatBuffer();
|
||||
FloatBuffer w0FloatView = wAdditionVector[13].asFloatBuffer();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user