From cccacb047c45f6429ffe93fc2e83d56f329be54e Mon Sep 17 00:00:00 2001 From: Lendemor Date: Tue, 14 Jun 2016 18:58:49 +0200 Subject: [PATCH] fixed valgrind error --- CMakeLists.txt | 7 ++++++- src/system.cpp | 2 +- src/tools/loader.cpp | 17 +---------------- src/tools/noise.cpp | 14 +++++++------- src/tools/noise.h | 3 ++- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18afc38..7a0c7e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ project(SparrowEngine) cmake_minimum_required(VERSION 2.8) +SET(VERSION_MAJOR 0) +SET(VERSION_MINOR 1) + # choose source file file(GLOB LIB_SRC_LIST src/*.cpp src/tools/*.cpp) file(GLOB LIB_HEAD_LIST src/*.h src/tools/*.h) @@ -14,4 +17,6 @@ set(USE_INPUT True) set(USE_BULLET True) set(SFML_MODULES audio graphics) -include(../cmaketemplate/template.cmake) +set(CMAKE_TEMPLATE_PATH "../CMakeTemplate") + +include(${CMAKE_TEMPLATE_PATH}/template.cmake) diff --git a/src/system.cpp b/src/system.cpp index feee297..ef8d0de 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -21,7 +21,7 @@ void InputSystem::initInput(sf::Window *window){ void InputSystem::update(){ int action; Message* message; - while (action = m_input->getAction() != NO_ACTION){ + while ((action = m_input->getAction()) != NO_ACTION){ message = new Message(std::to_string(action),SystemType::INPUT_SYSTEM); m_msgBus->postMessage(message); } diff --git a/src/tools/loader.cpp b/src/tools/loader.cpp index 70a9be5..d956796 100644 --- a/src/tools/loader.cpp +++ b/src/tools/loader.cpp @@ -7,7 +7,7 @@ #include #include #include -#include "../sparrowrenderer/src/texture.h" +#include "texture.h" #include @@ -15,7 +15,6 @@ std::string Loader::obj_directory = ""; std::string Loader::mtl_directory = ""; std::string Loader::tex_directory = ""; - std::string* Loader::loadTextFile(const std::string &filename) { std::ifstream t(filename); @@ -319,17 +318,3 @@ void Loader::setMtlDirectory(std::string dir_){ void Loader::setTexDirectory(std::string dir_){ tex_directory = dir_; } - -/* -//glfinish -void temp_glfinish(){ - for(std::size_t i=0; iinitGL(); - todos[i].target = images[i]->texture; - delete images[i]; - } - } -} -*/ diff --git a/src/tools/noise.cpp b/src/tools/noise.cpp index 77ea584..eb33832 100644 --- a/src/tools/noise.cpp +++ b/src/tools/noise.cpp @@ -41,10 +41,10 @@ float Noise::PerlinNoise2D(float x, float z) glm::vec2 grad[4]; int idx[4]; - idx[0] = calculIdx2D(x0,z0); - idx[1] = calculIdx2D(x1,z0); - idx[2] = calculIdx2D(x0,z1); - idx[3] = calculIdx2D(x1,z1); + idx[0] = process2DIndex(x0,z0); + idx[1] = process2DIndex(x1,z0); + idx[2] = process2DIndex(x0,z1); + idx[3] = process2DIndex(x1,z1); for(int i=0; i < 4; i++) grad[i] = gradient2[idx[i]]; @@ -156,13 +156,13 @@ float Noise::OctavePerlinNoise(float nb_octave, float persistence, float x, floa return total/maxAmplitude; } +// NOT IMPLEMENTED float Noise::SimplexNoise(float x, float y, float z){ - int x0, x1, y0, y1, z0, z1; - + // int x0, x1, y0, y1, z0, z1; return 1.f; } -int Noise::calculIdx2D(int x, int z) +int Noise::process2DIndex(int x, int z) { int u = x%ARBITRARY_VALUE; u = u < 0 ? u + ARBITRARY_VALUE : u; diff --git a/src/tools/noise.h b/src/tools/noise.h index 90e64c8..e80f2a6 100644 --- a/src/tools/noise.h +++ b/src/tools/noise.h @@ -12,8 +12,9 @@ private: static glm::vec2 gradient2[ARBITRARY_VALUE]; static glm::vec3 gradient3[ARBITRARY_VALUE]; static int permut[ARBITRARY_VALUE]; + //private function - static int calculIdx2D(int x, int z); // TODO : remove french namings + static int process2DIndex(int x, int z); static int fastfloor(float v); static float lerp(float a, float b, float w);