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