From e94886c14068eb3b9f70e4ec4ae02b7f832b8fdc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Mar 2015 00:59:53 +0000 Subject: Fixed grass spread, closes #1743 - Removed the salt parameter in cFastRandom functions, it wasn't doing what we thought it was following the move to C++11 --- src/FastRandom.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/FastRandom.cpp') diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp index 515dc25ea..ad1390a92 100644 --- a/src/FastRandom.cpp +++ b/src/FastRandom.cpp @@ -105,18 +105,6 @@ int cFastRandom::NextInt(int a_Range) -int cFastRandom::NextInt(int a_Range, int a_Salt) -{ - m_LinearRand.seed(a_Salt); - std::uniform_int_distribution<> distribution(0, a_Range - 1); - return distribution(m_LinearRand); -} - - - - - - float cFastRandom::NextFloat(float a_Range) { std::uniform_real_distribution distribution(0, a_Range); @@ -128,18 +116,6 @@ float cFastRandom::NextFloat(float a_Range) -float cFastRandom::NextFloat(float a_Range, int a_Salt) -{ - m_LinearRand.seed(a_Salt); - std::uniform_real_distribution distribution(0, a_Range); - return distribution(m_LinearRand); -} - - - - - - int cFastRandom::GenerateRandomInteger(int a_Begin, int a_End) { std::uniform_int_distribution<> distribution(a_Begin, a_End); -- cgit v1.2.3 From a8a2d3d504a84f26d71aa364a169963a70ce6288 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Mar 2015 21:52:13 +0000 Subject: Use thread_local in cFastRandom --- src/FastRandom.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/FastRandom.cpp') diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp index ad1390a92..737b13535 100644 --- a/src/FastRandom.cpp +++ b/src/FastRandom.cpp @@ -6,6 +6,12 @@ #include "Globals.h" #include "FastRandom.h" +#ifdef _WIN32 + #define thread_local __declspec(thread) +#endif + +thread_local unsigned int m_Counter = 0; + @@ -86,7 +92,7 @@ public: cFastRandom::cFastRandom(void) : - m_LinearRand(static_cast(std::chrono::system_clock::now().time_since_epoch().count())) + m_LinearRand(m_Counter++) { } @@ -130,7 +136,7 @@ int cFastRandom::GenerateRandomInteger(int a_Begin, int a_End) // MTRand: MTRand::MTRand() : - m_MersenneRand(static_cast(std::chrono::system_clock::now().time_since_epoch().count())) + m_MersenneRand(m_Counter++) { } -- cgit v1.2.3