From 28c41baa9397b9f2827dcdd8c6c38f0097b19a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 1 Nov 2021 20:59:30 +0100 Subject: [PATCH] Render outer block layer separately --- code/game/src/debug_ui_actions.c | 2 +- code/game/src/renderer_3d.c | 9 +++++++++ code/game/src/renderer_v0.c | 9 +++++++++ code/game/src/world/blocks.c | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/game/src/debug_ui_actions.c b/code/game/src/debug_ui_actions.c index 1f4d276..abd9847 100644 --- a/code/game/src/debug_ui_actions.c +++ b/code/game/src/debug_ui_actions.c @@ -65,7 +65,7 @@ ActPlaceIceRink(void) { for (int y = 0; y < 100; y++) { for (int x = 0; x < 100; x++) { world_block_lookup l = world_block_from_realpos((p->x - (x*bs)/2.0f), p->y - (y*bs)/2.0f); - world_chunk_replace_block(l.chunk_id, l.id, watr_id); + world_chunk_place_block(l.chunk_id, l.id, watr_id); } } diff --git a/code/game/src/renderer_3d.c b/code/game/src/renderer_3d.c index 27b6330..86fe49c 100644 --- a/code/game/src/renderer_3d.c +++ b/code/game/src/renderer_3d.c @@ -22,6 +22,15 @@ void DEBUG_draw_ground_3d(uint64_t key, entity_view * data) { RenderTexture2D tex = GetChunkTexture(key); DrawCubeTexture(tex.texture, (Vector3){x+half_size, 0.0f, y+half_size}, size, 0.01f, size, WHITE); + for (size_t ty = 0; ty < view->chunk_size; ty++) { + for (size_t tx = 0; tx < view->chunk_size; tx++) { + uint8_t blk_id = data->outer_blocks[(ty*view->chunk_size)+tx]; + if (blk_id != 0) { + DrawCubeTexture(GetBlockImage(blk_id), (Vector3){x + tx*WORLD_BLOCK_SIZE+half_block_size, 32.0f, y + ty*WORLD_BLOCK_SIZE+half_block_size}, 64, 0.01f, 64, WHITE); + } + } + } + for (int by = 0; by < 16; by++) { for (int bx = 0; bx < 16; bx++) { switch (blocks_get_flags(data->blocks[by*16+bx])) { diff --git a/code/game/src/renderer_v0.c b/code/game/src/renderer_v0.c index 4a83c17..46ad7bd 100644 --- a/code/game/src/renderer_v0.c +++ b/code/game/src/renderer_v0.c @@ -30,6 +30,15 @@ void DEBUG_draw_ground(uint64_t key, entity_view * data) { DrawTextEco(TextFormat("%d %d", (int)data->x, (int)data->y), (int16_t)x+15, (int16_t)y+15, 200 , ColorAlpha(BLACK, data->tran_time*zoom_overlay_tran), 0.0); } + + for (size_t ty = 0; ty < view->chunk_size; ty++) { + for (size_t tx = 0; tx < view->chunk_size; tx++) { + uint8_t blk_id = data->outer_blocks[(ty*view->chunk_size)+tx]; + if (blk_id != 0) { + DrawTextureRec(GetBlockImage(blk_id), ASSET_SRC_RECT(), (Vector2){x+tx*WORLD_BLOCK_SIZE, y+ty*WORLD_BLOCK_SIZE}, ColorAlpha(WHITE, data->tran_time)); + } + } + } }break; default:break; diff --git a/code/game/src/world/blocks.c b/code/game/src/world/blocks.c index 43d0af0..d4f88c9 100644 --- a/code/game/src/world/blocks.c +++ b/code/game/src/world/blocks.c @@ -121,10 +121,12 @@ void blocks_build_chunk_tex(uint64_t id, uint8_t *chunk_blocks, uint8_t *outer_c Rectangle dst = {x*blk_dims + half_block, y*blk_dims + half_block, blk_dims, blk_dims}; DrawTexturePro(blk, src, dst, (Vector2){half_block, half_block}, rot, WHITE); +#if 0 if (outer_chunk_blocks[(y*view->chunk_size)+x] != 0) { Texture2D blk2 = blocks[outer_chunk_blocks[(y*view->chunk_size)+x]].img; DrawTexturePro(blk2, src, dst, (Vector2){half_block, half_block}, rot, WHITE); } +#endif #endif } }