noise/basis: parameterise lerp function
This commit is contained in:
parent
ebbc90c88d
commit
cacaee4c5d
@ -82,27 +82,27 @@ basis::eval (double, double) const
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
value<L>::value (seed_t _seed):
|
||||
basis (_seed)
|
||||
{ ; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
value<L>::value ()
|
||||
{ ; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
util::range<double>
|
||||
value<L>::bounds (void) const
|
||||
{ return { -1.0, 1.0 }; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
double
|
||||
value<L>::eval (double x, double y) const {
|
||||
intmax_t x_int = static_cast<intmax_t> (x);
|
||||
@ -140,27 +140,27 @@ namespace util {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
gradient<L>::gradient (seed_t _seed):
|
||||
basis (_seed)
|
||||
{ ; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
gradient<L>::gradient ()
|
||||
{ ; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
util::range<double>
|
||||
gradient<L>::bounds (void) const
|
||||
{ return { -sqrt(2.0) / 2.0, sqrt (2.0) / 2.0 }; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <util::noise::lerp_function L>
|
||||
template <util::noise::lerp_t<double> L>
|
||||
double
|
||||
gradient<L>::eval (double x, double y) const {
|
||||
intmax_t x_int = static_cast<intmax_t> (x);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
namespace util {
|
||||
namespace noise {
|
||||
typedef double (*lerp_function)(double, double, double);
|
||||
template <typename T> using lerp_t = T (*)(T,T,T);
|
||||
|
||||
struct basis {
|
||||
typedef uint64_t seed_t;
|
||||
@ -40,7 +40,7 @@ namespace util {
|
||||
|
||||
|
||||
/// Perlin: single value per grid space
|
||||
template <lerp_function L>
|
||||
template <lerp_t<double>>
|
||||
struct value : public basis {
|
||||
value (seed_t);
|
||||
value ();
|
||||
@ -51,7 +51,7 @@ namespace util {
|
||||
|
||||
|
||||
/// Perlin: interpolated value across each grid space
|
||||
template <lerp_function L>
|
||||
template <lerp_t<double>L>
|
||||
struct gradient : public basis {
|
||||
gradient (seed_t);
|
||||
gradient ();
|
||||
|
Loading…
Reference in New Issue
Block a user