From 4f7a3d790f1980dac6a3a253c842a6cd66869bf7 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 2 Jun 2015 16:17:44 +1000 Subject: [PATCH] n/f/fbm: accumulate frequency directly on point avoids (minimal) extra multiplications. --- noise/fractal/fbm.ipp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/noise/fractal/fbm.ipp b/noise/fractal/fbm.ipp index 8302b61a..7021aafa 100644 --- a/noise/fractal/fbm.ipp +++ b/noise/fractal/fbm.ipp @@ -60,14 +60,15 @@ namespace util { namespace noise { namespace fractal { fbm::operator() (util::point<2,T> p) const { T total = 0; - T f = this->m_frequency; - T a = this->m_invAH; + T scale = this->m_invAH; + + p *= this->m_frequency; for (size_t i = 0; i < this->m_octaves; ++i) { - total += this->m_basis (p * f) * a; + total += this->m_basis (p) * scale; - f *= this->m_lacunarity; - a *= this->m_invGH; + p *= this->m_lacunarity; + scale *= this->m_invGH; } return total;