condense normalize loops
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
c3e319280a
commit
abb48d7a1a
@ -11,11 +11,6 @@
|
||||
*/
|
||||
LIBRARY_API void fluid_pressurecell_calculate_expected_intake(Environment * env, Chunk * chunk);
|
||||
|
||||
/**
|
||||
* Calculates the ratio to normalize the chunk by
|
||||
*/
|
||||
LIBRARY_API void fluid_pressurecell_calculate_normalization_ratio(Environment * env, Chunk * chunk);
|
||||
|
||||
/**
|
||||
* Normalizes the chunk
|
||||
*/
|
||||
|
||||
@ -26,10 +26,11 @@ LIBRARY_API void fluid_pressurecell_calculate_expected_intake(Environment * env,
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the ratio to normalize the chunk by
|
||||
* Normalizes the chunk
|
||||
*/
|
||||
LIBRARY_API void fluid_pressurecell_calculate_normalization_ratio(Environment * env, Chunk * chunk){
|
||||
LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * chunk){
|
||||
int x, y, z;
|
||||
//calculate ratio
|
||||
double sum;
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
@ -39,7 +40,6 @@ LIBRARY_API void fluid_pressurecell_calculate_normalization_ratio(Environment *
|
||||
}
|
||||
}
|
||||
double expected = chunk->pressureCellData.densitySum;
|
||||
env->state.existingDensity = env->state.existingDensity + expected;
|
||||
if(sum > 0){
|
||||
double normalizationRatio = expected / sum;
|
||||
chunk->pressureCellData.normalizationRatio = normalizationRatio;
|
||||
@ -49,13 +49,7 @@ LIBRARY_API void fluid_pressurecell_calculate_normalization_ratio(Environment *
|
||||
}
|
||||
chunk->pressureCellData.normalizationRatio = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the chunk
|
||||
*/
|
||||
LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * chunk){
|
||||
int x, y, z;
|
||||
//apply ratio
|
||||
double ratio = chunk->pressureCellData.normalizationRatio;
|
||||
for(x = 1; x < DIM-1; x++){
|
||||
for(y = 1; y < DIM-1; y++){
|
||||
@ -64,6 +58,8 @@ LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * c
|
||||
}
|
||||
}
|
||||
}
|
||||
//metadata work
|
||||
env->state.existingDensity = env->state.existingDensity + expected;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -145,16 +145,20 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Normalization Phase
|
||||
//
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
fluid_pressurecell_normalize_chunk(environment,currentChunk);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Setup for next iteration
|
||||
//
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
fluid_pressurecell_calculate_normalization_ratio(environment,currentChunk);
|
||||
}
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
fluid_pressurecell_normalize_chunk(environment,currentChunk);
|
||||
pressurecell_copy_for_next_frame(environment,currentChunk);
|
||||
fluid_pressurecell_clearArr(currentChunk->d0[CENTER_LOC]);
|
||||
fluid_pressurecell_clearArr(currentChunk->u0[CENTER_LOC]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user