bring back chunk mask
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
27fe4e12a5
commit
37093a2ebe
@ -1,4 +1,5 @@
|
|||||||
@page fluidsimindex Fluid Simulation Architecture
|
@page fluidsimindex Fluid Simulation Architecture
|
||||||
|
|
||||||
[TOC]
|
[TOC]
|
||||||
- @subpage fluidsimarchoverview
|
- @subpage fluidsimarchoverview
|
||||||
|
- @subpage fluidsimnotes
|
||||||
36
docs/src/architecture/fluidsim/fluidsimnotes.md
Normal file
36
docs/src/architecture/fluidsim/fluidsimnotes.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@page fluidsimnotes Fluid Sim Notes
|
||||||
|
|
||||||
|
|
||||||
|
approaches to improve speed
|
||||||
|
- Multithreading
|
||||||
|
- Caching phi values between evaluations to precompute multigrid or whatever solver we're using
|
||||||
|
- When precomputing phi, factor in density/gravity/whatever to get a better guess
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
multigrid improvements
|
||||||
|
loading/unloading
|
||||||
|
https://stackoverflow.com/questions/46468026/fast-copy-every-second-byte-to-new-memory-area
|
||||||
|
|
||||||
|
|
||||||
|
Pressure caching
|
||||||
|
Cache value of phi from projection on previous frame (gonna have to do this per chunk (yikes!))
|
||||||
|
Use this to populate neighbors for next frame
|
||||||
|
|
||||||
|
|
||||||
|
internal boundaries approach 1
|
||||||
|
calculate a normal mask from border values
|
||||||
|
normal uses 3x3x3 sample of border mask to generate an index into a lookup table that contains the normal
|
||||||
|
(think marching cubes)
|
||||||
|
could probably parallelize this by calculating it in parts
|
||||||
|
ie, grab -1,-1,-1 for a whole bunch, then -1,-1,0 for a whole bunch, etc
|
||||||
|
|
||||||
|
|
||||||
|
edge boundaries
|
||||||
|
"warm up" empty chunks by adding velocity to the edges of an empty chunk where it borders a non-empty chunk
|
||||||
|
|
||||||
|
extension of the "warm up" idea
|
||||||
|
Run minified solver that just performs velocity step (no density)
|
||||||
|
when advecting, check if density is at the advection position
|
||||||
|
if there is density, pull it along as well and fully activate the empty chunk
|
||||||
@ -1,11 +1,11 @@
|
|||||||
#include <jni.h>
|
|
||||||
|
|
||||||
//Must be included for public functions to be imported/exported on windows
|
|
||||||
#include "public.h"
|
|
||||||
|
|
||||||
#ifndef CHUNK_H
|
#ifndef CHUNK_H
|
||||||
#define CHUNK_H
|
#define CHUNK_H
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "public.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum fluid value
|
* The minimum fluid value
|
||||||
*/
|
*/
|
||||||
@ -49,7 +49,7 @@ typedef struct {
|
|||||||
float * v0[27];
|
float * v0[27];
|
||||||
float * w0[27];
|
float * w0[27];
|
||||||
float * bounds[27];
|
float * bounds[27];
|
||||||
int chunkMask;
|
uint32_t chunkMask;
|
||||||
jobject chunkJRaw;
|
jobject chunkJRaw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#ifndef CHUNKMASK_H
|
#ifndef CHUNKMASK_H
|
||||||
#define CHUNKMASK_H
|
#define CHUNKMASK_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of entries in the neighbor array
|
* The number of entries in the neighbor array
|
||||||
*/
|
*/
|
||||||
@ -50,4 +50,9 @@ extern const char CHUNK_NORMALIZE_V[];
|
|||||||
|
|
||||||
extern const char CHUNK_NORMALIZE_W[];
|
extern const char CHUNK_NORMALIZE_W[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the bitmask for available chunks for the provided chunk's neighbor array
|
||||||
|
*/
|
||||||
|
LIBRARY_API uint32_t calculateChunkMask(JNIEnv * env, jobjectArray jrx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,4 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
#include "fluid/env/utilities.h"
|
#include "fluid/env/utilities.h"
|
||||||
#include "fluid/queue/chunkmask.h"
|
#include "fluid/queue/chunkmask.h"
|
||||||
@ -59,4 +60,48 @@ const char CHUNK_NORMALIZE_W[] = {
|
|||||||
-1, -1, -1,
|
-1, -1, -1,
|
||||||
-1, -1, -1,
|
-1, -1, -1,
|
||||||
-1, -1, -1,
|
-1, -1, -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates a mask that represents all nearby chunks that are actually accessible and exist
|
||||||
|
*/
|
||||||
|
uint32_t matrix_transform(JNIEnv * env, jobjectArray jrx){
|
||||||
|
|
||||||
|
//The returned value, an availability mask that contains the availability of each neighbor chunk
|
||||||
|
uint32_t rVal = 0;
|
||||||
|
|
||||||
|
//Add to maks for initial chunks
|
||||||
|
for(int i = 0; i < CENTER_LOC; i++){
|
||||||
|
if((*env)->GetObjectArrayElement(env,jrx,i)!=NULL){
|
||||||
|
rVal = rVal + 1;
|
||||||
|
}
|
||||||
|
rVal = rVal << 1;
|
||||||
|
}
|
||||||
|
//add 1 for center chunk because we already have that
|
||||||
|
rVal = rVal + 1;
|
||||||
|
rVal = rVal << 1;
|
||||||
|
//continue on for remaining chunks
|
||||||
|
for(int i = CENTER_LOC+1; i < 27; i++){
|
||||||
|
if((*env)->GetObjectArrayElement(env,jrx,i)!=NULL){
|
||||||
|
rVal = rVal + 1;
|
||||||
|
}
|
||||||
|
if(i < 26){
|
||||||
|
rVal = rVal << 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the bitmask for available chunks for the provided chunk's neighbor array
|
||||||
|
*/
|
||||||
|
LIBRARY_API uint32_t calculateChunkMask(JNIEnv * env, jobjectArray jrx){
|
||||||
|
return matrix_transform(env,jrx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,8 +31,6 @@
|
|||||||
|
|
||||||
//declarations
|
//declarations
|
||||||
int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment);
|
int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment);
|
||||||
int calculateChunkMask(JNIEnv * env, jobjectArray jrx);
|
|
||||||
uint32_t matrix_transform(JNIEnv * env, jobjectArray jrx);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -274,40 +272,3 @@ void * getArray(JNIEnv * env, jobjectArray arr, int index){
|
|||||||
return (*env)->GetDirectBufferAddress(env,arrayEl);
|
return (*env)->GetDirectBufferAddress(env,arrayEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the bitmask for available chunks for the provided chunk's neighbor array
|
|
||||||
*/
|
|
||||||
int calculateChunkMask(JNIEnv * env, jobjectArray jrx){
|
|
||||||
return matrix_transform(env,jrx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates a mask that represents all nearby chunks that are actually accessible and exist
|
|
||||||
*/
|
|
||||||
uint32_t matrix_transform(JNIEnv * env, jobjectArray jrx){
|
|
||||||
|
|
||||||
//The returned value, an availability mask that contains the availability of each neighbor chunk
|
|
||||||
uint32_t rVal = 0;
|
|
||||||
|
|
||||||
//Add to maks for initial chunks
|
|
||||||
for(int i = 0; i < CENTER_LOC; i++){
|
|
||||||
if((*env)->GetObjectArrayElement(env,jrx,i)!=NULL){
|
|
||||||
rVal = rVal + 1;
|
|
||||||
}
|
|
||||||
rVal = rVal << 1;
|
|
||||||
}
|
|
||||||
//add 1 for center chunk because we already have that
|
|
||||||
rVal = rVal + 1;
|
|
||||||
rVal = rVal << 1;
|
|
||||||
//continue on for remaining chunks
|
|
||||||
for(int i = CENTER_LOC+1; i < 27; i++){
|
|
||||||
if((*env)->GetObjectArrayElement(env,jrx,i)!=NULL){
|
|
||||||
rVal = rVal + 1;
|
|
||||||
}
|
|
||||||
if(i < 26){
|
|
||||||
rVal = rVal << 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user