fix velocity not being tracked properly
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
757a4aa409
commit
c50e22cfd3
@ -10,7 +10,7 @@
|
|||||||
/**
|
/**
|
||||||
* Spacing of cells
|
* Spacing of cells
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_SPACING (1.0f/DIM)
|
#define FLUID_PRESSURECELL_SPACING 1.0f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplier applied to pressure calculations to encourage advection
|
* Multiplier applied to pressure calculations to encourage advection
|
||||||
@ -25,12 +25,12 @@
|
|||||||
/**
|
/**
|
||||||
* Diffusion constant
|
* Diffusion constant
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.01f
|
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.00001f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Viscosity constant
|
* Viscosity constant
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.01f
|
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.00001f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of the residual to add to the pressure field each frame
|
* Amount of the residual to add to the pressure field each frame
|
||||||
|
|||||||
@ -13,7 +13,7 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
|
|||||||
int x, y, z;
|
int x, y, z;
|
||||||
//values stored across frames
|
//values stored across frames
|
||||||
float * presureCache = chunk->pressureCache[CENTER_LOC];
|
float * presureCache = chunk->pressureCache[CENTER_LOC];
|
||||||
float * divArr = chunk->divergenceCache[CENTER_LOC];
|
float * divCache = chunk->divergenceCache[CENTER_LOC];
|
||||||
float * uArr = chunk->u[CENTER_LOC];
|
float * uArr = chunk->u[CENTER_LOC];
|
||||||
float * vArr = chunk->v[CENTER_LOC];
|
float * vArr = chunk->v[CENTER_LOC];
|
||||||
float * wArr = chunk->w[CENTER_LOC];
|
float * wArr = chunk->w[CENTER_LOC];
|
||||||
@ -81,12 +81,12 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
|
|||||||
for(z = 0; z < DIM; z++){
|
for(z = 0; z < DIM; z++){
|
||||||
for(y = 0; y < DIM; y++){
|
for(y = 0; y < DIM; y++){
|
||||||
for(x = 0; x < DIM; x++){
|
for(x = 0; x < DIM; x++){
|
||||||
phi0[IX(x,y,z)] = divArr[IX(x,y,z)];
|
phi0[IX(x,y,z)] = divCache[IX(x,y,z)];
|
||||||
pressureTemp[IX(x,y,z)] = pressureCache[IX(x,y,z)];
|
pressureTemp[IX(x,y,z)] = pressureCache[IX(x,y,z)];
|
||||||
// pressureTemp[IX(x,y,z)] = 0;
|
// pressureTemp[IX(x,y,z)] = 0;
|
||||||
if(divArr[IX(x,y,z)] > 3){
|
if(divCache[IX(x,y,z)] > 3){
|
||||||
printf("invalid divergence!\n");
|
printf("invalid divergence!\n");
|
||||||
printf("%f \n", divArr[IX(x,y,z)]);
|
printf("%f \n", divCache[IX(x,y,z)]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,12 +107,12 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
|
|||||||
// pressureTemp[IX(x,y,DIM-1)] = pressureCache[IX(x,y,DIM-1)];
|
// pressureTemp[IX(x,y,DIM-1)] = pressureCache[IX(x,y,DIM-1)];
|
||||||
|
|
||||||
//divergence borders
|
//divergence borders
|
||||||
phi0[IX(0,x,y)] = divArr[IX(0,x,y)];
|
phi0[IX(0,x,y)] = divCache[IX(0,x,y)];
|
||||||
phi0[IX(DIM-1,x,y)] = divArr[IX(DIM-1,x,y)];
|
phi0[IX(DIM-1,x,y)] = divCache[IX(DIM-1,x,y)];
|
||||||
phi0[IX(x,0,y)] = divArr[IX(x,0,y)];
|
phi0[IX(x,0,y)] = divCache[IX(x,0,y)];
|
||||||
phi0[IX(x,DIM-1,y)] = divArr[IX(x,DIM-1,y)];
|
phi0[IX(x,DIM-1,y)] = divCache[IX(x,DIM-1,y)];
|
||||||
phi0[IX(x,y,0)] = divArr[IX(x,y,0)];
|
phi0[IX(x,y,0)] = divCache[IX(x,y,0)];
|
||||||
phi0[IX(x,y,DIM-1)] = divArr[IX(x,y,DIM-1)];
|
phi0[IX(x,y,DIM-1)] = divCache[IX(x,y,DIM-1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float a = 1;
|
float a = 1;
|
||||||
|
|||||||
@ -90,7 +90,7 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
|||||||
// fflush(stdout);
|
// fflush(stdout);
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
//uTemp->u
|
//uTemp->u0
|
||||||
pressurecell_diffuse_velocity(environment,currentChunk);
|
pressurecell_diffuse_velocity(environment,currentChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
|||||||
// fflush(stdout);
|
// fflush(stdout);
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
//u->uTemp
|
//u0->uTemp
|
||||||
pressurecell_advect_velocity(environment,currentChunk);
|
pressurecell_advect_velocity(environment,currentChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,9 +54,9 @@ LIBRARY_API void pressurecell_add_velocity(Environment * environment, Chunk * ch
|
|||||||
LIBRARY_API void pressurecell_diffuse_velocity(Environment * environment, Chunk * chunk){
|
LIBRARY_API void pressurecell_diffuse_velocity(Environment * environment, Chunk * chunk){
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
float * dArr = chunk->d[CENTER_LOC];
|
float * dArr = chunk->d[CENTER_LOC];
|
||||||
float * uArr = chunk->u[CENTER_LOC];
|
float * uArr = chunk->u0[CENTER_LOC];
|
||||||
float * vArr = chunk->v[CENTER_LOC];
|
float * vArr = chunk->v0[CENTER_LOC];
|
||||||
float * wArr = chunk->w[CENTER_LOC];
|
float * wArr = chunk->w0[CENTER_LOC];
|
||||||
float * uTemp = chunk->uTempCache;
|
float * uTemp = chunk->uTempCache;
|
||||||
float * vTemp = chunk->vTempCache;
|
float * vTemp = chunk->vTempCache;
|
||||||
float * wTemp = chunk->wTempCache;
|
float * wTemp = chunk->wTempCache;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user