work on cellular sim
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
86da26675f
commit
9861ff4af6
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Fri Dec 06 19:29:52 EST 2024
|
||||
buildNumber=570
|
||||
#Fri Dec 06 19:51:41 EST 2024
|
||||
buildNumber=579
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
#include "fluid/env/utilities.h"
|
||||
|
||||
|
||||
#define FLUID_CELLULAR_DIFFUSE_RATE 0.001
|
||||
|
||||
/**
|
||||
* Simulates the cellular chunk queue
|
||||
* @param environment The environment storing the simulation queues
|
||||
@ -22,11 +24,32 @@ LIBRARY_API void fluid_cellular_simulate(Environment * environment){
|
||||
float * d = currentChunk->d[CENTER_LOC];
|
||||
float * bounds = currentChunk->bounds[CENTER_LOC];
|
||||
|
||||
// printf("%f %d %d %d\n",bounds[IX(1,0,1)],currentChunk->x,currentChunk->y,currentChunk->z);
|
||||
for(int x = 1; x < DIM-1; x++){
|
||||
for(int y = 1; y < DIM-1; y++){
|
||||
for(int z = 1; z < DIM-1; z++){
|
||||
|
||||
//diffuse density
|
||||
d[IX(x,y,z)] = d[IX(x,y,z)];
|
||||
if(x > 1){
|
||||
d[IX(x,y,z)] += (d[IX(x-1,y,z)] - d[IX(x,y,z)]) * FLUID_CELLULAR_DIFFUSE_RATE;
|
||||
}
|
||||
if(x < DIM-2){
|
||||
d[IX(x,y,z)] += (d[IX(x+1,y,z)] - d[IX(x,y,z)]) * FLUID_CELLULAR_DIFFUSE_RATE;
|
||||
}
|
||||
if(y > 1){
|
||||
d[IX(x,y,z)] += (d[IX(x,y-1,z)] - d[IX(x,y,z)]) * FLUID_CELLULAR_DIFFUSE_RATE;
|
||||
}
|
||||
if(y < DIM-2){
|
||||
d[IX(x,y,z)] += (d[IX(x,y+1,z)] - d[IX(x,y,z)]) * FLUID_CELLULAR_DIFFUSE_RATE;
|
||||
}
|
||||
if(z > 1){
|
||||
d[IX(x,y,z)] += (d[IX(x,y,z-1)] - d[IX(x,y,z)]) * FLUID_CELLULAR_DIFFUSE_RATE;
|
||||
}
|
||||
if(z < DIM-2){
|
||||
d[IX(x,y,z)] += (d[IX(x,y,z+1)] - d[IX(x,y,z)]) * FLUID_CELLULAR_DIFFUSE_RATE;
|
||||
}
|
||||
if(d[IX(x,y,z)] <= 0){
|
||||
continue;
|
||||
} else {
|
||||
//transfer straight down
|
||||
if(bounds[IX(x,y-1,z)] <= BOUND_CUTOFF_VALUE){
|
||||
@ -42,27 +65,6 @@ LIBRARY_API void fluid_cellular_simulate(Environment * environment){
|
||||
d[IX(x,y-1,z)] += transferLower;
|
||||
}
|
||||
}
|
||||
//transfer laterally if available
|
||||
//propagate sideways
|
||||
int offsetX[5] = {-1,1,0,0};
|
||||
int offsetZ[5] = {0,0,-1,1};
|
||||
for(int i = 0; i < 4; i++){
|
||||
int nX = x + offsetX[i];
|
||||
int nZ = z + offsetZ[i];
|
||||
if(bounds[IX(nX,y,nZ)] <= BOUND_CUTOFF_VALUE){
|
||||
float deltaLateral = d[IX(x,y,z)] - d[IX(nX,y,nZ)];
|
||||
if(deltaLateral > 0){
|
||||
float transferLateral;
|
||||
if(d[IX(x,y,z)] >= deltaLateral){
|
||||
transferLateral = deltaLateral;
|
||||
} else {
|
||||
transferLateral = d[IX(x,y,z)];
|
||||
}
|
||||
d[IX(x,y,z)] -= transferLateral;
|
||||
d[IX(nX,y,nZ)] += transferLateral;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user