--- deliantra/server/include/noise.h 2011/05/01 13:18:23 1.12 +++ deliantra/server/include/noise.h 2018/11/17 23:40:01 1.22 @@ -1,35 +1,57 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. - * - * Copyright (©) 2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team - * + * + * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team + * Copyright (©) 2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . - * + * * The authors can be reached via e-mail to */ #ifndef NOISE_H_ #define NOISE_H_ +#if 0 // blitz++0.09 +#include // workaround for tinyvec using memcpy without including string.h +#include // workaround for tinyvec using labs without including cstdlib #include #include - -#include "global.h" - typedef blitz::TinyVector vec2d; typedef blitz::TinyVector vec3d; +#else + +// blitz++ 0.10 - not working +#include +#include +#include + +template +struct vecnd +: blitz::TinyVector +{ + static const int numElements = length; + using blitz::TinyVector::TinyVector; +}; + +typedef vecnd vec2d; +typedef vecnd vec3d; + +#endif + +#include "global.h" vec2d inline floor (vec2d v) @@ -154,7 +176,7 @@ void seed (seedable_rand_gen &rng); - T operator ()(T v) func_pure + ecb_pure T operator ()(T v) { return pmap[v & T(N - 1)]; } @@ -172,7 +194,7 @@ void seed (seedable_rand_gen &rng); void seed (seed_t seed); - value_t operator ()(vec_t P, uint32_t seed = 0) func_pure; + ecb_pure value_t operator ()(vec_t P, uint32_t seed = 0); }; template @@ -195,7 +217,7 @@ using noise_gen_base::operator (); // noise projected on a surface with normal n - vec2d::T_numtype operator() (vec3d P, vec3d N, uint32_t seed = 0) func_pure; + ecb_pure vec2d::T_numtype operator() (vec3d P, vec3d N, uint32_t seed = 0); }; typedef noise_gen noise2d; @@ -218,20 +240,20 @@ frac_gen (int octaves = 3, value_t lacunarity = 2, value_t hurst_expo = .5, uint32_t seed = 0); - value_t noise (vec_t P, uint32_t seed = 0) func_pure + ecb_pure value_t noise (vec_t P, uint32_t seed = 0) { - return operator() (P, seed); + return this->operator() (P, seed); } - value_t fBm (vec_t P) func_pure; - value_t turbulence (vec_t P) func_pure; - value_t multifractal (vec_t P, value_t offset = 1) func_pure; - value_t heterofractal (vec_t P, value_t offset = 1) func_pure; - value_t hybridfractal (vec_t P, value_t offset = 1, value_t gain = 1) func_pure; - value_t ridgedmultifractal (vec_t P, value_t offset = 1, value_t gain = 8) func_pure; - value_t billowfractal (vec_t P, value_t offset = 1, value_t gain = 2) func_pure; - value_t terrain (vec_t P) func_pure; - value_t terrain2 (vec_t P) func_pure; + ecb_pure value_t fBm (vec_t P); + ecb_pure value_t turbulence (vec_t P); + ecb_pure value_t multifractal (vec_t P, value_t offset = 1); + ecb_pure value_t heterofractal (vec_t P, value_t offset = 1); + ecb_pure value_t hybridfractal (vec_t P, value_t offset = 1, value_t gain = 1); + ecb_pure value_t ridgedmultifractal (vec_t P, value_t offset = 1, value_t gain = 8); + ecb_pure value_t billowfractal (vec_t P, value_t offset = 1, value_t gain = 2); + ecb_pure value_t terrain (vec_t P); + ecb_pure value_t terrain2 (vec_t P); }; typedef frac_gen frac2d; @@ -240,8 +262,8 @@ ///////////////////////////////////////////////////////////////////////////// template -T -inline border_blend (T a, T b, vec2d P, U N, U W) +inline T +border_blend (T a, T b, vec2d P, U N, U W) { U border = W; // within n places of the border @@ -250,7 +272,7 @@ min_it (border, P [1]); min_it (border, N - P [1]); - return blend (a, b,border, U(0), W); + return blend (a, b, border, U(0), W); } #endif