From 6446be1cebc63139e63f832f6f2e757e249a79fc Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Fri, 19 Nov 2021 13:25:52 -0500 Subject: [PATCH] =?UTF-8?q?Ajout=C3=A9=20checks=20de=20fin=20de=20monde=20?= =?UTF-8?q?pour=20que=20le=20bonhomme=20puisse=20sauter=20dans=20le=20vide?= =?UTF-8?q?=20et=20ne=20pas=20avoir=20d'exception=20avant!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim2021/engine.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 6f880cc..243b146 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -182,7 +182,6 @@ void Engine::Render(float elapsedTime) { Transformation all; Transformation skybox; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Transformations initiales @@ -193,11 +192,16 @@ void Engine::Render(float elapsedTime) { m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonnées du joueur et // son vecteur de vélocité (pour l'effet Doppler) m_player.ApplyTransformation(all); + m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation // (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!). glDisable(GL_LIGHT0); m_skybox.Render(skybox); + + + + // Chunks all.Use(); glEnable(GL_LIGHT0); @@ -210,7 +214,9 @@ void Engine::Render(float elapsedTime) { for (int chx = cx - CHUNK_SIZE_X * 6; chx < cx + CHUNK_SIZE_X * 6; chx+= CHUNK_SIZE_X) for (int chy = cy - CHUNK_SIZE_Z * 6; chy < cy + CHUNK_SIZE_Z * 6; chy += CHUNK_SIZE_Z) { - if (!m_world.ChunkAt(chx, 1, chy)) { + if (chx / CHUNK_SIZE_X < VIEW_DISTANCE && chy / CHUNK_SIZE_Z < VIEW_DISTANCE && + chx >= 0 && chy >= 0) + if (!m_world.ChunkAt(chx, 1, chy)) { m_world.GetChunks().Set(chx / CHUNK_SIZE_X, chy / CHUNK_SIZE_Z, new Chunk(chx / CHUNK_SIZE_X, chy / CHUNK_SIZE_Z));