fix fluid dispatch array deref
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
89b4fbb862
commit
c022ee1206
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Fri Dec 06 15:07:16 EST 2024
|
||||
buildNumber=525
|
||||
#Fri Dec 06 15:38:11 EST 2024
|
||||
buildNumber=526
|
||||
|
||||
@ -1254,6 +1254,7 @@ More test file refactoring
|
||||
Native fluid chunk dispatcher
|
||||
Dedicated native fluid simulator
|
||||
Define cellular simulator
|
||||
Fix fluid dispatcher array deref
|
||||
|
||||
|
||||
|
||||
|
||||
13
src/main/c/includes/fluid/env/environment.h
vendored
13
src/main/c/includes/fluid/env/environment.h
vendored
@ -60,6 +60,15 @@ typedef struct {
|
||||
float dt;
|
||||
} FluidSimConsts;
|
||||
|
||||
/**
|
||||
* Used for tracking the change in density over time of the environment
|
||||
*/
|
||||
typedef struct {
|
||||
double existingDensity;
|
||||
double newDensity;
|
||||
float normalizationRatio;
|
||||
} FluidDensityTracking;
|
||||
|
||||
/**
|
||||
* Stores data about the simulation environment
|
||||
*/
|
||||
@ -67,9 +76,7 @@ typedef struct {
|
||||
JNILookupTable lookupTable;
|
||||
FluidSimQueue queue;
|
||||
FluidSimConsts consts;
|
||||
double existingDensity;
|
||||
double newDensity;
|
||||
float normalizationRatio;
|
||||
FluidDensityTracking densityTracking;
|
||||
} Environment;
|
||||
|
||||
/**
|
||||
|
||||
@ -13,23 +13,22 @@
|
||||
* @param environment The environment storing the simulation queues
|
||||
*/
|
||||
LIBRARY_API void fluid_dispatch(int numReadIn, Chunk ** chunkViewC, Environment * environment){
|
||||
FluidSimQueue queue = environment->queue;
|
||||
//clear queues
|
||||
int countCurrent;
|
||||
countCurrent = stbds_arrlen(queue.cellularQueue);
|
||||
countCurrent = arrlen(environment->queue.cellularQueue);
|
||||
if(countCurrent > 0){
|
||||
stbds_arrdeln(queue.cellularQueue,0,countCurrent);
|
||||
arrdeln(environment->queue.cellularQueue,0,countCurrent);
|
||||
}
|
||||
countCurrent = stbds_arrlen(queue.gridQueue);
|
||||
countCurrent = arrlen(environment->queue.gridQueue);
|
||||
if(countCurrent > 0){
|
||||
stbds_arrdeln(queue.gridQueue,0,countCurrent);
|
||||
arrdeln(environment->queue.gridQueue,0,countCurrent);
|
||||
}
|
||||
|
||||
//queue new chunks
|
||||
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)
|
||||
stbds_arrput(queue.gridQueue,currentChunk);
|
||||
arrput(environment->queue.gridQueue,currentChunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -98,9 +98,9 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate
|
||||
|
||||
//store variables from java side
|
||||
environment->consts.gravity = gravity;
|
||||
environment->existingDensity = 0;
|
||||
environment->newDensity = 0;
|
||||
environment->normalizationRatio = 0;
|
||||
environment->densityTracking.existingDensity = 0;
|
||||
environment->densityTracking.newDensity = 0;
|
||||
environment->densityTracking.normalizationRatio = 0;
|
||||
|
||||
//store jni lookup tables
|
||||
jclass listClass = (*env)->FindClass(env,"java/util/List");
|
||||
|
||||
@ -88,7 +88,7 @@ void updateMetadata(JNIEnv * env, int numChunks, Chunk ** passedInChunks, Enviro
|
||||
}
|
||||
|
||||
//alert java side to updated static values
|
||||
float normalizationRatio = environment->normalizationRatio;
|
||||
float normalizationRatio = environment->densityTracking.normalizationRatio;
|
||||
(*env)->SetStaticFloatField(env,environment->lookupTable.serverFluidChunkClass,environment->lookupTable.serverFluidChunkTable.normalizationRatioId,normalizationRatio);
|
||||
}
|
||||
|
||||
|
||||
@ -26,8 +26,8 @@ void addDensity(
|
||||
float * x = GET_ARR_RAW(d,CENTER_LOC);
|
||||
float * s = GET_ARR_RAW(d0,CENTER_LOC);
|
||||
for(i=0; i<size; i++){
|
||||
environment->newDensity = environment->newDensity + dt * s[i];
|
||||
environment->existingDensity = environment->existingDensity + x[i];
|
||||
environment->densityTracking.newDensity = environment->densityTracking.newDensity + dt * s[i];
|
||||
environment->densityTracking.existingDensity = environment->densityTracking.existingDensity + x[i];
|
||||
x[i] += dt*s[i];
|
||||
if(x[i] < MIN_VALUE){
|
||||
x[i] = MIN_VALUE;
|
||||
|
||||
@ -445,8 +445,8 @@ void fluid_grid_simulate(
|
||||
//add density
|
||||
{
|
||||
double deltaDensity = 0;
|
||||
environment->existingDensity = 0;
|
||||
environment->newDensity = 0;
|
||||
environment->densityTracking.existingDensity = 0;
|
||||
environment->densityTracking.newDensity = 0;
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
addDensity(environment,DIM,currentChunk->chunkMask,currentChunk->d,currentChunk->d0,timestep);
|
||||
@ -525,8 +525,8 @@ void fluid_grid_simulate(
|
||||
}
|
||||
float normalizationRatio = 0;
|
||||
if(transformedDensity != 0){
|
||||
normalizationRatio = (environment->existingDensity + environment->newDensity) / transformedDensity;
|
||||
environment->normalizationRatio = normalizationRatio;
|
||||
normalizationRatio = (environment->densityTracking.existingDensity + environment->densityTracking.newDensity) / transformedDensity;
|
||||
environment->densityTracking.normalizationRatio = normalizationRatio;
|
||||
}
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
|
||||
#include "stb/stb_ds.h"
|
||||
|
||||
#include "fluid/dispatch/dispatcher.h"
|
||||
#include "fluid/env/environment.h"
|
||||
|
||||
#include "../../util/chunk_test_utils.h"
|
||||
#include "../../util/test.h"
|
||||
|
||||
int fluid_dispatch_dispatcher_tests(){
|
||||
int rVal = 0;
|
||||
@ -13,5 +16,8 @@ int fluid_dispatch_dispatcher_tests(){
|
||||
Chunk ** queue = chunk_create_queue(queueSize);
|
||||
fluid_dispatch(queueSize,queue,env);
|
||||
|
||||
int gridChunksFound = stbds_arrlen(env->queue.gridQueue);
|
||||
rVal += assertEquals(gridChunksFound,queueSize,"should have 10 queued chunks -- %d %d \n");
|
||||
|
||||
return rVal;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user