From 07077845b311feba448acc85df285ffee8e33f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sun, 26 Aug 2012 20:38:28 +0000 Subject: [PATCH] paysages : Small refactor. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@423 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 2 ++ lib_paysages/noise.c | 10 +++++----- lib_paysages/{simplexnoise.c => noisesimplex.c} | 10 +++++----- lib_paysages/noisesimplex.h | 17 +++++++++++++++++ lib_paysages/simplexnoise.h | 17 ----------------- 5 files changed, 29 insertions(+), 27 deletions(-) rename lib_paysages/{simplexnoise.c => noisesimplex.c} (98%) create mode 100644 lib_paysages/noisesimplex.h delete mode 100644 lib_paysages/simplexnoise.h diff --git a/TODO b/TODO index a7fe1b8..9916908 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ Technology Preview 2 : - Fully move layer management from BaseForm to BaseFormLayer. - Replace math.h methods by optimized ones (fastfloor, fastsin...). +- Reimplement perlin noise and custom noise. +- Add ridged noise option (with configurable ridge offset and direction). - Replace terrain canvas editor by full sculpting editor. => Add a generation dialog, with fixed resolution. => Store local terrain modifications in fully dynamic canvas. diff --git a/lib_paysages/noise.c b/lib_paysages/noise.c index 22bfd0f..9f4fc3d 100644 --- a/lib_paysages/noise.c +++ b/lib_paysages/noise.c @@ -5,7 +5,7 @@ #include #include "tools.h" -#include "simplexnoise.h" +#include "noisesimplex.h" #define MAX_LEVEL_COUNT 30 @@ -22,7 +22,7 @@ struct NoiseGenerator void noiseInit() { - simplexNoiseInit(); + noiseSimplexInit(); } void noiseQuit() @@ -274,7 +274,7 @@ void noiseNormalizeHeight(NoiseGenerator* generator, double min_height, double m static inline double _get1DRawNoiseValue(NoiseGenerator* generator, double x) { - return simplexNoiseGet2DValue(x, 0.0) * 0.5; + return noiseSimplexGet2DValue(x, 0.0) * 0.5; } static inline double _get1DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x) @@ -336,7 +336,7 @@ double noiseGet1DDetail(NoiseGenerator* generator, double x, double detail) static inline double _get2DRawNoiseValue(NoiseGenerator* generator, double x, double y) { - return simplexNoiseGet2DValue(x, y) * 0.5; + return noiseSimplexGet2DValue(x, y) * 0.5; } static inline double _get2DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y) @@ -398,7 +398,7 @@ double noiseGet2DDetail(NoiseGenerator* generator, double x, double y, double de static inline double _get3DRawNoiseValue(NoiseGenerator* generator, double x, double y, double z) { - return simplexNoiseGet3DValue(x, y, z) * 0.5; + return noiseSimplexGet3DValue(x, y, z) * 0.5; } static inline double _get3DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y, double z) diff --git a/lib_paysages/simplexnoise.c b/lib_paysages/noisesimplex.c similarity index 98% rename from lib_paysages/simplexnoise.c rename to lib_paysages/noisesimplex.c index a588ff2..79e7451 100644 --- a/lib_paysages/simplexnoise.c +++ b/lib_paysages/noisesimplex.c @@ -1,4 +1,4 @@ -#include "simplexnoise.h" +#include "noisesimplex.h" /* * Simplex noise implementation. @@ -119,7 +119,7 @@ static double _dot4(Grad4 g, double x, double y, double z, double w) return g.x * x + g.y * y + g.z * z + g.w * w; } -void simplexNoiseInit() +void noiseSimplexInit() { int i; @@ -139,7 +139,7 @@ void simplexNoiseInit() _G4 = (5.0 - sqrt(5.0)) / 20.0; } -double simplexNoiseGet2DValue(double xin, double yin) +double noiseSimplexGet2DValue(double xin, double yin) { double n0, n1, n2; /* Noise contributions from the three corners */ /* Skew the input space to determine which simplex cell we're in */ @@ -204,7 +204,7 @@ double simplexNoiseGet2DValue(double xin, double yin) return 70.0 * (n0 + n1 + n2); } -double simplexNoiseGet3DValue(double xin, double yin, double zin) +double noiseSimplexGet3DValue(double xin, double yin, double zin) { double n0, n1, n2, n3; /* Noise contributions from the four corners */ /* Skew the input space to determine which simplex cell we're in */ @@ -338,7 +338,7 @@ double simplexNoiseGet3DValue(double xin, double yin, double zin) return 32.0 * (n0 + n1 + n2 + n3); } -double simplexNoiseGet4DValue(double x, double y, double z, double w) +double noiseSimplexGet4DValue(double x, double y, double z, double w) { double n0, n1, n2, n3, n4; /* Noise contributions from the five corners */ /* Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in */ diff --git a/lib_paysages/noisesimplex.h b/lib_paysages/noisesimplex.h new file mode 100644 index 0000000..1ecdd77 --- /dev/null +++ b/lib_paysages/noisesimplex.h @@ -0,0 +1,17 @@ +#ifndef _PAYSAGES_SIMPLEXNOISE_H_ +#define _PAYSAGES_SIMPLEXNOISE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +void noiseSimplexInit(); +double noiseSimplexGet2DValue(double xin, double yin); +double noiseSimplexGet3DValue(double xin, double yin, double zin); +double noiseSimplexGet4DValue(double x, double y, double z, double w); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib_paysages/simplexnoise.h b/lib_paysages/simplexnoise.h deleted file mode 100644 index 4e7be70..0000000 --- a/lib_paysages/simplexnoise.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _PAYSAGES_SIMPLEXNOISE_H_ -#define _PAYSAGES_SIMPLEXNOISE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -void simplexNoiseInit(); -double simplexNoiseGet2DValue(double xin, double yin); -double simplexNoiseGet3DValue(double xin, double yin, double zin); -double simplexNoiseGet4DValue(double x, double y, double z, double w); - -#ifdef __cplusplus -} -#endif - -#endif