Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
hash.hpp
1
7
8
#pragma once
9
10
namespace
toast {
11
12
inline
constexpr
uint64_t k_golden_gamma = 0x9e3779b97f4a7c15ull;
13
14
[[nodiscard]]
15
constexpr
auto
splitmix64(uint64_t value)
noexcept
-> uint64_t {
16
value = (value ^ (value >> 30)) * 0xbf58476d1ce4e5b9ull;
17
value = (value ^ (value >> 27)) * 0x94d049bb133111ebull;
18
return
value ^ (value >> 31);
19
}
20
21
constexpr
void
hashCombine(uint64_t& seed, uint64_t value)
noexcept
{
22
seed = splitmix64(value + k_golden_gamma + seed);
23
}
24
25
constexpr
void
hashFloats(uint64_t& seed,
const
float
* data,
size_t
count)
noexcept
{
26
for
(
size_t
i = 0; i < count; ++i) {
27
hashCombine(seed, std::bit_cast<uint32_t>(data[i]));
28
}
29
}
30
31
}
engine
src
toast
hash.hpp
Generated by
1.17.0