BLI: make noise hash functions available in header

This commit is contained in:
Jacques Lucke 2021-09-24 10:54:11 +02:00
parent 7ca48a3814
commit bc27bafa54
2 changed files with 11 additions and 4 deletions

View File

@ -22,6 +22,13 @@
namespace blender::noise {
/* Create a randomized hash from the given inputs. Contrary to hash functions in `BLI_hash.hh`
* these functions produce better randomness but are more expensive to compute. */
uint32_t hash(uint32_t kx);
uint32_t hash(uint32_t kx, uint32_t ky);
uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz);
uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz, uint32_t kw);
/* Perlin noise in the range [-1, 1]. */
float perlin_signed(float position);

View File

@ -109,7 +109,7 @@ BLI_INLINE void hash_bit_final(uint32_t &a, uint32_t &b, uint32_t &c)
c -= hash_bit_rotate(b, 24);
}
BLI_INLINE uint32_t hash(uint32_t kx)
uint32_t hash(uint32_t kx)
{
uint32_t a, b, c;
a = b = c = 0xdeadbeef + (1 << 2) + 13;
@ -120,7 +120,7 @@ BLI_INLINE uint32_t hash(uint32_t kx)
return c;
}
BLI_INLINE uint32_t hash(uint32_t kx, uint32_t ky)
uint32_t hash(uint32_t kx, uint32_t ky)
{
uint32_t a, b, c;
a = b = c = 0xdeadbeef + (2 << 2) + 13;
@ -132,7 +132,7 @@ BLI_INLINE uint32_t hash(uint32_t kx, uint32_t ky)
return c;
}
BLI_INLINE uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz)
uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz)
{
uint32_t a, b, c;
a = b = c = 0xdeadbeef + (3 << 2) + 13;
@ -145,7 +145,7 @@ BLI_INLINE uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz)
return c;
}
BLI_INLINE uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz, uint32_t kw)
uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz, uint32_t kw)
{
uint32_t a, b, c;
a = b = c = 0xdeadbeef + (4 << 2) + 13;