work on increating grid2 accuracy
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
36e40cd0ae
commit
a835ebb3eb
@ -34,7 +34,6 @@ void fluid_grid2_addDensity(
|
|||||||
LIBRARY_API void fluid_grid2_solveDiffuseDensity(
|
LIBRARY_API void fluid_grid2_solveDiffuseDensity(
|
||||||
float ** d,
|
float ** d,
|
||||||
float ** d0,
|
float ** d0,
|
||||||
float DIFFUSION_CONST,
|
|
||||||
float dt
|
float dt
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ void fluid_grid2_add_source(float * x, float * s, float dt);
|
|||||||
*/
|
*/
|
||||||
LIBRARY_API void fluid_grid2_setBoundsToNeighborsRaw(
|
LIBRARY_API void fluid_grid2_setBoundsToNeighborsRaw(
|
||||||
int vector_dir,
|
int vector_dir,
|
||||||
float ** neighborArray
|
float * target
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,10 +41,9 @@ void fluid_grid2_addDensity(
|
|||||||
LIBRARY_API void fluid_grid2_solveDiffuseDensity(
|
LIBRARY_API void fluid_grid2_solveDiffuseDensity(
|
||||||
float ** d,
|
float ** d,
|
||||||
float ** d0,
|
float ** d0,
|
||||||
float DIFFUSION_CONST,
|
|
||||||
float dt
|
float dt
|
||||||
){
|
){
|
||||||
float a=dt*DIFFUSION_CONST/(FLUID_GRID2_H*FLUID_GRID2_H);
|
float a=dt*FLUID_GRID2_DIFFUSION_CONSTANT/(FLUID_GRID2_H*FLUID_GRID2_H);
|
||||||
float c=1+6*a;
|
float c=1+6*a;
|
||||||
int i, j, k, l, m;
|
int i, j, k, l, m;
|
||||||
float * x = GET_ARR_RAW(d,CENTER_LOC);
|
float * x = GET_ARR_RAW(d,CENTER_LOC);
|
||||||
|
|||||||
@ -82,16 +82,16 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
//solve vector diffusion
|
//solve vector diffusion
|
||||||
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//setup projection
|
//setup projection
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
||||||
|
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->v0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->v0[CENTER_LOC]);
|
||||||
|
|
||||||
//samples u0, v0
|
//samples u0, v0
|
||||||
//sets u0
|
//sets u0
|
||||||
@ -99,7 +99,7 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
//
|
//
|
||||||
//Perform main projection solver
|
//Perform main projection solver
|
||||||
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
//samples u,v,w,u0
|
//samples u,v,w,u0
|
||||||
//sets u,v,w
|
//sets u,v,w
|
||||||
//Finalize projection
|
//Finalize projection
|
||||||
@ -107,9 +107,9 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
|
|
||||||
//set boundaries a final time for u,v,w
|
//set boundaries a final time for u,v,w
|
||||||
//...
|
//...
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
|
||||||
|
|
||||||
//swap all vector fields
|
//swap all vector fields
|
||||||
//swap vector fields
|
//swap vector fields
|
||||||
@ -121,14 +121,14 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
//advect
|
//advect
|
||||||
fluid_grid2_advectVectors(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
fluid_grid2_advectVectors(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
||||||
//update neighbor arr
|
//update neighbor arr
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
|
||||||
//setup projection
|
//setup projection
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
|
||||||
//samples u0, v0
|
//samples u0, v0
|
||||||
//sets u0
|
//sets u0
|
||||||
//these should have just been mirrored in the above
|
//these should have just been mirrored in the above
|
||||||
@ -136,7 +136,7 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
//Perform main projection solver
|
//Perform main projection solver
|
||||||
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
||||||
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//samples u,v,w,u0
|
//samples u,v,w,u0
|
||||||
//sets u,v,w
|
//sets u,v,w
|
||||||
@ -144,9 +144,9 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
||||||
//set boundaries a final time for u,v,w
|
//set boundaries a final time for u,v,w
|
||||||
//...
|
//...
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -178,8 +178,8 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0);
|
fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0);
|
||||||
//diffuse density
|
//diffuse density
|
||||||
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
||||||
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_DIFFUSION_CONSTANT,timestep);
|
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,timestep);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d);
|
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
//swap vector fields
|
//swap vector fields
|
||||||
@ -192,7 +192,7 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d);
|
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//normalize densities
|
//normalize densities
|
||||||
|
|||||||
@ -29,9 +29,8 @@ void fluid_grid2_add_source(float * x, float * s, float dt){
|
|||||||
*/
|
*/
|
||||||
LIBRARY_API void fluid_grid2_setBoundsToNeighborsRaw(
|
LIBRARY_API void fluid_grid2_setBoundsToNeighborsRaw(
|
||||||
int vector_dir,
|
int vector_dir,
|
||||||
float ** neighborArray
|
float * target
|
||||||
){
|
){
|
||||||
float * target = GET_ARR_RAW(neighborArray,CENTER_LOC);
|
|
||||||
//set the faces bounds
|
//set the faces bounds
|
||||||
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++){
|
||||||
|
|||||||
@ -242,7 +242,7 @@ LIBRARY_API void fluid_grid2_solveProjection(
|
|||||||
//perform iteration of v cycle multigrid method
|
//perform iteration of v cycle multigrid method
|
||||||
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
||||||
solver_multigrid_iterate(p,div,a,c);
|
solver_multigrid_iterate(p,div,a,c);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,jru0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,jru0[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// solver_conjugate_gradient_solve_serial(p,div,a,c);
|
// solver_conjugate_gradient_solve_serial(p,div,a,c);
|
||||||
@ -360,7 +360,9 @@ void fluid_grid2_advect_velocity(int b, float ** jrd, float ** jrd0, float * u,
|
|||||||
int m,n,o;
|
int m,n,o;
|
||||||
float x, y, z, s0, t0, s1, t1, u1, u0, dtx,dty,dtz;
|
float x, y, z, s0, t0, s1, t1, u1, u0, dtx,dty,dtz;
|
||||||
|
|
||||||
dtx=dty=dtz=dt/FLUID_GRID2_H;
|
dtx = dt/FLUID_GRID2_H;
|
||||||
|
dty = dt/FLUID_GRID2_H;
|
||||||
|
dtz = dt/FLUID_GRID2_H;
|
||||||
|
|
||||||
float * d = GET_ARR_RAW(jrd,CENTER_LOC);
|
float * d = GET_ARR_RAW(jrd,CENTER_LOC);
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
|
#include "fluid/sim/grid2/utilities.h"
|
||||||
#include "math/ode/gauss_seidel.h"
|
#include "math/ode/gauss_seidel.h"
|
||||||
#include "math/ode/multigrid.h"
|
#include "math/ode/multigrid.h"
|
||||||
|
|
||||||
@ -39,12 +40,23 @@ void solver_multigrid_iterate(float * phi, float * phi0, float a, float c){
|
|||||||
//
|
//
|
||||||
//gauss-seidel at highest res
|
//gauss-seidel at highest res
|
||||||
solver_gauss_seidel_iterate_parallel(phi,phi0,a,c,DIM);
|
solver_gauss_seidel_iterate_parallel(phi,phi0,a,c,DIM);
|
||||||
|
fluid_grid2_setBoundsToNeighborsRaw(0,phi);
|
||||||
|
|
||||||
//
|
//
|
||||||
//half res
|
//half res
|
||||||
for(int x = 1; x < halfDim - 2; x++){
|
//clear grid
|
||||||
for(int y = 1; y < halfDim - 2; y++){
|
for(int x = 0; x < halfDim - 1; x++){
|
||||||
for(int z = 1; z < halfDim - 2; z++){
|
for(int y = 0; y < halfDim - 1; y++){
|
||||||
|
for(int z = 0; z < halfDim - 1; z++){
|
||||||
|
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0;
|
||||||
|
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//populate grid
|
||||||
|
for(int x = 1; x < halfDim - 1; x++){
|
||||||
|
for(int y = 1; y < halfDim - 1; y++){
|
||||||
|
for(int z = 1; z < halfDim - 1; z++){
|
||||||
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = phi[solver_gauss_seidel_get_index(x*2,y*2,z*2,DIM)];
|
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = phi[solver_gauss_seidel_get_index(x*2,y*2,z*2,DIM)];
|
||||||
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = phi0[solver_gauss_seidel_get_index(x*2,y*2,z*2,DIM)];
|
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = phi0[solver_gauss_seidel_get_index(x*2,y*2,z*2,DIM)];
|
||||||
}
|
}
|
||||||
@ -57,24 +69,51 @@ void solver_multigrid_iterate(float * phi, float * phi0, float a, float c){
|
|||||||
//
|
//
|
||||||
//quarter res
|
//quarter res
|
||||||
//
|
//
|
||||||
//half res
|
//clear grid
|
||||||
for(int x = 1; x < quarterDim - 2; x++){
|
for(int x = 0; x < quarterDim - 1; x++){
|
||||||
for(int y = 1; y < quarterDim - 2; y++){
|
for(int y = 0; y < quarterDim - 1; y++){
|
||||||
for(int z = 1; z < quarterDim - 2; z++){
|
for(int z = 0; z < quarterDim - 1; z++){
|
||||||
|
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = 0;
|
||||||
|
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//populate grid
|
||||||
|
for(int x = 1; x < quarterDim - 1; x++){
|
||||||
|
for(int y = 1; y < quarterDim - 1; y++){
|
||||||
|
for(int z = 1; z < quarterDim - 1; z++){
|
||||||
quarterGridPhi[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = halfGridPhi[solver_gauss_seidel_get_index(x*2,y*2,z*2,halfDim)];
|
quarterGridPhi[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = halfGridPhi[solver_gauss_seidel_get_index(x*2,y*2,z*2,halfDim)];
|
||||||
quarterGridPhi0[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = halfGridPhi0[solver_gauss_seidel_get_index(x*2,y*2,z*2,halfDim)];
|
quarterGridPhi0[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = halfGridPhi0[solver_gauss_seidel_get_index(x*2,y*2,z*2,halfDim)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
solver_gauss_seidel_iterate_parallel(quarterGridPhi,quarterGridPhi0,a,c,quarterDim);
|
solver_gauss_seidel_iterate_parallel(quarterGridPhi,quarterGridPhi0,a,c,quarterDim);
|
||||||
for(int x = 1; x < halfDim - 2; x++){
|
|
||||||
for(int y = 1; y < halfDim - 2; y++){
|
|
||||||
for(int z = 1; z < halfDim - 2; z++){
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//half res
|
||||||
|
//
|
||||||
|
//clear grid
|
||||||
|
for(int x = 0; x < halfDim - 1; x++){
|
||||||
|
for(int y = 0; y < halfDim - 1; y++){
|
||||||
|
for(int z = 0; z < halfDim - 1; z++){
|
||||||
|
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0;
|
||||||
|
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//populate grid
|
||||||
|
for(int x = 1; x < halfDim - 1; x++){
|
||||||
|
for(int y = 1; y < halfDim - 1; y++){
|
||||||
|
for(int z = 1; z < halfDim - 1; z++){
|
||||||
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = quarterGridPhi[solver_gauss_seidel_get_index(x/2,y/2,z/2,quarterDim)];
|
halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = quarterGridPhi[solver_gauss_seidel_get_index(x/2,y/2,z/2,quarterDim)];
|
||||||
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = quarterGridPhi0[solver_gauss_seidel_get_index(x/2,y/2,z/2,quarterDim)];
|
halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = quarterGridPhi0[solver_gauss_seidel_get_index(x/2,y/2,z/2,quarterDim)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
solver_gauss_seidel_iterate_parallel(halfGridPhi,halfGridPhi0,a,c,halfDim);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -83,11 +122,10 @@ void solver_multigrid_iterate(float * phi, float * phi0, float a, float c){
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//half res
|
//full res
|
||||||
solver_gauss_seidel_iterate_parallel(halfGridPhi,halfGridPhi0,a,c,halfDim);
|
for(int x = 1; x < DIM - 1; x++){
|
||||||
for(int x = 1; x < DIM - 2; x++){
|
for(int y = 1; y < DIM - 1; y++){
|
||||||
for(int y = 1; y < DIM - 2; y++){
|
for(int z = 1; z < DIM - 1; z++){
|
||||||
for(int z = 1; z < DIM - 2; z++){
|
|
||||||
phi[solver_gauss_seidel_get_index(x,y,z,DIM)] = halfGridPhi[solver_gauss_seidel_get_index(x/2,y/2,z/2,halfDim)];
|
phi[solver_gauss_seidel_get_index(x,y,z,DIM)] = halfGridPhi[solver_gauss_seidel_get_index(x/2,y/2,z/2,halfDim)];
|
||||||
phi0[solver_gauss_seidel_get_index(x,y,z,DIM)] = halfGridPhi0[solver_gauss_seidel_get_index(x/2,y/2,z/2,halfDim)];
|
phi0[solver_gauss_seidel_get_index(x,y,z,DIM)] = halfGridPhi0[solver_gauss_seidel_get_index(x/2,y/2,z/2,halfDim)];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package electrosphere.entity.state.movement.editor;
|
|||||||
|
|
||||||
|
|
||||||
import electrosphere.entity.state.gravity.GravityUtils;
|
import electrosphere.entity.state.gravity.GravityUtils;
|
||||||
|
import electrosphere.client.scene.ClientWorldData;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.game.data.creature.type.movement.EditorMovementSystem;
|
import electrosphere.game.data.creature.type.movement.EditorMovementSystem;
|
||||||
@ -196,6 +197,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
|||||||
float maxNaturalVelocity = EDITOR_MAX_VELOCITY;
|
float maxNaturalVelocity = EDITOR_MAX_VELOCITY;
|
||||||
|
|
||||||
Entity serverEntity = EntityLookupUtils.getEntityById(Globals.clientSceneWrapper.mapClientToServerId(parent.getId()));
|
Entity serverEntity = EntityLookupUtils.getEntityById(Globals.clientSceneWrapper.mapClientToServerId(parent.getId()));
|
||||||
|
ClientWorldData clientWorldData = Globals.clientWorldData;
|
||||||
|
|
||||||
//
|
//
|
||||||
//rotation update
|
//rotation update
|
||||||
@ -258,7 +260,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
|||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity)));
|
position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity)));
|
||||||
if(serverEntity != null){
|
if(serverEntity != null){
|
||||||
if(position.x >= 0 && position.y >= 0 && position.z >= 0){
|
if(position.x >= 0 && position.y >= 0 && position.z >= 0 && position.x < clientWorldData.getWorldBoundMax().x && position.y < clientWorldData.getWorldBoundMax().y && position.z < clientWorldData.getWorldBoundMax().z){
|
||||||
ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position));
|
ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,7 +277,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
|||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity)));
|
position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity)));
|
||||||
if(serverEntity != null){
|
if(serverEntity != null){
|
||||||
if(position.x >= 0 && position.y >= 0 && position.z >= 0){
|
if(position.x >= 0 && position.y >= 0 && position.z >= 0 && position.x < clientWorldData.getWorldBoundMax().x && position.y < clientWorldData.getWorldBoundMax().y && position.z < clientWorldData.getWorldBoundMax().z){
|
||||||
ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position));
|
ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +300,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
|||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity)));
|
position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity)));
|
||||||
if(serverEntity != null){
|
if(serverEntity != null){
|
||||||
if(position.x >= 0 && position.y >= 0 && position.z >= 0){
|
if(position.x >= 0 && position.y >= 0 && position.z >= 0 && position.x < clientWorldData.getWorldBoundMax().x && position.y < clientWorldData.getWorldBoundMax().y && position.z < clientWorldData.getWorldBoundMax().z){
|
||||||
ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position));
|
ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,10 +60,10 @@ int fluid_sim_grid2_advect_projection_test1(){
|
|||||||
|
|
||||||
////project
|
////project
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
|
||||||
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
|
|
||||||
//advect density
|
//advect density
|
||||||
@ -125,10 +125,10 @@ int fluid_sim_grid2_advect_projection_compute_error_over_time(){
|
|||||||
|
|
||||||
////project
|
////project
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
|
||||||
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
|
|
||||||
//advect density
|
//advect density
|
||||||
|
|||||||
@ -76,8 +76,8 @@ int fluid_sim_grid2_density_diffuse_test1(){
|
|||||||
}
|
}
|
||||||
//diffuse density
|
//diffuse density
|
||||||
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
||||||
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_DIFFUSION_CONSTANT,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d);
|
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
//swap vector fields
|
//swap vector fields
|
||||||
@ -134,8 +134,8 @@ int fluid_sim_grid2_density_diffuse_test2(){
|
|||||||
}
|
}
|
||||||
//diffuse density
|
//diffuse density
|
||||||
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
|
||||||
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_DIFFUSION_CONSTANT,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d);
|
fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
//swap vector fields
|
//swap vector fields
|
||||||
|
|||||||
@ -37,7 +37,7 @@ int fluid_sim_grid2_finalize_projection_test1(){
|
|||||||
currentChunk->u[CENTER_LOC][IX(3,3,3)] = 1.0f;
|
currentChunk->u[CENTER_LOC][IX(3,3,3)] = 1.0f;
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
|
|
||||||
//finalize
|
//finalize
|
||||||
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
|
|||||||
@ -39,7 +39,7 @@ int fluid_sim_grid2_solve_projection_test1(){
|
|||||||
|
|
||||||
//actually solve
|
//actually solve
|
||||||
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
|
||||||
|
|
||||||
//test the result
|
//test the result
|
||||||
float expected, actual;
|
float expected, actual;
|
||||||
|
|||||||
@ -57,9 +57,9 @@ int fluid_sim_grid2_velocity_diffuse_test1(){
|
|||||||
//solve vector diffusion
|
//solve vector diffusion
|
||||||
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP);
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
//swap vector fields
|
//swap vector fields
|
||||||
@ -117,9 +117,9 @@ int fluid_sim_grid2_velocity_diffuse_test2(){
|
|||||||
//solve vector diffusion
|
//solve vector diffusion
|
||||||
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP);
|
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP);
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
|
||||||
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w);
|
fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
|
||||||
}
|
}
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
//swap vector fields
|
//swap vector fields
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user