1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
10 | * |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
14 | * GNU General Public License for more details. |
15 | * |
15 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
16 | * You should have received a copy of the Affero GNU General Public License |
17 | * and the GNU General Public License along with this program. If not, see |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
18 | * <http://www.gnu.org/licenses/>. |
19 | * |
19 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #ifndef NOISE_H_ |
23 | #ifndef NOISE_H_ |
24 | #define NOISE_H_ |
24 | #define NOISE_H_ |
25 | |
25 | |
|
|
26 | #if 1 // blitz++0.09 |
|
|
27 | #include <string.h> // workaround for tinyvec using memcpy without including string.h |
|
|
28 | #include <cstdlib> // workaround for tinyvec using labs without including cstdlib |
26 | #include <blitz/tinyvec.h> |
29 | #include <blitz/tinyvec.h> |
27 | #include <blitz/tinyvec-et.h> |
30 | #include <blitz/tinyvec-et.h> |
|
|
31 | #else |
|
|
32 | // blitz++ 0.10 - not working |
|
|
33 | #include <blitz/array.h> |
|
|
34 | #include <blitz/tinyvec2.h> |
|
|
35 | #endif |
28 | |
36 | |
29 | #include "global.h" |
37 | #include "global.h" |
30 | |
38 | |
31 | typedef blitz::TinyVector<float,2> vec2d; |
39 | typedef blitz::TinyVector<float,2> vec2d; |
32 | typedef blitz::TinyVector<float,3> vec3d; |
40 | typedef blitz::TinyVector<float,3> vec3d; |
… | |
… | |
218 | |
226 | |
219 | frac_gen (int octaves = 3, value_t lacunarity = 2, value_t hurst_expo = .5, uint32_t seed = 0); |
227 | frac_gen (int octaves = 3, value_t lacunarity = 2, value_t hurst_expo = .5, uint32_t seed = 0); |
220 | |
228 | |
221 | value_t noise (vec_t P, uint32_t seed = 0) func_pure |
229 | value_t noise (vec_t P, uint32_t seed = 0) func_pure |
222 | { |
230 | { |
223 | return operator() (P, seed); |
231 | return this->operator() (P, seed); |
224 | } |
232 | } |
225 | |
233 | |
226 | value_t fBm (vec_t P) func_pure; |
234 | value_t fBm (vec_t P) func_pure; |
227 | value_t turbulence (vec_t P) func_pure; |
235 | value_t turbulence (vec_t P) func_pure; |
228 | value_t multifractal (vec_t P, value_t offset = 1) func_pure; |
236 | value_t multifractal (vec_t P, value_t offset = 1) func_pure; |
… | |
… | |
235 | }; |
243 | }; |
236 | |
244 | |
237 | typedef frac_gen<vec2d> frac2d; |
245 | typedef frac_gen<vec2d> frac2d; |
238 | typedef frac_gen<vec3d> frac3d; |
246 | typedef frac_gen<vec3d> frac3d; |
239 | |
247 | |
|
|
248 | ///////////////////////////////////////////////////////////////////////////// |
|
|
249 | |
|
|
250 | template<typename T, typename U> |
|
|
251 | inline T |
|
|
252 | border_blend (T a, T b, vec2d P, U N, U W) |
|
|
253 | { |
|
|
254 | U border = W; // within n places of the border |
|
|
255 | |
|
|
256 | min_it (border, P [0]); |
|
|
257 | min_it (border, N - P [0]); |
|
|
258 | min_it (border, P [1]); |
|
|
259 | min_it (border, N - P [1]); |
|
|
260 | |
|
|
261 | return blend (a, b, border, U(0), W); |
|
|
262 | } |
|
|
263 | |
240 | #endif |
264 | #endif |
241 | |
265 | |