add bound checking border transfer
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
e9ffee3c83
commit
382c8e05d6
@ -76,6 +76,92 @@ void fluid_pressurecell_set_bounds_legacy(
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bounds reflecting off hard borders and otherwise assuming continuity
|
||||
*/
|
||||
void fluid_pressurecell_set_bounds_chunked(
|
||||
Environment * environment,
|
||||
int vector_dir,
|
||||
float * target,
|
||||
float * boundDir
|
||||
){
|
||||
//set the boundary planes
|
||||
for(int x = 1; x < DIM-1; x++){
|
||||
for(int y = 1; y < DIM-1; y++){
|
||||
|
||||
//x-direction boundary planes
|
||||
if(vector_dir == FLUID_PRESSURECELL_DIRECTION_U){
|
||||
if(boundDir[IX(0,x,y)] < BOUND_CUTOFF_VALUE){
|
||||
target[IX(0,x,y)] = -target[IX(1,x,y)];
|
||||
}
|
||||
if(boundDir[IX(DIM-1,x,y)] < BOUND_CUTOFF_VALUE){
|
||||
target[IX(DIM-1,x,y)] = -target[IX(DIM-2,x,y)];
|
||||
}
|
||||
} else {
|
||||
target[IX(0,x,y)] = target[IX(1,x,y)];
|
||||
target[IX(DIM-1,x,y)] = target[IX(DIM-2,x,y)];
|
||||
}
|
||||
|
||||
//y-direction boundary planes
|
||||
if(vector_dir == FLUID_PRESSURECELL_DIRECTION_V){
|
||||
if(boundDir[IX(x,0,y)] < BOUND_CUTOFF_VALUE){
|
||||
target[IX(x,0,y)] = -target[IX(x,1,y)];
|
||||
}
|
||||
if(boundDir[IX(x,DIM-1,y)] < BOUND_CUTOFF_VALUE){
|
||||
target[IX(x,DIM-1,y)] = -target[IX(x,DIM-2,y)];
|
||||
}
|
||||
} else {
|
||||
target[IX(x,0,y)] = target[IX(x,1,y)];
|
||||
target[IX(x,DIM-1,y)] = target[IX(x,DIM-2,y)];
|
||||
}
|
||||
|
||||
//z-direction boundary planes
|
||||
if(vector_dir == FLUID_PRESSURECELL_DIRECTION_W){
|
||||
if(boundDir[IX(x,y,0)] < BOUND_CUTOFF_VALUE){
|
||||
target[IX(x,y,0)] = -target[IX(x,y,1)];
|
||||
}
|
||||
if(boundDir[IX(x,y,DIM-1)] < BOUND_CUTOFF_VALUE){
|
||||
target[IX(x,y,DIM-1)] = -target[IX(x,y,DIM-2)];
|
||||
}
|
||||
} else {
|
||||
target[IX(x,y,0)] = target[IX(x,y,1)];
|
||||
target[IX(x,y,DIM-1)] = target[IX(x,y,DIM-2)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//sets the edges of the chunk
|
||||
//this should logically follow from how we're treating the boundary planes
|
||||
for(int x = 1; x < DIM-1; x++){
|
||||
target[IX(x,0,0)] = (float)(0.5f * (target[IX(x,1,0)] + target[IX(x,0,1)]));
|
||||
target[IX(x,DIM-1,0)] = (float)(0.5f * (target[IX(x,DIM-2,0)] + target[IX(x,DIM-1,1)]));
|
||||
target[IX(x,0,DIM-1)] = (float)(0.5f * (target[IX(x,1,DIM-1)] + target[IX(x,0,DIM-2)]));
|
||||
target[IX(x,DIM-1,DIM-1)] = (float)(0.5f * (target[IX(x,DIM-2,DIM-1)] + target[IX(x,DIM-1,DIM-2)]));
|
||||
|
||||
target[IX(0,x,0)] = (float)(0.5f * (target[IX(1,x,0)] + target[IX(0,x,1)]));
|
||||
target[IX(DIM-1,x,0)] = (float)(0.5f * (target[IX(DIM-2,x,0)] + target[IX(DIM-1,x,1)]));
|
||||
target[IX(0,x,DIM-1)] = (float)(0.5f * (target[IX(1,x,DIM-1)] + target[IX(0,x,DIM-2)]));
|
||||
target[IX(DIM-1,x,DIM-1)] = (float)(0.5f * (target[IX(DIM-2,x,DIM-1)] + target[IX(DIM-1,x,DIM-2)]));
|
||||
|
||||
|
||||
target[IX(0,0,x)] = (float)(0.5f * (target[IX(1,0,x)] + target[IX(0,1,x)]));
|
||||
target[IX(DIM-1,0,x)] = (float)(0.5f * (target[IX(DIM-2,0,x)] + target[IX(DIM-1,1,x)]));
|
||||
target[IX(0,DIM-1,x)] = (float)(0.5f * (target[IX(1,DIM-1,x)] + target[IX(0,DIM-2,x)]));
|
||||
target[IX(DIM-1,DIM-1,x)] = (float)(0.5f * (target[IX(DIM-2,DIM-1,x)] + target[IX(DIM-1,DIM-2,x)]));
|
||||
|
||||
}
|
||||
//sets the corners of the chunk
|
||||
//this should logically follow from how we're treating the boundary planes
|
||||
target[IX(0,0,0)] = (float)((target[IX(1,0,0)]+target[IX(0,1,0)]+target[IX(0,0,1)])/3.0);
|
||||
target[IX(DIM-1,0,0)] = (float)((target[IX(DIM-2,0,0)]+target[IX(DIM-1,1,0)]+target[IX(DIM-1,0,1)])/3.0);
|
||||
target[IX(0,DIM-1,0)] = (float)((target[IX(1,DIM-1,0)]+target[IX(0,DIM-2,0)]+target[IX(0,DIM-1,1)])/3.0);
|
||||
target[IX(0,0,DIM-1)] = (float)((target[IX(0,0,DIM-2)]+target[IX(1,0,DIM-1)]+target[IX(0,1,DIM-1)])/3.0);
|
||||
target[IX(DIM-1,DIM-1,0)] = (float)((target[IX(DIM-2,DIM-1,0)]+target[IX(DIM-1,DIM-2,0)]+target[IX(DIM-1,DIM-1,1)])/3.0);
|
||||
target[IX(0,DIM-1,DIM-1)] = (float)((target[IX(1,DIM-1,DIM-1)]+target[IX(0,DIM-2,DIM-1)]+target[IX(0,DIM-1,DIM-2)])/3.0);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bounds to 0
|
||||
*/
|
||||
@ -143,6 +229,10 @@ LIBRARY_API void fluid_pressurecell_update_bounds(Environment * environment, Chu
|
||||
fluid_pressurecell_set_bounds_legacy(environment,FLUID_PRESSURECELL_DIRECTION_V,chunk->v[CENTER_LOC]);
|
||||
fluid_pressurecell_set_bounds_legacy(environment,FLUID_PRESSURECELL_DIRECTION_W,chunk->w[CENTER_LOC]);
|
||||
|
||||
// fluid_pressurecell_set_bounds_chunked(environment,FLUID_PRESSURECELL_DIRECTION_U,chunk->u[CENTER_LOC],chunk->bounds[CENTER_LOC]);
|
||||
// fluid_pressurecell_set_bounds_chunked(environment,FLUID_PRESSURECELL_DIRECTION_V,chunk->v[CENTER_LOC],chunk->bounds[CENTER_LOC]);
|
||||
// fluid_pressurecell_set_bounds_chunked(environment,FLUID_PRESSURECELL_DIRECTION_W,chunk->w[CENTER_LOC],chunk->bounds[CENTER_LOC]);
|
||||
|
||||
fluid_pressurecell_set_bounds_zero(environment,FLUID_PRESSURECELL_DIRECTION_U,chunk->u0[CENTER_LOC]);
|
||||
fluid_pressurecell_set_bounds_zero(environment,FLUID_PRESSURECELL_DIRECTION_V,chunk->v0[CENTER_LOC]);
|
||||
fluid_pressurecell_set_bounds_zero(environment,FLUID_PRESSURECELL_DIRECTION_W,chunk->w0[CENTER_LOC]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user