place / break blocks

This commit is contained in:
onezplpl 2024-07-18 11:06:32 -04:00
parent fb639f96c3
commit 227d642be6
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
7 changed files with 191 additions and 55 deletions

20
cubes.c
View file

@ -30,8 +30,8 @@ void cubes_face(struct v3f *cube, int i, int x, int y, int z, int x2, int y2,
if (is_text) {
a.pos[i]--;
int exists = 0;
int type = gen_cube(x, y, z, dat, ci);
int typeB = gen_cube(a.pos[0], a.pos[1], a.pos[2], dat, ci);
int type = gen_cube(x, y, z, dat, ci, -1);
int typeB = gen_cube(a.pos[0], a.pos[1], a.pos[2], dat, ci, -1);
exists = ((!!type) != (!!typeB));
a2.pos[0] = exists ? TEXT_GAP_H * (type ? (type - 1) : (typeB - 1)) : -1.0;
@ -136,6 +136,17 @@ void *cubes_chunk(void *args) {
void cubes_free() { free(chunk_old); }
void cubes_refresh(int x, int y, int z, struct chunk dat) {
for (int i = 0; i < CHUNK_ALL; i++) {
if (chunk_old[i].exists != 0 && chunk_old[i].x == x &&
chunk_old[i].y == y && chunk_old[i].z == z) {
chunk_old[i].exists = 0;
gen_save(dat);
return;
}
}
}
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}};
@ -199,10 +210,9 @@ int cubes_vert(struct v3f *cube, struct v3f *text, struct v3f *cubeO,
old_chunk.y == pos.pos[1] / CHUNK_LENGTH &&
old_chunk.z == pos.pos[2] / CHUNK_LENGTH && old_chunk.exists != 0);
if (cached) {
thread_return[a2] = i2[a2 / a3];
thread_return[a2] = i2[a2 / a3] - 6;
thread_id[a2] = -1;
} else if (pos.pos[0] < 0 || pos.pos[1] < 0 || pos.pos[2] < 0 ||
pos.pos[1] < ((y - CHUNK_LENGTH * CHUNK_RADIUS_V) * 1.05)) {
} else if (pos.pos[0] < 0 || pos.pos[1] < 0 || pos.pos[2] < 0) {
thread_return[a2] = -1;
thread_id[a2] = -1;
} else {