paysages : Noise adjustements.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@429 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
0c7a8205c5
commit
c9d4676280
3 changed files with 19 additions and 6 deletions
1
TODO
1
TODO
|
@ -1,7 +1,6 @@
|
|||
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.
|
||||
- Replace terrain canvas editor by full sculpting editor.
|
||||
=> Add a generation dialog, with fixed resolution.
|
||||
=> Store local terrain modifications in fully dynamic canvas.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <QScrollArea>
|
||||
#include <QPushButton>
|
||||
#include <math.h>
|
||||
#include <qt4/QtGui/qwidget.h>
|
||||
|
||||
/**************** Previews ****************/
|
||||
class PreviewLevel:public BasePreview
|
||||
|
@ -124,13 +125,14 @@ DialogNoise::DialogNoise(QWidget *parent, NoiseGenerator* value):
|
|||
|
||||
function->layout()->addWidget(new QLabel(tr("Noise function")));
|
||||
function_algo = new QComboBox(function);
|
||||
function_algo->addItems(QStringList(tr("Simplex")) << tr("Perlin") << tr("Naive"));
|
||||
function_algo->addItems(QStringList(tr("Simplex (best)")) << tr("Perlin (fast)") << tr("Naive (slow)"));
|
||||
function->layout()->addWidget(function_algo);
|
||||
function->layout()->addWidget(new QLabel(tr("Ridge factor")));
|
||||
function_ridge = new QSlider(Qt::Horizontal, function);
|
||||
function_ridge->setRange(-10, 10);
|
||||
function_ridge->setTickInterval(10);
|
||||
function_ridge->setTickPosition(QSlider::TicksBelow);
|
||||
function_ridge->setMinimumWidth(150);
|
||||
function->layout()->addWidget(function_ridge);
|
||||
QObject::connect(function_algo, SIGNAL(currentIndexChanged(int)), this, SLOT(functionChanged()));
|
||||
QObject::connect(function_ridge, SIGNAL(valueChanged(int)), this, SLOT(functionChanged()));
|
||||
|
|
|
@ -361,6 +361,18 @@ void noiseNormalizeHeight(NoiseGenerator* generator, double min_height, double m
|
|||
static inline double _applyRidge(double value, double ridge)
|
||||
{
|
||||
if (ridge > 0.0)
|
||||
{
|
||||
return fabs(value + 0.5 - ridge) / (1.0 - ridge) - 0.5;
|
||||
}
|
||||
else if (ridge < 0.0)
|
||||
{
|
||||
return -fabs(value - 0.5 - ridge) / (1.0 + ridge) + 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
/*if (ridge > 0.0)
|
||||
{
|
||||
return fabs(value + 0.5 - ridge) - 0.5 + ridge;
|
||||
}
|
||||
|
@ -371,7 +383,7 @@ static inline double _applyRidge(double value, double ridge)
|
|||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -379,7 +391,7 @@ static inline double _applyRidge(double value, double ridge)
|
|||
|
||||
static inline double _get1DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x)
|
||||
{
|
||||
return _applyRidge(generator->_func_noise_1d(x / level->scaling + level->xoffset) * level->height, generator->function.ridge_factor);
|
||||
return _applyRidge(generator->_func_noise_1d(x / level->scaling + level->xoffset), generator->function.ridge_factor) * level->height;
|
||||
}
|
||||
|
||||
double noiseGet1DLevel(NoiseGenerator* generator, int level, double x)
|
||||
|
@ -436,7 +448,7 @@ double noiseGet1DDetail(NoiseGenerator* generator, double x, double detail)
|
|||
|
||||
static inline double _get2DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y)
|
||||
{
|
||||
return _applyRidge(generator->_func_noise_2d(x / level->scaling + level->xoffset, y / level->scaling + level->yoffset) * level->height, generator->function.ridge_factor);
|
||||
return _applyRidge(generator->_func_noise_2d(x / level->scaling + level->xoffset, y / level->scaling + level->yoffset), generator->function.ridge_factor) * level->height;
|
||||
}
|
||||
|
||||
double noiseGet2DLevel(NoiseGenerator* generator, int level, double x, double y)
|
||||
|
@ -493,7 +505,7 @@ double noiseGet2DDetail(NoiseGenerator* generator, double x, double y, double de
|
|||
|
||||
static inline double _get3DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y, double z)
|
||||
{
|
||||
return _applyRidge(generator->_func_noise_3d(x / level->scaling + level->xoffset, y / level->scaling + level->yoffset, z / level->scaling + level->zoffset) * level->height, generator->function.ridge_factor);
|
||||
return _applyRidge(generator->_func_noise_3d(x / level->scaling + level->xoffset, y / level->scaling + level->yoffset, z / level->scaling + level->zoffset), generator->function.ridge_factor) * level->height;
|
||||
}
|
||||
|
||||
double noiseGet3DLevel(NoiseGenerator* generator, int level, double x, double y, double z)
|
||||
|
|
Loading…
Reference in a new issue