aboutsummaryrefslogtreecommitdiff
path: root/src/noise.cpp
AgeCommit message (Collapse)Author
2022-06-11Inline triLinearInterpolationNoEase and triLinearInterpolation (#12421)paradust7
Performance profiling on Linux AMD64 showed this to be a significant bottleneck. The non-inlined functions are expensive due to XMM registers spilling onto the stack.
2022-06-03fix integer overflow in mapgen (#11641)JosiahWI
* fix integer overflow in mapgen Some calculations involving the magic seed had overflow because the result of an intermediate arithmetic step could not fit in an s32. By making the magic seed unsigned, the other operand in the equation will be cast to unsigned, and possibly other operands or intermediate operands. This will result in unexpected behavior if an operand is negative, which is technically possible, but logically should not happen. * comment noise2d bitshift While working through the code I was momentarily concerned that the right bitshift in noise2d could fill ones in some cases. It turns out that with signed integers, this is indeed true, but this one is shifting an unsigned integer, so the behavior is as expected. I put a comment here to clarify this, in case someone else wonders the same thing down the line. * noise2d and noise3d unittests I have added 3 tests each for noise2d and noise3d, testing all zero inputs, a very large seed (case which caused UB in the old implementation) and some fun primes I picked for no particular reason. This should be sufficient to demonstrate that the behavior of the new implementation has not changed. I used uniform initialization because it is a good feature of C++11. Please do not explode. * uncomment the noise2d bitshift This reverts commit 583b77ee9f1ad6bb77340ebb5ba51eb9a88ff51c. It's a well-defined language semantic; it doesn't need to be commented. * code cleanliness
2021-10-12Remove a few unused functions reported by callcatcher (#11658)SmallJoker
2021-03-23Fix broken `BiomeGen` abstraction (#11107)sfan5
2020-08-01Fix GCC class-memaccess warnings (#10239)Paul Ouellette
2020-04-26Remove unused lookup table from noise.cppsfan5
closes #9757
2020-02-12Display an error when a noise parameter has too many octaves (#9394)Paramat
Display an error and throw exception when one or more octaves of a noise has spread < 1, causing random looking broken noise.
2018-04-03Fix more clang-tidy reported problems for performance-type-promotion-in-math-fnLoic Blot
Based on https://travis-ci.org/minetest/minetest/jobs/361714253 output
2017-08-19Code modernization: src/n*, src/o* (#6280)Loïc Blot
* 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-07-29Noise: Prevent unittest crash caused by division by zeroSmallJoker
2017-07-27Revert "Noise::perlinMap2D,3D: replace a loop init with a single memset call"Loïc Blot
This reverts commit bc1654feedc90caa8c26328ca6f0fc59fbe5b76c.
2017-07-27Noise::perlinMap2D,3D: replace a loop init with a single memset callLoic Blot
2017-06-27Fix msvc annoyances (#5963)adrido
* 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-18Cpp11 patchset 11: continue working on constructor style migration (#6004)Loïc Blot
2016-06-04PcgRandom: Fix/improve documentationkwolekr
2016-06-04Change internal type for seeds to s32kwolekr
This fixes value truncation (and therefore incompatibility) on platforms with an LP32 data model, such as VAX or MS-DOS.
2015-12-06Fix spelling of noise_thresholdJun Zhang
2015-11-01Fix Noise compiled under clang >= 3.7.x with -O2 or higherkwolekr
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-08-12Fix Lua PcgRandomest31
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-07-24Remove some old dead code. Fix some Clang warnings in SRP (ng->N... willLoic Blot
always evaluate to true.
2015-07-10Misc. minor fixeskwolekr
2015-05-17Noise: Fix interpolation at negative coordinateskwolekr
2015-05-16Add -Wsign-compare for Clang builds and fix some signed/unsigned compiler ↵kwolekr
warnings
2015-05-15Noise: Make buffer size parameters unsignedkwolekr
2015-04-29Fix MSVC compatibilitykwolekr
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-27Noise: Fix PcgRandom::randNormalDist() when range contains negative numberskwolekr
This fixes an issue with erroneous float-to-int rounding that resulted in truncation toward 0, causing a biased distribution.
2015-04-27Replace PRNG assertions with PrngExceptionkwolekr
2015-04-21Noise: Add noise unittestskwolekr
Fix buffer size calculation for lacunarity < 1.0 Add guard against absurd noise parameters
2015-04-19Noise: Correct noise objects created with invalid dimensionskwolekr
2015-03-23Fix endianness inconsistency with PcgRandom::bytes()kwolekr
2015-03-22Fix some loose ends from 3993093fkwolekr
2015-03-22Add support for the PCG32 PRNG algo (and associated script APIs)kwolekr
2014-12-14Noise: Don't assume Noise is used for 2D unless gradientMap2D is actually calledkwolekr
2014-12-11Clean up Noise macroskwolekr
2014-12-10Noise: Automatically transform noise maps if neededkwolekr
2014-12-10Noise: Create a deep copy of NoiseParamskwolekr
2014-12-09Noise: Update Noise::resizeNoiseBuf to account for lacunarity not equal to 2kwolekr
2014-12-08Optimize noise implementationskwolekr
2014-12-07Add flags and lacunarity as new noise parameterskwolekr
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-11-29noise: Throw exception on noise allocation failurekwolekr
2014-11-12Add eased 3d point-value noise functionskwolekr
2014-11-08Add mgv5. New noise code, uses biome API. Eased 3d noise for terrain, caves, ↵paramat
blobs
2014-10-27Change license of noise implementation to Simplified BSDkwolekr
2014-10-27Add support for eased 3d noisekwolekr
2013-08-14Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl
2013-04-07Add Mapgen V7, reorganize biomeskwolekr
2013-02-26Fix most warnings, re-fix MSVC compile errorkwolekr
2013-02-24Update Copyright YearsSfan5
2013-02-24Change Minetest-c55 to MinetestPilzAdam
2013-02-06Fix and improve noise map functionskwolekr