From cacaee4c5d0ca976d9e8512a55a8b7d9b39c8f00 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 18 May 2015 15:01:06 +1000 Subject: [PATCH] noise/basis: parameterise lerp function --- noise/basis.cpp | 16 ++++++++-------- noise/basis.hpp | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/noise/basis.cpp b/noise/basis.cpp index a1eb594d..ffdffe1f 100644 --- a/noise/basis.cpp +++ b/noise/basis.cpp @@ -82,27 +82,27 @@ basis::eval (double, double) const /////////////////////////////////////////////////////////////////////////////// -template +template L> value::value (seed_t _seed): basis (_seed) { ; } //----------------------------------------------------------------------------- -template +template L> value::value () { ; } //----------------------------------------------------------------------------- -template +template L> util::range value::bounds (void) const { return { -1.0, 1.0 }; } //----------------------------------------------------------------------------- -template +template L> double value::eval (double x, double y) const { intmax_t x_int = static_cast (x); @@ -140,27 +140,27 @@ namespace util { /////////////////////////////////////////////////////////////////////////////// -template +template L> gradient::gradient (seed_t _seed): basis (_seed) { ; } //----------------------------------------------------------------------------- -template +template L> gradient::gradient () { ; } //----------------------------------------------------------------------------- -template +template L> util::range gradient::bounds (void) const { return { -sqrt(2.0) / 2.0, sqrt (2.0) / 2.0 }; } //----------------------------------------------------------------------------- -template +template L> double gradient::eval (double x, double y) const { intmax_t x_int = static_cast (x); diff --git a/noise/basis.hpp b/noise/basis.hpp index 9f7e6dd4..a1bd30c5 100644 --- a/noise/basis.hpp +++ b/noise/basis.hpp @@ -23,7 +23,7 @@ namespace util { namespace noise { - typedef double (*lerp_function)(double, double, double); + template 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 + template > struct value : public basis { value (seed_t); value (); @@ -51,7 +51,7 @@ namespace util { /// Perlin: interpolated value across each grid space - template + template L> struct gradient : public basis { gradient (seed_t); gradient ();