From 9cb9ef381197c7e378937a5a0de01a0d1412ab79 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 11 Jun 2015 19:32:57 +1000 Subject: [PATCH] n/turbulence: add seed accessors --- noise/turbulence.hpp | 3 +++ noise/turbulence.ipp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/noise/turbulence.hpp b/noise/turbulence.hpp index f24057ce..9ccb10eb 100644 --- a/noise/turbulence.hpp +++ b/noise/turbulence.hpp @@ -34,6 +34,9 @@ namespace util { namespace noise { using seed_t = uint64_t; turbulence (seed_t, vector<2,T> scale); + seed_t seed (seed_t); + seed_t seed (void) const; + constexpr T operator() (point<2,T>) const; D data; diff --git a/noise/turbulence.ipp b/noise/turbulence.ipp index f0ebd8a4..8d66bb64 100644 --- a/noise/turbulence.ipp +++ b/noise/turbulence.ipp @@ -32,6 +32,29 @@ namespace util { namespace noise { scale (_scale) { ; } + //////////////////////////////////////////////////////////////////////////// + template + typename turbulence::seed_t + turbulence::seed (void) const + { + return data.seed (); + } + + + //------------------------------------------------------------------------- + template + typename turbulence::seed_t + turbulence::seed (seed_t _seed) + { + auto ret = _seed; + + data.seed (_seed); _seed = hash::wang (_seed); + perturb[0].seed (_seed); _seed = hash::wang (_seed); + perturb[1].seed (_seed); _seed = hash::wang (_seed); + + return ret; + } + /////////////////////////////////////////////////////////////////////////// template