Noise: First pass of refactoring
Former-commit-id: c71e76f337fd3fc1793f105d189f3ceecb80e537 [formerly 5ac3cfc15257e407cb388bcedb1a96be5381ef67] Former-commit-id: c97fb23feb0e4bd4d6965e83d91a38cec1382e48
This commit is contained in:
@@ -12,10 +12,10 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
float HybridMultiFractal::Get(std::initializer_list<float> coordinates, float scale) const
|
||||
float HybridMultiFractal::Get(float x, float y, float scale) const
|
||||
{
|
||||
float offset = 1.0f;
|
||||
float value = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(0);
|
||||
float value = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(0);
|
||||
float weight = value;
|
||||
float signal = 0.f;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
if (weight > 1.f)
|
||||
weight = 1.f;
|
||||
|
||||
signal = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(i);
|
||||
signal = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(i);
|
||||
value += weight * signal;
|
||||
weight *= signal;
|
||||
scale *= m_lacunarity;
|
||||
@@ -35,7 +35,63 @@ namespace Nz
|
||||
float remainder = m_octaves - static_cast<int>(m_octaves);
|
||||
|
||||
if (remainder > 0.f)
|
||||
value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast<int>(m_octaves-1));
|
||||
value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast<int>(m_octaves-1));
|
||||
|
||||
return value / m_sum - offset;
|
||||
}
|
||||
|
||||
float HybridMultiFractal::Get(float x, float y, float z, float scale) const
|
||||
{
|
||||
float offset = 1.0f;
|
||||
float value = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(0);
|
||||
float weight = value;
|
||||
float signal = 0.f;
|
||||
|
||||
scale *= m_lacunarity;
|
||||
|
||||
for(int i(1) ; i < m_octaves; ++i)
|
||||
{
|
||||
if (weight > 1.f)
|
||||
weight = 1.f;
|
||||
|
||||
signal = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(i);
|
||||
value += weight * signal;
|
||||
weight *= signal;
|
||||
scale *= m_lacunarity;
|
||||
}
|
||||
|
||||
float remainder = m_octaves - static_cast<int>(m_octaves);
|
||||
|
||||
if (remainder > 0.f)
|
||||
value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast<int>(m_octaves-1));
|
||||
|
||||
return value / m_sum - offset;
|
||||
}
|
||||
|
||||
float HybridMultiFractal::Get(float x, float y, float z, float w, float scale) const
|
||||
{
|
||||
float offset = 1.0f;
|
||||
float value = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(0);
|
||||
float weight = value;
|
||||
float signal = 0.f;
|
||||
|
||||
scale *= m_lacunarity;
|
||||
|
||||
for(int i(1) ; i < m_octaves; ++i)
|
||||
{
|
||||
if (weight > 1.f)
|
||||
weight = 1.f;
|
||||
|
||||
signal = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(i);
|
||||
value += weight * signal;
|
||||
weight *= signal;
|
||||
scale *= m_lacunarity;
|
||||
}
|
||||
|
||||
float remainder = m_octaves - static_cast<int>(m_octaves);
|
||||
|
||||
if (remainder > 0.f)
|
||||
value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast<int>(m_octaves-1));
|
||||
|
||||
return value / m_sum - offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user