noise/fractal: add default constructors

we often use these in arrays which are annoying to construct otherwise
This commit is contained in:
Danny Robson 2015-10-13 00:01:26 +11:00
parent 02e0885ee9
commit 51b8ef762a
6 changed files with 7 additions and 10 deletions

View File

@ -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;
};

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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];
};
scale_t scale;
};

View File

@ -31,7 +31,7 @@ namespace util { namespace noise {
scale (_scale)
{
for (auto &p: perturb)
new (&p) P (_seed = hash::wang (_seed));
p.seed (_seed = hash::wang (_seed));
}
////////////////////////////////////////////////////////////////////////////