From 69fba0fc6909340b8f4c2d3d2c192be5f21569dc Mon Sep 17 00:00:00 2001 From: Michael Lemaire Date: Tue, 20 May 2014 10:39:02 +0200 Subject: [PATCH] Fixed some unit tests issues --- src/basics/NoiseGenerator.cpp | 9 ++++++--- src/basics/NoiseGenerator.h | 3 ++- src/tests/TerrainPainting_Test.cpp | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/basics/NoiseGenerator.cpp b/src/basics/NoiseGenerator.cpp index 7dcafd6..06b3f85 100644 --- a/src/basics/NoiseGenerator.cpp +++ b/src/basics/NoiseGenerator.cpp @@ -112,6 +112,8 @@ void NoiseGenerator::validate() _func_noise_2d = noiseSimplexGet2DValue; _func_noise_3d = noiseSimplexGet3DValue; break; + case NOISE_FUNCTION_CUSTOM: + break; } if (function.ridge_factor > 0.5) @@ -163,9 +165,10 @@ void NoiseGenerator::setFunction(NoiseFunction* function) void NoiseGenerator::setCustomFunction(double (*func1d)(double x), double (*func2d)(double x, double y), double (*func3d)(double x, double y, double z)) { - this->_func_noise_1d = func1d; - this->_func_noise_2d = func2d; - this->_func_noise_3d = func3d; + _func_noise_1d = func1d; + _func_noise_2d = func2d; + _func_noise_3d = func3d; + function.algorithm = NOISE_FUNCTION_CUSTOM; } void NoiseGenerator::setFunctionParams(NoiseFunctionAlgorithm algorithm, double ridge_factor, double curve_factor) diff --git a/src/basics/NoiseGenerator.h b/src/basics/NoiseGenerator.h index 6bb3d4d..89eb688 100644 --- a/src/basics/NoiseGenerator.h +++ b/src/basics/NoiseGenerator.h @@ -15,7 +15,8 @@ public: typedef enum { NOISE_FUNCTION_PERLIN, - NOISE_FUNCTION_SIMPLEX + NOISE_FUNCTION_SIMPLEX, + NOISE_FUNCTION_CUSTOM } NoiseFunctionAlgorithm; typedef struct diff --git a/src/tests/TerrainPainting_Test.cpp b/src/tests/TerrainPainting_Test.cpp index 13274f0..6f4f542 100644 --- a/src/tests/TerrainPainting_Test.cpp +++ b/src/tests/TerrainPainting_Test.cpp @@ -31,6 +31,7 @@ protected: terrain->height = 3.0; terrain->scaling = 1.0; terrain->_height_noise->clearLevels(); + terrain->water_height = 0.0; NoiseGenerator::NoiseLevel level = {1.0, 2.0, -1.0}; terrain->_height_noise->addLevel(level); noise_state.resetOffsets();