ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/noise.h
(Generate patch)

Comparing deliantra/server/include/noise.h (file contents):
Revision 1.10 by root, Sat Apr 30 05:41:17 2011 UTC vs.
Revision 1.14 by root, Tue Jan 3 11:25:32 2012 UTC

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.
145{ 145{
146}; 146};
147 147
148///////////////////////////////////////////////////////////////////////////// 148/////////////////////////////////////////////////////////////////////////////
149 149
150template<int N, typename T = uint8_t> 150template< int N, typename T>
151struct permutation 151struct permutation
152{ 152{
153 T pmap[N]; 153 T pmap[N];
154 154
155 void seed (seedable_rand_gen &rng); 155 void seed (seedable_rand_gen &rng);
156 156
157 T operator ()(T v) func_pure 157 T operator ()(T v) func_pure
158 { 158 {
159 return pmap[v & (N - 1)]; 159 return pmap[v & T(N - 1)];
160 } 160 }
161}; 161};
162 162
163///////////////////////////////////////////////////////////////////////////// 163/////////////////////////////////////////////////////////////////////////////
164 164
165template<class vec_t> 165template<class vec_t>
166struct noise_gen_base 166struct noise_gen_base
167{ 167{
168 permutation<256, uint8_t> rvmap[vec_t::numElements]; 168 permutation<256, uint8_t> rvmap[vec_t::numElements + 1];
169 169
170 typedef typename vec_t::T_numtype value_t; 170 typedef typename vec_t::T_numtype value_t;
171 171
172 void seed (seedable_rand_gen &rng); 172 void seed (seedable_rand_gen &rng);
173 void seed (seed_t seed); 173 void seed (seed_t seed);
235}; 235};
236 236
237typedef frac_gen<vec2d> frac2d; 237typedef frac_gen<vec2d> frac2d;
238typedef frac_gen<vec3d> frac3d; 238typedef frac_gen<vec3d> frac3d;
239 239
240/////////////////////////////////////////////////////////////////////////////
241
242template<typename T, typename U>
243inline T
244border_blend (T a, T b, vec2d P, U N, U W)
245{
246 U border = W; // within n places of the border
247
248 min_it (border, P [0]);
249 min_it (border, N - P [0]);
250 min_it (border, P [1]);
251 min_it (border, N - P [1]);
252
253 return blend (a, b, border, U(0), W);
254}
255
240#endif 256#endif
241 257

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines