[Bf-blender-cvs] [bc27bafa542] master: BLI: make noise hash functions available in header

Jacques Lucke noreply at git.blender.org
Fri Sep 24 10:55:48 CEST 2021


Commit: bc27bafa542d5a5f85b45b83676fe1ad21a3f926
Author: Jacques Lucke
Date:   Fri Sep 24 10:54:11 2021 +0200
Branches: master
https://developer.blender.org/rBbc27bafa542d5a5f85b45b83676fe1ad21a3f926

BLI: make noise hash functions available in header

===================================================================

M	source/blender/blenlib/BLI_noise.hh
M	source/blender/blenlib/intern/noise.cc

===================================================================

diff --git a/source/blender/blenlib/BLI_noise.hh b/source/blender/blenlib/BLI_noise.hh
index 760ff082d06..b5a06b2b020 100644
--- a/source/blender/blenlib/BLI_noise.hh
+++ b/source/blender/blenlib/BLI_noise.hh
@@ -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);
diff --git a/source/blender/blenlib/intern/noise.cc b/source/blender/blenlib/intern/noise.cc
index c057c12e543..0f80fa0f294 100644
--- a/source/blender/blenlib/intern/noise.cc
+++ b/source/blender/blenlib/intern/noise.cc
@@ -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;



More information about the Bf-blender-cvs mailing list