Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_hash.h
| Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | BLI_INLINE unsigned int BLI_hash_string(const char *str) | ||||
| unsigned int i = 0, c; | unsigned int i = 0, c; | ||||
| while ((c = *str++)) { | while ((c = *str++)) { | ||||
| i = i * 37 + c; | i = i * 37 + c; | ||||
| } | } | ||||
| return i; | return i; | ||||
| } | } | ||||
| BLI_INLINE float BLI_hash_int_2d_to_float(uint32_t kx, uint32_t ky) | |||||
| { | |||||
| return (float)BLI_hash_int_2d(kx, ky) / (float)0xFFFFFFFFu; | |||||
| } | |||||
| BLI_INLINE float BLI_hash_int_3d_to_float(uint32_t kx, uint32_t ky, uint32_t kz) | |||||
| { | |||||
| return (float)BLI_hash_int_3d(kx, ky, kz) / (float)0xFFFFFFFFu; | |||||
| } | |||||
| BLI_INLINE unsigned int BLI_hash_int(unsigned int k) | BLI_INLINE unsigned int BLI_hash_int(unsigned int k) | ||||
| { | { | ||||
| return BLI_hash_int_2d(k, 0); | return BLI_hash_int_2d(k, 0); | ||||
| } | } | ||||
| BLI_INLINE float BLI_hash_int_01(unsigned int k) | BLI_INLINE float BLI_hash_int_01(unsigned int k) | ||||
| { | { | ||||
| return (float)BLI_hash_int(k) * (1.0f / (float)0xFFFFFFFF); | return (float)BLI_hash_int(k) * (1.0f / (float)0xFFFFFFFF); | ||||
| Show All 16 Lines | |||||