1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add API for restoring PseudoRandom and PcgRandom state (#14123)

This commit is contained in:
sfence 2024-01-16 23:20:52 +01:00 committed by GitHub
parent 8093044f07
commit ceaa7e2fb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 155 additions and 29 deletions

View file

@ -152,6 +152,18 @@ s32 PcgRandom::randNormalDist(s32 min, s32 max, int num_trials)
return myround((float)accum / num_trials);
}
void PcgRandom::getState(u64 state[2]) const
{
state[0] = m_state;
state[1] = m_inc;
}
void PcgRandom::setState(const u64 state[2])
{
m_state = state[0];
m_inc = state[1];
}
///////////////////////////////////////////////////////////////////////////////
float noise2d(int x, int y, s32 seed)