native bounds solver
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
53a9a1b383
commit
e5ce16a734
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -35,6 +35,7 @@
|
||||
"simulator.h": "c",
|
||||
"dispatcher.h": "c",
|
||||
"cellular.h": "c",
|
||||
"limits": "c"
|
||||
"limits": "c",
|
||||
"boundsolver.h": "c"
|
||||
}
|
||||
}
|
||||
@ -1256,6 +1256,8 @@ Dedicated native fluid simulator
|
||||
Define cellular simulator
|
||||
Fix fluid dispatcher array deref
|
||||
Bounds array allocation
|
||||
Store world pos on native side
|
||||
Native bounds solver
|
||||
|
||||
|
||||
|
||||
|
||||
3
src/main/c/includes/fluid/env/environment.h
vendored
3
src/main/c/includes/fluid/env/environment.h
vendored
@ -27,6 +27,9 @@ typedef struct {
|
||||
jfieldID v0JId;
|
||||
jfieldID w0JId;
|
||||
jfieldID boundsId;
|
||||
jfieldID worldXId;
|
||||
jfieldID worldYId;
|
||||
jfieldID worldZId;
|
||||
jfieldID neighborsId;
|
||||
jfieldID chunkmaskJId;
|
||||
jfieldID updatedId;
|
||||
|
||||
21
src/main/c/includes/fluid/queue/boundsolver.h
Normal file
21
src/main/c/includes/fluid/queue/boundsolver.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef FLUID_BOUNDSOLVER_H
|
||||
#define FLUID_BOUNDSOLVER_H
|
||||
|
||||
#include "public.h"
|
||||
#include "fluid/queue/chunk.h"
|
||||
#include "fluid/env/environment.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the boundary values for each chunk
|
||||
* @param numReadIn The number of chunks
|
||||
* @param chunkViewC The array of chunks
|
||||
* @param environment The environment storing the simulation queues
|
||||
*/
|
||||
LIBRARY_API void fluid_solve_bounds(int numReadIn, Chunk ** chunkViewC, Environment * environment);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
359
src/main/c/src/fluid/queue/boundsolver.c
Normal file
359
src/main/c/src/fluid/queue/boundsolver.c
Normal file
@ -0,0 +1,359 @@
|
||||
|
||||
|
||||
#include "fluid/queue/boundsolver.h"
|
||||
#include "fluid/queue/chunkmask.h"
|
||||
#include "fluid/env/utilities.h"
|
||||
|
||||
|
||||
/**
|
||||
* Sets the boundary values for each chunk
|
||||
* @param numReadIn The number of chunks
|
||||
* @param chunkViewC The array of chunks
|
||||
* @param environment The environment storing the simulation queues
|
||||
*/
|
||||
LIBRARY_API void fluid_solve_bounds(int numReadIn, Chunk ** chunkViewC, Environment * environment){
|
||||
int i, j, k;
|
||||
int chunkIndex;
|
||||
int index;
|
||||
int neighborIndex;
|
||||
for(chunkIndex = 0; chunkIndex < numReadIn; chunkIndex++){
|
||||
Chunk * current = chunkViewC[chunkIndex];
|
||||
|
||||
//x+ face
|
||||
neighborIndex = CK(2,1,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, i, j)] = current->d[neighborIndex][IX( 1, i, j)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
for(j = 1; j < DIM; j++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, i, j)] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//x- face
|
||||
neighborIndex = CK(0,1,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(0, i, j)] = current->d[neighborIndex][IX(DIM-2, i, j)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(0, i, j)] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//y+ face
|
||||
neighborIndex = CK(1,2,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX( i, DIM-1, j)] = current->d[neighborIndex][IX( i, 1, j)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX( i, DIM-1, j)] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//y- face
|
||||
neighborIndex = CK(1,0,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(i, 0, j)] = current->d[neighborIndex][IX( i, DIM-2, j)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(i, 0, j)] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//z+ face
|
||||
neighborIndex = CK(1,1,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX( i, j, DIM-1)] = current->d[neighborIndex][IX( i, j, 1)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX( i, j, DIM-1)] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//z- face
|
||||
neighborIndex = CK(1,1,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(i, j, 0)] = current->d[neighborIndex][IX( i, j, DIM-2)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
for(j = 1; j < DIM-1; j++){
|
||||
current->d[CENTER_LOC][IX(i, j, 0)] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// edges
|
||||
//
|
||||
|
||||
//x+ y+ edge
|
||||
neighborIndex = CK(2,2,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, DIM-1, i)] = current->d[neighborIndex][IX( 1, 1, i)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, DIM-1, i)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//x+ y- edge
|
||||
neighborIndex = CK(2,0,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, 0, i)] = current->d[neighborIndex][IX( 1, DIM-2, i)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, 0, i)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//x- y+ edge
|
||||
neighborIndex = CK(0,2,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( 0, DIM-1, i)] = current->d[neighborIndex][IX( DIM-2, 1, i)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( 0, DIM-1, i)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//x- y- edge
|
||||
neighborIndex = CK(0,0,1);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( 0, 0, i)] = current->d[neighborIndex][IX( DIM-2, DIM-2, i)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( 0, 0, i)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//x+ z+ edge
|
||||
neighborIndex = CK(2,1,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, i, DIM-1)] = current->d[neighborIndex][IX( 1, i, 1)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, i, DIM-1)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//x+ z- edge
|
||||
neighborIndex = CK(2,1,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, i, 0)] = current->d[neighborIndex][IX( 1, i, DIM-2)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX(DIM-1, i, 0)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//x- z+ edge
|
||||
neighborIndex = CK(0,1,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( 0, i, DIM-1)] = current->d[neighborIndex][IX( DIM-2, i, 1)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( 0, i, DIM-1)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//x- z- edge
|
||||
neighborIndex = CK(0,1,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( 0, i, 0)] = current->d[neighborIndex][IX( DIM-2, i, DIM-2)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( 0, i, 0)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//y+ z+ edge
|
||||
neighborIndex = CK(1,2,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( i, DIM-1, DIM-1)] = current->d[neighborIndex][IX( i, 1, 1)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( i, DIM-1, DIM-1)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//y+ z- edge
|
||||
neighborIndex = CK(1,2,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( i,DIM-1, 0)] = current->d[neighborIndex][IX( i, 1, DIM-2)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( i,DIM-1, 0)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//y- z+ edge
|
||||
neighborIndex = CK(1,0,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( i, 0, DIM-1)] = current->d[neighborIndex][IX( i, DIM-2, 1)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( i, 0, DIM-1)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//y- z- edge
|
||||
neighborIndex = CK(1,0,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
for(i = 1; i < DIM-1; i++){
|
||||
current->d[CENTER_LOC][IX( i, 0, 0)] = current->d[neighborIndex][IX( i, DIM-2, DIM-2)];
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < DIM; i++){
|
||||
current->d[CENTER_LOC][IX( i, 0, 0)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// CORNERS
|
||||
//
|
||||
|
||||
//x+ y+ z+ corner
|
||||
neighborIndex = CK(2,2,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = current->d[neighborIndex][IX( 1, 1, 1)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = 0;
|
||||
}
|
||||
|
||||
//x+ y+ z- corner
|
||||
neighborIndex = CK(2,2,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = current->d[neighborIndex][IX( 1, 1, DIM-2)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//x+ y- z+ corner
|
||||
neighborIndex = CK(2,0,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = current->d[neighborIndex][IX( 1, DIM-2, 1)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = 0;
|
||||
}
|
||||
|
||||
//x+ y- z- corner
|
||||
neighborIndex = CK(2,0,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(DIM-1, 0, 0)] = current->d[neighborIndex][IX( 1, DIM-2, DIM-2)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(DIM-1, 0, 0)] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//x- y+ z+ corner
|
||||
neighborIndex = CK(0,2,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(0, DIM-1, DIM-1)] = current->d[neighborIndex][IX( DIM-2, 1, 1)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(0, DIM-1, DIM-1)] = 0;
|
||||
}
|
||||
|
||||
//x- y+ z- corner
|
||||
neighborIndex = CK(0,2,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(0, DIM-1, 0)] = current->d[neighborIndex][IX( DIM-2, 1, DIM-2)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(0, DIM-1, 0)] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//x- y- z+ corner
|
||||
neighborIndex = CK(0,0,2);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(0, 0, DIM-1)] = current->d[neighborIndex][IX( DIM-2, DIM-2, 1)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(0, 0, DIM-1)] = 0;
|
||||
}
|
||||
|
||||
//x- y- z- corner
|
||||
neighborIndex = CK(0,0,0);
|
||||
if(current->d[neighborIndex] != NULL){
|
||||
current->d[CENTER_LOC][IX(0, 0, 0)] = current->d[neighborIndex][IX( DIM-2, DIM-2, DIM-2)];
|
||||
} else {
|
||||
current->d[CENTER_LOC][IX(0, 0, 0)] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,6 +120,9 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate
|
||||
environment->lookupTable.serverFluidChunkTable.v0JId = (*env)->GetFieldID(env,fluidSimStorageClass,"b0VelocityY","[Ljava/nio/ByteBuffer;");
|
||||
environment->lookupTable.serverFluidChunkTable.w0JId = (*env)->GetFieldID(env,fluidSimStorageClass,"b0VelocityZ","[Ljava/nio/ByteBuffer;");
|
||||
environment->lookupTable.serverFluidChunkTable.boundsId = (*env)->GetFieldID(env,fluidSimStorageClass,"bBounds","[Ljava/nio/ByteBuffer;");
|
||||
environment->lookupTable.serverFluidChunkTable.worldXId = (*env)->GetFieldID(env,fluidSimStorageClass,"worldX","I");
|
||||
environment->lookupTable.serverFluidChunkTable.worldYId = (*env)->GetFieldID(env,fluidSimStorageClass,"worldY","I");
|
||||
environment->lookupTable.serverFluidChunkTable.worldZId = (*env)->GetFieldID(env,fluidSimStorageClass,"worldZ","I");
|
||||
environment->lookupTable.serverFluidChunkTable.neighborsId = (*env)->GetFieldID(env,fluidSimStorageClass,"neighbors","[Lelectrosphere/server/fluid/manager/ServerFluidChunk;");
|
||||
environment->lookupTable.serverFluidChunkTable.chunkmaskJId = (*env)->GetFieldID(env,fluidSimStorageClass,"chunkMask","I");
|
||||
environment->lookupTable.serverFluidChunkTable.totalDensityId = (*env)->GetFieldID(env,fluidSimStorageClass,"totalDensity","F");
|
||||
@ -153,6 +156,9 @@ int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment){
|
||||
jfieldID boundsId = environment->lookupTable.serverFluidChunkTable.boundsId;
|
||||
jfieldID chunkmaskJId = environment->lookupTable.serverFluidChunkTable.chunkmaskJId;
|
||||
jfieldID asleepId = environment->lookupTable.serverFluidChunkTable.asleepId;
|
||||
jfieldID worldXId = environment->lookupTable.serverFluidChunkTable.worldXId;
|
||||
jfieldID worldYId = environment->lookupTable.serverFluidChunkTable.worldYId;
|
||||
jfieldID worldZId = environment->lookupTable.serverFluidChunkTable.worldZId;
|
||||
|
||||
//the number of chunks
|
||||
numChunks = (*env)->CallIntMethod(env,chunkList,jListSize);
|
||||
@ -217,6 +223,9 @@ int readInChunks(JNIEnv * env, jobject chunkList, Environment * environment){
|
||||
bounds = (*env)->GetObjectField(env,chunkJRaw,boundsId);
|
||||
newChunk->chunkMask = chunkMask;
|
||||
newChunk->chunkJRaw = chunkJRaw;
|
||||
newChunk->x = (*env)->GetIntField(env,chunkJRaw,worldXId);
|
||||
newChunk->y = (*env)->GetIntField(env,chunkJRaw,worldYId);
|
||||
newChunk->z = (*env)->GetIntField(env,chunkJRaw,worldZId);
|
||||
for(int j = 0; j < 27; j++){
|
||||
if((chunkMask & CHUNK_INDEX_ARR[j]) > 0){
|
||||
newChunk->d[j] = getArray(env,jd,j);
|
||||
|
||||
872
src/test/c/fluid/queue/boundsolver_tests.c
Normal file
872
src/test/c/fluid/queue/boundsolver_tests.c
Normal file
@ -0,0 +1,872 @@
|
||||
|
||||
#include "stb/stb_ds.h"
|
||||
|
||||
#include "fluid/dispatch/dispatcher.h"
|
||||
#include "fluid/queue/boundsolver.h"
|
||||
#include "fluid/queue/chunkmask.h"
|
||||
#include "fluid/env/environment.h"
|
||||
#include "fluid/env/utilities.h"
|
||||
|
||||
#include "../../util/chunk_test_utils.h"
|
||||
#include "../../util/test.h"
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the bounds were set correctly for a given chunk
|
||||
* @param chunk The chunk
|
||||
* @param x the world x
|
||||
* @param y the world y
|
||||
* @param z the world z
|
||||
* @param invert Inverts the check (ie for validating data prior to call)
|
||||
*/
|
||||
int checkBounds(Chunk * chunk, int x, int y, int z, int invert){
|
||||
int rVal = 0;
|
||||
int i, j;
|
||||
int neighborIndex;
|
||||
//
|
||||
//check planes
|
||||
//
|
||||
|
||||
//x+ plane
|
||||
neighborIndex = CK(2,1,1);
|
||||
if(x > 1){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(DIM-1,i,j)],0,"chunk should NOT have (x=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(DIM-1,i,j)],0,"chunk should have (x=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,i,j)] != chunk->d[neighborIndex][IX(1,i,j)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,i,j)] == chunk->d[neighborIndex][IX(1,i,j)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x!=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- plane
|
||||
neighborIndex = CK(0,1,1);
|
||||
if(x < 1){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(0,i,j)],0,"chunk should NOT have (x=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(0,i,j)],0,"chunk should have (x=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(0,i,j)] != chunk->d[neighborIndex][IX(DIM-2,i,j)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(0,i,j)] == chunk->d[neighborIndex][IX(DIM-2,i,j)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x!=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//y+ plane
|
||||
neighborIndex = CK(1,2,1);
|
||||
if(y > 1){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,DIM-1,j)],0,"chunk should NOT have (y=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,DIM-1,j)],0,"chunk should have (y=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly y<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,DIM-1,j)] != chunk->d[neighborIndex][IX(i,1,j)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,DIM-1,j)] == chunk->d[neighborIndex][IX(i,1,j)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (y!=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//y- plane
|
||||
neighborIndex = CK(1,0,1);
|
||||
if(y < 1){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,0,j)],0,"chunk should NOT have (y=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,0,j)],0,"chunk should have (y=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly y>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,0,j)] != chunk->d[neighborIndex][IX(i,DIM-2,j)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,0,j)] == chunk->d[neighborIndex][IX(i,DIM-2,j)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (y!=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//z+ plane
|
||||
neighborIndex = CK(1,1,2);
|
||||
if(z > 1){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,j,DIM-1)],0,"chunk should NOT have (z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,j,DIM-1)],0,"chunk should have (z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,j,DIM-1)] != chunk->d[neighborIndex][IX(i,j,1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,j,DIM-1)] == chunk->d[neighborIndex][IX(i,j,1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (z!=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//z- plane
|
||||
neighborIndex = CK(1,1,0);
|
||||
if(z < 1){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,j,0)],0,"chunk should NOT have (z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,j,0)],0,"chunk should have (z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
for(j = 1; j < DIM - 1; j++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,j,0)] != chunk->d[neighborIndex][IX(i,j,DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,j,0)] == chunk->d[neighborIndex][IX(i,j,DIM-2)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (z!=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// edges
|
||||
//
|
||||
|
||||
//x+ y+ edge
|
||||
neighborIndex = CK(2,2,1);
|
||||
if(x == 2 || y == 2){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(DIM-1,DIM-1,i)],0,"chunk should NOT have (x=2 y=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(DIM-1,DIM-1,i)],0,"chunk should have (x=2 y=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 y<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,DIM-1,i)] != chunk->d[neighborIndex][IX(1,1,i)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,DIM-1,i)] == chunk->d[neighborIndex][IX(1,1,i)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 y=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x+ y- edge
|
||||
neighborIndex = CK(2,0,1);
|
||||
if(x == 2 || y == 0){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(DIM-1,0,i)],0,"chunk should NOT have (x=2 y=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(DIM-1,0,i)],0,"chunk should have (x=2 y=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 y>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,0,i)] != chunk->d[neighborIndex][IX(1,DIM-2,i)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,0,i)] == chunk->d[neighborIndex][IX(1,DIM-2,i)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 y=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- y+ edge
|
||||
neighborIndex = CK(0,2,1);
|
||||
if(x == 0 || y == 2){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(0,DIM-1,i)],0,"chunk should NOT have (x=0 y=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(0,DIM-1,i)],0,"chunk should have (x=0 y=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 y<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(0,DIM-1,i)] != chunk->d[neighborIndex][IX(1,1,i)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(0,DIM-1,i)] == chunk->d[neighborIndex][IX(1,1,i)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 y=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- y- edge
|
||||
neighborIndex = CK(0,0,1);
|
||||
if(x == 0 || y == 0){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(0,0,i)],0,"chunk should NOT have (x=0 y=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(0,0,i)],0,"chunk should have (x=0 y=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 y>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(0,0,i)] != chunk->d[neighborIndex][IX(DIM-2,DIM-2,i)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(0,0,i)] == chunk->d[neighborIndex][IX(DIM-2,DIM-2,i)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 y=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//x+ z+ edge
|
||||
neighborIndex = CK(2,1,2);
|
||||
if(x == 2 || z == 2){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(DIM-1,i,DIM-1)],0,"chunk should NOT have (x=2 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(DIM-1,i,DIM-1)],0,"chunk should have (x=2 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,i,DIM-1)] != chunk->d[neighborIndex][IX(1,i,1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,i,DIM-1)] == chunk->d[neighborIndex][IX(1,i,1)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x+ z- edge
|
||||
neighborIndex = CK(2,1,0);
|
||||
if(x == 2 || z == 0){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(DIM-1,i,0)],0,"chunk should NOT have (x=2 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(DIM-1,i,0)],0,"chunk should have (x=2 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,i,0)] != chunk->d[neighborIndex][IX(1,i,DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(DIM-1,i,0)] == chunk->d[neighborIndex][IX(1,i,DIM-2)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- z+ edge
|
||||
neighborIndex = CK(0,1,2);
|
||||
if(x == 0 || z == 2){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(0,i,DIM-1)],0,"chunk should NOT have (x=0 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(0,i,DIM-1)],0,"chunk should have (x=0 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(0,i,DIM-1)] != chunk->d[neighborIndex][IX(1,i,1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(0,i,DIM-1)] == chunk->d[neighborIndex][IX(1,i,1)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- z- edge
|
||||
neighborIndex = CK(0,1,0);
|
||||
if(x == 0 || z == 0){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(0,i,0)],0,"chunk should NOT have (x=0 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(0,i,0)],0,"chunk should have (x=0 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(0,i,0)] != chunk->d[neighborIndex][IX(DIM-2,i,DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(0,i,0)] == chunk->d[neighborIndex][IX(DIM-2,i,DIM-2)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//y+ z+ edge
|
||||
neighborIndex = CK(1,2,2);
|
||||
if(y == 2 || z == 2){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,DIM-1,DIM-1)],0,"chunk should NOT have (y=2 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,DIM-1,DIM-1)],0,"chunk should have (y=2 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly y<2 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,DIM-1,DIM-1)] != chunk->d[neighborIndex][IX(i,1,1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,DIM-1,DIM-1)] == chunk->d[neighborIndex][IX(i,1,1)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (y=2 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//y+ z- edge
|
||||
neighborIndex = CK(1,2,0);
|
||||
if(y == 2 || z == 0){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,DIM-1,0)],0,"chunk should NOT have (y=2 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,DIM-1,0)],0,"chunk should have (y=2 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly y<2 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,DIM-1,0)] != chunk->d[neighborIndex][IX(i,1,DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,DIM-1,0)] == chunk->d[neighborIndex][IX(i,1,DIM-2)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (y=2 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//y- z+ edge
|
||||
neighborIndex = CK(1,0,2);
|
||||
if(y == 0 || z == 2){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,0,DIM-1)],0,"chunk should NOT have (y=0 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,0,DIM-1)],0,"chunk should have (y=0 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly y>0 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,0,DIM-1)] != chunk->d[neighborIndex][IX(i,1,1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,0,DIM-1)] == chunk->d[neighborIndex][IX(i,1,1)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (y=0 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//y- z- edge
|
||||
neighborIndex = CK(1,0,0);
|
||||
if(y == 0 || z == 0){
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX(i,0,0)],0,"chunk should NOT have (y=0 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX(i,0,0)],0,"chunk should have (y=0 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly y>0 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
for(i = 1; i < DIM - 1; i++){
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX(i,0,0)] != chunk->d[neighborIndex][IX(i,DIM-2,DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX(i,0,0)] == chunk->d[neighborIndex][IX(i,DIM-2,DIM-2)];
|
||||
}
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (y=0 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// CORNERS
|
||||
//
|
||||
|
||||
//x+ y+ z+
|
||||
neighborIndex = CK(2,2,2);
|
||||
if(x == 2 || y == 2 || z == 2){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, DIM-1 )],0,"chunk should NOT have (x=2 y=2 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, DIM-1 )],0,"chunk should have (x=2 y=2 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 y<2 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, DIM-1 )] != chunk->d[neighborIndex][IX( 1, 1, 1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, DIM-1 )] == chunk->d[neighborIndex][IX( 1, 1, 1)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 y=2 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x+ y+ z-
|
||||
neighborIndex = CK(2,2,0);
|
||||
if(x == 2 || y == 2 || z == 0){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, 0 )],0,"chunk should NOT have (x=2 y=2 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, 0 )],0,"chunk should have (x=2 y=2 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 y<2 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, 0 )] != chunk->d[neighborIndex][IX( 1, 1, DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, DIM-1, 0 )] == chunk->d[neighborIndex][IX( 1, 1, DIM-2)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 y=2 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//x+ y- z+
|
||||
neighborIndex = CK(2,0,2);
|
||||
if(x == 2 || y == 0 || z == 2){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( DIM-1, 0, DIM-1 )],0,"chunk should NOT have (x=2 y=0 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( DIM-1, 0, DIM-1 )],0,"chunk should have (x=2 y=0 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 y>0 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, 0, DIM-1 )] != chunk->d[neighborIndex][IX( 1, 1, 1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, 0, DIM-1 )] == chunk->d[neighborIndex][IX( 1, 1, 1)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 y=0 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x+ y- z-
|
||||
neighborIndex = CK(2,0,0);
|
||||
if(x == 2 || y == 0 || z == 0){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( DIM-1, 0, 0 )],0,"chunk should NOT have (x=2 y=0 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( DIM-1, 0, 0 )],0,"chunk should have (x=2 y=0 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x<2 y>0 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, 0, 0 )] != chunk->d[neighborIndex][IX( 1, DIM-2, DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( DIM-1, 0, 0 )] == chunk->d[neighborIndex][IX( 1, DIM-2, DIM-2)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=2 y=0 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//x- y+ z+
|
||||
neighborIndex = CK(0,2,2);
|
||||
if(x == 0 || y == 2 || z == 2){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( 0, DIM-1, DIM-1 )],0,"chunk should NOT have (x=0 y=2 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( 0, DIM-1, DIM-1 )],0,"chunk should have (x=0 y=2 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 y<2 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, DIM-1, DIM-1 )] != chunk->d[neighborIndex][IX( DIM-2, 1, 1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, DIM-1, DIM-1 )] == chunk->d[neighborIndex][IX( DIM-2, 1, 1)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 y=2 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- y+ z-
|
||||
neighborIndex = CK(0,2,0);
|
||||
if(x == 0 || y == 2 || z == 0){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( 0, DIM-1, 0 )],0,"chunk should NOT have (x=0 y=2 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( 0, DIM-1, 0 )],0,"chunk should have (x=0 y=2 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 y<2 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, DIM-1, 0 )] != chunk->d[neighborIndex][IX( DIM-2, 1, DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, DIM-1, 0 )] == chunk->d[neighborIndex][IX( DIM-2, 1, DIM-2)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 y=2 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//x- y- z+
|
||||
neighborIndex = CK(0,0,2);
|
||||
if(x == 0 || y == 0 || z == 2){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( 0, 0, DIM-1 )],0,"chunk should NOT have (x=0 y=0 z=2) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( 0, 0, DIM-1 )],0,"chunk should have (x=0 y=0 z=2) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 y>0 z<2\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, 0, DIM-1 )] != chunk->d[neighborIndex][IX( DIM-2, 1, 1)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, 0, DIM-1 )] == chunk->d[neighborIndex][IX( DIM-2, 1, 1)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 y=0 z=2) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
//x- y- z-
|
||||
neighborIndex = CK(0,0,0);
|
||||
if(x == 0 || y == 0 || z == 0){
|
||||
if(invert == 1){
|
||||
rVal += assertNotEquals(chunk->d[CENTER_LOC][IX( 0, 0, 0 )],0,"chunk should NOT have (x=0 y=0 z=0) bound set to 0 -- %d %d \n");
|
||||
} else {
|
||||
rVal += assertEquals(chunk->d[CENTER_LOC][IX( 0, 0, 0 )],0,"chunk should have (x=0 y=0 z=0) bound set to 0-- %d %d \n");
|
||||
}
|
||||
} else {
|
||||
if(chunk->d[neighborIndex] == NULL){
|
||||
rVal += assertEquals(0,1,"Failed to assign neighbors properly x>0 y>0 z>0\n");
|
||||
}
|
||||
int pass = 0;
|
||||
if(invert == 1){
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, 0, 0 )] != chunk->d[neighborIndex][IX( DIM-2, DIM-2, DIM-2)];
|
||||
} else {
|
||||
pass = chunk->d[CENTER_LOC][IX( 0, 0, 0 )] == chunk->d[neighborIndex][IX( DIM-2, DIM-2, DIM-2)];
|
||||
}
|
||||
if(!pass){
|
||||
rVal += assertEquals(0,1,"chunk should have (x=0 y=0 z=0) bound set to neighbor\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
int kernelx[27] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
};
|
||||
|
||||
int kernely[27] = {
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2,
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2,
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2,
|
||||
};
|
||||
|
||||
int kernelz[27] = {
|
||||
0, 1, 2, 0, 1, 2, 0, 1, 2,
|
||||
0, 1, 2, 0, 1, 2, 0, 1, 2,
|
||||
0, 1, 2, 0, 1, 2, 0, 1, 2,
|
||||
};
|
||||
|
||||
int fluid_queue_boundsolver_tests(){
|
||||
int rVal = 0;
|
||||
|
||||
Environment * env = fluid_environment_create();
|
||||
|
||||
int chunkCount = 27;
|
||||
|
||||
Chunk ** queue = NULL;
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
arrput(queue,chunk_create(kernelx[i],kernely[i],kernelz[i]));
|
||||
}
|
||||
|
||||
//link neighbors
|
||||
chunk_link_neighbors(queue);
|
||||
|
||||
//fill them with values
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
chunk_fill(queue[i],i+1);
|
||||
}
|
||||
|
||||
//make sure the data is setup correctly before the call
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
rVal += checkBounds(queue[i],kernelx[i],kernely[i],kernelz[i],1);
|
||||
}
|
||||
|
||||
//call bounds setter
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
|
||||
//check that the 0 values are 0'd
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
rVal += checkBounds(queue[i],kernelx[i],kernely[i],kernelz[i],0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//cleanup test
|
||||
chunk_free_queue(queue);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
@ -3,12 +3,24 @@
|
||||
#include "stb/stb_ds.h"
|
||||
#include "fluid/queue/chunk.h"
|
||||
#include "fluid/queue/chunkmask.h"
|
||||
#include "fluid/env/utilities.h"
|
||||
|
||||
/**
|
||||
* Creates a chunk at a world position
|
||||
*/
|
||||
Chunk * chunk_create(int x, int y, int z){
|
||||
Chunk * chunk1 = (Chunk *)malloc(sizeof(Chunk));
|
||||
for(int i = 0; i < 27; i++){
|
||||
chunk1->d[i] = NULL;
|
||||
chunk1->d0[i] = NULL;
|
||||
chunk1->u[i] = NULL;
|
||||
chunk1->v[i] = NULL;
|
||||
chunk1->w[i] = NULL;
|
||||
chunk1->u0[i] = NULL;
|
||||
chunk1->v0[i] = NULL;
|
||||
chunk1->w0[i] = NULL;
|
||||
chunk1->bounds[i] = NULL;
|
||||
}
|
||||
chunk1->d[CENTER_LOC] = (float *)malloc(DIM * DIM * DIM * sizeof(float));
|
||||
chunk1->d0[CENTER_LOC] = (float *)malloc(DIM * DIM * DIM * sizeof(float));
|
||||
chunk1->u[CENTER_LOC] = (float *)malloc(DIM * DIM * DIM * sizeof(float));
|
||||
@ -36,6 +48,7 @@ void chunk_free(Chunk * chunk){
|
||||
free(chunk->u0[CENTER_LOC]);
|
||||
free(chunk->v0[CENTER_LOC]);
|
||||
free(chunk->w0[CENTER_LOC]);
|
||||
free(chunk->bounds[CENTER_LOC]);
|
||||
free(chunk);
|
||||
}
|
||||
|
||||
@ -52,6 +65,155 @@ Chunk ** chunk_create_queue(int size){
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees a chunk queue
|
||||
*/
|
||||
void chunk_free_queue(Chunk ** chunks){
|
||||
int num = arrlen(chunks);
|
||||
for(int i = 0; i < num; i++){
|
||||
chunk_free(chunks[i]);
|
||||
}
|
||||
arrfree(chunks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills a chunk with a value
|
||||
* @param chunk The chunk to fill
|
||||
* @param val The value to fill
|
||||
*/
|
||||
void chunk_fill(Chunk * chunk, int val){
|
||||
for(int i = 0; i < DIM*DIM*DIM; i++){
|
||||
chunk->d[CENTER_LOC][i] = val;
|
||||
chunk->d0[CENTER_LOC][i] = val;
|
||||
chunk->u[CENTER_LOC][i] = val;
|
||||
chunk->v[CENTER_LOC][i] = val;
|
||||
chunk->w[CENTER_LOC][i] = val;
|
||||
chunk->u0[CENTER_LOC][i] = val;
|
||||
chunk->v0[CENTER_LOC][i] = val;
|
||||
chunk->w0[CENTER_LOC][i] = val;
|
||||
chunk->bounds[CENTER_LOC][i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used in chunk_link_neighbors
|
||||
*/
|
||||
void chunk_link_by_index(Chunk * chunk1, Chunk * chunk2, int x, int y, int z){
|
||||
chunk1->d[CK(x,y,z)] = chunk2->d[CENTER_LOC];
|
||||
chunk1->d0[CK(x,y,z)] = chunk2->d0[CENTER_LOC];
|
||||
chunk1->u[CK(x,y,z)] = chunk2->u[CENTER_LOC];
|
||||
chunk1->v[CK(x,y,z)] = chunk2->v[CENTER_LOC];
|
||||
chunk1->w[CK(x,y,z)] = chunk2->w[CENTER_LOC];
|
||||
chunk1->u0[CK(x,y,z)] = chunk2->u0[CENTER_LOC];
|
||||
chunk1->v0[CK(x,y,z)] = chunk2->v0[CENTER_LOC];
|
||||
chunk1->w0[CK(x,y,z)] = chunk2->w0[CENTER_LOC];
|
||||
chunk1->bounds[CK(x,y,z)] = chunk2->bounds[CENTER_LOC];
|
||||
}
|
||||
|
||||
/**
|
||||
* Links all neighbors in a chunk queue
|
||||
*/
|
||||
void chunk_link_neighbors(Chunk ** chunks){
|
||||
int num = arrlen(chunks);
|
||||
for(int i = 0; i < num; i++){
|
||||
for(int j = 0; j < num; j++){
|
||||
if(i == j){
|
||||
continue;
|
||||
}
|
||||
Chunk * chunk1 = chunks[i];
|
||||
Chunk * chunk2 = chunks[j];
|
||||
|
||||
//one coord
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,1,1);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,0,1);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,1,0);
|
||||
}
|
||||
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,1,1);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,2,1);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,1,2);
|
||||
}
|
||||
|
||||
//two coords
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,0,1);
|
||||
}
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,2,1);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,0,1);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,2,1);
|
||||
}
|
||||
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,1,0);
|
||||
}
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,1,2);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,1,0);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,1,2);
|
||||
}
|
||||
|
||||
if(chunk1->x == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,0,0);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,0,2);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,2,0);
|
||||
}
|
||||
if(chunk1->x == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,1,2,2);
|
||||
}
|
||||
|
||||
//three coords
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,0,0);
|
||||
}
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,0,2);
|
||||
}
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,2,0);
|
||||
}
|
||||
if(chunk1->x - 1 == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,0,2,2);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,0,0);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y - 1 == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,0,2);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z - 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,2,0);
|
||||
}
|
||||
if(chunk1->x + 1 == chunk2->x && chunk1->y + 1 == chunk2->y && chunk1->z + 1 == chunk2->z){
|
||||
chunk_link_by_index(chunk1,chunk2,2,2,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty test launcher
|
||||
*/
|
||||
|
||||
@ -71,4 +71,21 @@ void chunk_set_val(Chunk * chunk, int i, int arr);
|
||||
*/
|
||||
Chunk ** chunk_create_queue(int size);
|
||||
|
||||
/**
|
||||
* Fills a chunk with a value
|
||||
* @param chunk The chunk to fill
|
||||
* @param val The value to fill
|
||||
*/
|
||||
void chunk_fill(Chunk * chunk, int val);
|
||||
|
||||
/**
|
||||
* Frees a chunk queue
|
||||
*/
|
||||
void chunk_free_queue(Chunk ** chunks);
|
||||
|
||||
/**
|
||||
* Links all neighbors in a chunk queue
|
||||
*/
|
||||
void chunk_link_neighbors(Chunk ** chunks);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user