From 51b8ef762ae23288a90281fd5046056bf4db50b6 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 13 Oct 2015 00:01:26 +1100 Subject: [PATCH] noise/fractal: add default constructors we often use these in arrays which are annoying to construct otherwise --- noise/fractal/fbm.hpp | 2 +- noise/fractal/hetero.hpp | 2 +- noise/fractal/hmf.hpp | 2 +- noise/fractal/rmf.hpp | 2 +- noise/turbulence.hpp | 5 +---- noise/turbulence.ipp | 4 ++-- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/noise/fractal/fbm.hpp b/noise/fractal/fbm.hpp index 7972f2d7..9c5a7b40 100644 --- a/noise/fractal/fbm.hpp +++ b/noise/fractal/fbm.hpp @@ -52,7 +52,7 @@ namespace util { namespace noise { namespace fractal { value_t lacunarity, value_t amplitude, value_t gain); - fbm (seed_t); + explicit fbm (seed_t = 0); value_t operator() (point_t) const noexcept; }; diff --git a/noise/fractal/hetero.hpp b/noise/fractal/hetero.hpp index cc87b9da..a9926033 100644 --- a/noise/fractal/hetero.hpp +++ b/noise/fractal/hetero.hpp @@ -55,7 +55,7 @@ namespace util { namespace noise { namespace fractal { value_t gain, value_t offset); - hetero (seed_t); + explicit hetero (seed_t = 0); constexpr value_t offset (void) const; value_t offset (value_t); diff --git a/noise/fractal/hmf.hpp b/noise/fractal/hmf.hpp index 141dca34..7e3311ea 100644 --- a/noise/fractal/hmf.hpp +++ b/noise/fractal/hmf.hpp @@ -47,7 +47,7 @@ namespace util { namespace noise { namespace fractal { value_t gain, value_t offset); - hmf (seed_t); + explicit hmf (seed_t = 0); value_t operator() (point_t) const; diff --git a/noise/fractal/rmf.hpp b/noise/fractal/rmf.hpp index d51a43f7..6c06d526 100644 --- a/noise/fractal/rmf.hpp +++ b/noise/fractal/rmf.hpp @@ -54,7 +54,7 @@ namespace util { namespace noise { namespace fractal { value_t gain, value_t offset); - rmf (seed_t); + explicit rmf (seed_t = 0); value_t operator() (point_t) const; diff --git a/noise/turbulence.hpp b/noise/turbulence.hpp index d8b22eeb..70e56dc1 100644 --- a/noise/turbulence.hpp +++ b/noise/turbulence.hpp @@ -57,10 +57,7 @@ namespace util { namespace noise { // XXX: use a union to defer initialization of pertubation fractals in // the constructor. i know this is horrible, but there's no time to // write the proper generator constructor to pass out the seeds. - union { - char _; - P perturb[S]; - }; + P perturb[S]; scale_t scale; }; diff --git a/noise/turbulence.ipp b/noise/turbulence.ipp index a0a42f82..89d73768 100644 --- a/noise/turbulence.ipp +++ b/noise/turbulence.ipp @@ -26,12 +26,12 @@ namespace util { namespace noise { /////////////////////////////////////////////////////////////////////////// template turbulence::turbulence (seed_t _seed, - scale_t _scale): + scale_t _scale): data (_seed), scale (_scale) { for (auto &p: perturb) - new (&p) P (_seed = hash::wang (_seed)); + p.seed (_seed = hash::wang (_seed)); } ////////////////////////////////////////////////////////////////////////////