pressurecell work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-14 00:27:03 -05:00
parent eba3bbe0ca
commit eb845a3891
7 changed files with 48 additions and 2 deletions

View File

@ -10,6 +10,8 @@
#define FLUID_DISPATCHER_OVERRIDE_CELLULAR 1
#define FLUID_DISPATCHER_OVERRIDE_GRID2 1
/**
* Dispatches chunks to different simulation queues based on the chunk's properties

View File

@ -59,6 +59,7 @@ typedef struct {
Chunk ** cellularQueue;
Chunk ** gridQueue;
Chunk ** grid2Queue;
Chunk ** pressurecellQueue;
} FluidSimQueue;
/**

View File

@ -7,6 +7,12 @@
#include "fluid/queue/chunkmask.h"
/**
* Adds velocity from the delta buffer to this chunk
*/
LIBRARY_API void pressurecell_add_gravity(Environment * environment, Chunk * chunk);
/**
* Adds velocity from the delta buffer to this chunk
*/

View File

@ -44,7 +44,8 @@ LIBRARY_API void fluid_dispatch(int numReadIn, Chunk ** chunkViewC, Environment
for(int i = 0; i < numReadIn; i++){
Chunk * currentChunk = chunkViewC[i];
//TODO: conditionally add to queues based on some values (ie lod, spatial loc, etc)
arrput(environment->queue.grid2Queue,currentChunk);
arrput(environment->queue.pressurecellQueue,currentChunk);
}
}

View File

@ -39,6 +39,11 @@ LIBRARY_API void fluid_pressurecell_simulate(
// Velocity phase
//
for(int i = 0; i < numChunks; i++){
Chunk * currentChunk = chunks[i];
pressurecell_add_gravity(environment,currentChunk);
}
for(int i = 0; i < numChunks; i++){
Chunk * currentChunk = chunks[i];
pressurecell_add_velocity(environment,currentChunk);

View File

@ -3,6 +3,24 @@
#include "fluid/sim/pressurecell/solver_consts.h"
/**
* Adds velocity from the delta buffer to this chunk
*/
LIBRARY_API void pressurecell_add_gravity(Environment * environment, Chunk * chunk){
int x, y, z;
float * dArr = chunk->d[CENTER_LOC];
float * vArr = chunk->v[CENTER_LOC];
float * vSourceArr = chunk->v0[CENTER_LOC];
for(z = 1; z < DIM-1; z++){
for(y = 1; y < DIM-1; y++){
for(x = 1; x < DIM-1; x++){
vSourceArr[IX(x,y,z)] = vSourceArr[IX(x,y,z)] + dArr[IX(x,y,z)] * environment->consts.gravity * environment->consts.dt;
}
}
}
}
/**
* Adds velocity from the delta buffer to this chunk
*/
@ -126,7 +144,11 @@ LIBRARY_API void pressurecell_advect_velocity(Environment * environment, Chunk *
x1 < 0 || y1 < 0 || z1 < 0 ||
x1 > DIM-1 || y1 > DIM-1 || z1 > DIM-1
){
printf("advect dens: %d %d %d %d %d %d --- %f %f %f\n", x0, y0, z0, x1, y1, z1, x, y, z);
printf("advect vel: out of bounds \n");
printf("%d %d %d\n", x0, y0, z0);
printf("%d %d %d\n ", x1, y1, z1);
printf("%f %f %f\n", x, y, z);
printf("\n");
fflush(stdout);
}

View File

@ -6,6 +6,7 @@
#include "fluid/sim/simulator.h"
#include "fluid/sim/grid/simulation.h"
#include "fluid/sim/grid2/grid2.h"
#include "fluid/sim/pressurecell/pressurecell.h"
#include "fluid/sim/cellular/cellular.h"
#include "fluid/queue/chunk.h"
#include "fluid/env/environment.h"
@ -42,5 +43,13 @@ LIBRARY_API void fluid_simulate(Environment * environment){
fluid_grid2_simulate(currentCount,queue.grid2Queue,environment,environment->consts.dt);
}
}
//pressurecell sim
{
currentCount = stbds_arrlen(queue.pressurecellQueue);
if(currentCount > 0){
fluid_pressurecell_simulate(currentCount,queue.pressurecellQueue,environment,environment->consts.dt);
}
}
}