diff --git a/src/frontend/gui/GUI.cpp b/src/frontend/gui/GUI.cpp index db2b97a8..6cceef02 100644 --- a/src/frontend/gui/GUI.cpp +++ b/src/frontend/gui/GUI.cpp @@ -94,7 +94,7 @@ void GUI::act(float delta) { for (auto key : Events::pressedKeys) { focus->keyPressed(key); } - if (Events::clicked(mousecode::BUTTON_1)) { + if (!Events::_cursor_locked && Events::clicked(mousecode::BUTTON_1)) { int mx = Events::x; int my = Events::y; focus->mouseMove(this, mx, my); diff --git a/src/frontend/gui/panels.cpp b/src/frontend/gui/panels.cpp index 8bca8572..edbb708e 100644 --- a/src/frontend/gui/panels.cpp +++ b/src/frontend/gui/panels.cpp @@ -5,6 +5,7 @@ #include "../../window/Window.h" #include "../../assets/Assets.h" #include "../../graphics/Batch2D.h" +#include "../../window/Events.h" using std::shared_ptr; @@ -18,6 +19,7 @@ Container::Container(vec2 coord, vec2 size) : UINode(coord, size) { } shared_ptr Container::getAt(vec2 pos, shared_ptr self) { + if (!isInside(vec2(Events::x, Events::y))) return nullptr; for (auto node : nodes) { if (!node->visible()) continue; diff --git a/src/frontend/world_render.cpp b/src/frontend/world_render.cpp index dd2bdddd..3764cebc 100644 --- a/src/frontend/world_render.cpp +++ b/src/frontend/world_render.cpp @@ -171,14 +171,15 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool occlusion) } if (level->player->debug) { - float length = 40.f; + GfxContext ctx = pctx.sub(); + ctx.depthTest(true); linesShader->use(); if (engine->getSettings().debug.showChunkBorders){ linesShader->uniformMatrix("u_projview", camera->getProjView()); - GfxContext ctx = pctx.sub(); - ctx.depthTest(true); vec3 coord = level->player->camera->position; + if (coord.x < 0) coord.x--; + if (coord.z < 0) coord.z--; int cx = floordiv((int)coord.x, CHUNK_W); int cz = floordiv((int)coord.z, CHUNK_D); for (int i = 0; i < CHUNK_W; i++) { @@ -195,20 +196,23 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool occlusion) lineBatch->render(); } + float length = 40.f; // top-right: vec3 tsl = vec3(displayWidth - length - 4, -length - 4, 0.f); - vec3 tsl = vec3(displayWidth/2, -((int)displayHeight)/2, 0.f); + vec3 tsl = vec3(displayWidth/2, displayHeight/2, 0.f); glm::mat4 model(glm::translate(glm::mat4(1.f), tsl)); linesShader->uniformMatrix("u_projview", glm::ortho( 0.f, (float)displayWidth, - -(float)displayHeight, 0.f, + 0.f, (float)displayHeight, -length, length) * model * glm::inverse(camera->rotation)); + ctx.depthTest(false); lineBatch->lineWidth(4.0f); lineBatch->line(0.f, 0.f, 0.f, length, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 0.f, 1.f); lineBatch->render(); + ctx.depthTest(true); lineBatch->lineWidth(2.0f); lineBatch->line(0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 0.f, 0.f, 1.f); lineBatch->line(0.f, 0.f, 0.f, 0.f, length, 0.f, 0.f, 1.f, 0.f, 1.f);