136 lines
2.4 KiB
C
136 lines
2.4 KiB
C
#include <jni.h>
|
|
|
|
//Must be included for public functions to be imported/exported on windows
|
|
#include "public.h"
|
|
|
|
#ifndef CHUNK_H
|
|
#define CHUNK_H
|
|
|
|
#define MIN_VALUE 0
|
|
#define MAX_VALUE 1
|
|
|
|
/**
|
|
* The dimension of a single chunk's array
|
|
*/
|
|
#define DIM 18
|
|
|
|
/**
|
|
* A chunk
|
|
*/
|
|
typedef struct {
|
|
float * d[27];
|
|
float * d0[27];
|
|
float * u[27];
|
|
float * v[27];
|
|
float * w[27];
|
|
float * u0[27];
|
|
float * v0[27];
|
|
float * w0[27];
|
|
int chunkMask;
|
|
jobject chunkJRaw;
|
|
} Chunk;
|
|
|
|
/**
|
|
* The size of the main array's real data
|
|
*/
|
|
#define MAIN_ARRAY_DIM 16
|
|
|
|
/**
|
|
* The number of chunks to place next to one another
|
|
*/
|
|
#define SPARSE_ARRAY_CHUNK_DIM 7
|
|
|
|
/**
|
|
* The total number of chunks in the chunk tracking array
|
|
*/
|
|
#define SPARSE_ARRAY_TOTAL_CHUNKS SPARSE_ARRAY_CHUNK_DIM * SPARSE_ARRAY_CHUNK_DIM * SPARSE_ARRAY_CHUNK_DIM
|
|
|
|
/**
|
|
* The extra values at the edges of the sparse array (to allow pulling data from borders)
|
|
*/
|
|
#define SPARSE_ARRAY_BORDER_SIZE 2
|
|
|
|
/**
|
|
* The size of the dimension of the memory of the sparse array
|
|
*/
|
|
#define SPARSE_ARRAY_RAW_DIM SPARSE_ARRAY_CHUNK_DIM * MAIN_ARRAY_DIM + SPARSE_ARRAY_BORDER_SIZE
|
|
|
|
/**
|
|
* The size of a sparse array in number of elements
|
|
*/
|
|
#define SPARSE_ARRAY_FULL_SIZE SPARSE_ARRAY_RAW_DIM * SPARSE_ARRAY_RAW_DIM * SPARSE_ARRAY_RAW_DIM
|
|
|
|
/**
|
|
* A set of sparse matricies for simulating fluids
|
|
*/
|
|
typedef struct {
|
|
|
|
/**
|
|
* The density array
|
|
*/
|
|
float * d;
|
|
|
|
/**
|
|
* The density delta array
|
|
*/
|
|
float * d0;
|
|
|
|
/**
|
|
* The x velocity array
|
|
*/
|
|
float * u;
|
|
|
|
/**
|
|
* The y velocity array
|
|
*/
|
|
float * v;
|
|
|
|
/**
|
|
* The z velocity array
|
|
*/
|
|
float * w;
|
|
|
|
/**
|
|
* The x velocity delta array
|
|
*/
|
|
float * u0;
|
|
|
|
/**
|
|
* The y velocity delta array
|
|
*/
|
|
float * v0;
|
|
|
|
/**
|
|
* The z velocity delta array
|
|
*/
|
|
float * w0;
|
|
|
|
/**
|
|
* The chunks inside the array
|
|
*/
|
|
Chunk ** chunks;
|
|
|
|
} SparseChunkArray;
|
|
|
|
|
|
/**
|
|
* Creates a sparse chunk array
|
|
*/
|
|
LIBRARY_API SparseChunkArray * fluid_create_sparse_array();
|
|
|
|
/**
|
|
* Frees a sparse chunk array
|
|
*/
|
|
LIBRARY_API void fluid_free_sparse_array(SparseChunkArray * array);
|
|
|
|
/**
|
|
* Adds a chunk to the sparse array
|
|
*/
|
|
LIBRARY_API void fluid_add_chunk(SparseChunkArray * array, Chunk * chunk, int x, int y, int z);
|
|
|
|
/**
|
|
* Adds a chunk to the sparse array
|
|
*/
|
|
LIBRARY_API void fluid_remove_chunk(SparseChunkArray * array, Chunk * chunk, int x, int y, int z, int copy);
|
|
|
|
#endif |