n/fractal: style/cleanup

This commit is contained in:
Danny Robson 2015-05-26 16:53:50 +10:00
parent 6c27fa420a
commit 0f18702ff9

View File

@ -166,32 +166,37 @@ rmf<T,B>::rmf ():
template <typename T, typename B> template <typename T, typename B>
T T
rmf<T,B>::operator() (T x, T y) const { rmf<T,B>::operator() (T x, T y) const {
T H = 1; const T offset = 1;
const T H = 1;
T exponents[octaves]; T exponents[octaves];
T offset = 1; for (size_t i = 0; i < octaves; ++i)
exponents[i] = std::pow (std::pow (lacunarity, float (i)), -H);
T f = 1.f; T signal = 0;
for (size_t i = 0; i < octaves; ++i) { T result = 0;
exponents[i] = std::pow (f, -H); T weight = 1;
f *= lacunarity;
}
T signal = 0, result = 0, weight = 1;
x *= frequency; x *= frequency;
y *= frequency; y *= frequency;
for (size_t i = 0; i < octaves; ++i) { for (size_t i = 0; i < octaves; ++i) {
// generates ridged noise
signal = basis (x, y); signal = basis (x, y);
signal = std::fabs (signal); signal = std::fabs (signal);
signal = offset - signal; signal = offset - signal;
// sharpens the ridges
signal *= signal; signal *= signal;
// influence by sharpness of previous iteration
signal *= weight; signal *= weight;
// contribute to the weight
weight = signal * gain; weight = signal * gain;
weight = limit (weight, 0, 1); weight = limit (weight, 0, 1);
// record and continue
result += signal * exponents[i]; result += signal * exponents[i];
x *= lacunarity; x *= lacunarity;