This commit is contained in:
MihailRis 2023-11-16 19:55:31 +03:00
parent 6cd775c27d
commit 0ec7f3348e

View File

@ -23,6 +23,7 @@
#include "../objects/player_control.h"
#include "../maths/FrustumCulling.h"
using glm::vec3;
using std::shared_ptr;
WorldRenderer::WorldRenderer(Level* level, Assets* assets) : assets(assets), level(level) {
@ -52,8 +53,8 @@ bool WorldRenderer::drawChunk(size_t index, Camera* camera, Shader* shader, bool
// Simple frustum culling
if (occlusion){
glm::vec3 min(chunk->x * CHUNK_W, chunk->bottom, chunk->z * CHUNK_D);
glm::vec3 max(chunk->x * CHUNK_W + CHUNK_W, chunk->top, chunk->z * CHUNK_D + CHUNK_D);
vec3 min(chunk->x * CHUNK_W, chunk->bottom, chunk->z * CHUNK_D);
vec3 max(chunk->x * CHUNK_W + CHUNK_W, chunk->top, chunk->z * CHUNK_D + CHUNK_D);
if (!frustumCulling->IsBoxVisible(min, max)) return false;
}
@ -145,7 +146,7 @@ void WorldRenderer::draw(Camera* camera, bool occlusion, float fogFactor, float
float lenght = 40.f;
linesShader->use();
glm::mat4 model(glm::translate(glm::mat4(1.f), glm::vec3(Window::width >> 1, -static_cast<int>(Window::height) >> 1, 0.f)));
glm::mat4 model(glm::translate(glm::mat4(1.f), vec3(Window::width >> 1, -static_cast<int>(Window::height) >> 1, 0.f)));
linesShader->uniformMatrix("u_projview", glm::ortho(0.f, static_cast<float>(Window::width), -static_cast<float>(Window::height), 0.f, -lenght, lenght) * model * glm::inverse(camera->rotation));
glDisable(GL_DEPTH_TEST);