Skip to content

Commit

Permalink
Merge pull request #6 from winipcfg/master
Browse files Browse the repository at this point in the history
Add new constructor for DefaultPRNG
  • Loading branch information
corporateshark authored Jun 17, 2016
2 parents e1a9044 + e485838 commit 6d3674e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions PoissonGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// Implementation based on http://devmag.org.za/2009/05/03/poisson-disk-sampling/

/* Versions history:
1.1.3a Jun 9, 2016 Update constructor for DefaultPRNG
* 1.1.3 Mar 10, 2016 Header-only library, no global mutable state
* 1.1.2 Apr 9, 2015 Output a text file with XY coordinates
* 1.1.1 May 23, 2014 Initialize PRNG seed, fixed uninitialized fields
Expand All @@ -46,14 +47,19 @@ class DefaultPRNG
{
public:
DefaultPRNG()
: m_RD()
, m_Gen( m_RD() )
: m_Gen( std::random_device()() )
, m_Dis( 0.0f, 1.0f )
{
// prepare PRNG
m_Gen.seed( time( nullptr ) );
}

explicit DefaultPRNG( uint32_t seed )
: m_Gen( seed )
, m_Dis( 0.0f, 1.0f )
{
}

float RandomFloat()
{
return static_cast<float>( m_Dis( m_Gen ) );
Expand All @@ -66,7 +72,6 @@ class DefaultPRNG
}

private:
std::random_device m_RD;
std::mt19937 m_Gen;
std::uniform_real_distribution<float> m_Dis;
};
Expand Down

0 comments on commit 6d3674e

Please sign in to comment.