1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-13 08:35:20 +02: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
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)