From fbf4e62d9cf84dd29fed9411b7bea29f701d9414 Mon Sep 17 00:00:00 2001 From: unknown <> Date: Mon, 24 Jul 2023 19:16:51 -0400 Subject: [PATCH] Chunking fluids working partway --- src/main/c/velocitystep.c | 192 ++++++++++++++++++++++++++ src/main/java/electrosphere/Main.java | 4 +- 2 files changed, 194 insertions(+), 2 deletions(-) diff --git a/src/main/c/velocitystep.c b/src/main/c/velocitystep.c index 17e8183..5d6b86c 100644 --- a/src/main/c/velocitystep.c +++ b/src/main/c/velocitystep.c @@ -612,6 +612,13 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_copyNeighbors int DIM = N; float * target = GET_ARR(env,neighborArray,CENTER_LOC); float * source; + + + // + // + // PLANES + // + // 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++){ @@ -629,4 +636,189 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_copyNeighbors } } } + + if(ARR_EXISTS(chunk_mask,1,0,1)){ + source = GET_ARR(env,neighborArray,CK(1,0,1)); + for(int x=1; x < DIM-1; x++){ + for(int y = 1; y < DIM-1; y++){ + target[IX(x,0,y)] = source[IX(x,DIM-2,y)]; + } + } + } + + if(ARR_EXISTS(chunk_mask,1,2,1)){ + source = GET_ARR(env,neighborArray,CK(1,2,1)); + for(int x=1; x < DIM-1; x++){ + for(int y = 1; y < DIM-1; y++){ + target[IX(x,DIM-1,y)] = source[IX(x,1,y)]; + } + } + } + + if(ARR_EXISTS(chunk_mask,1,1,0)){ + source = GET_ARR(env,neighborArray,CK(1,1,0)); + for(int x=1; x < DIM-1; x++){ + for(int y = 1; y < DIM-1; y++){ + target[IX(x,y,0)] = source[IX(x,y,DIM-2)]; + } + } + } + + if(ARR_EXISTS(chunk_mask,1,1,2)){ + source = GET_ARR(env,neighborArray,CK(1,1,2)); + for(int x=1; x < DIM-1; x++){ + for(int y = 1; y < DIM-1; y++){ + target[IX(x,y,DIM-1)] = source[IX(x,y,1)]; + } + } + } + + + // + // + // EDGES + // + // + if(ARR_EXISTS(chunk_mask,0,0,1)){ + source = GET_ARR(env,neighborArray,CK(0,0,1)); + for(int x=1; x < DIM-1; x++){ + target[IX(0,0,x)] = source[IX(DIM-2,DIM-2,x)]; + } + } + + if(ARR_EXISTS(chunk_mask,2,0,1)){ + source = GET_ARR(env,neighborArray,CK(2,0,1)); + for(int x=1; x < DIM-1; x++){ + target[IX(DIM-1,0,x)] = source[IX(1,DIM-2,x)]; + } + } + + if(ARR_EXISTS(chunk_mask,0,2,1)){ + source = GET_ARR(env,neighborArray,CK(0,2,1)); + for(int x=1; x < DIM-1; x++){ + target[IX(0,DIM-1,x)] = source[IX(DIM-2,1,x)]; + } + } + + if(ARR_EXISTS(chunk_mask,2,2,1)){ + source = GET_ARR(env,neighborArray,CK(2,2,1)); + for(int x=1; x < DIM-1; x++){ + target[IX(DIM-1,DIM-1,x)] = source[IX(1,1,x)]; + } + } + + // + // + + if(ARR_EXISTS(chunk_mask,0,1,0)){ + source = GET_ARR(env,neighborArray,CK(0,1,0)); + for(int x=1; x < DIM-1; x++){ + target[IX(0,x,0)] = source[IX(DIM-2,x,DIM-2)]; + } + } + + if(ARR_EXISTS(chunk_mask,2,1,0)){ + source = GET_ARR(env,neighborArray,CK(2,1,0)); + for(int x=1; x < DIM-1; x++){ + target[IX(DIM-1,x,0)] = source[IX(1,x,DIM-2)]; + } + } + + if(ARR_EXISTS(chunk_mask,0,1,2)){ + source = GET_ARR(env,neighborArray,CK(0,1,2)); + for(int x=1; x < DIM-1; x++){ + target[IX(0,x,DIM-1)] = source[IX(DIM-2,x,1)]; + } + } + + if(ARR_EXISTS(chunk_mask,2,1,2)){ + source = GET_ARR(env,neighborArray,CK(2,1,2)); + for(int x=1; x < DIM-1; x++){ + target[IX(DIM-1,x,DIM-1)] = source[IX(1,x,1)]; + } + } + + // + // + + if(ARR_EXISTS(chunk_mask,1,0,0)){ + source = GET_ARR(env,neighborArray,CK(1,0,0)); + for(int x=1; x < DIM-1; x++){ + target[IX(x,0,0)] = source[IX(x,DIM-2,DIM-2)]; + } + } + + if(ARR_EXISTS(chunk_mask,1,2,0)){ + source = GET_ARR(env,neighborArray,CK(1,2,0)); + for(int x=1; x < DIM-1; x++){ + target[IX(x,DIM-1,0)] = source[IX(x,1,DIM-2)]; + } + } + + if(ARR_EXISTS(chunk_mask,1,0,2)){ + source = GET_ARR(env,neighborArray,CK(1,0,2)); + for(int x=1; x < DIM-1; x++){ + target[IX(x,0,DIM-1)] = source[IX(x,DIM-2,1)]; + } + } + + if(ARR_EXISTS(chunk_mask,1,2,2)){ + source = GET_ARR(env,neighborArray,CK(1,2,2)); + for(int x=1; x < DIM-1; x++){ + target[IX(x,DIM-1,DIM-1)] = source[IX(x,1,1)]; + } + } + + + // + // + // CORNERS + // + // + + if(ARR_EXISTS(chunk_mask,0,0,0)){ + source = GET_ARR(env,neighborArray,CK(0,0,0)); + target[IX(0,0,0)] = source[IX(DIM-2,DIM-2,DIM-2)]; + } + + if(ARR_EXISTS(chunk_mask,2,0,0)){ + source = GET_ARR(env,neighborArray,CK(2,0,0)); + target[IX(DIM-1,0,0)] = source[IX(1,DIM-2,DIM-2)]; + } + + if(ARR_EXISTS(chunk_mask,0,2,0)){ + source = GET_ARR(env,neighborArray,CK(0,2,0)); + target[IX(0,DIM-1,0)] = source[IX(DIM-2,1,DIM-2)]; + } + + if(ARR_EXISTS(chunk_mask,2,2,0)){ + source = GET_ARR(env,neighborArray,CK(2,2,0)); + target[IX(DIM-1,DIM-1,0)] = source[IX(1,1,DIM-2)]; + } + + // + // + + if(ARR_EXISTS(chunk_mask,0,0,2)){ + source = GET_ARR(env,neighborArray,CK(0,0,2)); + target[IX(0,0,DIM-1)] = source[IX(DIM-2,DIM-2,1)]; + } + + if(ARR_EXISTS(chunk_mask,2,0,2)){ + source = GET_ARR(env,neighborArray,CK(2,0,2)); + target[IX(DIM-1,0,DIM-1)] = source[IX(1,DIM-2,1)]; + } + + if(ARR_EXISTS(chunk_mask,0,2,2)){ + source = GET_ARR(env,neighborArray,CK(0,2,2)); + target[IX(0,DIM-1,DIM-1)] = source[IX(DIM-2,1,1)]; + } + + if(ARR_EXISTS(chunk_mask,2,2,2)){ + source = GET_ARR(env,neighborArray,CK(2,2,2)); + target[IX(DIM-1,DIM-1,DIM-1)] = source[IX(1,1,1)]; + } + + + } \ No newline at end of file diff --git a/src/main/java/electrosphere/Main.java b/src/main/java/electrosphere/Main.java index a8fa961..7a80154 100644 --- a/src/main/java/electrosphere/Main.java +++ b/src/main/java/electrosphere/Main.java @@ -36,9 +36,9 @@ public class Main { Mesh.initShaderProgram(); - FluidSim[][][] simArray = initFluidSim(dim,1,1); + FluidSim[][][] simArray = initFluidSim(dim,dim,dim); - Mesh[][][] meshArray = initMeshes(dim,1,1,simArray); + Mesh[][][] meshArray = initMeshes(dim,dim,dim,simArray);