yet another API cleanup
This commit is contained in:
parent
2008f70983
commit
b6b3483a39
9 changed files with 134 additions and 114 deletions
37
cubes.c
37
cubes.c
|
@ -22,16 +22,16 @@ int oz = -1024;
|
|||
|
||||
struct chunk *chunk_old = NULL;
|
||||
|
||||
void gen_face(struct v3f *cube, int i, int x, int y, int z, int x2, int y2,
|
||||
int z2, int *j, int is_text, struct chunk dat, int ci, int a3) {
|
||||
void cubes_face(struct v3f *cube, int i, int x, int y, int z, int x2, int y2,
|
||||
int z2, int *j, int is_text, struct chunk dat, int ci, int a3) {
|
||||
struct v3i a = {{x, y, z}};
|
||||
struct v3f a2 = {{x, y, z}};
|
||||
|
||||
if (is_text) {
|
||||
a.pos[i]--;
|
||||
int exists = 0;
|
||||
int type = cube_exists(x, y, z, dat, ci);
|
||||
int typeB = cube_exists(a.pos[0], a.pos[1], a.pos[2], dat, ci);
|
||||
int type = gen_cube(x, y, z, dat, ci);
|
||||
int typeB = gen_cube(a.pos[0], a.pos[1], a.pos[2], dat, ci);
|
||||
exists = ((!!type) != (!!typeB));
|
||||
|
||||
a2.pos[0] = exists ? TEXT_GAP_H * (type ? (type - 1) : (typeB - 1)) : -1.0;
|
||||
|
@ -67,7 +67,7 @@ void gen_face(struct v3f *cube, int i, int x, int y, int z, int x2, int y2,
|
|||
cube[*j + 5] = d;
|
||||
}
|
||||
|
||||
void *gen_chunk(void *args) {
|
||||
void *cubes_chunk(void *args) {
|
||||
|
||||
struct args args2 = ((struct args *)args)[0];
|
||||
|
||||
|
@ -95,10 +95,10 @@ void *gen_chunk(void *args) {
|
|||
|
||||
// int is_text = args2.is_text;
|
||||
|
||||
int the_j = a2;
|
||||
int the_j = a2;
|
||||
|
||||
struct chunk chunk = fetch_chunk(x2 / CHUNK_LENGTH, y2 / CHUNK_LENGTH,
|
||||
z2 / CHUNK_LENGTH, a, 0);
|
||||
struct chunk chunk =
|
||||
gen_chunk(x2 / CHUNK_LENGTH, y2 / CHUNK_LENGTH, z2 / CHUNK_LENGTH, a, 0);
|
||||
|
||||
if (chunk.exists != 0 && the_j > -1)
|
||||
chunk_old[the_j] = chunk;
|
||||
|
@ -117,8 +117,8 @@ void *gen_chunk(void *args) {
|
|||
int z3 = z2 + z4;
|
||||
|
||||
for (int m = 0; m < 3; m++) {
|
||||
gen_face(cube, m, x3, y3, z3, x4, y4, z4, &i, 0, chunk, a, a3);
|
||||
gen_face(text, m, x3, y3, z3, x4, y4, z4, &i, 1, chunk, a, a3);
|
||||
cubes_face(cube, m, x3, y3, z3, x4, y4, z4, &i, 0, chunk, a, a3);
|
||||
cubes_face(text, m, x3, y3, z3, x4, y4, z4, &i, 1, chunk, a, a3);
|
||||
i += 6 * a3;
|
||||
if (i > CBLOCK_ALL * 18)
|
||||
return (void *)i;
|
||||
|
@ -134,10 +134,10 @@ void *gen_chunk(void *args) {
|
|||
return (void *)i;
|
||||
}
|
||||
|
||||
void free_chunks_old() { free(chunk_old); }
|
||||
void cubes_free() { free(chunk_old); }
|
||||
|
||||
int gen_cubes(struct v3f *cube, struct v3f *text, struct v3f *cubeO,
|
||||
struct v3f *textO, int x, int y, int z, int is_purge, int *i2) {
|
||||
int cubes_vert(struct v3f *cube, struct v3f *text, struct v3f *cubeO,
|
||||
struct v3f *textO, int x, int y, int z, int is_purge, int *i2) {
|
||||
struct v3f noth = {{-1, -1, -1}};
|
||||
for (int i = 0; i < CBLOCK_ALL * 18; i++) {
|
||||
cube[i] = noth;
|
||||
|
@ -149,17 +149,12 @@ int gen_cubes(struct v3f *cube, struct v3f *text, struct v3f *cubeO,
|
|||
y *= CHUNK_LENGTH;
|
||||
z *= CHUNK_LENGTH;
|
||||
int a3 = CHUNK_DIAMETER_H;
|
||||
int a =
|
||||
0; //(z % CHUNK_DIAMETER_H) + (x % CHUNK_DIAMETER_H) * CHUNK_DIAMETER_H +
|
||||
//(y % CHUNK_DIAMETER_V) * CHUNK_DIAMETER_H * CHUNK_DIAMETER_H;
|
||||
// a = a % a3;
|
||||
// if (a < 0) a = -a;
|
||||
|
||||
int a = 0;
|
||||
struct args args[a3];
|
||||
int thread_return[a3];
|
||||
if (is_purge) {
|
||||
for (int k = 0; k < a3; k++) {
|
||||
purge_chunks(k);
|
||||
gen_init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +206,7 @@ int gen_cubes(struct v3f *cube, struct v3f *text, struct v3f *cubeO,
|
|||
thread_return[a2] = -1;
|
||||
thread_id[a2] = -1;
|
||||
} else {
|
||||
pthread_create(&(thread_id[a2]), NULL, gen_chunk,
|
||||
pthread_create(&(thread_id[a2]), NULL, cubes_chunk,
|
||||
(void *)&(args[a2]));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue