From 02a7f37d4405711e640b55464f5bcfaac012df57 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 17 Nov 2024 20:07:28 -0700 Subject: [PATCH] Fixed world q/r calculation --- client/shader/hex.vert | 13 +++++++------ client/src/editor.c | 8 ++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/shader/hex.vert b/client/shader/hex.vert index e8cfdd2..4f7f0ed 100644 --- a/client/shader/hex.vert +++ b/client/shader/hex.vert @@ -58,14 +58,15 @@ void main() { /* vec2 hex_qr = start_coords[side]*radius + direction_coords[side]*(ring-(radius*side)); vec2 world_qr = vec2(0, 0); + world_qr.x = hex_qr.x + + region_qr.x*((region_size-1)*2 + 1.0) + + region_qr.y*((region_size-1) + 0.0); + world_qr.y = hex_qr.y - - region_qr.x*(region_size + 0.5) - - region_qr.y*(region_size*2 + 1.0); + - region_qr.x*((region_size-1) + 0.5) + - region_qr.y*((region_size-1)*2 + 1.0); - world_qr.x = hex_qr.x - + region_qr.x*(region_size*2 + 1.0) - + region_qr.y*(region_size + 0.0); - color = vec4(world_qr/100, 0, 1); + color = vec4(world_qr/100, 0, 1); vec4 hex_pos = vec4(0, 0, 0, 1); hex_pos.x = x*hex_qr.x; diff --git a/client/src/editor.c b/client/src/editor.c index 891e375..c601c9f 100644 --- a/client/src/editor.c +++ b/client/src/editor.c @@ -958,8 +958,12 @@ VkResult update_hex_info_ui(ClientContext* context) { int32_t hex_q = hex_starts_qr[side][0]*radius + hex_directions_qr[side][0]*(ring-(radius*side)); int32_t hex_r = hex_starts_qr[side][1]*radius + hex_directions_qr[side][1]*(ring-(radius*side)); - int32_t world_q = hex_q + region->data.q*(REGION_SIZE*2 + 1) + region->data.r*REGION_SIZE; - int32_t world_r = hex_r + region->data.q*(REGION_SIZE + 0.5) + region->data.r*(REGION_SIZE*2+1); + int32_t region_q = region->data.q*((REGION_SIZE-1)*2 + 1) + region->data.r*(REGION_SIZE-1); + + int32_t region_r = region->data.q*((REGION_SIZE-1) + 0.5) + region->data.r*((REGION_SIZE-1)*2+1); + + int32_t world_q = hex_q + region_q; + int32_t world_r = hex_r - region_r; snprintf( temp,