diff --git a/client/shader/hex_highlight.vert b/client/shader/hex_highlight.vert index 45ba1c9..815b5e7 100644 --- a/client/shader/hex_highlight.vert +++ b/client/shader/hex_highlight.vert @@ -12,12 +12,12 @@ void main() { if(gl_InstanceIndex == 0) { hex_index = pc.context.clicked_hex; region = pc.context.regions[pc.context.clicked_region]; - color = vec4(0.3, 0.3, 0.3, 0.3); + color = vec4(0.5, 0.5, 0.5, 0.3); raise = 0.015; } else { hex_index = pc.context.hovered_hex; region = pc.context.regions[pc.context.hovered_region]; - color = vec4(0.8, 0.8, 0.8, 0.3); + color = vec4(0.25, 0.25, 0.25, 0.3); raise = 0.01; } diff --git a/client/src/gpu.c b/client/src/gpu.c index 879043e..36cb795 100644 --- a/client/src/gpu.c +++ b/client/src/gpu.c @@ -1292,6 +1292,16 @@ VkResult add_transfer( FrameContext* frame = &gpu->frame[frame_index]; TransferBuffer* transfer = &frame->transfers[frame->transfer_index % 2]; + VkDeviceSize src_offset = 0; + for(uint32_t i = 0; i < transfer->count; i++) { + if(transfer->infos[i].buffer == buffer && transfer->infos[i].size == size && transfer->infos[i].offset == offset) { + memcpy(transfer->mapped + src_offset, data, size); + return VK_SUCCESS; + } else { + src_offset += transfer->infos[i].size; + } + } + if(transfer->written + size >= transfer->max_size) { uint32_t new_size = 2*transfer->max_size; while(transfer->written + size >= new_size) { diff --git a/client/src/main.c b/client/src/main.c index d3deceb..2e51267 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -288,8 +288,8 @@ VkResult main_thread(ClientContext* context) { context->zoom = 0; context->cur_spin[0] = 0; context->cur_spin[1] = 0; - glfwPollEvents(); + glfwPollEvents(); if((context->key_spin[0] != 0 || context->key_spin[1] != 0 || context->zoom != 0 || context->cur_spin[0] != 0 || context->cur_spin[1] != 0 || @@ -535,6 +535,22 @@ void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) { cursor_to_world_ray(context, context->cursor, context->hex->data.hover_start, context->hex->data.hover_end); add_transfer(&context->hex->data.hover_start, context->hex->context, offsetof(GPUHexContext, hover_start), sizeof(vec4)*2, context->render->current_frame, context->render); + // Hex intersections + float distance; + for(uint32_t r = 0; r < MAX_LOADED_REGIONS; r++) { + if(context->hex->regions[r] == NULL) { + continue; + } else if(context->hex->regions[r]->data.map != context->hex->data.current_map) { + continue; + } + for(uint32_t h = 0; h < REGION_HEX_COUNT; h++) { + if(ray_hex_intersect(&distance, context->hex->data.hover_start, context->hex->data.hover_end, r, h, context->hex)) { + context->hex->data.hovered_region = r; + context->hex->data.hovered_hex = h; + add_transfer(&context->hex->data.hovered_region, context->hex->context, offsetof(GPUHexContext, hovered_region), sizeof(uint32_t)*2, context->render->current_frame, context->render); + } + } + } } int main() {