Commit Graph

65 Commits

Author SHA1 Message Date
SmallJoker
ecc6f4ba25
Remove a few unused functions reported by callcatcher (#11658) 2021-10-12 20:12:20 +02:00
sfan5
2da1eee394
Fix broken BiomeGen abstraction (#11107) 2021-03-23 15:43:26 +01:00
Paul Ouellette
542df11bed
Fix GCC class-memaccess warnings (#10239) 2020-08-01 17:25:33 +02:00
sfan5
68f45fc130 Remove unused lookup table from noise.cpp
closes #9757
2020-04-26 19:52:09 +02:00
Paramat
c2f48eab4d
Display an error when a noise parameter has too many octaves (#9394)
Display an error and throw exception when one or more octaves of
a noise has spread < 1, causing random looking broken noise.
2020-02-12 23:15:07 +00:00
Loic Blot
4827f754ec
Fix more clang-tidy reported problems for performance-type-promotion-in-math-fn
Based on https://travis-ci.org/minetest/minetest/jobs/361714253 output
2018-04-03 21:58:29 +02:00
Loïc Blot
1992db1395 Code modernization: src/n*, src/o* (#6280)
* Code modernization: src/n*, src/o*

* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* remove unused IWritableNodeDefManager::clone()
* C++ STL header style
* Pointer constness in some functions
2017-08-19 11:30:46 +02:00
SmallJoker
765fd9a0bc Noise: Prevent unittest crash caused by division by zero 2017-07-29 19:01:14 +02:00
Loïc Blot
e9d7005799 Revert "Noise::perlinMap2D,3D: replace a loop init with a single memset call"
This reverts commit bc1654feedc90caa8c26328ca6f0fc59fbe5b76c.
2017-07-27 17:12:18 +02:00
Loic Blot
bc1654feed
Noise::perlinMap2D,3D: replace a loop init with a single memset call 2017-07-27 00:24:14 +02:00
adrido
d7343b6c93 Fix msvc annoyances (#5963)
* MSVC: Fix '/std:c++11' is not a valid compiler option

* MSVC/MINGW: Define 'WIN32_LEAN_AND_MEAN' for the whole project

In some obscure cases 'Windows.h" got includet before that definition, which leaded to compilation warnings+errors

* MSVC: '/arch:SSE' is only available for x86

* MSVC: Fix float conversation

* MSVC/MINGW: use winthreads on Windows

* MSVC: 'USE_CMAKE_CONFIG' might be already definied by CMake build system

* MSVC: Use all available cpu cores for compiling

* Add missing include ctime and use std::time_t
2017-06-27 11:54:40 +02:00
Loïc Blot
4faaadc8d5 Cpp11 patchset 11: continue working on constructor style migration (#6004) 2017-06-18 19:55:15 +02:00
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