Commit Graph

53 Commits

Author SHA1 Message Date
kwolekr
8ed467d438 PcgRandom: Fix/improve documentation 2016-06-04 02:16:06 -04:00
kwolekr
dfbdb5bcd7 Change internal type for seeds to s32
This fixes value truncation (and therefore incompatibility) on platforms
with an LP32 data model, such as VAX or MS-DOS.
2016-06-04 01:51:44 -04:00
Jun Zhang
a78dd7f2b6 Fix spelling of noise_threshold 2015-12-06 11:38:03 +01:00
kwolekr
d198e420ec Fix Noise compiled under clang >= 3.7.x with -O2 or higher
When compiled with optimizations, the most recent versions of clang seem
to 'optimize' out a crucial "and %reg, 0x7FFFFFFF" instruction in noise2d(),
probably because it somehow assumed the variable n would never become greater
than that amount.
Indeed, signed integer underflow is undefined behavior in C and C++, so while
this optimization is "correct" in that sense, it breaks lots of existing code.
Solved by changing n to an unsigned type, making behavior well-defined.
2015-11-01 11:16:18 -05:00
est31
738fbc66d0 Fix Lua PcgRandom
Before, this lua code led to a crash:

local pcg = PcgRandom(42)
local value = pcg:next()

This was because if you called s32 PcgRandom::range(min, max) with the
minimum and maximum possible values for s32 integers (which the lua
binding code did), u32 PcgRandom::range(bound) got called with 0 as the
bound. The bound however is one above the maximum value, so 0 is a "special"
value to pass to this function. This commit fixes the lua crash by
assigning the RNG's full range to the bound 0, which is also fits to the
"maximum is bound - 1" principle, as (u32)-1 is the maximum value in the
u32 range.
2015-08-12 11:36:22 +02:00
Loic Blot
aab7c83d02 Remove some old dead code. Fix some Clang warnings in SRP (ng->N... will
always evaluate to true.
2015-07-24 21:48:02 +02:00
kwolekr
8eb272cea3 Misc. minor fixes 2015-07-10 15:58:57 -04:00
kwolekr
28b2476b11 Noise: Fix interpolation at negative coordinates 2015-05-17 00:04:51 -04:00
kwolekr
11a96e4901 Add -Wsign-compare for Clang builds and fix some signed/unsigned compiler warnings 2015-05-16 20:15:03 -04:00
kwolekr
5d1d7c17ea Noise: Make buffer size parameters unsigned 2015-05-15 16:20:30 -04:00
kwolekr
37ca3212ee Fix MSVC compatibility
Make sure to include random unittests in android builds, too
Use SWAP() macro
Ensure that negative ranges are tested as well in random unittests
2015-04-29 13:20:01 -04:00
kwolekr
415167b228 Noise: Fix PcgRandom::randNormalDist() when range contains negative numbers
This fixes an issue with erroneous float-to-int rounding that resulted in
truncation toward 0, causing a biased distribution.
2015-04-27 04:05:25 -04:00
kwolekr
cd1d625ab2 Replace PRNG assertions with PrngException 2015-04-27 01:24:37 -04:00
kwolekr
943c6e523e Noise: Add noise unittests
Fix buffer size calculation for lacunarity < 1.0
Add guard against absurd noise parameters
2015-04-21 13:05:14 -04:00
kwolekr
687d969c9c Noise: Correct noise objects created with invalid dimensions 2015-04-19 21:39:10 -04:00
kwolekr
9fc2b93d9f Fix endianness inconsistency with PcgRandom::bytes() 2015-03-23 22:23:16 -04:00
kwolekr
761b127060 Fix some loose ends from 3993093f 2015-03-22 02:58:54 -04:00
kwolekr
3993093f51 Add support for the PCG32 PRNG algo (and associated script APIs) 2015-03-22 00:48:08 -04:00
kwolekr
dcbf1b3ce5 Noise: Don't assume Noise is used for 2D unless gradientMap2D is actually called 2014-12-14 00:18:31 -05:00
kwolekr
fb80a7c111 Clean up Noise macros 2014-12-11 02:53:10 -05:00
kwolekr
16baed0467 Noise: Automatically transform noise maps if needed 2014-12-10 23:35:37 -05:00
kwolekr
fb2bc956b1 Noise: Create a deep copy of NoiseParams 2014-12-10 00:37:09 -05:00
kwolekr
941d000fc6 Noise: Update Noise::resizeNoiseBuf to account for lacunarity not equal to 2 2014-12-09 00:50:58 -05:00
kwolekr
2a7c6d27b3 Optimize noise implementations 2014-12-08 03:26:29 -05:00
kwolekr
2fd3d52020 Add flags and lacunarity as new noise parameters
Add 'absolute value' option to noise map functions
Extend persistence modulation to 3D noise
Extend 'eased' option to noise2d_perlin* functions
Some noise.cpp formatting fixups
2014-12-07 21:59:32 -05:00
kwolekr
25945dc539 noise: Throw exception on noise allocation failure 2014-11-29 16:52:45 -05:00
kwolekr
fc9521874c Add eased 3d point-value noise functions 2014-11-12 23:49:45 -05:00
paramat
92981b2fee Add mgv5. New noise code, uses biome API. Eased 3d noise for terrain, caves, blobs 2014-11-08 21:37:26 +01:00
kwolekr
6ddf458504 Change license of noise implementation to Simplified BSD 2014-10-27 21:17:07 -04:00
kwolekr
b994a7af13 Add support for eased 3d noise 2014-10-27 02:02:38 -04:00
Kahrl
4e1f50035e Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenu 2013-08-14 21:03:33 +02:00
kwolekr
8ec3fc35c6 Add Mapgen V7, reorganize biomes 2013-04-07 00:50:21 -04:00
kwolekr
d31f07bd4b Fix most warnings, re-fix MSVC compile error 2013-02-26 01:57:59 -05:00
Sfan5
6d0ea26c2d Update Copyright Years 2013-02-24 20:15:24 +01:00
PilzAdam
497ff1ecd6 Change Minetest-c55 to Minetest 2013-02-24 18:49:03 +01:00
kwolekr
77dbad72f7 Fix and improve noise map functions 2013-02-06 01:12:36 -05:00
kwolekr
631a835e07 Finish and clean up mapgen configuration 2013-01-21 21:41:37 +02:00
kwolekr
d5029958b9 Readded and optimized mapgen V6 2013-01-21 21:41:37 +02:00
kwolekr
bddd5f2b98 Cleaned & enhanced noise object management 2013-01-21 21:41:37 +02:00
kwolekr
96898c1794 Add initial Lua biomedef support, fixed biome selection 2013-01-21 21:41:37 +02:00
kwolekr
11afcbff69 The new mapgen, noise functions, et al. 2013-01-21 21:41:33 +02:00
PilzAdam
b701f8a878 Replace pow() with multiplikation to improve speed 2012-11-02 16:24:57 +01:00
Perttu Ahola
037b259197 Switch the license to be LGPLv2/later, with small parts still remaining as GPLv2/later, by agreement of major contributors 2012-06-05 18:54:07 +03:00
Perttu Ahola
2bd2bdff08 updated noise stuff 2011-06-26 18:50:13 +03:00
Perttu Ahola
7538b4c620 New map generator added (and SQLite, messed up the commits at that time...) (import from temporary git repo) 2011-06-25 04:25:14 +03:00
Perttu Ahola
ffb1128951 tested out and commented out some new stuff for the terrain generator, to be used in the future. 2011-04-26 15:38:42 +03:00
Perttu Ahola
2e7b15fed3 mapgen work-in-progress 2011-03-02 02:00:11 +02:00
Perttu Ahola
9a22d02903 mapgen tweaking 2011-03-01 01:32:54 +02:00
Perttu Ahola
c8be58a65c A third try on terrain generation. No trees yet. 2011-02-28 02:01:40 +02:00
Perttu Ahola
d9d0efdeed fixed 3d noise and made 2d noise faster 2011-02-27 00:59:56 +02:00