paysages : Small refactor.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@423 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-08-26 20:38:28 +00:00 committed by ThunderK
parent b5ff5d60a6
commit 07077845b3
5 changed files with 29 additions and 27 deletions

2
TODO
View file

@ -1,6 +1,8 @@
Technology Preview 2 : Technology Preview 2 :
- Fully move layer management from BaseForm to BaseFormLayer. - Fully move layer management from BaseForm to BaseFormLayer.
- Replace math.h methods by optimized ones (fastfloor, fastsin...). - 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. - Replace terrain canvas editor by full sculpting editor.
=> Add a generation dialog, with fixed resolution. => Add a generation dialog, with fixed resolution.
=> Store local terrain modifications in fully dynamic canvas. => Store local terrain modifications in fully dynamic canvas.

View file

@ -5,7 +5,7 @@
#include <string.h> #include <string.h>
#include "tools.h" #include "tools.h"
#include "simplexnoise.h" #include "noisesimplex.h"
#define MAX_LEVEL_COUNT 30 #define MAX_LEVEL_COUNT 30
@ -22,7 +22,7 @@ struct NoiseGenerator
void noiseInit() void noiseInit()
{ {
simplexNoiseInit(); noiseSimplexInit();
} }
void noiseQuit() void noiseQuit()
@ -274,7 +274,7 @@ void noiseNormalizeHeight(NoiseGenerator* generator, double min_height, double m
static inline double _get1DRawNoiseValue(NoiseGenerator* generator, double x) 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) 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) 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) 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) 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) static inline double _get3DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y, double z)

View file

@ -1,4 +1,4 @@
#include "simplexnoise.h" #include "noisesimplex.h"
/* /*
* Simplex noise implementation. * 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; return g.x * x + g.y * y + g.z * z + g.w * w;
} }
void simplexNoiseInit() void noiseSimplexInit()
{ {
int i; int i;
@ -139,7 +139,7 @@ void simplexNoiseInit()
_G4 = (5.0 - sqrt(5.0)) / 20.0; _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 */ double n0, n1, n2; /* Noise contributions from the three corners */
/* Skew the input space to determine which simplex cell we're in */ /* 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); 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 */ double n0, n1, n2, n3; /* Noise contributions from the four corners */
/* Skew the input space to determine which simplex cell we're in */ /* 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); 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 */ 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 */ /* Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in */

View file

@ -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

View file

@ -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