From 880c634be0e2a0ca944d3b8e079509e2141d94cb Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Thu, 21 Sep 2023 15:43:51 +0200 Subject: [PATCH] camera: set atomic position at startup this avoids the first few chunk update loops recognizing the camera as being positioned at (0,0,0), which in turns avoids wastefully generating chunks out of view at startup --- include/camera.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/camera.hpp b/include/camera.hpp index ca35f42..9460182 100644 --- a/include/camera.hpp +++ b/include/camera.hpp @@ -18,6 +18,10 @@ public: // This matrix needs to be also updated in viewPortCallback whenever it is changed projection = glm::perspective(glm::radians(90.0f), 800.0f / 600.0f, 0.1f, 1200.0f); + + posX = cameraPos.x; + posY = cameraPos.y; + posZ = cameraPos.z; } void update(GLFWwindow *window, float deltaTime) @@ -112,7 +116,7 @@ public: private: - glm::vec3 cameraPos = glm::vec3(256.0, 80.0f, 256.0f); + glm::vec3 cameraPos = glm::vec3(512.0, 80.0f, 512.0f); glm::vec3 cameraFront = glm::vec3(0.0f, 0.0f, -1.0f); glm::vec3 cameraUp = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 direction = glm::vec3(0.0f);