From 579eb9f540114635f5fc46cdd192930566cc2fef Mon Sep 17 00:00:00 2001 From: onezplpl Date: Mon, 15 Jul 2024 12:22:23 -0400 Subject: [PATCH] multiple textures --- const.h | 2 +- cubes.c | 11 ++++++----- gen.c | 4 ++-- test.png | Bin 313 -> 1095 bytes 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/const.h b/const.h index c58fad8..5aa1d6b 100644 --- a/const.h +++ b/const.h @@ -19,7 +19,7 @@ typedef struct Vertex2 { #define CHUNK_RADIUS_V 4 // 4 #define TEXT_GAP_H 1 / 3.0 -#define TEXT_GAP_V 1 / 1.0 +#define TEXT_GAP_V 1 / 6.0 #define CHUNK_DIAMETER_H (CHUNK_RADIUS_H * 2 + 1) #define CHUNK_DIAMETER_V (CHUNK_RADIUS_V * 2 + 1) diff --git a/cubes.c b/cubes.c index 5f28c94..644a945 100644 --- a/cubes.c +++ b/cubes.c @@ -32,11 +32,12 @@ void gen_face(Vertex *cube, int i, int x, int y, int z, int x2, int y2, int z2, if (is_text) { a.pos[i]--; int exists = 0; - exists = (cube_exists(x, y, z, dat, ci, read_order) != - cube_exists(a.pos[0], a.pos[1], a.pos[2], dat, ci, read_order)); + int type = cube_exists(x, y, z, dat, ci, read_order); + int typeB = cube_exists(a.pos[0], a.pos[1], a.pos[2], dat, ci, read_order); + exists = ((!!type) != (!!typeB)); - a2.pos[0] = exists ? TEXT_GAP_H * i : -1.0; - a2.pos[1] = exists ? TEXT_GAP_V * i : -1.0; + a2.pos[0] = exists ? TEXT_GAP_H * (type ? (type - 1) : (typeB-1)) : -1.0; + a2.pos[1] = exists ? TEXT_GAP_V * (i + (!!type) * 3) : -1.0; a2.pos[2] = 0; if (!exists) { *j = (*j - 6 * a3); @@ -213,7 +214,7 @@ int gen_cubes(Vertex *cube, Vertex *text, Vertex *cubeO, Vertex *textO, int x, if (cached) { thread_return[a2] = i2[a2 / a3]; thread_id[a2] = -1; - } else if (pos.pos[0] < 0 || pos.pos[1] < 0 || pos.pos[2] < 0 || pos.pos[1] < (y * 0.93)) { + } else if (pos.pos[0] < 0 || pos.pos[1] < 0 || pos.pos[2] < 0 || pos.pos[1] < ((y - CHUNK_LENGTH*CHUNK_RADIUS_V) * 1.1)) { thread_return[a2] = -1; thread_id[a2] = -1; } else { diff --git a/gen.c b/gen.c index a0c9ab8..1ccb55a 100644 --- a/gen.c +++ b/gen.c @@ -139,7 +139,7 @@ Chunk fetch_chunk(int x, int y, int z, int ci, int h, int r_order) { for (int y2 = 0; y2 < CHUNK_LENGTH; y2++) { int y3 = y2 + y * CHUNK_LENGTH; - chunk.blocks[c] = (y3 < h); + chunk.blocks[c] = (y3 < h) ? (((int)((hp + 64.0) * 2.98) % 3) + 1) : 0; c++; } } @@ -182,5 +182,5 @@ int cube_exists(int x, int y, int z, Chunk dat, int ci, int r_order) { int h = dat.blocks[(y % CHUNK_LENGTH) + (z % CHUNK_LENGTH) * CHUNK_LENGTH + (x % CHUNK_LENGTH) * CHUNK_LENGTH * CHUNK_LENGTH]; - return !!h; + return h; } \ No newline at end of file diff --git a/test.png b/test.png index e4f774e5ea65c7bfe4b76123e401ba46ebfd67f0..a53d88b653a08cd97f7078ea0398d89f70496d0f 100644 GIT binary patch literal 1095 zcmeAS@N?(olHy`uVBq!ia0vp^20)y^!3HFwdp;HbDb50q$YKTtJ!KGPtXOJa#=yY* z)6>NT^EbDuICi#5T`?>$B|EY2Ae_1lCVV;lBVgGwUUzVv@R0Ipj zn5+Jij@)+5o8@6Y@7CCUZ-t?Tnv5eR6 zI24^c8Uq{!lR@mucZdn0c<e%{{2Old|*y!vonRhl#>mD#n?cHil z+x-wc#d+jh?d^Y$Upu@~^ATHpl2O z_s!p^|8U2C>0|#t^u$lR`1`#REmqmYwb1ZImF<1@UF!_0 z{{Pt5+IM{MtSvxS?7r)FG`j5NpS!@+cKkY{N%8tz+wukP`<@gpc+V$N-2e?6NQT(5 zWK#DMXb2qzX9Yue2xZjZOlfPJGI(~y$^Y^EBd-!^DgAEAp$ov0fx*+&&t;ucLK6VH C(*YC! delta 280 zcmV+z0q6e52)P1~7YYyv1^@s6P_F#3ks%j<0P9IaK~zXfWBd;U3_}>OfZWc=$ViqK zV1B=N@giCJ_4V~3`j%cHOFu)j4g(Xq&c?<@tcKwd$7l1#jT=dJSkv8g7<#aY!4zS5 zfMgqSXduV&#_QO z2bVZCJr6UhPB{q0*a6AJwD1@`PE;LXG!#}e`sx}lUh6g~Ze%*Q5%H3rZ_mzWTzcalN3j}g?E8&++hfeukp?FYvI eshS3pdH|?TP)hu