From 4e623262ad85183b0b5fac75ece3f64b5f1c0b02 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 28 Aug 2015 21:07:44 +1000 Subject: [PATCH] noise/fractal: add amplitude/gain setter/getter --- noise/fractal/base.hpp | 8 +++++++- noise/fractal/base.ipp | 40 +++++++++++++++++++++++++++++++++++++++ noise/fractal/runtime.hpp | 19 ++++++++++++++++++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/noise/fractal/base.hpp b/noise/fractal/base.hpp index c45e7ba4..32f15ccd 100644 --- a/noise/fractal/base.hpp +++ b/noise/fractal/base.hpp @@ -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); diff --git a/noise/fractal/base.ipp b/noise/fractal/base.ipp index 8f73c798..2599705a 100644 --- a/noise/fractal/base.ipp +++ b/noise/fractal/base.ipp @@ -125,6 +125,46 @@ namespace util { namespace noise { namespace fractal { } + //------------------------------------------------------------------------- + template + constexpr T + base::amplitude (void) const + { + return m_amplitude; + } + + + //------------------------------------------------------------------------- + template + T + base::amplitude (T _amplitude) + { + m_amplitude = _amplitude; + m_invAH = std::pow (m_amplitude, -m_H); + return m_amplitude; + } + + + //------------------------------------------------------------------------- + template + constexpr T + base::gain (void) const + { + return m_gain; + } + + + //------------------------------------------------------------------------- + template + T + base::gain (T _gain) + { + m_gain = _gain; + m_invGH = std::pow (_gain, m_H); + return m_gain; + } + + //------------------------------------------------------------------------- template typename base::seed_t diff --git a/noise/fractal/runtime.hpp b/noise/fractal/runtime.hpp index bd3c1910..8cf3b6e1 100644 --- a/noise/fractal/runtime.hpp +++ b/noise/fractal/runtime.hpp @@ -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; };