const change + promising results
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-12-17 16:23:11 -05:00
parent 06502e665e
commit de3e29c99e
4 changed files with 24 additions and 26 deletions

View File

@ -10,7 +10,7 @@
/**
* Spacing of cells
*/
#define FLUID_PRESSURECELL_SPACING 1.0f
#define FLUID_PRESSURECELL_SPACING (1.0f/DIM)
/**
* Multiplier applied to pressure calculations to encourage advection
@ -25,12 +25,12 @@
/**
* Diffusion constant
*/
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.1f
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.01f
/**
* Viscosity constant
*/
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.1f
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.01f
/**
* Amount of the residual to add to the pressure field each frame
@ -52,15 +52,15 @@
*/
#define FLUID_PRESSURECELL_PROJECTION_CONVERGENCE_TOLERANCE 0.01f
/**
* The minimum pressure allowed
*/
#define FLUID_PRESSURECELL_MIN_PRESSURE -10000.0f
/**
* The maximum pressure allowed
*/
#define FLUID_PRESSURECELL_MAX_PRESSURE 10000.0f
#define FLUID_PRESSURECELL_MAX_PRESSURE 1000.0f
/**
* The minimum pressure allowed
*/
#define FLUID_PRESSURECELL_MIN_PRESSURE -FLUID_PRESSURECELL_MAX_PRESSURE
/**
* Percentage of presure to keep from last frame

View File

@ -71,9 +71,9 @@ LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * c
LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk * chunk){
int x, y;
float * dArr = chunk->d[CENTER_LOC];
float * uArr = chunk->u[CENTER_LOC];
float * vArr = chunk->v[CENTER_LOC];
float * wArr = chunk->w[CENTER_LOC];
float * uArr = chunk->uTempCache;
float * vArr = chunk->vTempCache;
float * wArr = chunk->wTempCache;
int ghostIndex, adjacentIndex;
float overdraw, estimatedLoss, invertedForce;
//clear neighbor outgoing values

View File

@ -157,7 +157,7 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
for(z = 1; z < DIM-1; z++){
for(y = 1; y < DIM-1; y++){
for(x = 1; x < DIM; x++){
if(pressureTemp[IX(x,y,z)] > 10000.0f){
if(pressureTemp[IX(x,y,z)] > FLUID_PRESSURECELL_MAX_PRESSURE){
printf("Invalid pressure!\n");
printf("%f %f \n", phi0[IX(x-1,y,z)], phi0[IX(x+1,y,z)]);
printf("\n");
@ -202,12 +202,14 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
for(z = 1; z < DIM-1; z++){
for(y = 1; y < DIM-1; y++){
for(x = 1; x < DIM; x++){
if(pressureTemp[IX(x,y,z)] > pressureMax){
if(fabs(pressureTemp[IX(x,y,z)]) > pressureMax){
pressureMax = pressureTemp[IX(x,y,z)];
}
}
}
}
if(pressureMax > FLUID_PRESSURECELL_MAX_PRESSURE){
printf("pressureMax: %f \n",pressureMax);
for(z = 1; z < DIM-1; z++){
for(y = 1; y < DIM-1; y++){
for(x = 1; x < DIM; x++){
@ -217,6 +219,7 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
}
}
}
}
//do NOT zero out pressure on edges
//this will cause the fluid to advect into the walls

View File

@ -107,12 +107,6 @@ LIBRARY_API void fluid_pressurecell_simulate(
pressurecell_advect_velocity(environment,currentChunk);
}
for(int i = 0; i < numChunks; i++){
Chunk * currentChunk = chunks[i];
//uTemp->div
pressurecell_enforce_bounds(environment,currentChunk);
}
// printf("approx div\n");
// fflush(stdout);
for(int i = 0; i < numChunks; i++){
@ -144,8 +138,10 @@ LIBRARY_API void fluid_pressurecell_simulate(
// printf("adv dens\n");
// fflush(stdout);
for(int i = 0; i < numChunks; i++){
//uTemp->d
Chunk * currentChunk = chunks[i];
pressurecell_advect_density(environment,currentChunk);
fluid_pressurecell_recapture_density(environment,currentChunk);
}
@ -159,7 +155,6 @@ LIBRARY_API void fluid_pressurecell_simulate(
for(int i = 0; i < numChunks; i++){
Chunk * currentChunk = chunks[i];
fluid_pressurecell_normalize_chunk(environment,currentChunk);
fluid_pressurecell_recapture_density(environment,currentChunk);
pressurecell_copy_for_next_frame(environment,currentChunk);
fluid_pressurecell_clearArr(currentChunk->d0[CENTER_LOC]);
fluid_pressurecell_clearArr(currentChunk->u0[CENTER_LOC]);