noise/fractal: add amplitude/gain setter/getter

This commit is contained in:
Danny Robson 2015-08-28 21:07:44 +10:00
parent bedd74747c
commit 4e623262ad
3 changed files with 65 additions and 2 deletions

View File

@ -51,13 +51,19 @@ namespace util { namespace noise { namespace fractal {
constexpr T H (void) const;
T H (T);
constexpr T frequency (void) const;
T frequency (T);
constexpr T lacunarity (void) const;
T lacunarity (T);
constexpr T amplitude (void) const;
T amplitude (T);
constexpr T gain (void) const;
T gain (T);
seed_t seed (void) const;
seed_t seed (seed_t);

View File

@ -125,6 +125,46 @@ namespace util { namespace noise { namespace fractal {
}
//-------------------------------------------------------------------------
template <typename T, typename B>
constexpr T
base<T,B>::amplitude (void) const
{
return m_amplitude;
}
//-------------------------------------------------------------------------
template <typename T, typename B>
T
base<T,B>::amplitude (T _amplitude)
{
m_amplitude = _amplitude;
m_invAH = std::pow (m_amplitude, -m_H);
return m_amplitude;
}
//-------------------------------------------------------------------------
template <typename T, typename B>
constexpr T
base<T,B>::gain (void) const
{
return m_gain;
}
//-------------------------------------------------------------------------
template <typename T, typename B>
T
base<T,B>::gain (T _gain)
{
m_gain = _gain;
m_invGH = std::pow (_gain, m_H);
return m_gain;
}
//-------------------------------------------------------------------------
template <typename T, typename B>
typename base<T,B>::seed_t

View File

@ -51,6 +51,12 @@ namespace util { namespace noise { namespace fractal {
T lacunarity (void) const { return m_child->lacunarity (); }
T lacunarity (T _lacunarity) { return m_child->lacunarity (_lacunarity); }
T amplitude (void) const { return m_child->amplitude (); }
T amplitude (T _amplitude) { return m_child->amplitude (_amplitude); }
T gain (void) const { return m_child->gain (); }
T gain (T _gain) { return m_child->gain (_gain); }
B& basis (void) { return m_child->basis (); }
const B& basis (void) const { return m_child->basis (); }
@ -75,6 +81,12 @@ namespace util { namespace noise { namespace fractal {
virtual T lacunarity (void) const = 0;
virtual T lacunarity (T) = 0;
virtual T amplitude (void) const = 0;
virtual T amplitude (T) = 0;
virtual T gain (void) const = 0;
virtual T gain (T) = 0;
virtual B& basis (void) = 0;
virtual const B& basis (void) const = 0;
@ -118,13 +130,18 @@ namespace util { namespace noise { namespace fractal {
T lacunarity (void) const override { return data.lacunarity (); }
T lacunarity (T _lacunarity) override { return data.lacunarity (_lacunarity); }
T amplitude (void) const override { return data.amplitude (); }
T amplitude (T _amplitude) override { return data.amplitude (_amplitude); }
T gain (void) const override { return data.gain (); }
T gain (T _gain) override { return data.gain (_gain); }
B& basis (void) override { return data.basis (); }
const B& basis (void) const override { return data.basis (); }
seed_t seed (void) const override { return data.seed (); }
seed_t seed (seed_t _seed) override { return data.seed (_seed); }
private:
F data;
};