noise: add constexpr to eval functions
This commit is contained in:
parent
59909ed860
commit
1ec4b7b9a1
@ -30,7 +30,7 @@ namespace util { namespace noise { namespace basis {
|
|||||||
perlin ();
|
perlin ();
|
||||||
|
|
||||||
range<T> bounds (void) const;
|
range<T> bounds (void) const;
|
||||||
T operator() (point<2,T>) const;
|
constexpr T operator() (point<2,T>) const;
|
||||||
|
|
||||||
seed_t seed;
|
seed_t seed;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace util { namespace noise { namespace basis {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, util::noise::lerp_t<T> L>
|
template <typename T, util::noise::lerp_t<T> L>
|
||||||
T
|
constexpr T
|
||||||
perlin<T,L>::operator() (util::point<2,T> p) const
|
perlin<T,L>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
// extract integer and fractional parts. be careful to always round down
|
// extract integer and fractional parts. be careful to always round down
|
||||||
|
@ -30,7 +30,7 @@ namespace util { namespace noise { namespace basis {
|
|||||||
value ();
|
value ();
|
||||||
|
|
||||||
range<T> bounds (void) const;
|
range<T> bounds (void) const;
|
||||||
T operator() (util::point<2,T>) const;
|
constexpr T operator() (util::point<2,T>) const;
|
||||||
|
|
||||||
seed_t seed;
|
seed_t seed;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace util { namespace noise { namespace basis {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, util::noise::lerp_t<T> L>
|
template <typename T, util::noise::lerp_t<T> L>
|
||||||
T
|
constexpr T
|
||||||
value<T,L>::operator() (util::point<2,T> p) const
|
value<T,L>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
// extract integer and fractional parts. be careful to always round down
|
// extract integer and fractional parts. be careful to always round down
|
||||||
|
@ -29,7 +29,7 @@ namespace util { namespace noise { namespace basis {
|
|||||||
worley ();
|
worley ();
|
||||||
|
|
||||||
range<T> bounds (void) const;
|
range<T> bounds (void) const;
|
||||||
T operator() (util::point<2,T>) const;
|
constexpr T operator() (util::point<2,T>) const;
|
||||||
|
|
||||||
seed_t seed;
|
seed_t seed;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace util { namespace noise { namespace basis {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, size_t F>
|
template <typename T, size_t F>
|
||||||
T
|
constexpr T
|
||||||
worley<T,F>::operator() (util::point<2,T> p) const
|
worley<T,F>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
// extract integer and fractional parts. be careful to always round down
|
// extract integer and fractional parts. be careful to always round down
|
||||||
@ -61,8 +61,8 @@ namespace util { namespace noise { namespace basis {
|
|||||||
auto p_rem = abs (p - p_int).template as<point> ();
|
auto p_rem = abs (p - p_int).template as<point> ();
|
||||||
|
|
||||||
// setup an array of distances
|
// setup an array of distances
|
||||||
static constexpr size_t RADIUS = 1;
|
constexpr size_t RADIUS = 1;
|
||||||
static constexpr size_t COUNT = pow2 (RADIUS * 2 + 1);
|
constexpr size_t COUNT = pow2 (RADIUS * 2 + 1);
|
||||||
T distances[COUNT] = { std::numeric_limits<T>::quiet_NaN () };
|
T distances[COUNT] = { std::numeric_limits<T>::quiet_NaN () };
|
||||||
T *cursor = distances;
|
T *cursor = distances;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
T gain;
|
T gain;
|
||||||
|
|
||||||
B basis;
|
B basis;
|
||||||
T operator() (util::point<2,T>) const;
|
constexpr T operator() (util::point<2,T>) const;
|
||||||
};
|
};
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, typename B>
|
template <typename T, typename B>
|
||||||
T
|
constexpr T
|
||||||
fbm<T,B>::operator() (util::point<2,T> p) const
|
fbm<T,B>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
T total = 0;
|
T total = 0;
|
||||||
|
@ -44,7 +44,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
|
|
||||||
B basis;
|
B basis;
|
||||||
|
|
||||||
T operator() (util::point<2,T>) const;
|
constexpr T operator() (util::point<2,T>) const;
|
||||||
};
|
};
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, typename B>
|
template <typename T, typename B>
|
||||||
T
|
constexpr T
|
||||||
hetero<T,B>::operator() (util::point<2,T> p) const
|
hetero<T,B>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
T exponents[octaves];
|
T exponents[octaves];
|
||||||
|
@ -44,7 +44,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
|
|
||||||
B basis;
|
B basis;
|
||||||
|
|
||||||
T operator() (util::point<2,T>) const;
|
constexpr T operator() (util::point<2,T>) const;
|
||||||
};
|
};
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, typename B>
|
template <typename T, typename B>
|
||||||
T
|
constexpr T
|
||||||
hmf<T,B>::operator() (util::point<2,T> p) const
|
hmf<T,B>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
T exponents[octaves];
|
T exponents[octaves];
|
||||||
|
@ -55,7 +55,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
T gain;
|
T gain;
|
||||||
|
|
||||||
B basis;
|
B basis;
|
||||||
T operator() (util::point<2,T>) const;
|
constexpr T operator() (util::point<2,T>) const;
|
||||||
};
|
};
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace util { namespace noise { namespace fractal {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T, typename B>
|
template <typename T, typename B>
|
||||||
T
|
constexpr T
|
||||||
rmf<T,B>::operator() (util::point<2,T> p) const
|
rmf<T,B>::operator() (util::point<2,T> p) const
|
||||||
{
|
{
|
||||||
const T offset = 1;
|
const T offset = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user