n/fractal: extract constants into named variables

This commit is contained in:
Danny Robson 2015-05-26 16:53:24 +10:00
parent 9701290c4b
commit 6c27fa420a
2 changed files with 25 additions and 3 deletions

View File

@ -88,7 +88,12 @@ fbm<T,B>::fbm (unsigned _octaves,
//-----------------------------------------------------------------------------
template <typename T, typename B>
fbm<T,B>::fbm ():
fbm<T,B> (8, T(0.1), 2, 1, 1/T(2), rand ())
fbm<T,B> (DEFAULT_OCTAVES,
DEFAULT_FREQUENCY,
DEFAULT_LACUNARITY,
DEFAULT_AMPLITUDE,
DEFAULT_GAIN,
rand ())
{ ; }
@ -148,7 +153,12 @@ rmf<T,B>::rmf (unsigned _octaves,
//-----------------------------------------------------------------------------
template <typename T, typename B>
rmf<T,B>::rmf ():
rmf<T,B> (6, T(1), 2, 1, T(2), rand ())
rmf<T,B> (DEFAULT_OCTAVES,
DEFAULT_FREQUENCY,
DEFAULT_LACUNARITY,
DEFAULT_AMPLITUDE,
DEFAULT_GAIN,
rand ())
{ ; }

View File

@ -50,6 +50,12 @@ namespace util {
struct fbm : public fractal<T> {
using seed_t = typename basis<T>::seed_t;
static constexpr unsigned DEFAULT_OCTAVES = 8;
static constexpr T DEFAULT_FREQUENCY = T(0.1);
static constexpr T DEFAULT_LACUNARITY = 2;
static constexpr T DEFAULT_AMPLITUDE = 1;
static constexpr T DEFAULT_GAIN = 1 / T(2);
fbm (unsigned octaves,
T frequency,
T lacunarity,
@ -71,7 +77,7 @@ namespace util {
};
/// Rigid Multifractal noise summation, based on Musgrave's algorithm
/// Rigid Multifractal summation, based on Musgrave's algorithm
///
/// octaves: count of layers to be summed
/// frequency: point scaling factor for the base octave
@ -80,6 +86,12 @@ namespace util {
struct rmf : public fractal<T> {
using seed_t = typename basis<T>::seed_t;
static constexpr unsigned DEFAULT_OCTAVES = 5;
static constexpr T DEFAULT_FREQUENCY = T(1);
static constexpr T DEFAULT_LACUNARITY = 2;
static constexpr T DEFAULT_AMPLITUDE = 1;
static constexpr T DEFAULT_GAIN = 2;
rmf (unsigned octaves,
T frequency,
T lacunarity,